Fix T52943: don't export curves objects with no faces to Cycles.
Also skip any objects with zero ray visibility and meshes with zero faces.
This commit is contained in:
parent
d2bbd41b4e
commit
9298c53e4c
@ -719,6 +719,11 @@ static void create_mesh(Scene *scene,
|
||||
int numngons = 0;
|
||||
bool use_loop_normals = b_mesh.use_auto_smooth() && (mesh->subdivision_type != Mesh::SUBDIVISION_CATMULL_CLARK);
|
||||
|
||||
/* If no faces, create empty mesh. */
|
||||
if(numfaces == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
BL::Mesh::vertices_iterator v;
|
||||
BL::Mesh::tessfaces_iterator f;
|
||||
BL::Mesh::polygons_iterator p;
|
||||
|
@ -63,8 +63,25 @@ bool BlenderSync::object_is_mesh(BL::Object& b_ob)
|
||||
{
|
||||
BL::ID b_ob_data = b_ob.data();
|
||||
|
||||
return (b_ob_data && (b_ob_data.is_a(&RNA_Mesh) ||
|
||||
b_ob_data.is_a(&RNA_Curve) || b_ob_data.is_a(&RNA_MetaBall)));
|
||||
if(!b_ob_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(b_ob.type() == BL::Object::type_CURVE) {
|
||||
/* Skip exporting curves without faces, overhead can be
|
||||
* significant if there are many for path animation. */
|
||||
BL::Curve b_curve(b_ob.data());
|
||||
|
||||
return (b_curve.bevel_object() ||
|
||||
b_curve.extrude() != 0.0f ||
|
||||
b_curve.bevel_depth() != 0.0f ||
|
||||
b_ob.modifiers.length());
|
||||
}
|
||||
else {
|
||||
return (b_ob_data.is_a(&RNA_Mesh) ||
|
||||
b_ob_data.is_a(&RNA_Curve) ||
|
||||
b_ob_data.is_a(&RNA_MetaBall));
|
||||
}
|
||||
}
|
||||
|
||||
bool BlenderSync::object_is_light(BL::Object& b_ob)
|
||||
@ -268,6 +285,29 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Visibility flags for both parent and child. */
|
||||
bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
|
||||
uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
|
||||
|
||||
if(b_parent.ptr.data != b_ob.ptr.data) {
|
||||
visibility &= object_ray_visibility(b_parent);
|
||||
}
|
||||
|
||||
/* Make holdout objects on excluded layer invisible for non-camera rays. */
|
||||
if(use_holdout && (layer_flag & render_layer.exclude_layer)) {
|
||||
visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
|
||||
}
|
||||
|
||||
/* Hide objects not on render layer from camera rays. */
|
||||
if(!(layer_flag & render_layer.layer)) {
|
||||
visibility &= ~PATH_RAY_CAMERA;
|
||||
}
|
||||
|
||||
/* Don't export completely invisible objects. */
|
||||
if(visibility == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* key to lookup object */
|
||||
ObjectKey key(b_parent, persistent_id, b_ob);
|
||||
Object *object;
|
||||
@ -308,8 +348,6 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
|
||||
if(object_map.sync(&object, b_ob, b_parent, key))
|
||||
object_updated = true;
|
||||
|
||||
bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
|
||||
|
||||
/* mesh sync */
|
||||
object->mesh = sync_mesh(b_ob, object_updated, hide_tris);
|
||||
|
||||
@ -322,22 +360,6 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
|
||||
object_updated = true;
|
||||
}
|
||||
|
||||
/* visibility flags for both parent and child */
|
||||
uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
|
||||
if(b_parent.ptr.data != b_ob.ptr.data) {
|
||||
visibility &= object_ray_visibility(b_parent);
|
||||
}
|
||||
|
||||
/* make holdout objects on excluded layer invisible for non-camera rays */
|
||||
if(use_holdout && (layer_flag & render_layer.exclude_layer)) {
|
||||
visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
|
||||
}
|
||||
|
||||
/* hide objects not on render layer from camera rays */
|
||||
if(!(layer_flag & render_layer.layer)) {
|
||||
visibility &= ~PATH_RAY_CAMERA;
|
||||
}
|
||||
|
||||
if(visibility != object->visibility) {
|
||||
object->visibility = visibility;
|
||||
object_updated = true;
|
||||
|
Loading…
Reference in New Issue
Block a user