diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-12-12 18:17:57 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-12-12 18:17:57 +0300 |
commit | 9be6d5ff18fd593e853647d9eec8b3fb074acd7c (patch) | |
tree | 485fb9203c310b5119a549e698db241012ed39ff /source/blender/blenkernel/intern | |
parent | 54528079e3cfaf74eaa119615386564820b45276 (diff) | |
parent | 5f852a4324212221500d11b2c7594f5e0ca894c6 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenloader/intern/versioning_270.c
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_particle.c
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 56 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library_remap.c | 29 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 27 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 17 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/seqeffects.c | 51 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 60 |
11 files changed, 128 insertions, 150 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 8716ebe4bfd..fb0087aefac 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -230,7 +230,9 @@ static MPoly *dm_dupPolyArray(DerivedMesh *dm) static int dm_getNumLoopTri(DerivedMesh *dm) { - return dm->looptris.num; + const int numlooptris = poly_to_tri_count(dm->getNumPolys(dm), dm->getNumLoops(dm)); + BLI_assert(ELEM(dm->looptris.num, 0, numlooptris)); + return numlooptris; } static CustomData *dm_getVertCData(DerivedMesh *dm) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9d4de30aa2c..cb74dbcd8d1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4404,6 +4404,7 @@ static void transformcache_free(bConstraint *con) #ifdef WITH_ALEMBIC CacheReader_free(data->reader); #endif + data->reader = NULL; } } diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 05cf5f6d7bd..e7c0e69b1cb 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -621,10 +621,33 @@ static void emDM_recalcTessellation(DerivedMesh *UNUSED(dm)) /* do nothing */ } -static void emDM_recalcLoopTri(DerivedMesh *UNUSED(dm)) +static void emDM_recalcLoopTri(DerivedMesh *dm) { - /* Nothing to do: emDM tessellation is known, - * allocate and fill in with emDM_getLoopTriArray */ + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMLoop *(*looptris)[3] = bmdm->em->looptris; + MLoopTri *mlooptri; + const int tottri = bmdm->em->tottri; + int i; + + DM_ensure_looptri_data(dm); + mlooptri = dm->looptris.array; + + BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); + BLI_assert(tottri == dm->looptris.num); + + BM_mesh_elem_index_ensure(bmdm->em->bm, BM_FACE | BM_LOOP); + + for (i = 0; i < tottri; i++) { + BMLoop **ltri = looptris[i]; + MLoopTri *lt = &mlooptri[i]; + + ARRAY_SET_ITEMS( + lt->tri, + BM_elem_index_get(ltri[0]), + BM_elem_index_get(ltri[1]), + BM_elem_index_get(ltri[2])); + lt->poly = BM_elem_index_get(ltri[0]->f); + } } static const MLoopTri *emDM_getLoopTriArray(DerivedMesh *dm) @@ -633,32 +656,9 @@ static const MLoopTri *emDM_getLoopTriArray(DerivedMesh *dm) BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); } else { - EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; - BMLoop *(*looptris)[3] = bmdm->em->looptris; - MLoopTri *mlooptri; - const int tottri = bmdm->em->tottri; - int i; - - DM_ensure_looptri_data(dm); - mlooptri = dm->looptris.array; - - BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); - BLI_assert(tottri == dm->looptris.num); - - BM_mesh_elem_index_ensure(bmdm->em->bm, BM_FACE | BM_LOOP); - - for (i = 0; i < tottri; i++) { - BMLoop **ltri = looptris[i]; - MLoopTri *lt = &mlooptri[i]; - - ARRAY_SET_ITEMS( - lt->tri, - BM_elem_index_get(ltri[0]), - BM_elem_index_get(ltri[1]), - BM_elem_index_get(ltri[2])); - lt->poly = BM_elem_index_get(ltri[0]->f); - } + dm->recalcLoopTri(dm); } + return dm->looptris.array; } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 9afcd7f2bbb..95d78436cb9 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -631,7 +631,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP force[1] = (0.5f - result->tg) * strength; force[2] = (0.5f - result->tb) * strength; } - else { + else if (nabla != 0) { strength/=nabla; tex_co[0] += nabla; @@ -671,6 +671,9 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP force[2] = (dgdx - drdy) * strength; } } + else { + zero_v3(force); + } if (eff->pd->flag & PFIELD_TEX_2D) { float fac = -dot_v3v3(force, efd->nor); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index ff0112b4378..4b854289814 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1157,31 +1157,6 @@ void *BKE_libblock_copy_nolib(ID *id, const bool do_action) return idn; } -static int id_relink_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag) -{ - ID *id = *id_pointer; - if (id) { - /* See: NEW_ID macro */ - if (id->newid) { - BKE_library_update_ID_link_user(id->newid, id, cd_flag); - *id_pointer = id->newid; - } - else if (id->tag & LIB_TAG_NEW) { - id->tag &= ~LIB_TAG_NEW; - BKE_libblock_relink(id); - } - } - return IDWALK_RET_NOP; -} - -void BKE_libblock_relink(ID *id) -{ - if (ID_IS_LINKED_DATABLOCK(id)) - return; - - BKE_library_foreach_ID_link(id, id_relink_looper, NULL, 0); -} - void BKE_library_free(Library *lib) { if (lib->packedfile) diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 3b757a46e2e..a257621dc2d 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -679,6 +679,35 @@ void BKE_libblock_relink_ex( } } +static int id_relink_to_newid_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag) +{ + ID *id = *id_pointer; + if (id) { + /* See: NEW_ID macro */ + if (id->newid) { + BKE_library_update_ID_link_user(id->newid, id, cd_flag); + *id_pointer = id->newid; + } + else if (id->tag & LIB_TAG_NEW) { + id->tag &= ~LIB_TAG_NEW; + BKE_libblock_relink_to_newid(id); + } + } + return IDWALK_RET_NOP; +} + +/** Similar to libblock_relink_ex, but is remapping IDs to their newid value if non-NULL, in given \a id. + * + * Very specific usage, not sure we'll keep it on the long run, currently only used in Object duplication code... + */ +void BKE_libblock_relink_to_newid(ID *id) +{ + if (ID_IS_LINKED_DATABLOCK(id)) + return; + + BKE_library_foreach_ID_link(id, id_relink_to_newid_looper, NULL, 0); +} + void BKE_libblock_free_data(Main *UNUSED(bmain), ID *id) { if (id->properties) { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index a227228ceb5..f16e8f328d4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1307,33 +1307,6 @@ bNodeTree *ntreeCopyTree(Main *bmain, bNodeTree *ntree) return ntreeCopyTree_ex(ntree, bmain, true); } -/* use when duplicating scenes */ -void ntreeSwitchID_ex(bNodeTree *ntree, ID *id_from, ID *id_to, const bool do_id_user) -{ - bNode *node; - - if (id_from == id_to) { - /* should never happen but may as well skip if it does */ - return; - } - - /* for scene duplication only */ - for (node = ntree->nodes.first; node; node = node->next) { - if (node->id == id_from) { - if (do_id_user) { - id_us_min(id_from); - id_us_plus(id_to); - } - - node->id = id_to; - } - } -} -void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to) -{ - ntreeSwitchID_ex(ntree, id_from, id_to, true); -} - void ntreeUserIncrefID(bNodeTree *ntree) { bNode *node; diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 0b361d479f9..4bed9e6476a 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -46,6 +46,7 @@ # include "RBI_api.h" #endif +#include "DNA_ID.h" #include "DNA_group_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -217,13 +218,6 @@ RigidBodyCon *BKE_rigidbody_copy_constraint(Object *ob) return rbcN; } -/* preserve relationships between constraints and rigid bodies after duplication */ -void BKE_rigidbody_relink_constraint(RigidBodyCon *rbc) -{ - ID_NEW_REMAP(rbc->ob1); - ID_NEW_REMAP(rbc->ob2); -} - /* ************************************** */ /* Setup Utilities - Validate Sim Instances */ @@ -963,12 +957,9 @@ RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw) void BKE_rigidbody_world_groups_relink(RigidBodyWorld *rbw) { - if (rbw->group && rbw->group->id.newid) - rbw->group = (Group *)rbw->group->id.newid; - if (rbw->constraints && rbw->constraints->id.newid) - rbw->constraints = (Group *)rbw->constraints->id.newid; - if (rbw->effector_weights->group && rbw->effector_weights->group->id.newid) - rbw->effector_weights->group = (Group *)rbw->effector_weights->group->id.newid; + ID_NEW_REMAP(rbw->group); + ID_NEW_REMAP(rbw->constraints); + ID_NEW_REMAP(rbw->effector_weights->group); } void BKE_rigidbody_world_id_loop(RigidBodyWorld *rbw, RigidbodyWorldIDFunc func, void *userdata) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index fb6173cf771..cab0a876292 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -78,6 +78,7 @@ #include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_library.h" +#include "BKE_library_remap.h" #include "BKE_linestyle.h" #include "BKE_main.h" #include "BKE_mask.h" @@ -209,7 +210,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) if (sce->nodetree) { /* ID's are managed on both copy and switch */ scen->nodetree = ntreeCopyTree(bmain, sce->nodetree); - ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); + BKE_libblock_relink_ex(bmain, scen->nodetree, &sce->id, &scen->id, false); } obase = sce->base.first; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index ce7c520438a..298671beedb 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1074,29 +1074,31 @@ static void do_sub_effect(const SeqRenderData *context, Sequence *UNUSED(seq), f static void do_drop_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect2i, unsigned char *rect1i, unsigned char *outi) { - int height, width, temp, fac, fac1, fac2; + int temp, fac, fac1, fac2; unsigned char *rt1, *rt2, *out; int field = 1; - width = x; - height = y; + const int width = x; + const int height = y; + const int xoff = min_ii(XOFF, width); + const int yoff = min_ii(YOFF, height); fac1 = (int) (70.0f * facf0); fac2 = (int) (70.0f * facf1); - rt2 = (unsigned char *) (rect2i + YOFF * width); - rt1 = (unsigned char *) rect1i; - out = (unsigned char *) outi; - for (y = 0; y < height - YOFF; y++) { + rt2 = rect2i + yoff * 4 * width; + rt1 = rect1i; + out = outi; + for (y = 0; y < height - yoff; y++) { if (field) fac = fac1; else fac = fac2; field = !field; - memcpy(out, rt1, sizeof(int) * XOFF); - rt1 += XOFF * 4; - out += XOFF * 4; + memcpy(out, rt1, sizeof(*out) * xoff * 4); + rt1 += xoff * 4; + out += xoff * 4; - for (x = XOFF; x < width; x++) { + for (x = xoff; x < width; x++) { temp = ((fac * rt2[3]) >> 8); *(out++) = MAX2(0, *rt1 - temp); rt1++; @@ -1105,37 +1107,38 @@ static void do_drop_effect_byte(float facf0, float facf1, int x, int y, unsigned *(out++) = MAX2(0, *rt1 - temp); rt1++; rt2 += 4; } - rt2 += XOFF * 4; + rt2 += xoff * 4; } - memcpy(out, rt1, sizeof(int) * YOFF * width); + memcpy(out, rt1, sizeof(*out) * yoff * 4 * width); } static void do_drop_effect_float(float facf0, float facf1, int x, int y, float *rect2i, float *rect1i, float *outi) { - int height, width; float temp, fac, fac1, fac2; float *rt1, *rt2, *out; int field = 1; - width = x; - height = y; + const int width = x; + const int height = y; + const int xoff = min_ii(XOFF, width); + const int yoff = min_ii(YOFF, height); fac1 = 70.0f * facf0; fac2 = 70.0f * facf1; - rt2 = (rect2i + YOFF * width); + rt2 = rect2i + yoff * 4 * width; rt1 = rect1i; out = outi; - for (y = 0; y < height - YOFF; y++) { + for (y = 0; y < height - yoff; y++) { if (field) fac = fac1; else fac = fac2; field = !field; - memcpy(out, rt1, 4 * sizeof(float) * XOFF); - rt1 += XOFF * 4; - out += XOFF * 4; + memcpy(out, rt1, sizeof(*out) * xoff * 4); + rt1 += xoff * 4; + out += xoff * 4; - for (x = XOFF; x < width; x++) { + for (x = xoff; x < width; x++) { temp = fac * rt2[3]; *(out++) = MAX2(0.0f, *rt1 - temp); rt1++; @@ -1144,9 +1147,9 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y, float * *(out++) = MAX2(0.0f, *rt1 - temp); rt1++; rt2 += 4; } - rt2 += XOFF * 4; + rt2 += xoff * 4; } - memcpy(out, rt1, 4 * sizeof(float) * YOFF * width); + memcpy(out, rt1, sizeof(*out) * yoff * 4 * width); } /*********************** Mul *************************/ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 6d57c5f09e8..c4665c40ec4 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -4474,46 +4474,46 @@ static void ccgDM_recalcTessellation(DerivedMesh *UNUSED(dm)) /* Nothing to do: CCG handles creating its own tessfaces */ } -static void ccgDM_recalcLoopTri(DerivedMesh *UNUSED(dm)) +static void ccgDM_recalcLoopTri(DerivedMesh *dm) { - /* Nothing to do: CCG tessellation is known, - * allocate and fill in with ccgDM_getLoopTriArray */ + BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_WRITE); + MLoopTri *mlooptri; + const int tottri = dm->numPolyData * 2; + int i, poly_index; + + DM_ensure_looptri_data(dm); + mlooptri = dm->looptris.array; + + BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); + BLI_assert(tottri == dm->looptris.num); + + for (i = 0, poly_index = 0; i < tottri; i += 2, poly_index += 1) { + MLoopTri *lt; + lt = &mlooptri[i]; + /* quad is (0, 3, 2, 1) */ + lt->tri[0] = (poly_index * 4) + 0; + lt->tri[1] = (poly_index * 4) + 2; + lt->tri[2] = (poly_index * 4) + 3; + lt->poly = poly_index; + + lt = &mlooptri[i + 1]; + lt->tri[0] = (poly_index * 4) + 0; + lt->tri[1] = (poly_index * 4) + 1; + lt->tri[2] = (poly_index * 4) + 2; + lt->poly = poly_index; + } + BLI_rw_mutex_unlock(&loops_cache_rwlock); } static const MLoopTri *ccgDM_getLoopTriArray(DerivedMesh *dm) { - BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_WRITE); if (dm->looptris.array) { BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); } else { - MLoopTri *mlooptri; - const int tottri = dm->numPolyData * 2; - int i, poly_index; - - DM_ensure_looptri_data(dm); - mlooptri = dm->looptris.array; - - BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); - BLI_assert(tottri == dm->looptris.num); - - for (i = 0, poly_index = 0; i < tottri; i += 2, poly_index += 1) { - MLoopTri *lt; - lt = &mlooptri[i]; - /* quad is (0, 3, 2, 1) */ - lt->tri[0] = (poly_index * 4) + 0; - lt->tri[1] = (poly_index * 4) + 2; - lt->tri[2] = (poly_index * 4) + 3; - lt->poly = poly_index; - - lt = &mlooptri[i + 1]; - lt->tri[0] = (poly_index * 4) + 0; - lt->tri[1] = (poly_index * 4) + 1; - lt->tri[2] = (poly_index * 4) + 2; - lt->poly = poly_index; - } + dm->recalcLoopTri(dm); } - BLI_rw_mutex_unlock(&loops_cache_rwlock); + return dm->looptris.array; } |