diff options
Diffstat (limited to 'intern/cycles/render/object.cpp')
-rw-r--r-- | intern/cycles/render/object.cpp | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index e2fe0bd72a1..662d87e8b6b 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -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_UINT(visibility, "Visibility", ~0); + SOCKET_UINT(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() @@ -137,12 +145,12 @@ void Object::apply_transform(bool apply_to_motion) /* apply transform to curve keys */ for(size_t i = 0; i < mesh->curve_keys.size(); i++) { - float3 co = transform_point(&tfm, float4_to_float3(mesh->curve_keys[i])); - float radius = mesh->curve_keys[i].w * scalar; + float3 co = transform_point(&tfm, mesh->curve_keys[i]); + float radius = mesh->curve_radius[i] * scalar; /* scale for curve radius is only correct for uniform scale */ - mesh->curve_keys[i] = float3_to_float4(co); - mesh->curve_keys[i].w = radius; + mesh->curve_keys[i] = co; + mesh->curve_radius[i] = radius; } if(apply_to_motion) { @@ -176,7 +184,7 @@ void Object::apply_transform(bool apply_to_motion) } /* tfm is not reset to identity, all code that uses it needs to check the - transform_applied boolean */ + * transform_applied boolean */ } void Object::tag_update(Scene *scene) @@ -217,6 +225,16 @@ vector<float> Object::motion_times() return times; } +bool Object::is_traceable() +{ + /* Mesh itself can be empty,can skip all such objects. */ + if (bounds.size() == make_float3(0.0f, 0.0f, 0.0f)) { + return false; + } + /* TODO(sergey): Check for mesh vertices/curves. visibility flags. */ + return true; +} + /* Object Manager */ ObjectManager::ObjectManager() @@ -269,7 +287,9 @@ void ObjectManager::device_update_object_transform(UpdateObejctTransformState *s state->surface_area_lock.unlock(); if(it == state->surface_area_map.end()) { - foreach(Mesh::Triangle& t, mesh->triangles) { + size_t num_triangles = mesh->num_triangles(); + for(size_t j = 0; j < num_triangles; j++) { + Mesh::Triangle t = mesh->get_triangle(j); float3 p1 = mesh->verts[t.v[0]]; float3 p2 = mesh->verts[t.v[1]]; float3 p3 = mesh->verts[t.v[2]]; @@ -288,7 +308,9 @@ void ObjectManager::device_update_object_transform(UpdateObejctTransformState *s surface_area *= uniform_scale; } else { - foreach(Mesh::Triangle& t, mesh->triangles) { + size_t num_triangles = mesh->num_triangles(); + for(size_t j = 0; j < num_triangles; j++) { + Mesh::Triangle t = mesh->get_triangle(j); float3 p1 = transform_point(&tfm, mesh->verts[t.v[0]]); float3 p2 = transform_point(&tfm, mesh->verts[t.v[1]]); float3 p3 = transform_point(&tfm, mesh->verts[t.v[2]]); @@ -360,7 +382,7 @@ void ObjectManager::device_update_object_transform(UpdateObejctTransformState *s state->object_flag[object_index] = flag; /* Have curves. */ - if(mesh->curves.size()) { + if(mesh->num_curves()) { state->have_curves = true; } } |