From 527f8b32b32187f754e5b176db6377736f9cb8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Mon, 26 Oct 2020 21:00:37 +0100 Subject: Cycles API: encapsulate Node socket members This encapsulates Node socket members behind a set of specific methods; as such it is no longer possible to directly access Node class members from exporters and parts of Cycles. The methods are defined via the NODE_SOCKET_API macros in `graph/ node.h`, and are for getting or setting a specific socket's value, as well as querying or modifying the state of its update flag. The setters will check whether the value has changed and tag the socket as modified appropriately. This will let us know how a Node has changed and what to update, which is the first concrete step toward a more granular scene update system. Since the setters will tag the Node sockets as modified when passed different data, this patch also removes the various `modified` methods on Nodes in favor of `Node::is_modified` which checks the sockets' update flags status. Reviewed By: brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D8544 --- intern/cycles/render/mesh.h | 80 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 14 deletions(-) (limited to 'intern/cycles/render/mesh.h') diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h index c8286a01e2c..b8107085006 100644 --- a/intern/cycles/render/mesh.h +++ b/intern/cycles/render/mesh.h @@ -118,36 +118,57 @@ class Mesh : public Geometry { float crease; }; + SubdEdgeCrease get_subd_crease(size_t i) const + { + SubdEdgeCrease s; + s.v[0] = subd_creases_edge[i * 2]; + s.v[1] = subd_creases_edge[i * 2 + 1]; + s.crease = subd_creases_weight[i]; + return s; + } + + bool need_tesselation(); + enum SubdivisionType { SUBDIVISION_NONE, SUBDIVISION_LINEAR, SUBDIVISION_CATMULL_CLARK, }; - SubdivisionType subdivision_type; + NODE_SOCKET_API(SubdivisionType, subdivision_type) /* Mesh Data */ - array triangles; - array verts; - array shader; - array smooth; + NODE_SOCKET_API_ARRAY(array, triangles) + NODE_SOCKET_API_ARRAY(array, verts) + NODE_SOCKET_API_ARRAY(array, shader) + NODE_SOCKET_API_ARRAY(array, smooth) /* used for storing patch info for subd triangles, only allocated if there are patches */ - array triangle_patch; /* must be < 0 for non subd triangles */ - array vert_patch_uv; + NODE_SOCKET_API_ARRAY(array, triangle_patch) /* must be < 0 for non subd triangles */ + NODE_SOCKET_API_ARRAY(array, vert_patch_uv) + + /* SubdFaces */ + NODE_SOCKET_API_ARRAY(array, subd_start_corner) + NODE_SOCKET_API_ARRAY(array, subd_num_corners) + NODE_SOCKET_API_ARRAY(array, subd_shader) + NODE_SOCKET_API_ARRAY(array, subd_smooth) + NODE_SOCKET_API_ARRAY(array, subd_ptex_offset) - array subd_faces; - array subd_face_corners; - int num_ngons; + NODE_SOCKET_API_ARRAY(array, subd_face_corners) + NODE_SOCKET_API(int, num_ngons) - array subd_creases; + NODE_SOCKET_API_ARRAY(array, subd_creases_edge) + NODE_SOCKET_API_ARRAY(array, subd_creases_weight) - SubdParams *subd_params; + /* Subdivisions parameters */ + NODE_SOCKET_API(float, subd_dicing_rate) + NODE_SOCKET_API(int, subd_max_level) + NODE_SOCKET_API(Transform, subd_objecttoworld) AttributeSet subd_attributes; + private: PackedPatchTable *patch_table; - /* BVH */ size_t vert_offset; @@ -157,13 +178,23 @@ class Mesh : public Geometry { size_t corner_offset; size_t num_subd_verts; + size_t num_subd_faces; - private: unordered_map vert_to_stitching_key_map; /* real vert index -> stitching index */ unordered_multimap vert_stitching_map; /* stitching index -> multiple real vert indices */ + + friend class BVH; + friend class BVHBuild; + friend class BVHEmbree; + friend class BVHSpatialSplit; friend class DiagSplit; + friend class EdgeDice; friend class GeometryManager; + friend class Object; + friend class ObjectManager; + + SubdParams *subd_params = nullptr; public: /* Functions */ @@ -174,12 +205,14 @@ class Mesh : public Geometry { void reserve_mesh(int numverts, int numfaces); void resize_subd_faces(int numfaces, int num_ngons, int numcorners); void reserve_subd_faces(int numfaces, int num_ngons, int numcorners); + void reserve_subd_creases(size_t num_creases); void clear(bool preserve_voxel_data); void clear() override; void add_vertex(float3 P); void add_vertex_slow(float3 P); void add_triangle(int v0, int v1, int v2, int shader, bool smooth); void add_subd_face(int *corners, int num_corners, int shader_, bool smooth_); + void add_crease(int v0, int v1, float weight); void copy_center_to_motion_step(const int motion_step); @@ -202,6 +235,25 @@ class Mesh : public Geometry { void pack_patches(uint *patch_data, uint vert_offset, uint face_offset, uint corner_offset); void tessellate(DiagSplit *split); + + SubdFace get_subd_face(size_t index) const; + + SubdParams *get_subd_params(); + + size_t get_num_subd_faces() const + { + return num_subd_faces; + } + + void set_num_subd_faces(size_t num_subd_faces_) + { + num_subd_faces = num_subd_faces_; + } + + size_t get_num_subd_verts() + { + return num_subd_verts; + } }; CCL_NAMESPACE_END -- cgit v1.2.3