[Bf-blender-cvs] [6abb0ea] alembic: Added visibility attribute for dupli objects in Alembic caches.
Lukas Tönne
noreply at git.blender.org
Thu Apr 9 18:51:50 CEST 2015
Commit: 6abb0eaa8ad0d3816218209ad98436f69888e452
Author: Lukas Tönne
Date: Thu Apr 9 18:50:26 2015 +0200
Branches: alembic
https://developer.blender.org/rB6abb0eaa8ad0d3816218209ad98436f69888e452
Added visibility attribute for dupli objects in Alembic caches.
This combines the DupliObject.no_draw flag with the instanced object's
visibility.
===================================================================
M source/blender/blenkernel/BKE_anim.h
M source/blender/blenkernel/intern/object_dupli.c
M source/blender/pointcache/alembic/abc_group.cpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 514c031..c0fe81b 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -103,7 +103,7 @@ void BKE_dupli_cache_free(struct DupliCache *dupcache);
void BKE_dupli_cache_clear(struct DupliCache *dupcache);
void BKE_dupli_cache_clear_instances(struct DupliCache *dupcache);
struct DupliObjectData *BKE_dupli_cache_add_object(struct DupliCache *dupcache, struct Object *ob);
-void BKE_dupli_cache_add_instance(struct DupliCache *dupcache, float obmat[4][4], struct DupliObjectData *data);
+struct DupliObject *BKE_dupli_cache_add_instance(struct DupliCache *dupcache, float obmat[4][4], struct DupliObjectData *data);
void BKE_dupli_cache_from_group(struct Scene *scene, struct Group *group, struct CacheLibrary *cachelib, struct DupliCache *dupcache, struct EvaluationContext *eval_ctx);
struct DupliCacheIterator *BKE_dupli_cache_iter_new(struct DupliCache *dupcache);
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index f1d06d6..d13b6e6 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1766,7 +1766,7 @@ DupliObjectData *BKE_dupli_cache_add_object(DupliCache *dupcache, Object *ob)
return data;
}
-void BKE_dupli_cache_add_instance(DupliCache *dupcache, float obmat[4][4], DupliObjectData *data)
+DupliObject *BKE_dupli_cache_add_instance(DupliCache *dupcache, float obmat[4][4], DupliObjectData *data)
{
DupliObject *dob = dupli_cache_add_object(dupcache);
@@ -1777,6 +1777,8 @@ void BKE_dupli_cache_add_instance(DupliCache *dupcache, float obmat[4][4], Dupli
copy_m4_m4(dob->mat, obmat);
dob->data = data;
+
+ return dob;
}
/* ------------------------------------------------------------------------- */
diff --git a/source/blender/pointcache/alembic/abc_group.cpp b/source/blender/pointcache/alembic/abc_group.cpp
index 2d8edf6..dc430b1 100644
--- a/source/blender/pointcache/alembic/abc_group.cpp
+++ b/source/blender/pointcache/alembic/abc_group.cpp
@@ -157,6 +157,7 @@ void AbcDupligroupWriter::write_sample_dupli(DupliObject *dob, int index)
OObject abc_dupli = m_abc_group.getChild(name);
OCompoundProperty props;
OM44fProperty prop_matrix;
+ OBoolProperty prop_visible;
if (!abc_dupli) {
abc_dupli = OObject(m_abc_group, name, 0);
m_object_writers.push_back(abc_dupli.getPtr());
@@ -166,14 +167,21 @@ void AbcDupligroupWriter::write_sample_dupli(DupliObject *dob, int index)
prop_matrix = OM44fProperty(props, "matrix", abc_archive()->frame_sampling());
m_property_writers.push_back(prop_matrix.getPtr());
+ prop_visible = OBoolProperty(props, "visible", abc_archive()->frame_sampling());
+ m_property_writers.push_back(prop_visible.getPtr());
}
else {
props = abc_dupli.getProperties();
prop_matrix = OM44fProperty(props.getProperty("matrix").getPtr()->asScalarPtr(), kWrapExisting);
+ prop_visible = OBoolProperty(props.getProperty("visible").getPtr()->asScalarPtr(), kWrapExisting);
}
prop_matrix.set(M44f(dob->mat));
+
+ bool show_object = (abc_archive()->use_render())? !(dob->ob->restrictflag & OB_RESTRICT_RENDER) : !(dob->ob->restrictflag & OB_RESTRICT_VIEW);
+ bool visible = show_object && (!dob->no_draw);
+ prop_visible.set(visible);
}
void AbcDupligroupWriter::write_sample()
@@ -283,6 +291,7 @@ void AbcDupliCacheWriter::write_sample_dupli(DupliObject *dob, int index)
OObject abc_dupli = m_abc_group.getChild(name);
OCompoundProperty props;
+ OBoolProperty prop_visible;
OM44fProperty prop_matrix;
if (!abc_dupli) {
abc_dupli = OObject(m_abc_group, name, 0);
@@ -293,14 +302,21 @@ void AbcDupliCacheWriter::write_sample_dupli(DupliObject *dob, int index)
prop_matrix = OM44fProperty(props, "matrix", abc_archive()->frame_sampling());
m_property_writers.push_back(prop_matrix.getPtr());
+ prop_visible = OBoolProperty(props, "visible", abc_archive()->frame_sampling());
+ m_property_writers.push_back(prop_visible.getPtr());
}
else {
props = abc_dupli.getProperties();
prop_matrix = OM44fProperty(props.getProperty("matrix").getPtr()->asScalarPtr(), kWrapExisting);
+ prop_visible = OBoolProperty(props.getProperty("visible").getPtr()->asScalarPtr(), kWrapExisting);
}
prop_matrix.set(M44f(dob->mat));
+
+ bool show_object = (abc_archive()->use_render())? !(dob->ob->restrictflag & OB_RESTRICT_RENDER) : !(dob->ob->restrictflag & OB_RESTRICT_VIEW);
+ bool visible = show_object && (!dob->no_draw);
+ prop_visible.set(visible);
}
void AbcDupliCacheWriter::write_sample()
@@ -451,11 +467,15 @@ void AbcDupliCacheReader::read_dupligroup_group(IObject abc_group, const ISample
float matrix[4][4];
memcpy(matrix, abc_matrix.getValue(), sizeof(matrix));
+ IBoolProperty prop_visible(props, "visible", 0);
+ bool visible = prop_visible.getValue(ss);
+
IObject abc_dupli_object = abc_dupli.getChild("object");
if (abc_dupli_object.isInstanceRoot()) {
DupliObjectData *dupli_data = find_dupli_data(abc_dupli_object.getPtr());
if (dupli_data) {
- BKE_dupli_cache_add_instance(dupli_cache, matrix, dupli_data);
+ DupliObject *dob = BKE_dupli_cache_add_instance(dupli_cache, matrix, dupli_data);
+ dob->no_draw = !visible;
}
}
}
More information about the Bf-blender-cvs
mailing list