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:
authorCampbell Barton <ideasman42@gmail.com>2018-05-02 16:47:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-02 16:48:17 +0300
commit9e477bdf63dc21d3ae5845bed303abb5a2b958e6 (patch)
tree26916d59361fea297c38e087985ac807cd4ad397
parent5659d8bc0aa334aee20f29548e048f3002f1cff6 (diff)
Mesh: move runtime members to own struct
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c8
-rw-r--r--source/blender/blenkernel/intern/mesh.c30
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c20
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h10
5 files changed, 38 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index fa0c1da5f63..dacc0c35e0f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2488,7 +2488,7 @@ static void editbmesh_calc_modifiers(
struct Mesh *mesh = ob->data;
if (mesh->id.tag & LIB_TAG_COPY_ON_WRITE) {
BKE_mesh_ensure_edit_data(mesh);
- mesh->emd->vertexCos = MEM_dupallocN(deformedVerts);
+ mesh->runtime.edit_data->vertexCos = MEM_dupallocN(deformedVerts);
}
*r_cage = getEditDerivedBMesh(
em, ob, mask,
@@ -2530,9 +2530,9 @@ static void editbmesh_calc_modifiers(
struct Mesh *mesh = ob->data;
if (mesh->id.tag & LIB_TAG_COPY_ON_WRITE) {
BKE_mesh_ensure_edit_data(mesh);
- if (mesh->emd->vertexCos != NULL)
- MEM_freeN((void *)mesh->emd->vertexCos);
- mesh->emd->vertexCos = MEM_dupallocN(deformedVerts);
+ if (mesh->runtime.edit_data->vertexCos != NULL)
+ MEM_freeN((void *)mesh->runtime.edit_data->vertexCos);
+ mesh->runtime.edit_data->vertexCos = MEM_dupallocN(deformedVerts);
}
*r_final = getEditDerivedBMesh(em, ob, dataMask, deformedVerts);
deformedVerts = NULL;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index a927377149c..df0fdd61806 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -392,30 +392,30 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
bool BKE_mesh_ensure_edit_data(struct Mesh *me)
{
- if (me->emd != NULL) {
+ if (me->runtime.edit_data != NULL) {
return false;
}
- me->emd = MEM_callocN(sizeof(EditMeshData), "EditMeshData");
+ me->runtime.edit_data = MEM_callocN(sizeof(EditMeshData), "EditMeshData");
return true;
}
bool BKE_mesh_clear_edit_data(struct Mesh *me)
{
- if (me->emd == NULL) {
+ if (me->runtime.edit_data == NULL) {
return false;
}
- if (me->emd->polyCos != NULL)
- MEM_freeN((void *)me->emd->polyCos);
- if (me->emd->polyNos != NULL)
- MEM_freeN((void *)me->emd->polyNos);
- if (me->emd->vertexCos != NULL)
- MEM_freeN((void *)me->emd->vertexCos);
- if (me->emd->vertexNos != NULL)
- MEM_freeN((void *)me->emd->vertexNos);
+ if (me->runtime.edit_data->polyCos != NULL)
+ MEM_freeN((void *)me->runtime.edit_data->polyCos);
+ if (me->runtime.edit_data->polyNos != NULL)
+ MEM_freeN((void *)me->runtime.edit_data->polyNos);
+ if (me->runtime.edit_data->vertexCos != NULL)
+ MEM_freeN((void *)me->runtime.edit_data->vertexCos);
+ if (me->runtime.edit_data->vertexNos != NULL)
+ MEM_freeN((void *)me->runtime.edit_data->vertexNos);
- MEM_SAFE_FREE(me->emd);
+ MEM_SAFE_FREE(me->runtime.edit_data);
return true;
}
@@ -602,7 +602,7 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
BKE_mesh_update_customdata_pointers(me_dst, do_tessface);
me_dst->edit_btmesh = NULL;
- me_dst->batch_cache = NULL;
+ me_dst->runtime.batch_cache = NULL;
me_dst->mselect = MEM_dupallocN(me_dst->mselect);
me_dst->bb = MEM_dupallocN(me_dst->bb);
@@ -2755,13 +2755,13 @@ void (*BKE_mesh_batch_cache_free_cb)(Mesh *me) = NULL;
void BKE_mesh_batch_cache_dirty(Mesh *me, int mode)
{
- if (me->batch_cache) {
+ if (me->runtime.batch_cache) {
BKE_mesh_batch_cache_dirty_cb(me, mode);
}
}
void BKE_mesh_batch_cache_free(Mesh *me)
{
- if (me->batch_cache) {
+ if (me->runtime.batch_cache) {
BKE_mesh_batch_cache_free_cb(me);
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3980c860641..05a74dc90c2 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4676,7 +4676,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
mesh->bb = NULL;
mesh->edit_btmesh = NULL;
- mesh->batch_cache = NULL;
+ mesh->runtime.batch_cache = NULL;
/* happens with old files */
if (mesh->mselect == NULL) {
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 6f44e7afc83..fb6fe306792 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -391,7 +391,7 @@ static MeshRenderData *mesh_render_data_create_ex(
BMesh *bm = embm->bm;
rdata->edit_bmesh = embm;
- rdata->edit_data = me->emd;
+ rdata->edit_data = me->runtime.edit_data;
int bm_ensure_types = 0;
if (types & (MR_DATATYPE_VERT)) {
@@ -1582,7 +1582,7 @@ typedef struct MeshBatchCache {
static bool mesh_batch_cache_valid(Mesh *me)
{
- MeshBatchCache *cache = me->batch_cache;
+ MeshBatchCache *cache = me->runtime.batch_cache;
if (cache == NULL) {
return false;
@@ -1623,10 +1623,10 @@ static bool mesh_batch_cache_valid(Mesh *me)
static void mesh_batch_cache_init(Mesh *me)
{
- MeshBatchCache *cache = me->batch_cache;
+ MeshBatchCache *cache = me->runtime.batch_cache;
if (!cache) {
- cache = me->batch_cache = MEM_callocN(sizeof(*cache), __func__);
+ cache = me->runtime.batch_cache = MEM_callocN(sizeof(*cache), __func__);
}
else {
memset(cache, 0, sizeof(*cache));
@@ -1653,12 +1653,12 @@ static MeshBatchCache *mesh_batch_cache_get(Mesh *me)
mesh_batch_cache_clear(me);
mesh_batch_cache_init(me);
}
- return me->batch_cache;
+ return me->runtime.batch_cache;
}
void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
{
- MeshBatchCache *cache = me->batch_cache;
+ MeshBatchCache *cache = me->runtime.batch_cache;
if (cache == NULL) {
return;
}
@@ -1704,7 +1704,7 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
**/
static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert)
{
- MeshBatchCache *cache = me->batch_cache;
+ MeshBatchCache *cache = me->runtime.batch_cache;
if (!cache) {
return;
}
@@ -1741,7 +1741,7 @@ static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert)
static void mesh_batch_cache_clear(Mesh *me)
{
- MeshBatchCache *cache = me->batch_cache;
+ MeshBatchCache *cache = me->runtime.batch_cache;
if (!cache) {
return;
}
@@ -1820,7 +1820,7 @@ static void mesh_batch_cache_clear(Mesh *me)
void DRW_mesh_batch_cache_free(Mesh *me)
{
mesh_batch_cache_clear(me);
- MEM_SAFE_FREE(me->batch_cache);
+ MEM_SAFE_FREE(me->runtime.batch_cache);
}
/* Gwn_Batch cache usage. */
@@ -3959,7 +3959,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me)
*/
void DRW_mesh_cache_sculpt_coords_ensure(Mesh *me)
{
- if (me->batch_cache) {
+ if (me->runtime.batch_cache) {
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache && cache->pos_with_normals && cache->is_sculpt_points_tag) {
/* XXX Force update of all the batches that contains the pos_with_normals buffer.
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index e8790a86fc5..91477578bf7 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -65,6 +65,12 @@ typedef struct EditMeshData {
const float (*polyCos)[3];
} EditMeshData;
+/* not saved in file! */
+typedef struct MeshRuntime {
+ struct EditMeshData *edit_data;
+ void *batch_cache;
+} MeshRuntime;
+
typedef struct Mesh {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
@@ -100,7 +106,6 @@ typedef struct Mesh {
/* When the object is available, the preferred access method is: BKE_editmesh_from_object(ob) */
struct BMEditMesh *edit_btmesh; /* not saved in file! */
- struct EditMeshData *emd; /* not saved in file! */
struct CustomData vdata, edata, fdata;
@@ -140,7 +145,8 @@ typedef struct Mesh {
short totcol;
struct Multires *mr DNA_DEPRECATED; /* deprecated multiresolution modeling data, only keep for loading old files */
- void *batch_cache;
+
+ MeshRuntime runtime;
} Mesh;
/* deprecated by MTFace, only here for file reading */