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/src/booleanops.c
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/src/booleanops.c')
-rw-r--r--source/blender/src/booleanops.c70
1 files changed, 22 insertions, 48 deletions
diff --git a/source/blender/src/booleanops.c b/source/blender/src/booleanops.c
index 11a3577ec0d..2b412eedb77 100644
--- a/source/blender/src/booleanops.c
+++ b/source/blender/src/booleanops.c
@@ -35,6 +35,8 @@
#include "MEM_guardedalloc.h"
+#include "BLI_arithb.h"
+#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "DNA_material_types.h"
@@ -47,6 +49,7 @@
#include "BKE_booleanops.h"
#include "BKE_cdderivedmesh.h"
+#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
@@ -62,13 +65,6 @@
#include <math.h>
-// TODO check to see how many of these includes are necessary
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_linklist.h"
-#include "BLI_memarena.h"
-
/**
* Here's the vertex iterator structure used to walk through
* the blender vertex structure.
@@ -286,23 +282,17 @@ static Object *AddNewBlenderMesh(Base *base)
return ob_new;
}
-/* editmode function, will be replaced soon once custom face data arrives */
-void interp_uv_vcol(float *v1, float *v2, float *v3, float *v4, float *co,
- TFace *tf, TFace *outtf, int j);
-
-static void ConvertCSGTFace(
+static void InterpCSGFace(
DerivedMesh *dm, Mesh *orig_me, int index, int orig_index, int nr,
- TFace *tface, TFace *orig_tface, float mapmat[][4])
+ float mapmat[][4])
{
- float obco[3], *co[4], *orig_co[4];
+ float obco[3], *co[4], *orig_co[4], w[4][4];
MFace *mface, *orig_mface;
int j;
mface = CDDM_get_face(dm, index);
orig_mface = orig_me->mface + orig_index;
- *tface = *orig_tface;
-
// get the vertex coordinates from the original mesh
orig_co[0] = (orig_me->mvert + orig_mface->v1)->co;
orig_co[1] = (orig_me->mvert + orig_mface->v2)->co;
@@ -322,9 +312,10 @@ static void ConvertCSGTFace(
else
VecCopyf(obco, co[j]);
- interp_uv_vcol(orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco,
- orig_tface, tface, j);
+ InterpWeightsQ3Dfl(orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco, w[j]);
}
+
+ CustomData_interp(&orig_me->fdata, &dm->faceData, &orig_index, NULL, (float*)w, 1, index);
}
/* Iterate over the CSG Output Descriptors and create a new DerivedMesh
@@ -348,14 +339,10 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
// create a new DerivedMesh
dm = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements);
- // add tface layers
- if (me1->mcol)
- mcol_to_tface(me1, 1);
- if (me2->mcol)
- mcol_to_tface(me2, 1);
-
- if (me1->tface || me2->tface)
- DM_add_face_layer(dm, LAYERTYPE_TFACE, 0, NULL);
+ CustomData_merge(&me1->fdata, &dm->faceData, CD_MASK_DERIVEDMESH, CD_DEFAULT,
+ face_it->num_elements);
+ CustomData_merge(&me2->fdata, &dm->faceData, CD_MASK_DERIVEDMESH, CD_DEFAULT,
+ face_it->num_elements);
// step through the vertex iterators:
for (i = 0; !vertex_it->Done(vertex_it->it); i++) {
@@ -383,8 +370,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
Object *orig_ob;
Material *orig_mat;
CSG_IFace csgface;
- MFace *mface, *orig_mface;
- TFace *tface, *orig_tface;
+ MFace *mface;
int orig_index, mat_nr;
// retrieve a csg face from the boolean module
@@ -395,8 +381,9 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
orig_me = (csgface.orig_face < me1->totface)? me1: me2;
orig_ob = (orig_me == me1)? ob1: ob2;
orig_index = (orig_me == me1)? csgface.orig_face: csgface.orig_face - me1->totface;
- orig_mface = orig_me->mface + orig_index;
- orig_mat= give_current_material(orig_ob, orig_mface->mat_nr+1);
+
+ // copy all face layers, including mface
+ CustomData_copy_data(&orig_me->fdata, &dm->faceData, orig_index, i, 1);
// set mface
mface = CDDM_get_face(dm, i);
@@ -404,9 +391,10 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
mface->v2 = csgface.vertex_index[1];
mface->v3 = csgface.vertex_index[2];
mface->v4 = (csgface.vertex_number == 4)? csgface.vertex_index[3]: 0;
- mface->flag = orig_mface->flag;
// set material, based on lookup in hash table
+ orig_mat= give_current_material(orig_ob, mface->mat_nr+1);
+
if (mat && orig_mat) {
if (!BLI_ghash_haskey(material_hash, orig_mat)) {
mat[*totmat] = orig_mat;
@@ -419,24 +407,10 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
else
mface->mat_nr = 0;
- // set tface
- if (me1->tface || me2->tface) {
- tface = DM_get_face_data(dm, i, LAYERTYPE_TFACE);;
-
- if (orig_me->tface) {
- orig_tface = orig_me->tface + orig_index;
-
- ConvertCSGTFace(dm, orig_me, i, orig_index,
- csgface.vertex_number, tface, orig_tface,
- (orig_me == me2)? mapmat: NULL);
- }
- else
- default_tface(tface);
- }
- else
- tface = NULL;
+ InterpCSGFace(dm, orig_me, i, orig_index, csgface.vertex_number,
+ (orig_me == me2)? mapmat: NULL);
- test_index_face(mface, NULL, tface, csgface.vertex_number);
+ test_index_face(mface, &dm->faceData, i, csgface.vertex_number);
}
if (material_hash)