[Bf-blender-cvs] [12dd009] alembic: Merge branch 'master' into alembic
Lukas Tönne
noreply at git.blender.org
Tue Apr 14 12:25:25 CEST 2015
Commit: 12dd009356321aefb08e51bad58d181374a32cf7
Author: Lukas Tönne
Date: Tue Apr 14 12:25:17 2015 +0200
Branches: alembic
https://developer.blender.org/rB12dd009356321aefb08e51bad58d181374a32cf7
Merge branch 'master' into alembic
Conflicts:
source/blender/blenkernel/intern/object_dupli.c
source/blenderplayer/bad_level_call_stubs/stubs.c
===================================================================
===================================================================
diff --cc intern/cycles/blender/blender_mesh.cpp
index 2e6b04f,d88ebb8..654f401
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@@ -622,27 -621,16 +622,33 @@@ Mesh *BlenderSync::sync_mesh(BL::Objec
}
/* test if we need to sync */
- bool use_mesh_geometry = render_layer.use_surfaces || render_layer.use_hair;
+ int requested_geometry_flags = Mesh::GEOMETRY_NONE;
+ if(render_layer.use_surfaces) {
+ requested_geometry_flags |= Mesh::GEOMETRY_TRIANGLES;
+ }
+ if(render_layer.use_hair) {
+ requested_geometry_flags |= Mesh::GEOMETRY_CURVES;
+ }
Mesh *mesh;
- if(!mesh_map.sync(&mesh, key)) {
+ bool need_update;
+ BL::CacheLibrary b_cachelib = b_parent.cache_library();
+ bool use_dupli_override = b_dupli_ob && b_cachelib &&
+ (b_cachelib.source_mode() == BL::CacheLibrary::source_mode_CACHE ||
+ b_cachelib.display_mode() == BL::CacheLibrary::display_mode_RESULT);
+ if (use_dupli_override) {
+ /* if a dupli override (cached data) is used, identify the mesh by object and parent together,
+ * so that individual per-dupli overrides are possible.
+ */
+ MeshKey key = MeshKey(b_parent, b_ob);
+ need_update = mesh_map.sync(&mesh, b_parent, PointerRNA_NULL, key);
+ }
+ else {
+ BL::ID key = (BKE_object_is_modified(b_ob))? b_ob: b_ob_data;
+ need_update = mesh_map.sync(&mesh, key);
+ }
+
+ if(!need_update) {
/* if transform was applied to mesh, need full update */
if(object_updated && mesh->transform_applied);
/* test if shaders changed, these can be object level so mesh
diff --cc source/blender/blenkernel/CMakeLists.txt
index d34ce32,67c8f0f..d50f6a0
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@@ -268,11 -267,8 +271,9 @@@ set(SR
BKE_softbody.h
BKE_sound.h
BKE_speaker.h
+ BKE_strands.h
BKE_subsurf.h
BKE_suggestions.h
- BKE_editmesh.h
- BKE_editmesh_bvh.h
BKE_text.h
BKE_texture.h
BKE_tracking.h
diff --cc source/blender/blenkernel/intern/object_dupli.c
index b65d4f5,8abe4bd..a5f3761
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@@ -1324,498 -1237,7 +1324,498 @@@ int count_duplilist(Object *ob
return 1;
}
+/* ------------------------------------------------------------------------- */
+
+static void dupli_cache_calc_boundbox(DupliObjectData *data)
+{
+ DupliObjectDataStrands *link;
+ float min[3], max[3];
+ bool has_data = false;
+
+ INIT_MINMAX(min, max);
+ if (data->dm) {
+ data->dm->getMinMax(data->dm, min, max);
+ has_data = true;
+ }
+ for (link = data->strands.first; link; link = link->next) {
+ if (link->strands) {
+ BKE_strands_get_minmax(link->strands, min, max, true);
+ has_data = true;
+ }
+ if (link->strands_children) {
+ BKE_strands_children_get_minmax(link->strands_children, min, max);
+ has_data = true;
+ }
+ }
+
+ if (!has_data) {
+ zero_v3(min);
+ zero_v3(max);
+ }
+
+ BKE_boundbox_init_from_minmax(&data->bb, min, max);
+}
+
+static bool UNUSED_FUNCTION(dupli_object_data_strands_unique_name)(ListBase *lb, DupliObjectDataStrands *link)
+{
+ if (lb && link) {
+ return BLI_uniquename(lb, link, DATA_("Strands"), '.', offsetof(DupliObjectDataStrands, name), sizeof(link->name));
+ }
+ return false;
+}
+
+void BKE_dupli_object_data_init(DupliObjectData *data, Object *ob)
+{
+ data->ob = ob;
+
+ data->dm = NULL;
+ BLI_listbase_clear(&data->strands);
+
+ memset(&data->bb, 0, sizeof(data->bb));
+ dupli_cache_calc_boundbox(data);
+}
+
+void BKE_dupli_object_data_clear(DupliObjectData *data)
+{
+ DupliObjectDataStrands *link;
+
+ if (data->dm) {
+ /* we lock DMs in the cache to prevent freeing outside,
+ * now allow releasing again
+ */
+ data->dm->needsFree = true;
+ data->dm->release(data->dm);
+ }
+
+ for (link = data->strands.first; link; link = link->next) {
+ if (link->strands)
+ BKE_strands_free(link->strands);
+ if (link->strands_children)
+ BKE_strands_children_free(link->strands_children);
+ }
+ BLI_freelistN(&data->strands);
+}
+
+void BKE_dupli_object_data_set_mesh(DupliObjectData *data, DerivedMesh *dm)
+{
+ if (data->dm) {
+ /* we lock DMs in the cache to prevent freeing outside,
+ * now allow releasing again
+ */
+ data->dm->needsFree = true;
+ data->dm->release(data->dm);
+ }
+
+ data->dm = dm;
+ /* we own this dm now and need to protect it until we free it ourselves */
+ dm->needsFree = false;
+
+ dupli_cache_calc_boundbox(data);
+}
+
+void BKE_dupli_object_data_add_strands(DupliObjectData *data, const char *name, Strands *strands)
+{
+ DupliObjectDataStrands *link = NULL;
+ for (link = data->strands.first; link; link = link->next) {
+ if (STREQ(link->name, name))
+ break;
+ }
+
+ if (!link) {
+ link = MEM_callocN(sizeof(DupliObjectDataStrands), "strands link");
+ BLI_strncpy(link->name, name, sizeof(link->name));
+ link->strands = strands;
+
+ BLI_addtail(&data->strands, link);
+ }
+ else {
+ if (link->strands && link->strands != strands)
+ BKE_strands_free(link->strands);
+ link->strands = strands;
+ }
+
+ dupli_cache_calc_boundbox(data);
+}
+
+void BKE_dupli_object_data_add_strands_children(DupliObjectData *data, const char *name, StrandsChildren *children)
+{
+ DupliObjectDataStrands *link = NULL;
+ for (link = data->strands.first; link; link = link->next) {
+ if (STREQ(link->name, name))
+ break;
+ }
+
+ if (!link) {
+ link = MEM_callocN(sizeof(DupliObjectDataStrands), "strands link");
+ BLI_strncpy(link->name, name, sizeof(link->name));
+ link->strands_children = children;
+
+ BLI_addtail(&data->strands, link);
+ }
+ else {
+ if (link->strands_children && link->strands_children != children)
+ BKE_strands_children_free(link->strands_children);
+ link->strands_children = children;
+ }
+
+ dupli_cache_calc_boundbox(data);
+}
+
+Strands *BKE_dupli_object_data_find_strands(DupliObjectData *data, const char *name)
+{
+ DupliObjectDataStrands *link;
+ for (link = data->strands.first; link; link = link->next) {
+ if (STREQ(link->name, name))
+ return link->strands;
+ }
+ return NULL;
+}
+
+StrandsChildren *BKE_dupli_object_data_find_strands_children(DupliObjectData *data, const char *name)
+{
+ DupliObjectDataStrands *link;
+ for (link = data->strands.first; link; link = link->next) {
+ if (STREQ(link->name, name))
+ return link->strands_children;
+ }
+ return NULL;
+}
+
+bool BKE_dupli_object_data_acquire_strands(DupliObjectData *data, Strands *strands)
+{
+ DupliObjectDataStrands *link, *link_next;
+ bool found = false;
+
+ if (!data || !strands)
+ return false;
+
+ for (link = data->strands.first; link; link = link_next) {
+ link_next = link->next;
+ if (link->strands == strands) {
+ link->strands = NULL;
+ found = true;
+ }
+ }
+ return found;
+}
+
+bool BKE_dupli_object_data_acquire_strands_children(DupliObjectData *data, StrandsChildren *children)
+{
+ DupliObjectDataStrands *link, *link_next;
+ bool found = false;
+
+ if (!data || !children)
+ return false;
+
+ for (link = data->strands.first; link; link = link_next) {
+ link_next = link->next;
+ if (link->strands_children == children) {
+ link->strands_children = NULL;
+ found = true;
+ }
+ }
+ return found;
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void dupli_object_data_free(DupliObjectData *data)
+{
+ BKE_dupli_object_data_clear(data);
+ MEM_freeN(data);
+}
+
+static void dupli_object_free(DupliObject *dob)
+{
+ MEM_freeN(dob);
+}
+
+DupliCache *BKE_dupli_cache_new(void)
+{
+ DupliCache *dupcache = MEM_callocN(sizeof(DupliCache), "dupli object cache");
+
+ dupcache->ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli object data hash");
+
+ return dupcache;
+}
+
+void BKE_dupli_cache_free(DupliCache *dupcache)
+{
+ BKE_dupli_cache_clear(dupcache);
+
+ BLI_ghash_free(dupcache->ghash, NULL, (GHashValFreeFP)dupli_object_data_free);
+ MEM_freeN(dupcache);
+}
+
+void BKE_dupli_cache_clear(DupliCache *dupcache)
+{
+ DupliObject *dob, *dob_next;
+ for (dob = dupcache->duplilist.first; dob; dob = dob_next) {
+ dob_next = dob->next;
+
+ dupli_object_free(dob);
+ }
+ BLI_listbase_clear(&dupcache->duplilist);
+
+ BLI_ghash_clear(dupcache->ghash, NULL, (GHashValFreeFP)dupli_object_data_free);
+}
+
+void BKE_dupli_cache_clear_instances(DupliCache *dupcache)
+{
+ DupliObject *dob, *dob_next;
+ for (dob = dupcache->duplilist.first; dob; dob = dob_next) {
+ dob_next = dob->next;
+
+ dupli_object_free(dob);
+ }
+ BLI_listbase_clear(&dupcache->duplilist);
+}
+
+static DupliObjectData *dupli_cache_add_object_data(DupliCache *dupcache, Object *ob)
+{
+ DupliObjectData *data = MEM_callocN(sizeof(DupliObjectData), "dupli object data");
+
+ data->ob = ob;
+ BLI_ghash_insert(dupcache->ghash, data->ob, data);
+ return data;
+}
+
+static DupliObject *dupli_cache_add_object(DupliCache *dupcache)
+{
+ DupliObject *dob = MEM_callocN(sizeof(DupliObject), "dupli object");
+
+ unit_m4(dob->mat);
+
+ BLI_addtail(&dupcache->duplilist, dob);
+ return dob;
+}
+
+static int count_hair_verts(ParticleSystem *psys)
+{
+ int numverts = 0;
+ int p;
+ for (p = 0; p < psys->totpart; ++p) {
+ numverts += psys->particles[p].totkey;
+ }
+ return numverts;
+}
+
+void BKE_dupli_cache_from_group(Scene *scene, Group *group, CacheLibrary *cachelib, DupliCache *dupcache, EvaluationContext *eval_ctx)
+{
+ DupliObject *dob;
+
+ BKE_dupli_cache_clear(dupcache);
+
+ if (!(group && cachelib))
+ return;
+
+ {
+ /* copy duplilist to the cache */
+ ListBase *duplilist = group_duplilist(eval_ctx, scene, group);
+ dupcache->duplilist = *duplilist;
+ MEM_freeN(duplilist);
+ }
+
+ for (dob = dupcache->duplilist.first; dob; dob = dob->next) {
+ DupliObjectData *data = BKE_dupli_cache_find_data(dupcache, dob->ob);
+ if (!data) {
+ ParticleSystem *psys;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list