From da376e0237517543aa21740ee2363234ee1c20ae Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 27 Apr 2011 11:58:34 +0000 Subject: Cycles render engine, initial commit. This is the engine itself, blender modifications and build instructions will follow later. Cycles uses code from some great open source projects, many thanks them: * BVH building and traversal code from NVidia's "Understanding the Efficiency of Ray Traversal on GPUs": http://code.google.com/p/understanding-the-efficiency-of-ray-traversal-on-gpus/ * Open Shading Language for a large part of the shading system: http://code.google.com/p/openshadinglanguage/ * Blender for procedural textures and a few other nodes. * Approximate Catmull Clark subdivision from NVidia Mesh tools: http://code.google.com/p/nvidia-mesh-tools/ * Sobol direction vectors from: http://web.maths.unsw.edu.au/~fkuo/sobol/ * Film response functions from: http://www.cs.columbia.edu/CAVE/software/softlib/dorf.php --- intern/cycles/render/mesh.h | 133 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 intern/cycles/render/mesh.h (limited to 'intern/cycles/render/mesh.h') diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h new file mode 100644 index 00000000000..367896697ed --- /dev/null +++ b/intern/cycles/render/mesh.h @@ -0,0 +1,133 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __MESH_H__ +#define __MESH_H__ + +#include "attribute.h" +#include "shader.h" + +#include "util_boundbox.h" +#include "util_list.h" +#include "util_map.h" +#include "util_param.h" +#include "util_transform.h" +#include "util_types.h" +#include "util_vector.h" + +CCL_NAMESPACE_BEGIN + +class BVH; +class Device; +class DeviceScene; +class Mesh; +class Progress; +class Scene; +class SceneParams; +class AttributeRequest; + +/* Mesh */ + +class Mesh { +public: + /* Mesh Triangle */ + struct Triangle { + int v[3]; + }; + + /* Displacement */ + enum DisplacementMethod { + DISPLACE_BUMP, + DISPLACE_TRUE, + DISPLACE_BOTH + }; + + ustring name; + + /* Mesh Data */ + vector verts; + vector triangles; + vector shader; + vector smooth; + + vector used_shaders; + AttributeSet attributes; + + BoundBox bounds; + bool transform_applied; + DisplacementMethod displacement_method; + + /* Update Flags */ + bool need_update; + bool need_update_rebuild; + + /* BVH */ + BVH *bvh; + size_t tri_offset; + size_t vert_offset; + + /* Functions */ + Mesh(); + ~Mesh(); + + void reserve(int numverts, int numfaces); + void clear(); + void add_triangle(int v0, int v1, int v2, int shader, bool smooth); + + void compute_bounds(); + void add_face_normals(); + void add_vertex_normals(); + + void pack_normals(Scene *scene, float4 *normal, float4 *vnormal); + void pack_verts(float4 *tri_verts, float4 *tri_vindex, size_t vert_offset); + void compute_bvh(SceneParams *params, Progress& progress); + + void tag_update(Scene *scene, bool rebuild); +}; + +/* Mesh Manager */ + +class MeshManager { +public: + BVH *bvh; + + bool need_update; + + MeshManager(); + ~MeshManager(); + + bool displace(Device *device, Scene *scene, Mesh *mesh, Progress& progress); + + /* attributes */ + void update_osl_attributes(Device *device, Scene *scene, vector& mesh_attributes); + void update_svm_attributes(Device *device, DeviceScene *dscene, Scene *scene, vector& mesh_attributes); + + void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); + void device_update_object(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); + void device_update_mesh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); + void device_update_attributes(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); + void device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); + void device_free(Device *device, DeviceScene *dscene); + + void tag_update(Scene *scene); +}; + +CCL_NAMESPACE_END + +#endif /* __MESH_H__ */ + -- cgit v1.2.3