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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2006-11-20 07:28:02 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2006-11-20 07:28:02 +0300
commite435fbc3c5a00e5b63c1cd2609ab6828187660d3 (patch)
tree3f1da9c51451dee55a203cd001d37f8774d2582f /source/blender/makesdna
parent0a7c43c6e5fc7d5d75a4645eca1164cede2d03a6 (diff)
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are still used of course, but allocating, copying or freeing these arrays should be done through the CustomData API. Work in progress documentation on this is here: http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData Replaced TFace by MTFace: This is the same struct, except that it does not contain color, that now always stays separated in MCol. This was not a good design decision to begin with, and it is needed for adding multiple color layers later. Note that this does mean older Blender versions will not be able to read UV coordinates from the next release, due to an SDNA limitation. Removed DispListMesh: This now fully replaced by DerivedMesh. To provide access to arrays of vertices, edges and faces, like DispListMesh does. The semantics of the DerivedMesh.getVertArray() and similar functions were changed to return a pointer to an array if one exists, or otherwise allocate a temporary one. On releasing the DerivedMesh, this temporary array will be removed automatically. Removed ssDM and meshDM DerivedMesh backends: The ssDM backend was for DispListMesh, so that became obsolete automatically. The meshDM backend was replaced by the custom data backend, that now figures out which layers need to be modified, and only duplicates those. This changes code in many places, and overall removes 2514 lines of code. So, there's a good chance this might break some stuff, although I've been testing it for a few days now. The good news is, adding multiple color and uv layers should now become easy.
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h44
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h70
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h55
-rw-r--r--source/blender/makesdna/intern/makesdna.c2
4 files changed, 93 insertions, 78 deletions
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 2886f012c8e..08b0345af8d 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -44,26 +44,32 @@ typedef struct CustomDataLayer {
* (vertices, edges or faces). The custom data is organised into a series of
* layers, each with a data type (e.g. TFace, MDeformVert, etc.). */
typedef struct CustomData {
- CustomDataLayer *layers; /* data layer descriptors, ordered by type */
- int numLayers; /* current number of layers */
- int maxLayers; /* maximum number of layers */
- int numElems; /* current number of elements */
- int maxElems; /* maximum number of elements */
- int subElems; /* number of sub-elements layers can have */
- int totSize; /* in editmode, total size of all data layers */
+ CustomDataLayer *layers; /* CustomDataLayers, ordered by type */
+ int totlayer, maxlayer; /* number of layers, size of layers array */
+ int totsize, pad; /* in editmode, total size of all data layers */
} CustomData;
-/* custom data types */
-#define LAYERTYPE_MVERT 0
-#define LAYERTYPE_MSTICKY 1
-#define LAYERTYPE_MDEFORMVERT 2
-#define LAYERTYPE_MEDGE 3
-#define LAYERTYPE_MFACE 4
-#define LAYERTYPE_TFACE 5
-#define LAYERTYPE_MCOL 6
-#define LAYERTYPE_ORIGINDEX 7
-#define LAYERTYPE_NORMAL 8
-#define LAYERTYPE_FLAGS 9
-#define LAYERTYPE_NUMTYPES 10
+/* CustomData.type */
+#define CD_MVERT 0
+#define CD_MSTICKY 1
+#define CD_MDEFORMVERT 2
+#define CD_MEDGE 3
+#define CD_MFACE 4
+#define CD_MTFACE 5
+#define CD_MCOL 6
+#define CD_ORIGINDEX 7
+#define CD_NORMAL 8
+#define CD_FLAGS 9
+#define CD_NUMTYPES 10
+
+/* CustomData.flag */
+
+/* indicates layer should not be copied by CustomData_from_template or
+ * CustomData_copy_data */
+#define CD_FLAG_NOCOPY (1<<0)
+/* indicates layer should not be freed (for layers backed by external data) */
+#define CD_FLAG_NOFREE (1<<1)
+/* indicates the layer is only temporary, also implies no copy */
+#define CD_FLAG_TEMPORARY ((1<<2)|CD_FLAG_NOCOPY)
#endif
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index d0ef6724ff0..fae7c851343 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -34,9 +34,9 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
+#include "DNA_customdata_types.h"
struct DerivedMesh;
-struct DispListMesh;
struct Ipo;
struct Key;
struct Material;
@@ -50,17 +50,6 @@ struct OcInfo;
struct Multires;
struct PartialVisibility;
-typedef struct TFace {
-
- /* this one gets interpreted as a image in texture.c */
- void *tpage;
-
- float uv[4][2]; /* when you change this: also do function set_correct_uv in editmesh.c, and there are more locations that use the size of this part */
- unsigned int col[4];
- char flag, transp;
- short mode, tile, unwrap;
-} TFace;
-
typedef struct Mesh {
ID id;
@@ -73,8 +62,8 @@ typedef struct Mesh {
struct Material **mat;
struct MFace *mface;
- struct TFace *tface;
- void *dface;
+ struct MTFace *mtface;
+ struct TFace *tface; /* depecrated, use mtface */
struct MVert *mvert;
struct MEdge *medge;
struct MDeformVert *dvert; /* __NLA */
@@ -86,6 +75,8 @@ typedef struct Mesh {
struct OcInfo *oc; /* not written in file */
void *sumohandle;
+ struct CustomData vdata, edata, fdata;
+
int totvert, totedge, totface, totselect, pad2;
int texflag;
@@ -109,7 +100,14 @@ typedef struct Mesh {
/*#endif*/
} Mesh;
-
+/* deprecated by MTFace, only here for file reading */
+typedef struct TFace {
+ void *tpage;
+ float uv[4][2];
+ unsigned int col[4];
+ char flag, transp;
+ short mode, tile, unwrap;
+} TFace;
/* **************** MESH ********************* */
@@ -131,48 +129,6 @@ typedef struct Mesh {
#define ME_CC_SUBSURF 0
#define ME_SIMPLE_SUBSURF 1
-#define TF_DYNAMIC 1
-/* #define TF_INVISIBLE 2 */
-#define TF_TEX 4
-#define TF_SHAREDVERT 8
-#define TF_LIGHT 16
-
-#define TF_SHAREDCOL 64
-#define TF_TILES 128
-#define TF_BILLBOARD 256
-#define TF_TWOSIDE 512
-#define TF_INVISIBLE 1024
-
-#define TF_OBCOL 2048
-#define TF_BILLBOARD2 4096 /* with Z axis constraint */
-#define TF_SHADOW 8192
-#define TF_BMFONT 16384
-
-/* tface->flag: 1=select 2=active*/
-#define TF_SELECT 1
-#define TF_ACTIVE 2
-#define TF_SEL1 4
-#define TF_SEL2 8
-#define TF_SEL3 16
-#define TF_SEL4 32
-#define TF_HIDE 64
-
-/* tface->transp */
-#define TF_SOLID 0
-#define TF_ADD 1
-#define TF_ALPHA 2
-#define TF_SUB 3
-
-/* tface->unwrap */
-#define TF_DEPRECATED1 1
-#define TF_DEPRECATED2 2
-#define TF_DEPRECATED3 4
-#define TF_DEPRECATED4 8
-#define TF_PIN1 16
-#define TF_PIN2 32
-#define TF_PIN3 64
-#define TF_PIN4 128
-
#define MESH_MAX_VERTS 2000000000L
#endif
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index a091a2d4ce7..c313b240b5a 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -33,6 +33,7 @@
#define DNA_MESHDATA_TYPES_H
struct Bone;
+struct Image;
typedef struct MFace {
unsigned int v1, v2, v3, v4;
@@ -76,6 +77,13 @@ typedef struct MSelect {
int type;
} MSelect;
+typedef struct MTFace {
+ float uv[4][2];
+ struct Image *tpage;
+ char flag, transp;
+ short mode, tile, unwrap;
+} MTFace;
+
/* Multiresolution modeling */
typedef struct MultiresCol {
float a, r, g, b, u, v;
@@ -171,9 +179,52 @@ typedef struct PartialVisibility {
#define ME_SMOOTH 1
#define ME_FACE_SEL 2
/* flag ME_HIDE==16 is used here too */
-
-#endif
/* mselect->type */
#define ME_VSEl 0
#define ME_ESEl 1
#define ME_FSEL 2
+
+/* mtface->flag */
+#define TF_SELECT 1
+#define TF_ACTIVE 2
+#define TF_SEL1 4
+#define TF_SEL2 8
+#define TF_SEL3 16
+#define TF_SEL4 32
+#define TF_HIDE 64
+
+/* mtface->mode */
+#define TF_DYNAMIC 1
+#define TF_DEPRECATED 2
+#define TF_TEX 4
+#define TF_SHAREDVERT 8
+#define TF_LIGHT 16
+
+#define TF_SHAREDCOL 64
+#define TF_TILES 128
+#define TF_BILLBOARD 256
+#define TF_TWOSIDE 512
+#define TF_INVISIBLE 1024
+
+#define TF_OBCOL 2048
+#define TF_BILLBOARD2 4096 /* with Z axis constraint */
+#define TF_SHADOW 8192
+#define TF_BMFONT 16384
+
+/* mtface->transp */
+#define TF_SOLID 0
+#define TF_ADD 1
+#define TF_ALPHA 2
+#define TF_SUB 3
+
+/* mtface->unwrap */
+#define TF_DEPRECATED1 1
+#define TF_DEPRECATED2 2
+#define TF_DEPRECATED3 4
+#define TF_DEPRECATED4 8
+#define TF_PIN1 16
+#define TF_PIN2 32
+#define TF_PIN3 64
+#define TF_PIN4 128
+
+#endif
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index e7abcb1508e..79e839a172f 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -126,6 +126,7 @@ char *includefiles[] = {
"DNA_node_types.h",
"DNA_color_types.h",
"DNA_brush_types.h",
+ "DNA_customdata_types.h",
// if you add files here, please add them at the end
// of makesdna.c (this file) as well
@@ -1135,4 +1136,5 @@ int main(int argc, char ** argv)
#include "DNA_node_types.h"
#include "DNA_color_types.h"
#include "DNA_brush_types.h"
+#include "DNA_customdata_types.h"
/* end of list */