Code refactor: nodify object and mesh, but not used for XML yet.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 7 May 2016 19:44:17 +0000 (21:44 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 28 May 2016 16:40:09 +0000 (18:40 +0200)
Differential Revision: https://developer.blender.org/D2016

intern/cycles/render/mesh.cpp
intern/cycles/render/mesh.h
intern/cycles/render/object.cpp
intern/cycles/render/object.h

index 722632b99340e69914351787314d65e6b509932b..00b8e02f87f8d86d5b508ccc7e8199338f45f675 100644 (file)
@@ -75,19 +75,42 @@ void Mesh::Curve::bounds_grow(const int k, const float3 *curve_keys, const float
 
 /* Mesh */
 
+NODE_DEFINE(Mesh)
+{
+       NodeType* type = NodeType::add("mesh", create);
+
+       static NodeEnum displacement_method_enum;
+       displacement_method_enum.insert("bump", DISPLACE_BUMP);
+       displacement_method_enum.insert("true", DISPLACE_TRUE);
+       displacement_method_enum.insert("both", DISPLACE_BOTH);
+       SOCKET_ENUM(displacement_method, "Displacement Method", displacement_method_enum, DISPLACE_BUMP);
+
+       SOCKET_INT(motion_steps, "Motion Steps", 3);
+       SOCKET_BOOLEAN(use_motion_blur, "Use Motion Blur", false);
+
+       SOCKET_INT_ARRAY(triangles, "Triangles", array<int>());
+       SOCKET_POINT_ARRAY(verts, "Vertices", array<float3>());
+       SOCKET_INT_ARRAY(shader, "Shader", array<int>());
+       SOCKET_BOOLEAN_ARRAY(smooth, "Smooth", array<bool>());
+
+       SOCKET_POINT_ARRAY(curve_keys, "Curve Keys", array<float3>());
+       SOCKET_FLOAT_ARRAY(curve_radius, "Curve Radius", array<float>());
+       SOCKET_INT_ARRAY(curve_first_key, "Curve First Key", array<int>());
+       SOCKET_INT_ARRAY(curve_shader, "Curve Shader", array<int>());
+
+       return type;
+}
+
 Mesh::Mesh()
+: Node(node_type)
 {
        need_update = true;
        need_update_rebuild = false;
        transform_applied = false;
        transform_negative_scaled = false;
        transform_normal = transform_identity();
-       displacement_method = DISPLACE_BUMP;
        bounds = BoundBox::empty;
 
-       motion_steps = 3;
-       use_motion_blur = false;
-
        bvh = NULL;
 
        tri_offset = 0;
index 2d1f3e3a83efd4cdfd0f1c88b83771b5323a282f..7556b7ccf1edb8dd6a0c6d7dce8b52e97f211ee6 100644 (file)
@@ -18,6 +18,7 @@
 #define __MESH_H__
 
 #include "attribute.h"
+#include "node.h"
 #include "shader.h"
 
 #include "util_boundbox.h"
@@ -42,8 +43,10 @@ class DiagSplit;
 
 /* Mesh */
 
-class Mesh {
+class Mesh : public Node {
 public:
+       NODE_DECLARE;
+
        /* Mesh Triangle */
        struct Triangle {
                int v[3];
@@ -95,8 +98,6 @@ public:
                DISPLACE_NUM_METHODS,
        };
 
-       ustring name;
-
        /* Mesh Data */
        enum GeometryFlags {
                GEOMETRY_NONE      = 0,
index 4e74940aff117382a990e8049091d9d92238556d..9ee1a9ef7a6612348519d89b6b462b29d8221672 100644 (file)
@@ -33,14 +33,25 @@ CCL_NAMESPACE_BEGIN
 
 /* Object */
 
+NODE_DEFINE(Object)
+{
+       NodeType* type = NodeType::add("object", create);
+
+       SOCKET_NODE(mesh, "Mesh", &Mesh::node_type);
+       SOCKET_TRANSFORM(tfm, "Transform", transform_identity());
+       SOCKET_INT(visibility, "Visibility", ~0);
+       SOCKET_INT(random_id, "Random ID", 0);
+       SOCKET_INT(pass_id, "Pass ID", 0);
+       SOCKET_BOOLEAN(use_holdout, "Use Holdout", false);
+       SOCKET_POINT(dupli_generated, "Dupli Generated", make_float3(0.0f, 0.0f, 0.0f));
+       SOCKET_POINT2(dupli_uv, "Dupli UV", make_float2(0.0f, 0.0f));
+
+       return type;
+}
+
 Object::Object()
+: Node(node_type)
 {
-       name = "";
-       mesh = NULL;
-       tfm = transform_identity();
-       visibility = ~0;
-       random_id = 0;
-       pass_id = 0;
        particle_system = NULL;
        particle_index = 0;
        bounds = BoundBox::empty;
@@ -48,9 +59,6 @@ Object::Object()
        motion.mid = transform_identity();
        motion.post = transform_identity();
        use_motion = false;
-       use_holdout = false;
-       dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
-       dupli_uv = make_float2(0.0f, 0.0f);
 }
 
 Object::~Object()
index c2a79ca8dc43bd7b16351da6babec17424e021d9..57614c95580e169a323d9c025f5d73888b9bf807 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef __OBJECT_H__
 #define __OBJECT_H__
 
+#include "node.h"
 #include "scene.h"
 
 #include "util_boundbox.h"
@@ -37,12 +38,13 @@ struct Transform;
 
 /* Object */
 
-class Object {
+class Object : public Node {
 public:
+       NODE_DECLARE;
+
        Mesh *mesh;
        Transform tfm;
        BoundBox bounds;
-       ustring name;
        uint random_id;
        int pass_id;
        vector<ParamValue> attributes;