Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-12-12 18:17:57 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-12-12 18:17:57 +0300
commit9be6d5ff18fd593e853647d9eec8b3fb074acd7c (patch)
tree485fb9203c310b5119a549e698db241012ed39ff /source/blender/blenkernel
parent54528079e3cfaf74eaa119615386564820b45276 (diff)
parent5f852a4324212221500d11b2c7594f5e0ca894c6 (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')
-rw-r--r--source/blender/blenkernel/BKE_global.h3
-rw-r--r--source/blender/blenkernel/BKE_library.h1
-rw-r--r--source/blender/blenkernel/BKE_library_remap.h1
-rw-r--r--source/blender/blenkernel/BKE_node.h2
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h1
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c4
-rw-r--r--source/blender/blenkernel/intern/constraint.c1
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c56
-rw-r--r--source/blender/blenkernel/intern/effect.c5
-rw-r--r--source/blender/blenkernel/intern/library.c25
-rw-r--r--source/blender/blenkernel/intern/library_remap.c29
-rw-r--r--source/blender/blenkernel/intern/node.c27
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c17
-rw-r--r--source/blender/blenkernel/intern/scene.c3
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c51
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c60
16 files changed, 131 insertions, 155 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 5ef5a807f63..4bb2b950901 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -129,10 +129,11 @@ enum {
G_DEBUG_GPU_MEM = (1 << 10), /* gpu memory in status bar */
G_DEBUG_DEPSGRAPH_NO_THREADS = (1 << 11), /* single threaded depsgraph */
G_DEBUG_GPU = (1 << 12), /* gpu debug */
+ G_DEBUG_IO = (1 << 13), /* IO Debugging (for Collada, ...)*/
};
#define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \
- G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM)
+ G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM | G_DEBUG_IO)
/* G.fileflags */
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index bdd791f5645..d3f98f2989a 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -56,7 +56,6 @@ void BKE_libblock_init_empty(struct ID *id);
void *BKE_libblock_copy(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void *BKE_libblock_copy_nolib(struct ID *id, const bool do_action) ATTR_NONNULL();
void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool do_action);
-void BKE_libblock_relink(struct ID *id);
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
diff --git a/source/blender/blenkernel/BKE_library_remap.h b/source/blender/blenkernel/BKE_library_remap.h
index 89b087014b2..53d438a0fdd 100644
--- a/source/blender/blenkernel/BKE_library_remap.h
+++ b/source/blender/blenkernel/BKE_library_remap.h
@@ -64,6 +64,7 @@ void BKE_libblock_relink_ex(
struct Main *bmain, void *idv, void *old_idv, void *new_idv,
const bool us_min_never_null) ATTR_NONNULL(1, 2);
+void BKE_libblock_relink_to_newid(struct ID *id) ATTR_NONNULL();
typedef void (*BKE_library_free_window_manager_cb)(struct bContext *, struct wmWindowManager *);
typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 95f06e9f695..546f0d97c2b 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -337,8 +337,6 @@ struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char
void ntreeFreeTree(struct bNodeTree *ntree);
struct bNodeTree *ntreeCopyTree_ex(struct bNodeTree *ntree, struct Main *bmain, const bool do_id_user);
struct bNodeTree *ntreeCopyTree(struct Main *bmain, struct bNodeTree *ntree);
-void ntreeSwitchID_ex(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to, const bool do_id_user);
-void ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
/* node->id user count */
void ntreeUserIncrefID(struct bNodeTree *ntree);
void ntreeUserDecrefID(struct bNodeTree *ntree);
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 6731356a5af..20b16b6cc2d 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -51,7 +51,6 @@ void BKE_rigidbody_free_constraint(struct Object *ob);
struct RigidBodyOb *BKE_rigidbody_copy_object(struct Object *ob);
struct RigidBodyCon *BKE_rigidbody_copy_constraint(struct Object *ob);
-void BKE_rigidbody_relink_constraint(struct RigidBodyCon *rbc);
/* Callback format for performing operations on ID-pointers for rigidbody world. */
typedef void (*RigidbodyWorldIDFunc)(struct RigidBodyWorld *rbw, struct ID **idpoin, void *userdata, int cd_flag);
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;
}