From 26e50295ceb81bd09f65d30116f897ba53e50daf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Apr 2015 20:03:49 +1000 Subject: Use BKE_ghash_ensure_p where possible --- source/blender/modifiers/intern/MOD_build.c | 42 ++++++++++++++++++----------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_build.c') diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 1dc1a1f8d64..96337c33373 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -131,6 +131,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), MPoly *mpoly, *mp; MLoop *ml, *mloop; MEdge *medge; + uintptr_t hash_num, hash_num_alt; if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) { BLI_array_randomize(faceMap, sizeof(*faceMap), @@ -142,40 +143,44 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), */ mpoly = mpoly_src; mloop = mloop_src; + hash_num = 0; for (i = 0; i < numFaces_dst; i++) { mp = mpoly + faceMap[i]; ml = mloop + mp->loopstart; for (j = 0; j < mp->totloop; j++, ml++) { - if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(ml->v))) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(ml->v), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); + void **val_p; + if (!BLI_ghash_ensure_p(vertHash, SET_INT_IN_POINTER(ml->v), &val_p)) { + *val_p = (void *)hash_num; + hash_num++; + } } - + numLoops_dst += mp->totloop; } + BLI_assert(hash_num == BLI_ghash_size(vertHash)); /* get the set of edges that will be in the new mesh (i.e. all edges * that have both verts in the new mesh) */ medge = medge_src; - for (i = 0; i < numEdge_src; i++) { + hash_num = 0; + hash_num_alt = 0; + for (i = 0; i < numEdge_src; i++, hash_num_alt++) { MEdge *me = medge + i; if (BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1)) && BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) { - j = BLI_ghash_size(edgeHash); - - BLI_ghash_insert(edgeHash, SET_INT_IN_POINTER(j), - SET_INT_IN_POINTER(i)); - BLI_ghash_insert(edgeHash2, SET_INT_IN_POINTER(i), - SET_INT_IN_POINTER(j)); + BLI_ghash_insert(edgeHash, (void *)hash_num, (void *)hash_num_alt); + BLI_ghash_insert(edgeHash2, (void *)hash_num_alt, (void *)hash_num); + hash_num++; } } } else if (numEdges_dst) { MEdge *medge, *me; + uintptr_t hash_num; if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) BLI_array_randomize(edgeMap, sizeof(*edgeMap), @@ -185,17 +190,22 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), * mapped to the new indices */ medge = medge_src; + hash_num = 0; + BLI_assert(hash_num == BLI_ghash_size(vertHash)); for (i = 0; i < numEdges_dst; i++) { + void **val_p; me = medge + edgeMap[i]; - if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1))) { - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me->v1), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); + if (!BLI_ghash_ensure_p(vertHash, SET_INT_IN_POINTER(me->v1), &val_p)) { + *val_p = (void *)hash_num; + hash_num++; } - if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) { - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me->v2), SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); + if (!BLI_ghash_ensure_p(vertHash, SET_INT_IN_POINTER(me->v2), &val_p)) { + *val_p = (void *)hash_num; + hash_num++; } } + BLI_assert(hash_num == BLI_ghash_size(vertHash)); /* get the set of edges that will be in the new mesh */ for (i = 0; i < numEdges_dst; i++) { -- cgit v1.2.3 From bac735380189c63d2b8824cba8e0398bb35e9af2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 May 2015 15:05:57 +0500 Subject: Depsgraph: New dependency graph integration commit This commit integrates the work done so far on the new dependency graph system, where goal was to replace legacy depsgraph with the new one, supporting loads of neat features like: - More granular dependency relation nature, which solves issues with fake cycles in the dependencies. - Move towards all-animatable, by better integration of drivers into the system. - Lay down some basis for upcoming copy-on-write, overrides and so on. The new system is living side-by-side with the previous one and disabled by default, so nothing will become suddenly broken. The way to enable new depsgraph is to pass `--new-depsgraph` command line argument. It's a bit early to consider the system production-ready, there are some TODOs and issues were discovered during the merge period, they'll be addressed ASAP. But it's important to merge, because it's the only way to attract artists to really start testing this system. There are number of assorted documents related on the design of the new system: * http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents * http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph There are also some user-related information online: * http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/ * http://code.blender.org/2015/03/more-dependency-graph-tricks/ Kudos to everyone who was involved into the project: - Joshua "Aligorith" Leung -- design specification, initial code - Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes - Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the project and so - Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the issues and recording/writing documentation. - Everyone else who i forgot to mention here :) --- source/blender/modifiers/intern/MOD_build.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/modifiers/intern/MOD_build.c') diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 96337c33373..507fad466a3 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -329,6 +329,7 @@ ModifierTypeInfo modifierType_Build = { /* freeData */ NULL, /* isDisabled */ NULL, /* updateDepgraph */ NULL, + /* updateDepsgraph */ NULL, /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, -- cgit v1.2.3