2010-01-05 23:33:41 +01:00
|
|
|
/*
|
2006-08-28 03:12:36 +02:00
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-08-28 03:12:36 +02:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): Ben Batt <benbatt@gmail.com>
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* Implementation of CDDerivedMesh.
|
|
|
|
*
|
|
|
|
* BKE_cdderivedmesh.h contains the function prototypes for this file.
|
|
|
|
*
|
2011-02-27 21:40:57 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file blender/blenkernel/intern/cdderivedmesh.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
/* TODO maybe BIF_gl.h should include string.h? */
|
|
|
|
#include <string.h>
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
#include "BKE_cdderivedmesh.h"
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
#include "BKE_global.h"
|
2006-08-28 03:12:36 +02:00
|
|
|
#include "BKE_mesh.h"
|
2010-03-22 12:59:36 +01:00
|
|
|
#include "BKE_paint.h"
|
2006-08-28 03:12:36 +02:00
|
|
|
#include "BKE_utildefines.h"
|
2009-05-16 18:18:08 +02:00
|
|
|
#include "BKE_tessmesh.h"
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-08-28 11:36:31 +02:00
|
|
|
#include "BLI_editVert.h"
|
|
|
|
#include "BLI_scanfill.h"
|
2009-11-10 21:43:45 +01:00
|
|
|
#include "BLI_math.h"
|
2006-08-28 03:12:36 +02:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_edgehash.h"
|
|
|
|
#include "BLI_editVert.h"
|
2010-03-22 12:59:36 +01:00
|
|
|
#include "BLI_math.h"
|
2009-10-27 20:53:34 +01:00
|
|
|
#include "BLI_pbvh.h"
|
2011-02-15 02:16:32 +01:00
|
|
|
#include "BLI_array.h"
|
|
|
|
#include "BLI_smallhash.h"
|
2011-01-07 19:36:47 +01:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
#include "BKE_cdderivedmesh.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_paint.h"
|
2011-01-07 20:18:31 +01:00
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
#include "DNA_object_types.h"
|
2010-03-08 14:49:13 +01:00
|
|
|
#include "DNA_curve_types.h" /* for Curve */
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2010-07-14 12:46:12 +02:00
|
|
|
#include "GPU_buffers.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
#include "GPU_draw.h"
|
|
|
|
#include "GPU_extensions.h"
|
|
|
|
#include "GPU_material.h"
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
2009-01-06 19:59:03 +01:00
|
|
|
#include <math.h>
|
2006-08-28 03:12:36 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
typedef struct {
|
|
|
|
DerivedMesh dm;
|
|
|
|
|
|
|
|
/* these point to data in the DerivedMesh custom data layers,
|
|
|
|
they are only here for efficiency and convenience **/
|
|
|
|
MVert *mvert;
|
|
|
|
MEdge *medge;
|
|
|
|
MFace *mface;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
MLoop *mloop;
|
|
|
|
MPoly *mpoly;
|
2009-10-28 07:06:05 +01:00
|
|
|
|
|
|
|
/* Cached */
|
|
|
|
struct PBVH *pbvh;
|
2010-06-02 20:04:31 +02:00
|
|
|
int pbvh_draw;
|
2011-01-31 21:02:51 +01:00
|
|
|
|
2009-10-28 07:06:05 +01:00
|
|
|
/* Mesh connectivity */
|
|
|
|
struct ListBase *fmap;
|
|
|
|
struct IndexNode *fmap_mem;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
} CDDerivedMesh;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
DMFaceIter *cdDM_newFaceIter(DerivedMesh *source);
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
/**************** DerivedMesh interface functions ****************/
|
|
|
|
static int cdDM_getNumVerts(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return dm->numVertData;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
static int cdDM_getNumEdges(DerivedMesh *dm)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return dm->numEdgeData;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
static int cdDM_getNumTessFaces(DerivedMesh *dm)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return dm->numFaceData;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
static int cdDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
return dm->numPolyData;
|
|
|
|
}
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
static void cdDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
|
|
|
*vert_r = cddm->mvert[index];
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
|
|
|
*edge_r = cddm->medge[index];
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_getFace(DerivedMesh *dm, int index, MFace *face_r)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
|
|
|
*face_r = cddm->mface[index];
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
static void cdDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
|
|
|
memcpy(vert_r, cddm->mvert, sizeof(*vert_r) * dm->numVertData);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
static void cdDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
|
|
|
memcpy(edge_r, cddm->medge, sizeof(*edge_r) * dm->numEdgeData);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2008-09-29 19:08:11 +02:00
|
|
|
static void cdDM_copyFaceArray(DerivedMesh *dm, MFace *face_r)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
|
|
|
memcpy(face_r, cddm->mface, sizeof(*face_r) * dm->numFaceData);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
2006-08-28 03:12:36 +02:00
|
|
|
int i;
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
if (dm->numVertData) {
|
|
|
|
for (i=0; i<dm->numVertData; i++) {
|
|
|
|
DO_MINMAX(cddm->mvert[i].co, min_r, max_r);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_getVertCo(DerivedMesh *dm, int index, float co_r[3])
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
|
|
|
|
VECCOPY(co_r, cddm->mvert[index].co);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
|
|
|
|
{
|
|
|
|
MVert *mv = CDDM_get_verts(dm);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
int i;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
for(i = 0; i < dm->numVertData; i++, mv++)
|
2006-08-28 03:12:36 +02:00
|
|
|
VECCOPY(cos_r[i], mv->co);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_getVertNo(DerivedMesh *dm, int index, float no_r[3])
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
2011-04-27 06:57:57 +02:00
|
|
|
normal_short_to_float_v3(no_r, cddm->mvert[index].no);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2010-01-04 17:53:32 +01:00
|
|
|
static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm)
|
2009-10-28 07:06:05 +01:00
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
|
2010-01-04 17:53:32 +01:00
|
|
|
if(!cddm->fmap && ob->type == OB_MESH) {
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
|
|
|
create_vert_face_map(&cddm->fmap, &cddm->fmap_mem, me->mface,
|
2010-03-22 10:30:00 +01:00
|
|
|
me->totvert, me->totface);
|
2009-10-28 07:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return cddm->fmap;
|
|
|
|
}
|
|
|
|
|
2010-06-21 22:10:59 +02:00
|
|
|
static int can_pbvh_draw(Object *ob, DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
2011-01-08 11:23:36 +01:00
|
|
|
Mesh *me= ob->data;
|
2011-04-23 11:07:46 +02:00
|
|
|
int deformed= 0;
|
2010-06-21 22:10:59 +02:00
|
|
|
|
2011-04-23 11:07:46 +02:00
|
|
|
/* active modifiers means extra deformation, which can't be handled correct
|
|
|
|
on bith of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
|
|
|
|
stuff and show final DerivedMesh so user would see actual object shape */
|
|
|
|
deformed|= ob->sculpt->modifiers_active;
|
|
|
|
|
|
|
|
/* as in case with modifiers, we can't synchronize deformation made against
|
|
|
|
PBVH and non-locked keyblock, so also use PBVH only for brushes and
|
|
|
|
final DM to give final result to user */
|
|
|
|
deformed|= ob->sculpt->kb && (ob->shapeflag&OB_SHAPE_LOCK) == 0;
|
2010-06-21 22:10:59 +02:00
|
|
|
|
2011-04-23 11:07:46 +02:00
|
|
|
if(deformed)
|
|
|
|
return 0;
|
2010-06-21 22:10:59 +02:00
|
|
|
|
|
|
|
return (cddm->mvert == me->mvert) || ob->sculpt->kb;
|
|
|
|
}
|
|
|
|
|
2009-11-25 14:11:44 +01:00
|
|
|
static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
2009-10-28 07:06:05 +01:00
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
|
2010-03-22 12:59:36 +01:00
|
|
|
if(!ob) {
|
|
|
|
cddm->pbvh= NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ob->sculpt)
|
|
|
|
return NULL;
|
2010-06-02 20:04:31 +02:00
|
|
|
if(ob->sculpt->pbvh) {
|
2010-03-22 12:59:36 +01:00
|
|
|
cddm->pbvh= ob->sculpt->pbvh;
|
2010-06-21 22:10:59 +02:00
|
|
|
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
|
2010-06-02 20:04:31 +02:00
|
|
|
}
|
2009-11-25 14:11:44 +01:00
|
|
|
|
2010-06-02 20:04:31 +02:00
|
|
|
/* always build pbvh from original mesh, and only use it for drawing if
|
|
|
|
this derivedmesh is just original mesh. it's the multires subsurf dm
|
|
|
|
that this is actually for, to support a pbvh on a modified mesh */
|
2009-11-25 14:11:44 +01:00
|
|
|
if(!cddm->pbvh && ob->type == OB_MESH) {
|
2011-05-04 15:15:42 +02:00
|
|
|
SculptSession *ss= ob->sculpt;
|
2010-12-17 20:05:10 +01:00
|
|
|
Mesh *me= ob->data;
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
cddm->pbvh = BLI_pbvh_new();
|
2010-06-21 22:10:59 +02:00
|
|
|
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
|
2009-11-25 14:40:43 +01:00
|
|
|
BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
|
2010-03-22 10:30:00 +01:00
|
|
|
me->totface, me->totvert);
|
2011-01-31 21:02:51 +01:00
|
|
|
|
2011-05-04 15:15:42 +02:00
|
|
|
if(ss->modifiers_active && ob->derivedDeform) {
|
|
|
|
DerivedMesh *deformdm= ob->derivedDeform;
|
2011-01-31 21:02:51 +01:00
|
|
|
float (*vertCos)[3];
|
|
|
|
int totvert;
|
|
|
|
|
2011-05-04 15:15:42 +02:00
|
|
|
totvert= deformdm->getNumVerts(deformdm);
|
2011-01-31 21:02:51 +01:00
|
|
|
vertCos= MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos");
|
2011-05-04 15:15:42 +02:00
|
|
|
deformdm->getVertCos(deformdm, vertCos);
|
2011-01-31 21:02:51 +01:00
|
|
|
BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos);
|
|
|
|
MEM_freeN(vertCos);
|
|
|
|
}
|
2009-10-28 07:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return cddm->pbvh;
|
|
|
|
}
|
|
|
|
|
2010-12-14 04:30:30 +01:00
|
|
|
/* update vertex normals so that drawing smooth faces works during sculpt
|
|
|
|
TODO: proper fix is to support the pbvh in all drawing modes */
|
|
|
|
static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
float (*face_nors)[3];
|
|
|
|
|
|
|
|
if(!cddm->pbvh || !cddm->pbvh_draw || !dm->numFaceData)
|
|
|
|
return;
|
|
|
|
|
|
|
|
face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
|
|
|
|
|
|
|
|
BLI_pbvh_update(cddm->pbvh, PBVH_UpdateNormals, face_nors);
|
|
|
|
}
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
static void cdDM_drawVerts(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *mv = cddm->mvert;
|
2006-08-28 03:12:36 +02:00
|
|
|
int i;
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if( GPU_buffer_legacy(dm) ) {
|
|
|
|
glBegin(GL_POINTS);
|
|
|
|
for(i = 0; i < dm->numVertData; i++, mv++)
|
|
|
|
glVertex3fv(mv->co);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
|
|
|
GPU_vertex_setup(dm);
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
2010-07-29 02:06:22 +02:00
|
|
|
if(dm->drawObject->nelements) glDrawArrays(GL_POINTS,0, dm->drawObject->nelements);
|
|
|
|
else glDrawArrays(GL_POINTS,0, dm->drawObject->nlooseverts);
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
GPU_buffer_unbind();
|
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_drawUVEdges(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MFace *mf = cddm->mface;
|
2009-08-15 19:31:28 +02:00
|
|
|
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
2006-08-28 03:12:36 +02:00
|
|
|
int i;
|
|
|
|
|
2007-04-29 15:39:46 +02:00
|
|
|
if(mf) {
|
2009-10-23 01:22:05 +02:00
|
|
|
if( GPU_buffer_legacy(dm) ) {
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(i = 0; i < dm->numFaceData; i++, mf++, tf++) {
|
|
|
|
if(!(mf->flag&ME_HIDE)) {
|
2006-08-28 03:12:36 +02:00
|
|
|
glVertex2fv(tf->uv[0]);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
|
|
|
|
glVertex2fv(tf->uv[1]);
|
2006-08-28 03:12:36 +02:00
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(!mf->v4) {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
} else {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int prevstart = 0;
|
|
|
|
int prevdraw = 1;
|
|
|
|
int draw = 1;
|
|
|
|
int curpos = 0;
|
|
|
|
|
|
|
|
GPU_uvedge_setup(dm);
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
|
|
|
for(i = 0; i < dm->numFaceData; i++, mf++) {
|
2010-11-15 09:03:20 +01:00
|
|
|
if(!(mf->flag&ME_HIDE)) {
|
2009-10-23 01:22:05 +02:00
|
|
|
draw = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
draw = 0;
|
|
|
|
}
|
|
|
|
if( prevdraw != draw ) {
|
|
|
|
if( prevdraw > 0 && (curpos-prevstart) > 0) {
|
|
|
|
glDrawArrays(GL_LINES,prevstart,curpos-prevstart);
|
|
|
|
}
|
|
|
|
prevstart = curpos;
|
|
|
|
}
|
|
|
|
if( mf->v4 ) {
|
|
|
|
curpos += 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
curpos += 6;
|
|
|
|
}
|
|
|
|
prevdraw = draw;
|
|
|
|
}
|
|
|
|
if( prevdraw > 0 && (curpos-prevstart) > 0 ) {
|
|
|
|
glDrawArrays(GL_LINES,prevstart,curpos-prevstart);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_buffer_unbind();
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-22 12:59:36 +01:00
|
|
|
static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *mvert = cddm->mvert;
|
|
|
|
MEdge *medge = cddm->medge;
|
2006-08-28 03:12:36 +02:00
|
|
|
int i;
|
2009-10-23 01:22:05 +02:00
|
|
|
|
|
|
|
if( GPU_buffer_legacy(dm) ) {
|
|
|
|
DEBUG_VBO( "Using legacy code. cdDM_drawEdges\n" );
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(i = 0; i < dm->numEdgeData; i++, medge++) {
|
2010-03-22 12:59:36 +01:00
|
|
|
if((drawAllEdges || (medge->flag&ME_EDGEDRAW))
|
2009-10-23 01:22:05 +02:00
|
|
|
&& (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
|
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
|
|
|
int prevstart = 0;
|
|
|
|
int prevdraw = 1;
|
|
|
|
int draw = 1;
|
|
|
|
|
|
|
|
GPU_edge_setup(dm);
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
|
|
|
for(i = 0; i < dm->numEdgeData; i++, medge++) {
|
2010-03-22 12:59:36 +01:00
|
|
|
if((drawAllEdges || (medge->flag&ME_EDGEDRAW))
|
2009-10-23 01:22:05 +02:00
|
|
|
&& (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
|
|
|
|
draw = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
draw = 0;
|
|
|
|
}
|
|
|
|
if( prevdraw != draw ) {
|
|
|
|
if( prevdraw > 0 && (i-prevstart) > 0 ) {
|
|
|
|
GPU_buffer_draw_elements( dm->drawObject->edges, GL_LINES, prevstart*2, (i-prevstart)*2 );
|
|
|
|
}
|
|
|
|
prevstart = i;
|
|
|
|
}
|
|
|
|
prevdraw = draw;
|
|
|
|
}
|
|
|
|
if( prevdraw > 0 && (i-prevstart) > 0 ) {
|
|
|
|
GPU_buffer_draw_elements( dm->drawObject->edges, GL_LINES, prevstart*2, (i-prevstart)*2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GPU_buffer_unbind();
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_drawLooseEdges(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *mvert = cddm->mvert;
|
|
|
|
MEdge *medge = cddm->medge;
|
2006-08-28 03:12:36 +02:00
|
|
|
int i;
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if( GPU_buffer_legacy(dm) ) {
|
|
|
|
DEBUG_VBO( "Using legacy code. cdDM_drawLooseEdges\n" );
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(i = 0; i < dm->numEdgeData; i++, medge++) {
|
|
|
|
if(medge->flag&ME_LOOSEEDGE) {
|
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
|
|
|
int prevstart = 0;
|
|
|
|
int prevdraw = 1;
|
|
|
|
int draw = 1;
|
|
|
|
|
|
|
|
GPU_edge_setup(dm);
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
|
|
|
for(i = 0; i < dm->numEdgeData; i++, medge++) {
|
|
|
|
if(medge->flag&ME_LOOSEEDGE) {
|
|
|
|
draw = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
draw = 0;
|
|
|
|
}
|
|
|
|
if( prevdraw != draw ) {
|
|
|
|
if( prevdraw > 0 && (i-prevstart) > 0) {
|
|
|
|
GPU_buffer_draw_elements( dm->drawObject->edges, GL_LINES, prevstart*2, (i-prevstart)*2 );
|
|
|
|
}
|
|
|
|
prevstart = i;
|
|
|
|
}
|
|
|
|
prevdraw = draw;
|
|
|
|
}
|
|
|
|
if( prevdraw > 0 && (i-prevstart) > 0 ) {
|
|
|
|
GPU_buffer_draw_elements( dm->drawObject->edges, GL_LINES, prevstart*2, (i-prevstart)*2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GPU_buffer_unbind();
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-28 07:06:05 +01:00
|
|
|
static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
2009-10-27 20:53:34 +01:00
|
|
|
float (*partial_redraw_planes)[4],
|
2010-10-16 16:32:17 +02:00
|
|
|
int UNUSED(fast), int (*setMaterial)(int, void *attribs))
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *mvert = cddm->mvert;
|
|
|
|
MFace *mface = cddm->mface;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
int a, glmode = -1, shademodel = -1, matnr = -1, drawCurrentMat = 1;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
#define PASSVERT(index) { \
|
|
|
|
if(shademodel == GL_SMOOTH) { \
|
|
|
|
short *no = mvert[index].no; \
|
|
|
|
glNormal3sv(no); \
|
|
|
|
} \
|
|
|
|
glVertex3fv(mvert[index].co); \
|
|
|
|
}
|
|
|
|
|
2010-06-02 20:04:31 +02:00
|
|
|
if(cddm->pbvh && cddm->pbvh_draw) {
|
2010-02-06 18:04:13 +01:00
|
|
|
if(dm->numFaceData) {
|
|
|
|
float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL);
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
|
2010-02-06 18:04:13 +01:00
|
|
|
/* should be per face */
|
|
|
|
if(!setMaterial(mface->mat_nr+1, NULL))
|
|
|
|
return;
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2010-02-06 18:04:13 +01:00
|
|
|
glShadeModel((mface->flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT);
|
2010-03-22 18:17:36 +01:00
|
|
|
BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, (mface->flag & ME_SMOOTH));
|
2010-02-06 18:04:13 +01:00
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
}
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
|
2009-10-27 20:53:34 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if( GPU_buffer_legacy(dm) ) {
|
|
|
|
DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid\n" );
|
|
|
|
glBegin(glmode = GL_QUADS);
|
|
|
|
for(a = 0; a < dm->numFaceData; a++, mface++) {
|
|
|
|
int new_glmode, new_matnr, new_shademodel;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
|
|
|
|
new_matnr = mface->mat_nr + 1;
|
|
|
|
new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT;
|
|
|
|
|
|
|
|
if(new_glmode != glmode || new_matnr != matnr
|
|
|
|
|| new_shademodel != shademodel) {
|
|
|
|
glEnd();
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
drawCurrentMat = setMaterial(matnr = new_matnr, NULL);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glShadeModel(shademodel = new_shademodel);
|
|
|
|
glBegin(glmode = new_glmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(drawCurrentMat) {
|
|
|
|
if(shademodel == GL_FLAT) {
|
|
|
|
if (nors) {
|
|
|
|
glNormal3fv(nors);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
else {
|
|
|
|
/* TODO make this better (cache facenormals as layer?) */
|
|
|
|
float nor[3];
|
|
|
|
if(mface->v4) {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
} else {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
glNormal3fv(nor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PASSVERT(mface->v1);
|
|
|
|
PASSVERT(mface->v2);
|
|
|
|
PASSVERT(mface->v3);
|
|
|
|
if(mface->v4) {
|
|
|
|
PASSVERT(mface->v4);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(nors) nors += 3;
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
|
|
|
GPU_vertex_setup( dm );
|
|
|
|
GPU_normal_setup( dm );
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
for( a = 0; a < dm->drawObject->nmaterials; a++ ) {
|
|
|
|
if( setMaterial(dm->drawObject->materials[a].mat_nr+1, NULL) )
|
|
|
|
glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start, dm->drawObject->materials[a].end-dm->drawObject->materials[a].start);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_buffer_unbind( );
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef PASSVERT
|
2009-10-23 01:22:05 +02:00
|
|
|
glShadeModel(GL_FLAT);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned char *col1, unsigned char *col2)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
2006-08-28 03:12:36 +02:00
|
|
|
int a, glmode;
|
|
|
|
unsigned char *cp1, *cp2;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
MVert *mvert = cddm->mvert;
|
|
|
|
MFace *mface = cddm->mface;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
cp1 = col1;
|
|
|
|
if(col2) {
|
|
|
|
cp2 = col2;
|
|
|
|
} else {
|
|
|
|
cp2 = NULL;
|
|
|
|
useTwoSided = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* there's a conflict here... twosided colors versus culling...? */
|
|
|
|
/* defined by history, only texture faces have culling option */
|
|
|
|
/* we need that as mesh option builtin, next to double sided lighting */
|
2011-04-24 12:51:45 +02:00
|
|
|
if(col2) {
|
2006-08-28 03:12:36 +02:00
|
|
|
glEnable(GL_CULL_FACE);
|
2011-04-24 12:51:45 +02:00
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2010-12-14 04:30:30 +01:00
|
|
|
cdDM_update_normals_from_pbvh(dm);
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if( GPU_buffer_legacy(dm) ) {
|
|
|
|
DEBUG_VBO( "Using legacy code. cdDM_drawFacesColored\n" );
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glBegin(glmode = GL_QUADS);
|
|
|
|
for(a = 0; a < dm->numFaceData; a++, mface++, cp1 += 16) {
|
|
|
|
int new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
|
|
|
|
|
|
|
|
if(new_glmode != glmode) {
|
|
|
|
glEnd();
|
|
|
|
glBegin(glmode = new_glmode);
|
|
|
|
}
|
|
|
|
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp1+0);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v1].co);
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp1+4);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v2].co);
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp1+8);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v3].co);
|
2006-08-28 03:12:36 +02:00
|
|
|
if(mface->v4) {
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp1+12);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v4].co);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(useTwoSided) {
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp2+8);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v3].co );
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp2+4);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v2].co );
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp2+0);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v1].co );
|
|
|
|
if(mface->v4) {
|
2011-05-04 14:00:11 +02:00
|
|
|
glColor3ubv(cp2+12);
|
2009-10-23 01:22:05 +02:00
|
|
|
glVertex3fv(mvert[mface->v4].co );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(col2) cp2 += 16;
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
|
|
|
GPU_color4_upload(dm,cp1);
|
|
|
|
GPU_vertex_setup(dm);
|
|
|
|
GPU_color_setup(dm);
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->nelements);
|
|
|
|
|
|
|
|
if( useTwoSided ) {
|
|
|
|
GPU_color4_upload(dm,cp2);
|
|
|
|
GPU_color_setup(dm);
|
|
|
|
glCullFace(GL_FRONT);
|
|
|
|
glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->nelements);
|
|
|
|
glCullFace(GL_BACK);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_buffer_unbind();
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
2009-07-24 12:43:58 +02:00
|
|
|
int (*drawParams)(MTFace *tface, int has_vcol, int matnr),
|
2006-08-28 03:12:36 +02:00
|
|
|
int (*drawParamsMapped)(void *userData, int index),
|
|
|
|
void *userData)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *mv = cddm->mvert;
|
2009-10-23 01:22:05 +02:00
|
|
|
MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
|
|
|
|
MCol *realcol = dm->getTessFaceDataArray(dm, CD_TEXTURE_MCOL);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL);
|
2009-08-15 19:31:28 +02:00
|
|
|
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
2009-10-23 01:22:05 +02:00
|
|
|
int i, j, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
|
|
|
|
int startFace = 0, lastFlag = 0xdeadbeef;
|
|
|
|
MCol *mcol = dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL);
|
|
|
|
if(!mcol)
|
|
|
|
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
|
|
|
|
|
2010-12-14 04:30:30 +01:00
|
|
|
cdDM_update_normals_from_pbvh(dm);
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if( GPU_buffer_legacy(dm) ) {
|
|
|
|
DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" );
|
|
|
|
for(i = 0; i < dm->numFaceData; i++, mf++) {
|
|
|
|
MVert *mvert;
|
|
|
|
int flag;
|
|
|
|
unsigned char *cp = NULL;
|
|
|
|
|
|
|
|
if(drawParams) {
|
2010-01-05 23:33:41 +01:00
|
|
|
flag = drawParams(tf? &tf[i]: NULL, mcol!=NULL, mf->mat_nr);
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(index) {
|
|
|
|
orig = *index++;
|
|
|
|
if(orig == ORIGINDEX_NONE) { if(nors) nors += 3; continue; }
|
|
|
|
if(drawParamsMapped) flag = drawParamsMapped(userData, orig);
|
|
|
|
else { if(nors) nors += 3; continue; }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if(drawParamsMapped) flag = drawParamsMapped(userData, i);
|
|
|
|
else { if(nors) nors += 3; continue; }
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flag != 0) {
|
|
|
|
if (flag==1 && mcol)
|
|
|
|
cp= (unsigned char*) &mcol[i*4];
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(!(mf->flag&ME_SMOOTH)) {
|
|
|
|
if (nors) {
|
|
|
|
glNormal3fv(nors);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float nor[3];
|
|
|
|
if(mf->v4) {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
} else {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
glNormal3fv(nor);
|
|
|
|
}
|
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
|
|
|
if(tf) glTexCoord2fv(tf[i].uv[0]);
|
|
|
|
if(cp) glColor3ub(cp[3], cp[2], cp[1]);
|
|
|
|
mvert = &mv[mf->v1];
|
|
|
|
if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
|
|
|
glVertex3fv(mvert->co);
|
|
|
|
|
|
|
|
if(tf) glTexCoord2fv(tf[i].uv[1]);
|
|
|
|
if(cp) glColor3ub(cp[7], cp[6], cp[5]);
|
|
|
|
mvert = &mv[mf->v2];
|
|
|
|
if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
|
|
|
glVertex3fv(mvert->co);
|
|
|
|
|
|
|
|
if(tf) glTexCoord2fv(tf[i].uv[2]);
|
|
|
|
if(cp) glColor3ub(cp[11], cp[10], cp[9]);
|
|
|
|
mvert = &mv[mf->v3];
|
|
|
|
if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
|
|
|
glVertex3fv(mvert->co);
|
|
|
|
|
|
|
|
if(mf->v4) {
|
|
|
|
if(tf) glTexCoord2fv(tf[i].uv[3]);
|
|
|
|
if(cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
mvert = &mv[mf->v4];
|
|
|
|
if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
|
|
|
glVertex3fv(mvert->co);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nors) nors += 3;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
} else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
|
|
|
MCol *col = realcol;
|
|
|
|
if(!col)
|
|
|
|
col = mcol;
|
|
|
|
|
|
|
|
GPU_vertex_setup( dm );
|
|
|
|
GPU_normal_setup( dm );
|
|
|
|
GPU_uv_setup( dm );
|
2011-02-13 11:52:18 +01:00
|
|
|
if( col != NULL ) {
|
2009-10-23 01:22:05 +02:00
|
|
|
/*if( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) {
|
|
|
|
col = 0;
|
|
|
|
} else if( mcol && dm->drawObject->colType == CD_MCOL ) {
|
|
|
|
col = 0;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
|
|
|
|
if( col != 0 ) {*/
|
|
|
|
unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common");
|
|
|
|
for( i=0; i < dm->getNumTessFaces(dm); i++ ) {
|
|
|
|
for( j=0; j < 4; j++ ) {
|
|
|
|
colors[i*12+j*3] = col[i*4+j].r;
|
|
|
|
colors[i*12+j*3+1] = col[i*4+j].g;
|
|
|
|
colors[i*12+j*3+2] = col[i*4+j].b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GPU_color3_upload(dm,colors);
|
|
|
|
MEM_freeN(colors);
|
|
|
|
if(realcol)
|
|
|
|
dm->drawObject->colType = CD_TEXTURE_MCOL;
|
|
|
|
else if(mcol)
|
|
|
|
dm->drawObject->colType = CD_MCOL;
|
|
|
|
//}
|
|
|
|
GPU_color_setup( dm );
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
2011-04-27 07:12:07 +02:00
|
|
|
/* warning!, this logic is incorrect, see bug [#27175]
|
|
|
|
* firstly, there are no checks for changes in context, such as texface image.
|
|
|
|
* secondly, drawParams() sets the GL context, so checking if there is a change
|
|
|
|
* from lastFlag is too late once glDrawArrays() runs, since drawing the arrays
|
|
|
|
* will use the modified, OpenGL settings.
|
|
|
|
*
|
|
|
|
* However its tricky to fix this without duplicating the internal logic
|
|
|
|
* of drawParams(), perhaps we need an argument like...
|
|
|
|
* drawParams(..., keep_gl_state_but_return_when_changed) ?.
|
|
|
|
*
|
|
|
|
* We could also just disable VBO's here, since texface may be deprecated - campbell.
|
|
|
|
*/
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glShadeModel( GL_SMOOTH );
|
2010-12-26 14:01:02 +01:00
|
|
|
lastFlag = 0;
|
2009-10-23 01:22:05 +02:00
|
|
|
for(i = 0; i < dm->drawObject->nelements/3; i++) {
|
|
|
|
int actualFace = dm->drawObject->faceRemap[i];
|
|
|
|
int flag = 1;
|
|
|
|
|
|
|
|
if(drawParams) {
|
2010-01-05 23:33:41 +01:00
|
|
|
flag = drawParams(tf? &tf[actualFace]: NULL, mcol!=NULL, mf[actualFace].mat_nr);
|
2007-04-29 15:39:46 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-10-23 01:22:05 +02:00
|
|
|
if(index) {
|
|
|
|
orig = index[actualFace];
|
2010-12-26 14:01:02 +01:00
|
|
|
if(orig == ORIGINDEX_NONE) continue;
|
2009-10-23 01:22:05 +02:00
|
|
|
if(drawParamsMapped)
|
|
|
|
flag = drawParamsMapped(userData, orig);
|
2007-04-29 15:39:46 +02:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
else
|
|
|
|
if(drawParamsMapped)
|
|
|
|
flag = drawParamsMapped(userData, actualFace);
|
|
|
|
}
|
|
|
|
if( flag != lastFlag ) {
|
|
|
|
if( startFace < i ) {
|
|
|
|
if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */
|
2010-06-23 18:35:42 +02:00
|
|
|
if (lastFlag==1 && col)
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_color_switch(1);
|
|
|
|
else
|
|
|
|
GPU_color_switch(0);
|
|
|
|
glDrawArrays(GL_TRIANGLES,startFace*3,(i-startFace)*3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastFlag = flag;
|
|
|
|
startFace = i;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
if( startFace < dm->drawObject->nelements/3 ) {
|
|
|
|
if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */
|
2010-06-23 18:35:42 +02:00
|
|
|
if (lastFlag==1 && col)
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_color_switch(1);
|
|
|
|
else
|
|
|
|
GPU_color_switch(0);
|
|
|
|
glDrawArrays(GL_TRIANGLES,startFace*3,dm->drawObject->nelements-startFace*3);
|
|
|
|
}
|
2007-04-29 15:39:46 +02:00
|
|
|
}
|
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
|
|
|
|
GPU_buffer_unbind();
|
|
|
|
glShadeModel( GL_FLAT );
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-28 11:36:31 +02:00
|
|
|
static void cdDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_vcol, int matnr))
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
|
|
|
cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2010-10-05 13:25:34 +02:00
|
|
|
static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs))
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *mv = cddm->mvert;
|
|
|
|
MFace *mf = cddm->mface;
|
2009-05-23 05:24:15 +02:00
|
|
|
MCol *mc;
|
2011-06-01 21:30:19 +02:00
|
|
|
float *nors= DM_get_tessface_data_layer(dm, CD_NORMAL);
|
2009-08-15 19:31:28 +02:00
|
|
|
int i, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
mc = DM_get_tessface_data_layer(dm, CD_ID_MCOL);
|
|
|
|
if(!mc)
|
|
|
|
mc = DM_get_tessface_data_layer(dm, CD_WEIGHT_MCOL);
|
2009-05-23 05:24:15 +02:00
|
|
|
if(!mc)
|
2009-08-15 19:31:28 +02:00
|
|
|
mc = DM_get_tessface_data_layer(dm, CD_MCOL);
|
2009-05-23 05:24:15 +02:00
|
|
|
|
2010-12-14 04:30:30 +01:00
|
|
|
cdDM_update_normals_from_pbvh(dm);
|
|
|
|
|
2010-02-05 14:38:41 +01:00
|
|
|
/* back-buffer always uses legacy since VBO's would need the
|
|
|
|
* color array temporarily overwritten for drawing, then reset. */
|
|
|
|
if( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) {
|
2009-10-23 01:22:05 +02:00
|
|
|
DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" );
|
|
|
|
for(i = 0; i < dm->numFaceData; i++, mf++) {
|
|
|
|
int drawSmooth = (mf->flag & ME_SMOOTH);
|
2010-10-05 13:25:34 +02:00
|
|
|
int draw= 1;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2010-10-05 13:25:34 +02:00
|
|
|
orig= (index==NULL) ? i : *index++;
|
|
|
|
|
|
|
|
if(orig == ORIGINDEX_NONE)
|
|
|
|
draw= setMaterial(mf->mat_nr + 1, NULL);
|
|
|
|
else if (setDrawOptions != NULL)
|
|
|
|
draw= setDrawOptions(userData, orig, &drawSmooth);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2010-10-05 13:25:34 +02:00
|
|
|
if(draw) {
|
2009-10-23 01:22:05 +02:00
|
|
|
unsigned char *cp = NULL;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(useColors && mc)
|
|
|
|
cp = (unsigned char *)&mc[i * 4];
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if (!drawSmooth) {
|
|
|
|
if (nors) {
|
|
|
|
glNormal3fv(nors);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float nor[3];
|
|
|
|
if(mf->v4) {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
} else {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
glNormal3fv(nor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cp) glColor3ub(cp[3], cp[2], cp[1]);
|
|
|
|
glVertex3fv(mv[mf->v1].co);
|
|
|
|
if(cp) glColor3ub(cp[7], cp[6], cp[5]);
|
|
|
|
glVertex3fv(mv[mf->v2].co);
|
|
|
|
if(cp) glColor3ub(cp[11], cp[10], cp[9]);
|
|
|
|
glVertex3fv(mv[mf->v3].co);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
if(mf->v4) {
|
2009-10-23 01:22:05 +02:00
|
|
|
if(cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
glVertex3fv(mv[mf->v4].co);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(cp) glColor3ub(cp[3], cp[2], cp[1]);
|
|
|
|
glNormal3sv(mv[mf->v1].no);
|
|
|
|
glVertex3fv(mv[mf->v1].co);
|
|
|
|
if(cp) glColor3ub(cp[7], cp[6], cp[5]);
|
|
|
|
glNormal3sv(mv[mf->v2].no);
|
|
|
|
glVertex3fv(mv[mf->v2].co);
|
|
|
|
if(cp) glColor3ub(cp[11], cp[10], cp[9]);
|
|
|
|
glNormal3sv(mv[mf->v3].no);
|
|
|
|
glVertex3fv(mv[mf->v3].co);
|
|
|
|
if(mf->v4) {
|
|
|
|
if(cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
glNormal3sv(mv[mf->v4].no);
|
|
|
|
glVertex3fv(mv[mf->v4].co);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glEnd();
|
2011-06-05 03:00:36 +02:00
|
|
|
} /*else {
|
|
|
|
printf("eek in cddm draw mapped faces!\n");
|
|
|
|
}*/
|
2009-10-23 01:22:05 +02:00
|
|
|
|
|
|
|
if (nors) nors += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
|
|
|
int prevstart = 0;
|
|
|
|
GPU_vertex_setup(dm);
|
|
|
|
GPU_normal_setup(dm);
|
|
|
|
if( useColors && mc )
|
|
|
|
GPU_color_setup(dm);
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
2010-06-11 09:57:43 +02:00
|
|
|
int tottri = dm->drawObject->nelements/3;
|
2009-10-23 01:22:05 +02:00
|
|
|
glShadeModel(GL_SMOOTH);
|
2010-10-04 21:01:25 +02:00
|
|
|
|
|
|
|
if(tottri == 0) {
|
|
|
|
/* avoid buffer problems in following code */
|
|
|
|
}
|
|
|
|
if(setDrawOptions == NULL) {
|
|
|
|
/* just draw the entire face array */
|
|
|
|
glDrawArrays(GL_TRIANGLES, 0, (tottri-1) * 3);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* we need to check if the next material changes */
|
|
|
|
int next_actualFace= dm->drawObject->faceRemap[0];
|
|
|
|
|
|
|
|
for( i = 0; i < tottri; i++ ) {
|
|
|
|
//int actualFace = dm->drawObject->faceRemap[i];
|
|
|
|
int actualFace = next_actualFace;
|
2010-10-05 13:25:34 +02:00
|
|
|
MFace *mface= mf + actualFace;
|
|
|
|
int drawSmooth= (mface->flag & ME_SMOOTH);
|
2010-10-04 21:01:25 +02:00
|
|
|
int draw = 1;
|
|
|
|
|
|
|
|
if(i != tottri-1)
|
|
|
|
next_actualFace= dm->drawObject->faceRemap[i+1];
|
2010-10-05 13:25:34 +02:00
|
|
|
|
|
|
|
orig= (index==NULL) ? actualFace : index[actualFace];
|
|
|
|
|
|
|
|
if(orig == ORIGINDEX_NONE)
|
|
|
|
draw= setMaterial(mface->mat_nr + 1, NULL);
|
|
|
|
else if (setDrawOptions != NULL)
|
|
|
|
draw= setDrawOptions(userData, orig, &drawSmooth);
|
2010-10-04 21:01:25 +02:00
|
|
|
|
|
|
|
/* Goal is to draw as long of a contiguous triangle
|
|
|
|
array as possible, so draw when we hit either an
|
|
|
|
invisible triangle or at the end of the array */
|
|
|
|
if(!draw || i == tottri - 1 || mf[actualFace].mat_nr != mf[next_actualFace].mat_nr) {
|
|
|
|
if(prevstart != i)
|
|
|
|
/* Add one to the length (via `draw')
|
|
|
|
if we're drawing at the end of the array */
|
|
|
|
glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3);
|
|
|
|
prevstart = i + 1;
|
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
}
|
2010-10-04 21:01:25 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glShadeModel(GL_FLAT);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_buffer_unbind();
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
|
|
|
{
|
|
|
|
cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs), int (*setDrawOptions)(void *userData, int index), void *userData)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
GPUVertexAttribs gattribs;
|
|
|
|
DMVertexAttribs attribs;
|
|
|
|
MVert *mvert = cddm->mvert;
|
|
|
|
MFace *mface = cddm->mface;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE);
|
|
|
|
float (*nors)[3] = dm->getTessFaceDataArray(dm, CD_NORMAL);
|
2011-01-14 22:06:28 +01:00
|
|
|
int a, b, dodraw, matnr, new_matnr;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
int transp, new_transp, orig_transp;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
int orig, *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2010-12-14 04:30:30 +01:00
|
|
|
cdDM_update_normals_from_pbvh(dm);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
matnr = -1;
|
|
|
|
dodraw = 0;
|
|
|
|
transp = GPU_get_material_blend_mode();
|
|
|
|
orig_transp = transp;
|
|
|
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
2011-02-13 11:52:18 +01:00
|
|
|
if( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) {
|
2009-10-23 01:22:05 +02:00
|
|
|
DEBUG_VBO( "Using legacy code. cdDM_drawMappedFacesGLSL\n" );
|
|
|
|
memset(&attribs, 0, sizeof(attribs));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glBegin(GL_QUADS);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
for(a = 0; a < dm->numFaceData; a++, mface++) {
|
2011-01-14 22:06:28 +01:00
|
|
|
const int smoothnormal = (mface->flag & ME_SMOOTH);
|
2009-10-23 01:22:05 +02:00
|
|
|
new_matnr = mface->mat_nr + 1;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(new_matnr != matnr) {
|
|
|
|
glEnd();
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
dodraw = setMaterial(matnr = new_matnr, &gattribs);
|
|
|
|
if(dodraw)
|
|
|
|
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glBegin(GL_QUADS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!dodraw) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
continue;
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
else if(setDrawOptions) {
|
2009-11-04 21:23:48 +01:00
|
|
|
orig = (index)? index[a]: a;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2010-10-05 13:25:34 +02:00
|
|
|
if(orig == ORIGINDEX_NONE) {
|
|
|
|
/* since the material is set by setMaterial(), faces with no
|
|
|
|
* origin can be assumed to be generated by a modifier */
|
|
|
|
|
|
|
|
/* continue */
|
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
else if(!setDrawOptions(userData, orig))
|
|
|
|
continue;
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(tf) {
|
|
|
|
new_transp = tf[a].transp;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(new_transp != transp) {
|
|
|
|
glEnd();
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(new_transp == GPU_BLEND_SOLID && orig_transp != GPU_BLEND_SOLID)
|
|
|
|
GPU_set_material_blend_mode(orig_transp);
|
|
|
|
else
|
|
|
|
GPU_set_material_blend_mode(new_transp);
|
|
|
|
transp = new_transp;
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
}
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
if(!smoothnormal) {
|
|
|
|
if(nors) {
|
|
|
|
glNormal3fv(nors[a]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* TODO ideally a normal layer should always be available */
|
|
|
|
float nor[3];
|
|
|
|
if(mface->v4) {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
} else {
|
2009-11-10 21:43:45 +01:00
|
|
|
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
glNormal3fv(nor);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PASSVERT(index, vert) { \
|
2009-10-03 17:35:01 +02:00
|
|
|
if(attribs.totorco) \
|
|
|
|
glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
|
|
|
|
for(b = 0; b < attribs.tottface; b++) { \
|
|
|
|
MTFace *tf = &attribs.tface[b].array[a]; \
|
|
|
|
glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
|
|
|
|
} \
|
|
|
|
for(b = 0; b < attribs.totmcol; b++) { \
|
|
|
|
MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \
|
|
|
|
GLubyte col[4]; \
|
|
|
|
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \
|
|
|
|
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
|
|
|
|
} \
|
|
|
|
if(attribs.tottang) { \
|
|
|
|
float *tang = attribs.tang.array[a*4 + vert]; \
|
2011-02-14 19:18:46 +01:00
|
|
|
glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
|
2009-10-03 17:35:01 +02:00
|
|
|
} \
|
|
|
|
if(smoothnormal) \
|
|
|
|
glNormal3sv(mvert[index].no); \
|
|
|
|
glVertex3fv(mvert[index].co); \
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
PASSVERT(mface->v1, 0);
|
|
|
|
PASSVERT(mface->v2, 1);
|
|
|
|
PASSVERT(mface->v3, 2);
|
|
|
|
if(mface->v4)
|
|
|
|
PASSVERT(mface->v4, 3)
|
|
|
|
else
|
|
|
|
PASSVERT(mface->v3, 2)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else {
|
2011-02-13 11:52:18 +01:00
|
|
|
GPUBuffer *buffer = NULL;
|
|
|
|
char *varray = NULL;
|
2009-10-23 01:22:05 +02:00
|
|
|
int numdata = 0, elementsize = 0, offset;
|
|
|
|
int start = 0, numfaces = 0, prevdraw = 0, curface = 0;
|
2010-02-15 13:35:32 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
MFace *mf = mface;
|
2010-02-09 19:06:57 +01:00
|
|
|
GPUAttrib datatypes[GPU_MAX_ATTRIB]; /* TODO, messing up when switching materials many times - [#21056]*/
|
2009-10-23 01:22:05 +02:00
|
|
|
memset(&attribs, 0, sizeof(attribs));
|
|
|
|
|
|
|
|
GPU_vertex_setup(dm);
|
|
|
|
GPU_normal_setup(dm);
|
|
|
|
|
|
|
|
if( !GPU_buffer_legacy(dm) ) {
|
2010-02-15 13:35:32 +01:00
|
|
|
for( i = 0; i < dm->drawObject->nelements/3; i++ ) {
|
|
|
|
|
|
|
|
a = dm->drawObject->faceRemap[i];
|
|
|
|
|
|
|
|
mface = mf + a;
|
2009-10-23 01:22:05 +02:00
|
|
|
new_matnr = mface->mat_nr + 1;
|
|
|
|
|
|
|
|
if(new_matnr != matnr ) {
|
|
|
|
numfaces = curface - start;
|
|
|
|
if( numfaces > 0 ) {
|
2010-02-15 13:35:32 +01:00
|
|
|
|
|
|
|
if( dodraw ) {
|
|
|
|
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
|
|
|
|
GPU_buffer_unlock(buffer);
|
|
|
|
|
|
|
|
GPU_interleaved_attrib_setup(buffer,datatypes,numdata);
|
|
|
|
}
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
glDrawArrays(GL_TRIANGLES,start*3,numfaces*3);
|
2010-02-15 13:35:32 +01:00
|
|
|
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
|
2011-02-13 11:52:18 +01:00
|
|
|
GPU_buffer_free(buffer, NULL);
|
2010-02-15 13:35:32 +01:00
|
|
|
|
2011-02-13 11:52:18 +01:00
|
|
|
buffer = NULL;
|
2010-02-15 13:35:32 +01:00
|
|
|
}
|
|
|
|
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
}
|
2010-02-11 22:55:07 +01:00
|
|
|
numdata = 0;
|
2009-10-23 01:22:05 +02:00
|
|
|
start = curface;
|
|
|
|
prevdraw = dodraw;
|
|
|
|
dodraw = setMaterial(matnr = new_matnr, &gattribs);
|
|
|
|
if(dodraw) {
|
|
|
|
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
|
|
|
|
|
|
|
|
if(attribs.totorco) {
|
|
|
|
datatypes[numdata].index = attribs.orco.glIndex;
|
|
|
|
datatypes[numdata].size = 3;
|
|
|
|
datatypes[numdata].type = GL_FLOAT;
|
|
|
|
numdata++;
|
|
|
|
}
|
|
|
|
for(b = 0; b < attribs.tottface; b++) {
|
|
|
|
datatypes[numdata].index = attribs.tface[b].glIndex;
|
|
|
|
datatypes[numdata].size = 2;
|
|
|
|
datatypes[numdata].type = GL_FLOAT;
|
|
|
|
numdata++;
|
|
|
|
}
|
|
|
|
for(b = 0; b < attribs.totmcol; b++) {
|
|
|
|
datatypes[numdata].index = attribs.mcol[b].glIndex;
|
|
|
|
datatypes[numdata].size = 4;
|
|
|
|
datatypes[numdata].type = GL_UNSIGNED_BYTE;
|
|
|
|
numdata++;
|
|
|
|
}
|
|
|
|
if(attribs.tottang) {
|
|
|
|
datatypes[numdata].index = attribs.tang.glIndex;
|
2011-02-14 19:18:46 +01:00
|
|
|
datatypes[numdata].size = 4;
|
2009-10-23 01:22:05 +02:00
|
|
|
datatypes[numdata].type = GL_FLOAT;
|
|
|
|
numdata++;
|
|
|
|
}
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
elementsize = GPU_attrib_element_size( datatypes, numdata );
|
2011-02-13 11:52:18 +01:00
|
|
|
buffer = GPU_buffer_alloc( elementsize*dm->drawObject->nelements, NULL );
|
|
|
|
if( buffer == NULL ) {
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_buffer_unbind();
|
|
|
|
dm->drawObject->legacy = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
varray = GPU_buffer_lock_stream(buffer);
|
2011-02-13 11:52:18 +01:00
|
|
|
if( varray == NULL ) {
|
2009-10-23 01:22:05 +02:00
|
|
|
GPU_buffer_unbind();
|
2011-02-13 11:52:18 +01:00
|
|
|
GPU_buffer_free(buffer, NULL);
|
2009-10-23 01:22:05 +02:00
|
|
|
dm->drawObject->legacy = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-02-08 22:33:47 +01:00
|
|
|
else {
|
|
|
|
/* if the buffer was set, dont use it again.
|
|
|
|
* prevdraw was assumed true but didnt run so set to false - [#21036] */
|
|
|
|
prevdraw= 0;
|
|
|
|
buffer= NULL;
|
|
|
|
}
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!dodraw) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tf) {
|
|
|
|
new_transp = tf[a].transp;
|
|
|
|
|
|
|
|
if(new_transp != transp) {
|
|
|
|
numfaces = curface - start;
|
|
|
|
if( numfaces > 0 ) {
|
|
|
|
if( dodraw ) {
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
GPU_buffer_unlock(buffer);
|
|
|
|
GPU_interleaved_attrib_setup(buffer,datatypes,numdata);
|
|
|
|
}
|
|
|
|
glDrawArrays(GL_TRIANGLES,start*3,(curface-start)*3);
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
varray = GPU_buffer_lock_stream(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
start = curface;
|
|
|
|
|
|
|
|
if(new_transp == GPU_BLEND_SOLID && orig_transp != GPU_BLEND_SOLID)
|
|
|
|
GPU_set_material_blend_mode(orig_transp);
|
|
|
|
else
|
|
|
|
GPU_set_material_blend_mode(new_transp);
|
|
|
|
transp = new_transp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
offset = 0;
|
|
|
|
if(attribs.totorco) {
|
|
|
|
VECCOPY((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v1]);
|
|
|
|
VECCOPY((float *)&varray[elementsize*curface*3+elementsize],(float *)attribs.orco.array[mface->v2]);
|
|
|
|
VECCOPY((float *)&varray[elementsize*curface*3+elementsize*2],(float *)attribs.orco.array[mface->v3]);
|
|
|
|
offset += sizeof(float)*3;
|
|
|
|
}
|
|
|
|
for(b = 0; b < attribs.tottface; b++) {
|
|
|
|
MTFace *tf = &attribs.tface[b].array[a];
|
2010-02-15 13:35:32 +01:00
|
|
|
VECCOPY2D((float *)&varray[elementsize*curface*3+offset],tf->uv[0]);
|
|
|
|
VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[1]);
|
|
|
|
|
|
|
|
VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[2]);
|
2009-10-23 01:22:05 +02:00
|
|
|
offset += sizeof(float)*2;
|
|
|
|
}
|
|
|
|
for(b = 0; b < attribs.totmcol; b++) {
|
|
|
|
MCol *cp = &attribs.mcol[b].array[a*4 + 0];
|
|
|
|
GLubyte col[4];
|
|
|
|
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
|
|
|
QUATCOPY((unsigned char *)&varray[elementsize*curface*3+offset], col);
|
|
|
|
cp = &attribs.mcol[b].array[a*4 + 1];
|
|
|
|
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
|
|
|
QUATCOPY((unsigned char *)&varray[elementsize*curface*3+offset+elementsize], col);
|
|
|
|
cp = &attribs.mcol[b].array[a*4 + 2];
|
|
|
|
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
|
|
|
QUATCOPY((unsigned char *)&varray[elementsize*curface*3+offset+elementsize*2], col);
|
|
|
|
offset += sizeof(unsigned char)*4;
|
|
|
|
}
|
|
|
|
if(attribs.tottang) {
|
|
|
|
float *tang = attribs.tang.array[a*4 + 0];
|
2011-02-14 19:18:46 +01:00
|
|
|
QUATCOPY((float *)&varray[elementsize*curface*3+offset], tang);
|
2009-10-23 01:22:05 +02:00
|
|
|
tang = attribs.tang.array[a*4 + 1];
|
2011-02-14 19:18:46 +01:00
|
|
|
QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang);
|
2009-10-23 01:22:05 +02:00
|
|
|
tang = attribs.tang.array[a*4 + 2];
|
2011-02-14 19:18:46 +01:00
|
|
|
QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang);
|
|
|
|
offset += sizeof(float)*4;
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
curface++;
|
|
|
|
if(mface->v4) {
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
offset = 0;
|
|
|
|
if(attribs.totorco) {
|
|
|
|
VECCOPY((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v3]);
|
|
|
|
VECCOPY((float *)&varray[elementsize*curface*3+elementsize],(float *)attribs.orco.array[mface->v4]);
|
|
|
|
VECCOPY((float *)&varray[elementsize*curface*3+elementsize*2],(float *)attribs.orco.array[mface->v1]);
|
|
|
|
offset += sizeof(float)*3;
|
|
|
|
}
|
|
|
|
for(b = 0; b < attribs.tottface; b++) {
|
|
|
|
MTFace *tf = &attribs.tface[b].array[a];
|
2010-02-15 13:35:32 +01:00
|
|
|
VECCOPY2D((float *)&varray[elementsize*curface*3+offset],tf->uv[2]);
|
|
|
|
VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[3]);
|
|
|
|
VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[0]);
|
2009-10-23 01:22:05 +02:00
|
|
|
offset += sizeof(float)*2;
|
|
|
|
}
|
|
|
|
for(b = 0; b < attribs.totmcol; b++) {
|
|
|
|
MCol *cp = &attribs.mcol[b].array[a*4 + 2];
|
|
|
|
GLubyte col[4];
|
|
|
|
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
|
|
|
QUATCOPY((unsigned char *)&varray[elementsize*curface*3+offset], col);
|
|
|
|
cp = &attribs.mcol[b].array[a*4 + 3];
|
|
|
|
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
|
|
|
QUATCOPY((unsigned char *)&varray[elementsize*curface*3+offset+elementsize], col);
|
|
|
|
cp = &attribs.mcol[b].array[a*4 + 0];
|
|
|
|
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
|
|
|
QUATCOPY((unsigned char *)&varray[elementsize*curface*3+offset+elementsize*2], col);
|
|
|
|
offset += sizeof(unsigned char)*4;
|
|
|
|
}
|
|
|
|
if(attribs.tottang) {
|
|
|
|
float *tang = attribs.tang.array[a*4 + 2];
|
2011-02-14 19:18:46 +01:00
|
|
|
QUATCOPY((float *)&varray[elementsize*curface*3+offset], tang);
|
2009-10-23 01:22:05 +02:00
|
|
|
tang = attribs.tang.array[a*4 + 3];
|
2011-02-14 19:18:46 +01:00
|
|
|
QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang);
|
2009-10-23 01:22:05 +02:00
|
|
|
tang = attribs.tang.array[a*4 + 0];
|
2011-02-14 19:18:46 +01:00
|
|
|
QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang);
|
|
|
|
offset += sizeof(float)*4;
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
curface++;
|
2010-02-15 13:35:32 +01:00
|
|
|
i++;
|
2009-10-23 01:22:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
numfaces = curface - start;
|
|
|
|
if( numfaces > 0 ) {
|
|
|
|
if( dodraw ) {
|
|
|
|
if( numdata != 0 ) {
|
|
|
|
GPU_buffer_unlock(buffer);
|
|
|
|
GPU_interleaved_attrib_setup(buffer,datatypes,numdata);
|
|
|
|
}
|
|
|
|
glDrawArrays(GL_TRIANGLES,start*3,(curface-start)*3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GPU_buffer_unbind();
|
|
|
|
}
|
2011-02-13 11:52:18 +01:00
|
|
|
GPU_buffer_free( buffer, NULL );
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs))
|
|
|
|
{
|
|
|
|
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
static void cdDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *vert = cddm->mvert;
|
|
|
|
MEdge *edge = cddm->medge;
|
|
|
|
int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
for(i = 0; i < dm->numEdgeData; i++, edge++) {
|
|
|
|
if(index) {
|
|
|
|
orig = *index++;
|
|
|
|
if(setDrawOptions && orig == ORIGINDEX_NONE) continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
orig = i;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
if(!setDrawOptions || setDrawOptions(userData, orig)) {
|
2006-08-28 03:12:36 +02:00
|
|
|
glVertex3fv(vert[edge->v1].co);
|
|
|
|
glVertex3fv(vert[edge->v2].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
static void cdDM_foreachMappedVert(
|
2010-03-22 10:30:00 +01:00
|
|
|
DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int index, float *co,
|
|
|
|
float *no_f, short *no_s),
|
|
|
|
void *userData)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
MVert *mv = CDDM_get_verts(dm);
|
|
|
|
int i, orig, *index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
|
|
|
|
|
|
|
|
for(i = 0; i < dm->numVertData; i++, mv++) {
|
|
|
|
if(index) {
|
|
|
|
orig = *index++;
|
|
|
|
if(orig == ORIGINDEX_NONE) continue;
|
|
|
|
func(userData, orig, mv->co, NULL, mv->no);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
func(userData, i, mv->co, NULL, mv->no);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_foreachMappedEdge(
|
2010-03-22 10:30:00 +01:00
|
|
|
DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int index,
|
|
|
|
float *v0co, float *v1co),
|
|
|
|
void *userData)
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
|
|
|
MVert *mv = cddm->mvert;
|
|
|
|
MEdge *med = cddm->medge;
|
|
|
|
int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
|
|
|
|
|
|
|
for(i = 0; i < dm->numEdgeData; i++, med++) {
|
|
|
|
if (index) {
|
|
|
|
orig = *index++;
|
|
|
|
if(orig == ORIGINDEX_NONE) continue;
|
|
|
|
func(userData, orig, mv[med->v1].co, mv[med->v2].co);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
func(userData, i, mv[med->v1].co, mv[med->v2].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdDM_foreachMappedFaceCenter(
|
2010-03-22 10:30:00 +01:00
|
|
|
DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int index,
|
|
|
|
float *cent, float *no),
|
|
|
|
void *userData)
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
MVert *mv = cddm->mvert;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
MPoly *mf = cddm->mpoly;
|
|
|
|
MLoop *ml = cddm->mloop;
|
2009-06-16 22:08:40 +02:00
|
|
|
int i, j, orig, *index;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
2009-06-16 22:08:40 +02:00
|
|
|
index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
|
|
|
|
mf = cddm->mpoly;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
for(i = 0; i < dm->numPolyData; i++, mf++) {
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
float cent[3];
|
|
|
|
float no[3];
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
orig = *index++;
|
|
|
|
if(orig == ORIGINDEX_NONE) continue;
|
2009-06-16 22:08:40 +02:00
|
|
|
} else
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
orig = i;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
|
|
|
ml = &cddm->mloop[mf->loopstart];
|
|
|
|
cent[0] = cent[1] = cent[2] = 0.0f;
|
|
|
|
for (j=0; j<mf->totloop; j++, ml++) {
|
2009-11-23 15:41:22 +01:00
|
|
|
add_v3_v3v3(cent, cent, mv[ml->v].co);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
}
|
2009-11-23 15:41:22 +01:00
|
|
|
mul_v3_fl(cent, 1.0f / (float)j);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
ml = &cddm->mloop[mf->loopstart];
|
|
|
|
if (j > 3) {
|
2009-11-23 15:41:22 +01:00
|
|
|
normal_quad_v3(no, mv[ml->v].co, mv[(ml+1)->v].co,
|
|
|
|
mv[(ml+2)->v].co, mv[(ml+3)->v].co);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
} else {
|
2009-11-23 15:41:22 +01:00
|
|
|
normal_tri_v3(no, mv[ml->v].co, mv[(ml+1)->v].co,
|
|
|
|
mv[(ml+2)->v].co);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
func(userData, orig, cent, no);
|
|
|
|
}
|
2009-06-16 22:08:40 +02:00
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2009-08-28 11:36:31 +02:00
|
|
|
static void cdDM_recalcTesselation(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
|
2009-08-30 23:30:07 +02:00
|
|
|
dm->numFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData,
|
2009-11-03 06:06:04 +01:00
|
|
|
&dm->polyData, cddm->mvert, dm->numFaceData, dm->numLoopData,
|
2010-01-05 23:33:41 +01:00
|
|
|
dm->numPolyData, 1, 0);
|
2009-11-03 06:06:04 +01:00
|
|
|
|
|
|
|
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ignores original poly origindex layer*/
|
|
|
|
static void cdDM_recalcTesselation2(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
|
|
|
|
dm->numFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData,
|
|
|
|
&dm->polyData, cddm->mvert, dm->numFaceData, dm->numLoopData,
|
2010-01-05 23:33:41 +01:00
|
|
|
dm->numPolyData, 0, 0);
|
2009-08-28 11:36:31 +02:00
|
|
|
|
2009-08-30 23:30:07 +02:00
|
|
|
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
2009-08-28 11:36:31 +02:00
|
|
|
}
|
|
|
|
|
2011-03-25 01:32:38 +01:00
|
|
|
void CDDM_recalc_tesselation(DerivedMesh *dm, int orig_use_polyorig)
|
|
|
|
{
|
|
|
|
if (orig_use_polyorig)
|
|
|
|
cdDM_recalcTesselation(dm);
|
|
|
|
else
|
|
|
|
cdDM_recalcTesselation2(dm);
|
|
|
|
}
|
|
|
|
|
2009-10-28 07:06:05 +01:00
|
|
|
static void cdDM_free_internal(CDDerivedMesh *cddm)
|
|
|
|
{
|
|
|
|
if(cddm->fmap) MEM_freeN(cddm->fmap);
|
|
|
|
if(cddm->fmap_mem) MEM_freeN(cddm->fmap_mem);
|
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
static void cdDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
|
2009-10-28 07:06:05 +01:00
|
|
|
if (DM_release(dm)) {
|
|
|
|
cdDM_free_internal(cddm);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
MEM_freeN(cddm);
|
2009-10-28 07:06:05 +01:00
|
|
|
}
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
}
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-09-06 08:47:59 +02:00
|
|
|
int CDDM_Check(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
return dm && dm->getMinMax == cdDM_getMinMax;
|
|
|
|
}
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
/**************** CDDM interface functions ****************/
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
static CDDerivedMesh *cdDM_create(const char *desc)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm;
|
2006-08-28 03:12:36 +02:00
|
|
|
DerivedMesh *dm;
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
cddm = MEM_callocN(sizeof(*cddm), desc);
|
|
|
|
dm = &cddm->dm;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
dm->getMinMax = cdDM_getMinMax;
|
|
|
|
|
|
|
|
dm->getNumVerts = cdDM_getNumVerts;
|
|
|
|
dm->getNumEdges = cdDM_getNumEdges;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
dm->getNumTessFaces = cdDM_getNumTessFaces;
|
|
|
|
dm->getNumFaces = cdDM_getNumFaces;
|
|
|
|
|
|
|
|
dm->newFaceIter = cdDM_newFaceIter;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
dm->getVert = cdDM_getVert;
|
|
|
|
dm->getEdge = cdDM_getEdge;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
dm->getTessFace = cdDM_getFace;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
dm->copyVertArray = cdDM_copyVertArray;
|
|
|
|
dm->copyEdgeArray = cdDM_copyEdgeArray;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
dm->copyTessFaceArray = cdDM_copyFaceArray;
|
2006-08-28 03:12:36 +02:00
|
|
|
dm->getVertData = DM_get_vert_data;
|
|
|
|
dm->getEdgeData = DM_get_edge_data;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
dm->getTessFaceData = DM_get_face_data;
|
2006-08-28 03:12:36 +02:00
|
|
|
dm->getVertDataArray = DM_get_vert_data_layer;
|
|
|
|
dm->getEdgeDataArray = DM_get_edge_data_layer;
|
2009-08-15 19:31:28 +02:00
|
|
|
dm->getTessFaceDataArray = DM_get_tessface_data_layer;
|
2009-08-28 11:36:31 +02:00
|
|
|
|
|
|
|
//doesn't work yet for all cases
|
|
|
|
//dm->recalcTesselation = cdDM_recalcTesselation;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
dm->getVertCos = cdDM_getVertCos;
|
|
|
|
dm->getVertCo = cdDM_getVertCo;
|
|
|
|
dm->getVertNo = cdDM_getVertNo;
|
|
|
|
|
2009-10-28 07:06:05 +01:00
|
|
|
dm->getPBVH = cdDM_getPBVH;
|
|
|
|
dm->getFaceMap = cdDM_getFaceMap;
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
dm->drawVerts = cdDM_drawVerts;
|
|
|
|
|
|
|
|
dm->drawUVEdges = cdDM_drawUVEdges;
|
|
|
|
dm->drawEdges = cdDM_drawEdges;
|
|
|
|
dm->drawLooseEdges = cdDM_drawLooseEdges;
|
|
|
|
dm->drawMappedEdges = cdDM_drawMappedEdges;
|
|
|
|
|
|
|
|
dm->drawFacesSolid = cdDM_drawFacesSolid;
|
|
|
|
dm->drawFacesColored = cdDM_drawFacesColored;
|
|
|
|
dm->drawFacesTex = cdDM_drawFacesTex;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
dm->drawFacesGLSL = cdDM_drawFacesGLSL;
|
2006-08-28 03:12:36 +02:00
|
|
|
dm->drawMappedFaces = cdDM_drawMappedFaces;
|
|
|
|
dm->drawMappedFacesTex = cdDM_drawMappedFacesTex;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 22:51:28 +02:00
|
|
|
dm->drawMappedFacesGLSL = cdDM_drawMappedFacesGLSL;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
dm->foreachMappedVert = cdDM_foreachMappedVert;
|
|
|
|
dm->foreachMappedEdge = cdDM_foreachMappedEdge;
|
|
|
|
dm->foreachMappedFaceCenter = cdDM_foreachMappedFaceCenter;
|
|
|
|
|
|
|
|
dm->release = cdDM_release;
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return cddm;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces, int numLoops, int numPolys)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = cdDM_create("CDDM_new dm");
|
|
|
|
DerivedMesh *dm = &cddm->dm;
|
|
|
|
|
2010-01-13 08:26:11 +01:00
|
|
|
DM_init(dm, DM_TYPE_CDDM, numVerts, numEdges, numFaces, numLoops, numPolys);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2008-06-09 19:22:38 +02:00
|
|
|
CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts);
|
|
|
|
CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numFaces);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
CustomData_add_layer(&dm->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, numPolys);
|
2008-06-09 19:22:38 +02:00
|
|
|
|
2006-12-12 22:29:09 +01:00
|
|
|
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_CALLOC, NULL, numVerts);
|
|
|
|
CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges);
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numFaces);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_CALLOC, NULL, numLoops);
|
|
|
|
CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_CALLOC, NULL, numPolys);
|
2006-12-12 22:29:09 +01:00
|
|
|
|
|
|
|
cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT);
|
|
|
|
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
|
|
|
|
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP);
|
|
|
|
cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
return dm;
|
|
|
|
}
|
|
|
|
|
2010-10-16 16:32:17 +02:00
|
|
|
DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = cdDM_create("CDDM_from_mesh dm");
|
|
|
|
DerivedMesh *dm = &cddm->dm;
|
2009-01-06 19:59:03 +01:00
|
|
|
CustomDataMask mask = CD_MASK_MESH & (~CD_MASK_MDISPS);
|
2009-11-04 21:23:48 +01:00
|
|
|
int alloctype;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-11-04 21:23:48 +01:00
|
|
|
/* this does a referenced copy, with an exception for fluidsim */
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2010-01-13 08:26:11 +01:00
|
|
|
DM_init(dm, DM_TYPE_CDDM, mesh->totvert, mesh->totedge, mesh->totface,
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
mesh->totloop, mesh->totpoly);
|
2008-06-09 19:22:38 +02:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 23:09:57 +01:00
|
|
|
dm->deformedOnly = 1;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2008-07-25 20:57:16 +02:00
|
|
|
alloctype= CD_REFERENCE;
|
2008-02-21 14:15:21 +01:00
|
|
|
|
2009-01-06 19:59:03 +01:00
|
|
|
CustomData_merge(&mesh->vdata, &dm->vertData, mask, alloctype,
|
2010-03-22 10:30:00 +01:00
|
|
|
mesh->totvert);
|
2009-01-06 19:59:03 +01:00
|
|
|
CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype,
|
2010-03-22 10:30:00 +01:00
|
|
|
mesh->totedge);
|
2009-09-05 08:10:30 +02:00
|
|
|
CustomData_merge(&mesh->fdata, &dm->faceData, mask|CD_MASK_ORIGINDEX, alloctype,
|
2010-03-22 10:30:00 +01:00
|
|
|
mesh->totface);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
CustomData_merge(&mesh->ldata, &dm->loopData, mask, alloctype,
|
|
|
|
mesh->totloop);
|
|
|
|
CustomData_merge(&mesh->pdata, &dm->polyData, mask, alloctype,
|
|
|
|
mesh->totpoly);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT);
|
|
|
|
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP);
|
|
|
|
cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
|
2009-09-05 08:10:30 +02:00
|
|
|
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2009-09-05 08:10:30 +02:00
|
|
|
if (!CustomData_has_layer(&cddm->dm.faceData, CD_ORIGINDEX))
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totface);
|
2009-08-28 11:36:31 +02:00
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
return dm;
|
|
|
|
}
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static DerivedMesh *disabled__CDDM_from_editmesh(EditMesh *em, Mesh *UNUSED(me))
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
|
|
|
DerivedMesh *dm = CDDM_new(BLI_countlist(&em->verts),
|
|
|
|
BLI_countlist(&em->edges),
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
BLI_countlist(&em->faces), 0, 0);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
2006-08-28 03:12:36 +02:00
|
|
|
EditVert *eve;
|
|
|
|
EditEdge *eed;
|
|
|
|
EditFace *efa;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
MVert *mvert = cddm->mvert;
|
|
|
|
MEdge *medge = cddm->medge;
|
|
|
|
MFace *mface = cddm->mface;
|
|
|
|
int i, *index;
|
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 23:09:57 +01:00
|
|
|
dm->deformedOnly = 1;
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CustomData_merge(&em->vdata, &dm->vertData, CD_MASK_DERIVEDMESH,
|
2010-03-22 10:30:00 +01:00
|
|
|
CD_CALLOC, dm->numVertData);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
/* CustomData_merge(&em->edata, &dm->edgeData, CD_MASK_DERIVEDMESH,
|
2010-03-22 10:30:00 +01:00
|
|
|
CD_CALLOC, dm->numEdgeData); */
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CustomData_merge(&em->fdata, &dm->faceData, CD_MASK_DERIVEDMESH,
|
2010-03-22 10:30:00 +01:00
|
|
|
CD_CALLOC, dm->numFaceData);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
CustomData_merge(&em->fdata, &dm->faceData, CD_MASK_DERIVEDMESH,
|
|
|
|
CD_CALLOC, dm->numFaceData);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2006-11-11 17:38:37 +01:00
|
|
|
/* set eve->hash to vert index */
|
2006-08-28 03:12:36 +02:00
|
|
|
for(i = 0, eve = em->verts.first; eve; eve = eve->next, ++i)
|
2006-11-13 16:36:33 +01:00
|
|
|
eve->tmp.l = i;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
/* Need to be able to mark loose edges */
|
|
|
|
for(eed = em->edges.first; eed; eed = eed->next) {
|
|
|
|
eed->f2 = 0;
|
|
|
|
}
|
|
|
|
for(efa = em->faces.first; efa; efa = efa->next) {
|
|
|
|
efa->e1->f2 = 1;
|
|
|
|
efa->e2->f2 = 1;
|
|
|
|
efa->e3->f2 = 1;
|
|
|
|
if(efa->e4) efa->e4->f2 = 1;
|
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
index = dm->getVertDataArray(dm, CD_ORIGINDEX);
|
|
|
|
for(i = 0, eve = em->verts.first; i < dm->numVertData;
|
2010-03-22 10:30:00 +01:00
|
|
|
i++, eve = eve->next, index++) {
|
2006-08-28 03:12:36 +02:00
|
|
|
MVert *mv = &mvert[i];
|
|
|
|
|
|
|
|
VECCOPY(mv->co, eve->co);
|
|
|
|
|
2011-03-28 04:34:55 +02:00
|
|
|
normal_float_to_short_v3(mv->no, eve->no);
|
2008-02-23 23:11:16 +01:00
|
|
|
mv->bweight = (unsigned char) (eve->bweight * 255.0f);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
mv->flag = 0;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CustomData_from_em_block(&em->vdata, &dm->vertData, eve->data, i);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
index = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
|
|
|
|
for(i = 0, eed = em->edges.first; i < dm->numEdgeData;
|
2010-03-22 10:30:00 +01:00
|
|
|
i++, eed = eed->next, index++) {
|
2006-08-28 03:12:36 +02:00
|
|
|
MEdge *med = &medge[i];
|
|
|
|
|
2006-11-13 16:36:33 +01:00
|
|
|
med->v1 = eed->v1->tmp.l;
|
|
|
|
med->v2 = eed->v2->tmp.l;
|
2006-08-28 03:12:36 +02:00
|
|
|
med->crease = (unsigned char) (eed->crease * 255.0f);
|
2008-02-23 23:11:16 +01:00
|
|
|
med->bweight = (unsigned char) (eed->bweight * 255.0f);
|
2006-08-28 03:12:36 +02:00
|
|
|
med->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
|
|
|
|
|
|
|
if(eed->seam) med->flag |= ME_SEAM;
|
|
|
|
if(eed->sharp) med->flag |= ME_SHARP;
|
|
|
|
if(!eed->f2) med->flag |= ME_LOOSEEDGE;
|
|
|
|
|
|
|
|
*index = i;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
|
|
|
/* CustomData_from_em_block(&em->edata, &dm->edgeData, eed->data, i); */
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
for(i = 0, efa = em->faces.first; i < dm->numFaceData;
|
2010-03-22 10:30:00 +01:00
|
|
|
i++, efa = efa->next, index++) {
|
2006-08-28 03:12:36 +02:00
|
|
|
MFace *mf = &mface[i];
|
|
|
|
|
2006-11-13 16:36:33 +01:00
|
|
|
mf->v1 = efa->v1->tmp.l;
|
|
|
|
mf->v2 = efa->v2->tmp.l;
|
|
|
|
mf->v3 = efa->v3->tmp.l;
|
|
|
|
mf->v4 = efa->v4 ? efa->v4->tmp.l : 0;
|
2006-08-28 03:12:36 +02:00
|
|
|
mf->mat_nr = efa->mat_nr;
|
|
|
|
mf->flag = efa->flag;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CustomData_from_em_block(&em->fdata, &dm->faceData, efa->data, i);
|
|
|
|
test_index_face(mf, &dm->faceData, i, efa->v4?4:3);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return dm;
|
|
|
|
}
|
|
|
|
|
2010-03-05 17:47:52 +01:00
|
|
|
DerivedMesh *CDDM_from_curve(Object *ob)
|
2010-03-08 14:49:13 +01:00
|
|
|
{
|
2011-01-05 11:40:38 +01:00
|
|
|
return CDDM_from_curve_customDB(ob, &ob->disp);
|
2010-03-08 14:49:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase)
|
2010-03-05 17:47:52 +01:00
|
|
|
{
|
|
|
|
DerivedMesh *dm;
|
|
|
|
CDDerivedMesh *cddm;
|
|
|
|
MVert *allvert;
|
|
|
|
MEdge *alledge;
|
|
|
|
MFace *allface;
|
2011-04-15 03:19:13 +02:00
|
|
|
MLoop *allloop;
|
|
|
|
MPoly *allpoly;
|
|
|
|
int totvert, totedge, totface, totloop, totpoly;
|
2010-03-05 17:47:52 +01:00
|
|
|
|
2010-03-08 14:49:13 +01:00
|
|
|
if (nurbs_to_mdata_customdb(ob, dispbase, &allvert, &totvert, &alledge,
|
2011-04-15 03:19:13 +02:00
|
|
|
&totedge, &allface, &allloop, &allpoly, &totface, &totloop, &totpoly) != 0) {
|
2010-03-05 17:47:52 +01:00
|
|
|
/* Error initializing mdata. This often happens when curve is empty */
|
2010-07-19 06:44:37 +02:00
|
|
|
return CDDM_new(0, 0, 0, 0, 0);
|
2010-03-05 17:47:52 +01:00
|
|
|
}
|
|
|
|
|
2011-04-15 03:19:13 +02:00
|
|
|
dm = CDDM_new(totvert, totedge, totface, totloop, totpoly);
|
2010-03-05 17:47:52 +01:00
|
|
|
dm->deformedOnly = 1;
|
|
|
|
|
|
|
|
cddm = (CDDerivedMesh*)dm;
|
|
|
|
|
|
|
|
memcpy(cddm->mvert, allvert, totvert*sizeof(MVert));
|
|
|
|
memcpy(cddm->medge, alledge, totedge*sizeof(MEdge));
|
|
|
|
memcpy(cddm->mface, allface, totface*sizeof(MFace));
|
2011-04-15 03:19:13 +02:00
|
|
|
memcpy(cddm->mloop, allloop, totloop*sizeof(MLoop));
|
|
|
|
memcpy(cddm->mpoly, allpoly, totpoly*sizeof(MPoly));
|
2010-03-05 17:47:52 +01:00
|
|
|
|
|
|
|
MEM_freeN(allvert);
|
|
|
|
MEM_freeN(alledge);
|
|
|
|
MEM_freeN(allface);
|
2011-04-15 03:19:13 +02:00
|
|
|
MEM_freeN(allloop);
|
|
|
|
MEM_freeN(allpoly);
|
2010-03-05 17:47:52 +01:00
|
|
|
|
|
|
|
return dm;
|
|
|
|
}
|
2009-05-16 18:18:08 +02:00
|
|
|
|
|
|
|
static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
|
2010-07-19 06:44:37 +02:00
|
|
|
int cdindex, BMLoop *l3[3],
|
|
|
|
int numCol, int numTex)
|
2009-05-16 18:18:08 +02:00
|
|
|
{
|
|
|
|
BMLoop *l;
|
|
|
|
BMFace *f = l3[0]->f;
|
|
|
|
MTFace *texface;
|
|
|
|
MTexPoly *texpoly;
|
|
|
|
MCol *mcol;
|
|
|
|
MLoopCol *mloopcol;
|
|
|
|
MLoopUV *mloopuv;
|
2009-08-31 17:57:13 +02:00
|
|
|
int i, j, hasWCol = CustomData_has_layer(&bm->ldata, CD_WEIGHT_MLOOPCOL);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
|
|
|
for(i=0; i < numTex; i++){
|
|
|
|
texface = CustomData_get_n(facedata, CD_MTFACE, cdindex, i);
|
2009-06-23 07:35:49 +02:00
|
|
|
texpoly = CustomData_bmesh_get_n(&bm->pdata, f->head.data, CD_MTEXPOLY, i);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
|
|
|
texface->tpage = texpoly->tpage;
|
|
|
|
texface->flag = texpoly->flag;
|
|
|
|
texface->transp = texpoly->transp;
|
|
|
|
texface->mode = texpoly->mode;
|
|
|
|
texface->tile = texpoly->tile;
|
|
|
|
texface->unwrap = texpoly->unwrap;
|
|
|
|
|
2009-07-22 02:51:13 +02:00
|
|
|
for (j=0; j<3; j++) {
|
2009-05-16 18:18:08 +02:00
|
|
|
l = l3[j];
|
2009-06-23 07:35:49 +02:00
|
|
|
mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
|
2009-05-16 18:18:08 +02:00
|
|
|
texface->uv[j][0] = mloopuv->uv[0];
|
|
|
|
texface->uv[j][1] = mloopuv->uv[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i < numCol; i++){
|
|
|
|
mcol = CustomData_get_n(facedata, CD_MCOL, cdindex, i);
|
|
|
|
|
|
|
|
for (j=0; j<3; j++) {
|
|
|
|
l = l3[j];
|
2009-06-23 07:35:49 +02:00
|
|
|
mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPCOL, i);
|
2009-05-16 18:18:08 +02:00
|
|
|
mcol[j].r = mloopcol->r;
|
|
|
|
mcol[j].g = mloopcol->g;
|
|
|
|
mcol[j].b = mloopcol->b;
|
|
|
|
mcol[j].a = mloopcol->a;
|
|
|
|
}
|
|
|
|
}
|
2009-08-31 17:57:13 +02:00
|
|
|
|
|
|
|
if (hasWCol) {
|
|
|
|
mcol = CustomData_get(facedata, cdindex, CD_WEIGHT_MCOL);
|
|
|
|
|
|
|
|
for (j=0; j<3; j++) {
|
|
|
|
l = l3[j];
|
|
|
|
mloopcol = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_WEIGHT_MLOOPCOL);
|
|
|
|
mcol[j].r = mloopcol->r;
|
|
|
|
mcol[j].g = mloopcol->g;
|
|
|
|
mcol[j].b = mloopcol->b;
|
|
|
|
mcol[j].a = mloopcol->a;
|
|
|
|
}
|
|
|
|
}
|
2009-05-16 18:18:08 +02:00
|
|
|
}
|
|
|
|
|
2011-05-09 16:32:55 +02:00
|
|
|
DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps)
|
2009-05-16 18:18:08 +02:00
|
|
|
{
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
DerivedMesh *dm = CDDM_new(em->bm->totvert, em->bm->totedge,
|
|
|
|
em->tottri, em->bm->totloop, em->bm->totface);
|
2009-05-16 18:18:08 +02:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
BMesh *bm = em->bm;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
BMIter iter, liter;
|
2009-05-16 18:18:08 +02:00
|
|
|
BMVert *eve;
|
|
|
|
BMEdge *eed;
|
|
|
|
BMFace *efa;
|
|
|
|
MVert *mvert = cddm->mvert;
|
|
|
|
MEdge *medge = cddm->medge;
|
|
|
|
MFace *mface = cddm->mface;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
MLoop *mloop = cddm->mloop;
|
|
|
|
MPoly *mpoly = cddm->mpoly;
|
2009-05-16 18:18:08 +02:00
|
|
|
int numCol = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
|
|
|
|
int numTex = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY);
|
2009-06-23 07:35:49 +02:00
|
|
|
int i, j, *index, add_orig;
|
2011-03-27 05:29:27 +02:00
|
|
|
int has_crease, has_edge_bweight, has_vert_bweight;
|
2011-03-29 07:48:18 +02:00
|
|
|
int flag;
|
2011-03-27 05:29:27 +02:00
|
|
|
|
|
|
|
has_edge_bweight = CustomData_has_layer(&em->bm->edata, CD_BWEIGHT);
|
|
|
|
has_vert_bweight = CustomData_has_layer(&em->bm->vdata, CD_BWEIGHT);
|
|
|
|
has_crease = CustomData_has_layer(&em->bm->edata, CD_CREASE);
|
|
|
|
|
2009-05-16 18:18:08 +02:00
|
|
|
dm->deformedOnly = 1;
|
2009-06-23 07:35:49 +02:00
|
|
|
|
|
|
|
/*don't add origindex layer if one already exists*/
|
|
|
|
add_orig = !CustomData_has_layer(&em->bm->pdata, CD_ORIGINDEX);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
2011-03-29 07:48:18 +02:00
|
|
|
flag = use_mdisps ? CD_MASK_DERIVEDMESH|CD_MASK_MDISPS : CD_MASK_DERIVEDMESH;
|
2011-04-15 07:20:18 +02:00
|
|
|
|
|
|
|
/*don't process shapekeys, we only feed them through the modifier stack as needed,
|
|
|
|
e.g. for applying modifiers or the like*/
|
|
|
|
flag &= ~CD_SHAPEKEY;
|
2011-03-29 07:48:18 +02:00
|
|
|
CustomData_merge(&em->bm->vdata, &dm->vertData, flag,
|
2009-05-16 18:18:08 +02:00
|
|
|
CD_CALLOC, dm->numVertData);
|
2011-03-29 07:48:18 +02:00
|
|
|
CustomData_merge(&em->bm->edata, &dm->edgeData, flag,
|
2009-06-23 07:35:49 +02:00
|
|
|
CD_CALLOC, dm->numEdgeData);
|
2011-03-29 07:48:18 +02:00
|
|
|
CustomData_merge(&em->bm->ldata, &dm->loopData, flag,
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
CD_CALLOC, dm->numLoopData);
|
2011-03-29 07:48:18 +02:00
|
|
|
CustomData_merge(&em->bm->pdata, &dm->polyData, flag,
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
CD_CALLOC, dm->numPolyData);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
2009-08-31 17:57:13 +02:00
|
|
|
/*add tesselation mface layers*/
|
|
|
|
CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
|
|
|
/* set vert index */
|
|
|
|
eve = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++)
|
2011-05-13 12:49:26 +02:00
|
|
|
BM_SetIndex(eve, i);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
|
|
|
index = dm->getVertDataArray(dm, CD_ORIGINDEX);
|
|
|
|
|
|
|
|
eve = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
|
2009-06-10 21:15:27 +02:00
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++, index++) {
|
2009-05-16 18:18:08 +02:00
|
|
|
MVert *mv = &mvert[i];
|
|
|
|
|
|
|
|
VECCOPY(mv->co, eve->co);
|
|
|
|
|
2011-05-13 12:49:26 +02:00
|
|
|
BM_SetIndex(eve, i);
|
2009-06-23 07:35:49 +02:00
|
|
|
|
2009-05-16 18:18:08 +02:00
|
|
|
mv->no[0] = eve->no[0] * 32767.0;
|
|
|
|
mv->no[1] = eve->no[1] * 32767.0;
|
|
|
|
mv->no[2] = eve->no[2] * 32767.0;
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
mv->flag = BMFlags_To_MEFlags(eve);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
2011-03-27 05:29:27 +02:00
|
|
|
if (has_vert_bweight)
|
|
|
|
mv->bweight = (unsigned char)(BM_GetCDf(&bm->vdata, eve, CD_BWEIGHT)*255.0f);
|
|
|
|
|
2009-06-23 07:35:49 +02:00
|
|
|
if (add_orig) *index = i;
|
2009-05-16 18:18:08 +02:00
|
|
|
|
2009-06-23 07:35:49 +02:00
|
|
|
CustomData_from_bmesh_block(&bm->vdata, &dm->vertData, eve->head.data, i);
|
2009-05-16 18:18:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
index = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
|
|
|
|
eed = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL);
|
2009-06-10 21:15:27 +02:00
|
|
|
for (i=0; eed; eed=BMIter_Step(&iter), i++, index++) {
|
2009-05-16 18:18:08 +02:00
|
|
|
MEdge *med = &medge[i];
|
|
|
|
|
2011-05-13 12:49:26 +02:00
|
|
|
BM_SetIndex(eed, i);
|
2009-06-23 07:35:49 +02:00
|
|
|
|
2011-05-13 12:49:26 +02:00
|
|
|
med->v1 = BM_GetIndex(eed->v1);
|
|
|
|
med->v2 = BM_GetIndex(eed->v2);
|
2009-05-16 18:18:08 +02:00
|
|
|
med->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
2011-03-27 05:29:27 +02:00
|
|
|
|
|
|
|
if (has_crease)
|
|
|
|
med->crease = (unsigned char)(BM_GetCDf(&bm->edata, eed, CD_CREASE)*255.0f);
|
|
|
|
if (has_edge_bweight)
|
|
|
|
med->bweight = (unsigned char)(BM_GetCDf(&bm->edata, eed, CD_BWEIGHT)*255.0f);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
med->flag = BMFlags_To_MEFlags(eed);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
2009-06-23 07:35:49 +02:00
|
|
|
CustomData_from_bmesh_block(&bm->edata, &dm->edgeData, eed->head.data, i);
|
|
|
|
if (add_orig) *index = i;
|
2009-05-16 18:18:08 +02:00
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
efa = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL);
|
|
|
|
for (i=0; efa; i++, efa=BMIter_Step(&iter)) {
|
2011-05-13 12:49:26 +02:00
|
|
|
BM_SetIndex(efa, i);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
|
2009-05-16 18:18:08 +02:00
|
|
|
for(i = 0; i < dm->numFaceData; i++, index++) {
|
|
|
|
MFace *mf = &mface[i];
|
|
|
|
BMLoop **l = em->looptris[i];
|
|
|
|
efa = l[0]->f;
|
|
|
|
|
2011-05-13 12:49:26 +02:00
|
|
|
mf->v1 = BM_GetIndex(l[0]->v);
|
|
|
|
mf->v2 = BM_GetIndex(l[1]->v);
|
|
|
|
mf->v3 = BM_GetIndex(l[2]->v);
|
2009-05-16 18:18:08 +02:00
|
|
|
mf->v4 = 0;
|
|
|
|
mf->mat_nr = efa->mat_nr;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
mf->flag = BMFlags_To_MEFlags(efa);
|
2009-06-23 07:35:49 +02:00
|
|
|
|
2011-05-13 12:49:26 +02:00
|
|
|
*index = add_orig ? BM_GetIndex(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
|
|
|
loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex);
|
|
|
|
test_index_face(mf, &dm->faceData, i, 3);
|
|
|
|
}
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
2009-06-23 07:35:49 +02:00
|
|
|
index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
j = 0;
|
|
|
|
efa = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL);
|
2009-06-10 21:15:27 +02:00
|
|
|
for (i=0; efa; i++, efa=BMIter_Step(&iter), index++) {
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
BMLoop *l;
|
|
|
|
MPoly *mp = &mpoly[i];
|
|
|
|
|
|
|
|
mp->totloop = efa->len;
|
|
|
|
mp->flag = BMFlags_To_MEFlags(efa);
|
|
|
|
mp->loopstart = j;
|
|
|
|
mp->mat_nr = efa->mat_nr;
|
|
|
|
|
|
|
|
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, efa) {
|
2011-05-13 12:49:26 +02:00
|
|
|
mloop->v = BM_GetIndex(l->v);
|
|
|
|
mloop->e = BM_GetIndex(l->e);
|
2009-06-23 07:35:49 +02:00
|
|
|
CustomData_from_bmesh_block(&bm->ldata, &dm->loopData, l->head.data, j);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
|
|
|
j++;
|
|
|
|
mloop++;
|
|
|
|
}
|
|
|
|
|
2009-06-23 07:35:49 +02:00
|
|
|
CustomData_from_bmesh_block(&bm->pdata, &dm->polyData, efa->head.data, i);
|
|
|
|
|
|
|
|
if (add_orig) *index = i;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
}
|
2009-05-16 18:18:08 +02:00
|
|
|
|
|
|
|
return dm;
|
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
typedef struct CDDM_LoopIter {
|
|
|
|
DMLoopIter head;
|
|
|
|
CDDerivedMesh *cddm;
|
|
|
|
int len, i;
|
|
|
|
} CDDM_LoopIter;
|
|
|
|
|
|
|
|
typedef struct CDDM_FaceIter {
|
|
|
|
DMFaceIter head;
|
|
|
|
CDDerivedMesh *cddm;
|
|
|
|
CDDM_LoopIter liter;
|
|
|
|
} CDDM_FaceIter;
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static void cddm_freeiter(void *self)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
{
|
|
|
|
MEM_freeN(self);
|
|
|
|
}
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static void cddm_stepiter(void *self)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
{
|
|
|
|
CDDM_FaceIter *iter = self;
|
|
|
|
MPoly *mp;
|
|
|
|
|
2010-01-28 01:45:30 +01:00
|
|
|
mp = iter->cddm->mpoly + iter->head.index;
|
|
|
|
mp->flag = iter->head.flags;
|
|
|
|
mp->mat_nr = iter->head.mat_nr;
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
iter->head.index++;
|
|
|
|
if (iter->head.index >= iter->cddm->dm.numPolyData) {
|
|
|
|
iter->head.done = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mp = iter->cddm->mpoly + iter->head.index;
|
|
|
|
|
|
|
|
iter->head.flags = mp->flag;
|
|
|
|
iter->head.mat_nr = mp->mat_nr;
|
|
|
|
iter->head.len = mp->totloop;
|
|
|
|
}
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static void *cddm_faceiter_getcddata(void *self, int type, int layer)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
{
|
|
|
|
CDDM_FaceIter *iter = self;
|
|
|
|
|
|
|
|
if (layer == -1) return CustomData_get(&iter->cddm->dm.polyData,
|
|
|
|
iter->head.index, type);
|
|
|
|
else return CustomData_get_n(&iter->cddm->dm.polyData, type,
|
|
|
|
iter->head.index, layer);
|
|
|
|
}
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static void *cddm_loopiter_getcddata(void *self, int type, int layer)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
{
|
2009-08-18 22:05:08 +02:00
|
|
|
CDDM_LoopIter *iter = self;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
|
|
|
if (layer == -1) return CustomData_get(&iter->cddm->dm.loopData,
|
|
|
|
iter->head.index, type);
|
|
|
|
else return CustomData_get_n(&iter->cddm->dm.loopData, type,
|
|
|
|
iter->head.index, layer);
|
|
|
|
}
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static void *cddm_loopiter_getvertcddata(void *self, int type, int layer)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
{
|
2009-08-18 22:05:08 +02:00
|
|
|
CDDM_LoopIter *iter = self;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
|
|
|
if (layer == -1) return CustomData_get(&iter->cddm->dm.vertData,
|
2011-03-19 22:33:33 +01:00
|
|
|
iter->cddm->mloop[iter->head.index].v,
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
type);
|
|
|
|
else return CustomData_get_n(&iter->cddm->dm.vertData, type,
|
2011-03-19 22:33:33 +01:00
|
|
|
iter->cddm->mloop[iter->head.index].v, layer);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
}
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static DMLoopIter *cddmiter_get_loopiter(void *self)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
{
|
|
|
|
CDDM_FaceIter *iter = self;
|
|
|
|
CDDM_LoopIter *liter = &iter->liter;
|
|
|
|
MPoly *mp = iter->cddm->mpoly + iter->head.index;
|
|
|
|
|
|
|
|
liter->i = -1;
|
|
|
|
liter->len = iter->head.len;
|
|
|
|
liter->head.index = mp->loopstart-1;
|
|
|
|
liter->head.done = 0;
|
|
|
|
|
|
|
|
liter->head.step(liter);
|
|
|
|
|
|
|
|
return (DMLoopIter*) liter;
|
|
|
|
}
|
|
|
|
|
2011-05-11 04:14:43 +02:00
|
|
|
static void cddm_loopiter_step(void *self)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
{
|
|
|
|
CDDM_LoopIter *liter = self;
|
|
|
|
MLoop *ml;
|
|
|
|
|
|
|
|
liter->i++;
|
|
|
|
liter->head.index++;
|
|
|
|
|
|
|
|
if (liter->i == liter->len) {
|
|
|
|
liter->head.done = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ml = liter->cddm->mloop + liter->head.index;
|
|
|
|
|
|
|
|
liter->head.eindex = ml->e;
|
|
|
|
liter->head.v = liter->cddm->mvert[ml->v];
|
|
|
|
liter->head.vindex = ml->v;
|
|
|
|
}
|
|
|
|
|
|
|
|
DMFaceIter *cdDM_newFaceIter(DerivedMesh *source)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*) source;
|
|
|
|
CDDM_FaceIter *iter = MEM_callocN(sizeof(CDDM_FaceIter), "DMFaceIter from cddm");
|
|
|
|
|
|
|
|
iter->head.free = cddm_freeiter;
|
|
|
|
iter->head.step = cddm_stepiter;
|
|
|
|
iter->head.getCDData = cddm_faceiter_getcddata;
|
|
|
|
iter->head.getLoopsIter = cddmiter_get_loopiter;
|
|
|
|
|
|
|
|
iter->liter.head.step = cddm_loopiter_step;
|
|
|
|
iter->liter.head.getLoopCDData = cddm_loopiter_getcddata;
|
|
|
|
iter->liter.head.getVertCDData = cddm_loopiter_getvertcddata;
|
|
|
|
iter->liter.cddm = cddm;
|
|
|
|
|
|
|
|
iter->cddm = cddm;
|
2010-01-28 01:45:30 +01:00
|
|
|
|
|
|
|
if (source->numFaceData) {
|
|
|
|
iter->head.index = -1;
|
|
|
|
iter->head.step(iter);
|
|
|
|
} else {
|
|
|
|
iter->head.done = 1;
|
|
|
|
}
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
|
|
|
return (DMFaceIter*) iter;
|
|
|
|
}
|
|
|
|
|
2009-09-15 17:32:09 +02:00
|
|
|
DerivedMesh *CDDM_copy(DerivedMesh *source, int faces_from_tessfaces)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = cdDM_create("CDDM_copy cddm");
|
|
|
|
DerivedMesh *dm = &cddm->dm;
|
|
|
|
int numVerts = source->numVertData;
|
|
|
|
int numEdges = source->numEdgeData;
|
|
|
|
int numFaces = source->numFaceData;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
int numLoops = source->numLoopData;
|
|
|
|
int numPolys = source->numPolyData;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
2009-11-25 14:11:44 +01:00
|
|
|
/* ensure these are created if they are made on demand */
|
|
|
|
source->getVertDataArray(source, CD_ORIGINDEX);
|
|
|
|
source->getEdgeDataArray(source, CD_ORIGINDEX);
|
2010-01-05 23:33:41 +01:00
|
|
|
source->getTessFaceDataArray(source, CD_ORIGINDEX);
|
2009-11-25 14:11:44 +01:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
/* this initializes dm, and copies all non mvert/medge/mface layers */
|
2010-01-13 08:26:11 +01:00
|
|
|
DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numFaces,
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
numLoops, numPolys);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 23:09:57 +01:00
|
|
|
dm->deformedOnly = source->deformedOnly;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
|
|
|
CustomData_copy_data(&source->vertData, &dm->vertData, 0, 0, numVerts);
|
|
|
|
CustomData_copy_data(&source->edgeData, &dm->edgeData, 0, 0, numEdges);
|
|
|
|
CustomData_copy_data(&source->faceData, &dm->faceData, 0, 0, numFaces);
|
|
|
|
|
|
|
|
/* now add mvert/medge/mface layers */
|
|
|
|
cddm->mvert = source->dupVertArray(source);
|
|
|
|
cddm->medge = source->dupEdgeArray(source);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
cddm->mface = source->dupTessFaceArray(source);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
2006-12-12 22:29:09 +01:00
|
|
|
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, cddm->mvert, numVerts);
|
|
|
|
CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, cddm->medge, numEdges);
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, cddm->mface, numFaces);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
2009-09-15 17:32:09 +02:00
|
|
|
if (!faces_from_tessfaces)
|
|
|
|
DM_DupPolys(source, dm);
|
|
|
|
else
|
|
|
|
CDDM_tessfaces_to_faces(dm);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
|
|
|
cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP);
|
|
|
|
cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
|
2011-06-01 21:30:19 +02:00
|
|
|
|
2011-06-02 01:46:48 +02:00
|
|
|
cdDM_recalcTesselation((DerivedMesh *)cddm);
|
2011-06-01 21:30:19 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return dm;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2010-10-20 11:18:55 +02:00
|
|
|
/* note, the CD_ORIGINDEX layers are all 0, so if there is a direct
|
|
|
|
* relationship betwen mesh data this needs to be set by the caller. */
|
2006-08-28 03:12:36 +02:00
|
|
|
DerivedMesh *CDDM_from_template(DerivedMesh *source,
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
int numVerts, int numEdges, int numFaces,
|
2010-07-19 06:44:37 +02:00
|
|
|
int numLoops, int numPolys)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = cdDM_create("CDDM_from_template dest");
|
|
|
|
DerivedMesh *dm = &cddm->dm;
|
|
|
|
|
2010-07-27 14:01:40 +02:00
|
|
|
/* ensure these are created if they are made on demand */
|
|
|
|
source->getVertDataArray(source, CD_ORIGINDEX);
|
|
|
|
source->getEdgeDataArray(source, CD_ORIGINDEX);
|
2010-09-04 07:31:25 +02:00
|
|
|
source->getTessFaceDataArray(source, CD_ORIGINDEX);
|
2010-07-27 14:01:40 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
/* this does a copy of all non mvert/medge/mface layers */
|
2010-01-13 08:26:11 +01:00
|
|
|
DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numFaces, numLoops, numPolys);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
|
|
|
/* now add mvert/medge/mface layers */
|
2006-12-12 22:29:09 +01:00
|
|
|
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_CALLOC, NULL, numVerts);
|
|
|
|
CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges);
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numFaces);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_CALLOC, NULL, numLoops);
|
|
|
|
CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_CALLOC, NULL, numPolys);
|
2006-12-12 22:29:09 +01:00
|
|
|
|
2009-11-04 21:23:48 +01:00
|
|
|
if(!CustomData_get_layer(&dm->vertData, CD_ORIGINDEX))
|
|
|
|
CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts);
|
|
|
|
if(!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX))
|
|
|
|
CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
|
|
|
|
if(!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numFaces);
|
|
|
|
|
2006-12-12 22:29:09 +01:00
|
|
|
cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT);
|
|
|
|
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
|
|
|
|
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP);
|
|
|
|
cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
|
|
|
return dm;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
MVert *vert;
|
2006-08-28 03:12:36 +02:00
|
|
|
int i;
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
/* this will just return the pointer if it wasn't a referenced layer */
|
|
|
|
vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
|
|
|
|
cddm->mvert = vert;
|
|
|
|
|
|
|
|
for(i = 0; i < dm->numVertData; ++i, ++vert)
|
2006-08-28 03:12:36 +02:00
|
|
|
VECCOPY(vert->co, vertCoords[i]);
|
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3])
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
MVert *vert;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* this will just return the pointer if it wasn't a referenced layer */
|
|
|
|
vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
|
|
|
|
cddm->mvert = vert;
|
|
|
|
|
|
|
|
for(i = 0; i < dm->numVertData; ++i, ++vert)
|
|
|
|
VECCOPY(vert->no, vertNormals[i]);
|
|
|
|
}
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
void CDDM_calc_normals(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
2011-04-15 03:19:13 +02:00
|
|
|
float (*face_nors)[3] = NULL;
|
|
|
|
|
2011-03-26 09:28:24 +01:00
|
|
|
if(dm->numVertData == 0) return;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
/* we don't want to overwrite any referenced layers */
|
2011-03-26 09:28:24 +01:00
|
|
|
cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
|
2011-04-15 03:19:13 +02:00
|
|
|
|
|
|
|
/*set tesselation origindex values to map to poly indices, rather then poly
|
|
|
|
poly origindex values*/
|
2009-11-03 06:06:04 +01:00
|
|
|
cdDM_recalcTesselation2(dm);
|
2009-11-02 07:31:23 +01:00
|
|
|
|
2011-04-15 03:19:13 +02:00
|
|
|
face_nors = MEM_mallocN(sizeof(float)*3*dm->numFaceData, "face_nors");
|
|
|
|
|
|
|
|
/* calculate face normals */
|
|
|
|
mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
|
|
|
|
dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numFaceData,
|
|
|
|
CustomData_get_layer(&dm->faceData, CD_ORIGINDEX), face_nors);
|
|
|
|
|
|
|
|
/*restore tesselation origindex indices to poly origindex indices*/
|
2009-11-03 06:06:04 +01:00
|
|
|
cdDM_recalcTesselation(dm);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
2009-11-03 06:06:04 +01:00
|
|
|
CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN,
|
|
|
|
face_nors, dm->numFaceData);
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2011-02-27 08:49:36 +01:00
|
|
|
#if 1
|
2011-02-15 02:16:32 +01:00
|
|
|
/*merge verts
|
|
|
|
|
|
|
|
vtargetmap is a table that maps vertices to target vertices. a value of -1
|
|
|
|
indicates a vertex is a target, and is to be kept.
|
|
|
|
|
2011-02-27 08:49:36 +01:00
|
|
|
this frees dm, and returns a new one.
|
|
|
|
|
2011-02-15 02:16:32 +01:00
|
|
|
this is a really horribly written function. ger. - joeedh
|
|
|
|
|
|
|
|
*/
|
|
|
|
DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, int *vtargetmap)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
CDDerivedMesh *cddm2 = NULL;
|
|
|
|
MVert *mv, *mvert = NULL;
|
|
|
|
BLI_array_declare(mvert);
|
|
|
|
MEdge *me, *medge = NULL;
|
|
|
|
BLI_array_declare(medge);
|
|
|
|
MPoly *mp, *mpoly = NULL;
|
|
|
|
BLI_array_declare(mpoly);
|
|
|
|
MLoop *ml, *mloop = NULL;
|
|
|
|
BLI_array_declare(mloop);
|
2011-02-27 08:49:36 +01:00
|
|
|
EdgeHash *ehash = BLI_edgehash_new();
|
2011-02-15 02:16:32 +01:00
|
|
|
int *newv = NULL, *newe = NULL, *newl = NULL;
|
|
|
|
int *oldv = NULL, *olde = NULL, *oldl = NULL, *oldp = NULL;
|
|
|
|
BLI_array_declare(oldv); BLI_array_declare(olde); BLI_array_declare(oldl); BLI_array_declare(oldp);
|
|
|
|
int i, j, c, totloop, totpoly;
|
|
|
|
|
|
|
|
totloop = dm->numLoopData;
|
|
|
|
totpoly = dm->numPolyData;
|
|
|
|
|
|
|
|
newv = MEM_callocN(sizeof(int)*dm->numVertData, "newv vtable CDDM_merge_verts");
|
|
|
|
newe = MEM_callocN(sizeof(int)*dm->numEdgeData, "newv etable CDDM_merge_verts");
|
|
|
|
newl = MEM_callocN(sizeof(int)*totloop, "newv ltable CDDM_merge_verts");
|
2011-02-27 08:49:36 +01:00
|
|
|
|
|
|
|
/*fill newl with destination vertex indices*/
|
2011-02-15 02:16:32 +01:00
|
|
|
mv = cddm->mvert;
|
|
|
|
c = 0;
|
|
|
|
for (i=0; i<dm->numVertData; i++, mv++) {
|
|
|
|
if (vtargetmap[i] == -1) {
|
|
|
|
BLI_array_append(oldv, i);
|
|
|
|
newv[i] = c++;
|
|
|
|
BLI_array_append(mvert, *mv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-27 08:49:36 +01:00
|
|
|
/*now link target vertices to destination indices*/
|
|
|
|
for (i=0; i<dm->numVertData; i++) {
|
|
|
|
if (vtargetmap[i] != -1) {
|
|
|
|
newv[i] = newv[vtargetmap[i]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-15 02:16:32 +01:00
|
|
|
/*find-replace merged vertices with target vertices*/
|
|
|
|
ml = cddm->mloop;
|
|
|
|
c = 0;
|
|
|
|
for (i=0; i<totloop; i++, ml++) {
|
|
|
|
if (ml->v == -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (vtargetmap[ml->v] != -1) {
|
|
|
|
me = &cddm->medge[ml->e];
|
|
|
|
if (me->v1 == ml->v)
|
|
|
|
me->v1 = vtargetmap[ml->v];
|
|
|
|
else
|
|
|
|
me->v2 = vtargetmap[ml->v];
|
|
|
|
|
|
|
|
ml->v = vtargetmap[ml->v];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*now go through and fix edges and faces*/
|
|
|
|
me = cddm->medge;
|
|
|
|
c = 0;
|
|
|
|
for (i=0; i<dm->numEdgeData; i++, me++) {
|
2011-02-27 08:49:36 +01:00
|
|
|
int v1, v2;
|
|
|
|
|
|
|
|
if (me->v1 == me->v2) {
|
|
|
|
newe[i] = -1;
|
2011-02-15 02:16:32 +01:00
|
|
|
continue;
|
2011-02-27 08:49:36 +01:00
|
|
|
}
|
2011-02-15 02:16:32 +01:00
|
|
|
|
2011-02-27 08:49:36 +01:00
|
|
|
if (vtargetmap[me->v1] != -1)
|
|
|
|
v1 = vtargetmap[me->v1];
|
|
|
|
else
|
|
|
|
v1 = me->v1;
|
|
|
|
|
|
|
|
if (vtargetmap[me->v2] != -1)
|
|
|
|
v2 = vtargetmap[me->v2];
|
|
|
|
else
|
|
|
|
v2 = me->v2;
|
|
|
|
|
|
|
|
if (BLI_edgehash_haskey(ehash, v1, v2)) {
|
|
|
|
newe[i] = GET_INT_FROM_POINTER(BLI_edgehash_lookup(ehash, v1, v2));
|
|
|
|
} else {
|
|
|
|
BLI_array_append(olde, i);
|
|
|
|
newe[i] = c;
|
|
|
|
BLI_array_append(medge, *me);
|
|
|
|
BLI_edgehash_insert(ehash, v1, v2, SET_INT_IN_POINTER(c));
|
|
|
|
c++;
|
|
|
|
}
|
2011-02-15 02:16:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mp = cddm->mpoly;
|
|
|
|
for (i=0; i<totpoly; i++, mp++) {
|
|
|
|
MPoly *mp2;
|
|
|
|
|
|
|
|
ml = cddm->mloop + mp->loopstart;
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
for (j=0; j<mp->totloop; j++, ml++) {
|
|
|
|
if (ml->v == -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
me = cddm->medge + ml->e;
|
|
|
|
if (me->v1 != me->v2) {
|
2011-02-27 08:49:36 +01:00
|
|
|
BLI_array_append(oldl, j+mp->loopstart);
|
2011-02-15 02:16:32 +01:00
|
|
|
BLI_array_append(mloop, *ml);
|
2011-02-27 08:49:36 +01:00
|
|
|
newl[j+mp->loopstart] = BLI_array_count(mloop)-1;
|
2011-02-15 02:16:32 +01:00
|
|
|
c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!c)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mp2 = BLI_array_append(mpoly, *mp);
|
|
|
|
mp2->totloop = c;
|
|
|
|
mp2->loopstart = BLI_array_count(mloop) - c;
|
|
|
|
|
|
|
|
BLI_array_append(oldp, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*create new cddm*/
|
2011-04-15 03:19:13 +02:00
|
|
|
cddm2 = (CDDerivedMesh*) CDDM_from_template((DerivedMesh*)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly));
|
2011-02-15 02:16:32 +01:00
|
|
|
|
|
|
|
/*update edge indices and copy customdata*/
|
2011-02-27 08:49:36 +01:00
|
|
|
me = medge;
|
2011-02-15 02:16:32 +01:00
|
|
|
for (i=0; i<cddm2->dm.numEdgeData; i++, me++) {
|
2011-02-27 08:49:36 +01:00
|
|
|
if (newv[me->v1] != -1)
|
|
|
|
me->v1 = newv[me->v1];
|
|
|
|
if (newv[me->v2] != -1)
|
|
|
|
me->v2 = newv[me->v2];
|
2011-02-15 02:16:32 +01:00
|
|
|
|
|
|
|
CustomData_copy_data(&dm->edgeData, &cddm2->dm.edgeData, olde[i], i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*update loop indices and copy customdata*/
|
2011-02-27 08:49:36 +01:00
|
|
|
ml = mloop;
|
2011-02-15 02:16:32 +01:00
|
|
|
for (i=0; i<cddm2->dm.numLoopData; i++, ml++) {
|
2011-02-27 08:49:36 +01:00
|
|
|
if (newe[ml->e] != -1)
|
|
|
|
ml->e = newe[ml->e];
|
|
|
|
if (newv[ml->v] != -1)
|
|
|
|
ml->v = newv[ml->v];
|
2011-02-15 02:16:32 +01:00
|
|
|
|
|
|
|
CustomData_copy_data(&dm->loopData, &cddm2->dm.loopData, oldl[i], i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*copy vertex customdata*/
|
2011-02-27 08:49:36 +01:00
|
|
|
mv = mvert;
|
2011-02-15 02:16:32 +01:00
|
|
|
for (i=0; i<cddm2->dm.numVertData; i++, mv++) {
|
|
|
|
CustomData_copy_data(&dm->vertData, &cddm2->dm.vertData, oldv[i], i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*copy poly customdata*/
|
2011-02-27 08:49:36 +01:00
|
|
|
mp = mpoly;
|
2011-02-15 02:16:32 +01:00
|
|
|
for (i=0; i<cddm2->dm.numPolyData; i++, mp++) {
|
|
|
|
CustomData_copy_data(&dm->polyData, &cddm2->dm.polyData, oldp[i], i, 1);
|
|
|
|
}
|
|
|
|
|
2011-02-27 08:49:36 +01:00
|
|
|
/*copy over data. CustomData_add_layer can do this, need to look it up.*/
|
|
|
|
memcpy(cddm2->mvert, mvert, sizeof(MVert)*BLI_array_count(mvert));
|
|
|
|
memcpy(cddm2->medge, medge, sizeof(MEdge)*BLI_array_count(medge));
|
|
|
|
memcpy(cddm2->mloop, mloop, sizeof(MLoop)*BLI_array_count(mloop));
|
|
|
|
memcpy(cddm2->mpoly, mpoly, sizeof(MPoly)*BLI_array_count(mpoly));
|
|
|
|
BLI_array_free(mvert); BLI_array_free(medge); BLI_array_free(mloop); BLI_array_free(mpoly);
|
|
|
|
|
2011-04-15 03:19:13 +02:00
|
|
|
CDDM_recalc_tesselation((DerivedMesh*)cddm2, 1);
|
2011-02-15 02:16:32 +01:00
|
|
|
|
|
|
|
if (newv)
|
|
|
|
MEM_freeN(newv);
|
|
|
|
if (newe)
|
|
|
|
MEM_freeN(newe);
|
|
|
|
if (newl)
|
|
|
|
MEM_freeN(newl);
|
|
|
|
if (oldv)
|
|
|
|
MEM_freeN(oldv);
|
|
|
|
if (olde)
|
|
|
|
MEM_freeN(olde);
|
|
|
|
if (oldl)
|
|
|
|
MEM_freeN(oldl);
|
|
|
|
if (oldp)
|
|
|
|
MEM_freeN(oldp);
|
2011-02-27 08:49:36 +01:00
|
|
|
if (ehash)
|
|
|
|
BLI_edgehash_free(ehash, NULL);
|
|
|
|
|
|
|
|
/*free old derivedmesh*/
|
2011-02-15 02:16:32 +01:00
|
|
|
dm->needsFree = 1;
|
|
|
|
dm->release(dm);
|
|
|
|
|
|
|
|
return (DerivedMesh*)cddm2;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
void CDDM_calc_edges(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
2006-08-28 03:12:36 +02:00
|
|
|
CustomData edgeData;
|
|
|
|
EdgeHashIterator *ehi;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
MFace *mf = cddm->mface;
|
2006-08-28 03:12:36 +02:00
|
|
|
MEdge *med;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
EdgeHash *eh = BLI_edgehash_new();
|
2006-11-23 18:35:45 +01:00
|
|
|
int i, *index, numEdges, maxFaces = dm->numFaceData;
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
for (i = 0; i < maxFaces; i++, mf++) {
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2))
|
|
|
|
BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL);
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3))
|
|
|
|
BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL);
|
|
|
|
|
|
|
|
if (mf->v4) {
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4))
|
|
|
|
BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
|
|
|
|
BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
|
|
|
|
} else {
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
|
|
|
|
BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
numEdges = BLI_edgehash_size(eh);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
/* write new edges into a temporary CustomData */
|
|
|
|
memset(&edgeData, 0, sizeof(edgeData));
|
2006-12-12 22:29:09 +01:00
|
|
|
CustomData_add_layer(&edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges);
|
|
|
|
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
|
2006-11-23 18:35:45 +01:00
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
ehi = BLI_edgehashIterator_new(eh);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
med = CustomData_get_layer(&edgeData, CD_MEDGE);
|
2006-12-12 22:29:09 +01:00
|
|
|
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
|
2006-08-28 03:12:36 +02:00
|
|
|
for(i = 0; !BLI_edgehashIterator_isDone(ehi);
|
2010-03-22 10:30:00 +01:00
|
|
|
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
|
2006-10-27 01:34:44 +02:00
|
|
|
BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
med->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
2006-11-23 18:35:45 +01:00
|
|
|
*index = ORIGINDEX_NONE;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
BLI_edgehashIterator_free(ehi);
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
/* free old CustomData and assign new one */
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 14:19:00 +02:00
|
|
|
CustomData_free(&dm->edgeData, dm->numEdgeData);
|
2006-08-28 03:12:36 +02:00
|
|
|
dm->edgeData = edgeData;
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
dm->numEdgeData = numEdges;
|
|
|
|
|
|
|
|
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
BLI_edgehash_free(eh, NULL);
|
|
|
|
}
|
|
|
|
|
2009-09-11 12:21:54 +02:00
|
|
|
|
|
|
|
void CDDM_calc_edges_poly(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
CustomData edgeData;
|
|
|
|
EdgeHashIterator *ehi;
|
|
|
|
MPoly *mp = cddm->mpoly;
|
|
|
|
MLoop *ml;
|
|
|
|
MEdge *med;
|
|
|
|
EdgeHash *eh = BLI_edgehash_new();
|
|
|
|
int v1, v2;
|
|
|
|
int *eindex;
|
|
|
|
int i, j, k, *index, numEdges = cddm->dm.numEdgeData, maxFaces = dm->numPolyData;
|
|
|
|
|
|
|
|
eindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
|
|
|
|
|
|
|
med = cddm->medge;
|
|
|
|
if (med) {
|
|
|
|
for (i=0; i < numEdges; i++, med++) {
|
|
|
|
BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i+1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i < maxFaces; i++, mp++) {
|
|
|
|
ml = cddm->mloop + mp->loopstart;
|
|
|
|
for (j=0; j<mp->totloop; j++, ml++) {
|
|
|
|
v1 = ml->v;
|
|
|
|
v2 = (cddm->mloop + mp->loopstart + ((j+1)%mp->totloop))->v;
|
|
|
|
if (!BLI_edgehash_haskey(eh, v1, v2)) {
|
|
|
|
BLI_edgehash_insert(eh, v1, v2, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k = numEdges;
|
|
|
|
numEdges = BLI_edgehash_size(eh);
|
|
|
|
|
|
|
|
/* write new edges into a temporary CustomData */
|
|
|
|
memset(&edgeData, 0, sizeof(edgeData));
|
|
|
|
CustomData_add_layer(&edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges);
|
|
|
|
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
|
|
|
|
|
|
|
|
ehi = BLI_edgehashIterator_new(eh);
|
|
|
|
med = CustomData_get_layer(&edgeData, CD_MEDGE);
|
|
|
|
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
|
|
|
|
for(i = 0; !BLI_edgehashIterator_isDone(ehi);
|
|
|
|
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
|
|
|
|
BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
|
|
|
|
j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
|
|
|
|
|
|
|
|
med->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
|
|
|
*index = j==0 ? ORIGINDEX_NONE : eindex[j-1];
|
|
|
|
|
|
|
|
BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i));
|
|
|
|
}
|
|
|
|
BLI_edgehashIterator_free(ehi);
|
|
|
|
|
|
|
|
/* free old CustomData and assign new one */
|
|
|
|
CustomData_free(&dm->edgeData, dm->numEdgeData);
|
|
|
|
dm->edgeData = edgeData;
|
|
|
|
dm->numEdgeData = numEdges;
|
|
|
|
|
|
|
|
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
|
|
|
|
|
|
|
|
mp = cddm->mpoly;
|
|
|
|
for (i=0; i < maxFaces; i++, mp++) {
|
|
|
|
ml = cddm->mloop + mp->loopstart;
|
|
|
|
for (j=0; j<mp->totloop; j++, ml++) {
|
|
|
|
v1 = ml->v;
|
|
|
|
v2 = (cddm->mloop + mp->loopstart + ((j+1)%mp->totloop))->v;
|
|
|
|
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, v1, v2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_edgehash_free(eh, NULL);
|
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
if (numVerts < dm->numVertData)
|
2006-12-12 22:29:09 +01:00
|
|
|
CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData-numVerts);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
|
|
|
dm->numVertData = numVerts;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
if (numEdges < dm->numEdgeData)
|
2006-12-12 22:29:09 +01:00
|
|
|
CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData-numEdges);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
|
|
|
dm->numEdgeData = numEdges;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
void CDDM_lower_num_faces(DerivedMesh *dm, int numFaces)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
if (numFaces < dm->numFaceData)
|
2006-12-12 22:29:09 +01:00
|
|
|
CustomData_free_elem(&dm->faceData, numFaces, dm->numFaceData-numFaces);
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
|
|
|
|
dm->numFaceData = numFaces;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MVert *CDDM_get_vert(DerivedMesh *dm, int index)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return &((CDDerivedMesh*)dm)->mvert[index];
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MEdge *CDDM_get_edge(DerivedMesh *dm, int index)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return &((CDDerivedMesh*)dm)->medge[index];
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
MFace *CDDM_get_tessface(DerivedMesh *dm, int index)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return &((CDDerivedMesh*)dm)->mface[index];
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MVert *CDDM_get_verts(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return ((CDDerivedMesh*)dm)->mvert;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MEdge *CDDM_get_edges(DerivedMesh *dm)
|
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return ((CDDerivedMesh*)dm)->medge;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
MFace *CDDM_get_tessfaces(DerivedMesh *dm)
|
2006-08-28 03:12:36 +02:00
|
|
|
{
|
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.
2006-11-20 05:28:02 +01:00
|
|
|
return ((CDDerivedMesh*)dm)->mface;
|
2006-08-28 03:12:36 +02:00
|
|
|
}
|
|
|
|
|
2011-02-27 08:49:36 +01:00
|
|
|
MLoop *CDDM_get_loops(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
return ((CDDerivedMesh*)dm)->mloop;
|
|
|
|
}
|
|
|
|
|
2011-02-27 07:19:40 +01:00
|
|
|
MPoly *CDDM_get_polys(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
return ((CDDerivedMesh*)dm)->mpoly;
|
|
|
|
}
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
void CDDM_tessfaces_to_faces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
/*converts mfaces to mpolys/mloops*/
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
|
|
|
MFace *mf;
|
|
|
|
MEdge *me;
|
|
|
|
MLoop *ml;
|
|
|
|
MPoly *mp;
|
|
|
|
EdgeHash *eh = BLI_edgehash_new();
|
2009-06-16 22:08:40 +02:00
|
|
|
int i, l, totloop, *index1, *index2;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
subsurf works now! YES! take *that* subsurf_ccg.cscons/scons.py BF_QUICK=bf_python,bf_blenkernel,bf_blenlib,bf_blenloader,bf_editors_mesh,bf_bmesh,bf_editors_space_view3d,bf_editors_transform,bf_makesdna,bf_makesrna,bf_dna,bf_rn,bf_bmesh,bf_editors_object,editors_uvedit,editors_space_image,editors_screen,editors_space_screen,editors_space_api,bf_windowmanager,bf_wm still an issue with some modifier combinations though, and I think there's some memory corruption going on, need to valgrind it.
2009-08-25 12:21:10 +02:00
|
|
|
/*ensure we have all the edges we need*/
|
|
|
|
CDDM_calc_edges(dm);
|
|
|
|
|
|
|
|
/*build edge hash*/
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
me = cddm->medge;
|
|
|
|
for (i=0; i<cddm->dm.numEdgeData; i++, me++) {
|
|
|
|
BLI_edgehash_insert(eh, me->v1, me->v2, SET_INT_IN_POINTER(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
mf = cddm->mface;
|
|
|
|
totloop = 0;
|
|
|
|
for (i=0; i<cddm->dm.numFaceData; i++, mf++) {
|
|
|
|
totloop += mf->v4 ? 4 : 3;
|
|
|
|
}
|
|
|
|
|
2009-06-16 22:08:40 +02:00
|
|
|
CustomData_free(&cddm->dm.polyData, cddm->dm.numPolyData);
|
|
|
|
CustomData_free(&cddm->dm.loopData, cddm->dm.numLoopData);
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
cddm->dm.numLoopData = totloop;
|
|
|
|
cddm->dm.numPolyData = cddm->dm.numFaceData;
|
2009-06-16 22:08:40 +02:00
|
|
|
|
|
|
|
if (!totloop) return;
|
|
|
|
|
|
|
|
cddm->mloop = MEM_callocN(sizeof(MLoop)*totloop, "cddm->mloop in CDDM_tessfaces_to_faces");
|
|
|
|
cddm->mpoly = MEM_callocN(sizeof(MPoly)*cddm->dm.numFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces");
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
|
|
|
|
CustomData_add_layer(&cddm->dm.loopData, CD_MLOOP, CD_ASSIGN, cddm->mloop, totloop);
|
|
|
|
CustomData_add_layer(&cddm->dm.polyData, CD_MPOLY, CD_ASSIGN, cddm->mpoly, cddm->dm.numPolyData);
|
2009-06-16 22:08:40 +02:00
|
|
|
CustomData_merge(&cddm->dm.faceData, &cddm->dm.polyData,
|
subsurf works now! YES! take *that* subsurf_ccg.cscons/scons.py BF_QUICK=bf_python,bf_blenkernel,bf_blenlib,bf_blenloader,bf_editors_mesh,bf_bmesh,bf_editors_space_view3d,bf_editors_transform,bf_makesdna,bf_makesrna,bf_dna,bf_rn,bf_bmesh,bf_editors_object,editors_uvedit,editors_space_image,editors_screen,editors_space_screen,editors_space_api,bf_windowmanager,bf_wm still an issue with some modifier combinations though, and I think there's some memory corruption going on, need to valgrind it.
2009-08-25 12:21:10 +02:00
|
|
|
CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numFaceData);
|
2009-06-16 22:08:40 +02:00
|
|
|
|
|
|
|
index1 = CustomData_get_layer(&cddm->dm.faceData, CD_ORIGINDEX);
|
|
|
|
index2 = CustomData_get_layer(&cddm->dm.polyData, CD_ORIGINDEX);
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
mf = cddm->mface;
|
|
|
|
mp = cddm->mpoly;
|
|
|
|
ml = cddm->mloop;
|
|
|
|
l = 0;
|
2009-06-12 16:02:37 +02:00
|
|
|
for (i=0; i<cddm->dm.numFaceData; i++, mf++, mp++) {
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 12:06:25 +02:00
|
|
|
mp->flag = mf->flag;
|
|
|
|
mp->loopstart = l;
|
|
|
|
mp->mat_nr = mf->mat_nr;
|
|
|
|
mp->totloop = mf->v4 ? 4 : 3;
|
|
|
|
|
|
|
|
ml->v = mf->v1;
|
|
|
|
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2));
|
|
|
|
ml++, l++;
|
|
|
|
|
|
|
|
ml->v = mf->v2;
|
|
|
|
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v2, mf->v3));
|
|
|
|
ml++, l++;
|
|
|
|
|
|
|
|
ml->v = mf->v3;
|
|
|
|
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v3, mf->v4?mf->v4:mf->v1));
|
|
|
|
ml++, l++;
|
|
|
|
|
|
|
|
if (mf->v4) {
|
|
|
|
ml->v = mf->v4;
|
|
|
|
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v4, mf->v1));
|
|
|
|
ml++, l++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_edgehash_free(eh, NULL);
|
|
|
|
}
|
|
|
|
|
2009-09-11 12:21:54 +02:00
|
|
|
void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
2011-04-23 01:37:58 +02:00
|
|
|
|
|
|
|
if (!CustomData_has_layer(&dm->vertData, CD_MVERT))
|
|
|
|
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, mvert, dm->numVertData);
|
|
|
|
|
2009-09-11 12:21:54 +02:00
|
|
|
cddm->mvert = mvert;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDDM_set_medge(DerivedMesh *dm, MEdge *medge)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
2010-01-05 23:33:41 +01:00
|
|
|
|
2011-04-23 01:37:58 +02:00
|
|
|
if (!CustomData_has_layer(&dm->edgeData, CD_MEDGE))
|
|
|
|
CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, medge, dm->numEdgeData);
|
|
|
|
|
2009-09-11 12:21:54 +02:00
|
|
|
cddm->medge = medge;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDDM_set_mface(DerivedMesh *dm, MFace *mface)
|
|
|
|
{
|
|
|
|
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
2009-01-06 19:59:03 +01:00
|
|
|
|
2011-04-23 01:37:58 +02:00
|
|
|
if (!CustomData_has_layer(&dm->faceData, CD_MFACE))
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, mface, dm->numFaceData);
|
|
|
|
|
2010-01-05 23:33:41 +01:00
|
|
|
cddm->mface = mface;
|
2009-01-06 19:59:03 +01:00
|
|
|
}
|