2011-02-18 14:05:18 +01:00
|
|
|
/*
|
2008-04-17 00:40:48 +02:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2005-03-27 22:34:18 +02:00
|
|
|
*
|
|
|
|
* 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
|
2008-04-17 00:40:48 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2005-03-27 22:34:18 +02:00
|
|
|
*
|
|
|
|
* 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.
|
2005-03-27 22:34:18 +02:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-17 00:40:48 +02:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2005-03-27 22:34:18 +02:00
|
|
|
*/
|
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#ifndef __BKE_DERIVEDMESH_H__
|
|
|
|
#define __BKE_DERIVEDMESH_H__
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2013-09-12 05:02:50 +02:00
|
|
|
/** \file BKE_DerivedMesh.h
|
|
|
|
* \ingroup bke
|
|
|
|
*
|
2012-03-03 21:19:11 +01:00
|
|
|
* Basic design of the DerivedMesh system:
|
|
|
|
*
|
|
|
|
* DerivedMesh is a common set of interfaces for mesh systems.
|
|
|
|
*
|
2012-06-27 19:48:39 +02:00
|
|
|
* There are three main mesh data structures in Blender:
|
|
|
|
* #Mesh, #CDDerivedMesh and #BMesh.
|
|
|
|
*
|
2012-03-03 21:19:11 +01:00
|
|
|
* These, and a few others, all implement DerivedMesh interfaces,
|
|
|
|
* which contains unified drawing interfaces, a few utility interfaces,
|
|
|
|
* and a bunch of read-only interfaces intended mostly for conversion from
|
|
|
|
* one format to another.
|
|
|
|
*
|
|
|
|
* All Mesh structures in blender make use of CustomData, which is used to store
|
|
|
|
* per-element attributes and interpolate them (e.g. uvs, vcols, vgroups, etc).
|
|
|
|
*
|
|
|
|
* Mesh is the "serialized" structure, used for storing object-mode mesh data
|
|
|
|
* and also for saving stuff to disk. It's interfaces are also what DerivedMesh
|
|
|
|
* uses to communicate with.
|
|
|
|
*
|
|
|
|
* CDDM is a little mesh library, that uses Mesh data structures in the backend.
|
|
|
|
* It's mostly used for modifiers, and has the advantages of not taking much
|
|
|
|
* resources.
|
|
|
|
*
|
|
|
|
* BMesh is a full-on brep, used for editmode, some modifiers, etc. It's much
|
|
|
|
* more capable (if memory-intensive) then CDDM.
|
|
|
|
*
|
|
|
|
* DerivedMesh is somewhat hackish. Many places assumes that a DerivedMesh is
|
|
|
|
* a CDDM (most of the time by simply copying it and converting it to one).
|
|
|
|
* CDDM is the original structure for modifiers, but has since been superseded
|
|
|
|
* by BMesh, at least for the foreseeable future.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2012-03-09 01:41:09 +01:00
|
|
|
* Note: This structure is read-only, for all practical purposes.
|
2009-07-17 03:57:12 +02:00
|
|
|
* At some point in the future, we may want to consider
|
|
|
|
* creating a replacement structure that implements a proper
|
|
|
|
* abstract mesh kernel interface. Or, we can leave this
|
|
|
|
* as it is and stick with using BMesh and CDDM.
|
|
|
|
*/
|
|
|
|
|
2006-11-11 17:38:37 +01:00
|
|
|
#include "DNA_customdata_types.h"
|
(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
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
2013-09-01 17:01:15 +02:00
|
|
|
#include "BLI_compiler_attrs.h"
|
|
|
|
|
2006-12-05 18:42:03 +01:00
|
|
|
#include "BKE_customdata.h"
|
2009-05-23 05:24:15 +02:00
|
|
|
#include "BKE_bvhutils.h"
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-05-10 22:33:09 +02:00
|
|
|
struct CCGElem;
|
|
|
|
struct CCGKey;
|
2005-07-17 19:41:03 +02:00
|
|
|
struct MVert;
|
2006-08-28 03:12:36 +02:00
|
|
|
struct MEdge;
|
|
|
|
struct MFace;
|
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
|
|
|
struct MTFace;
|
2005-03-27 22:34:18 +02:00
|
|
|
struct Object;
|
2009-01-04 15:14:06 +01:00
|
|
|
struct Scene;
|
2006-08-28 03:12:36 +02:00
|
|
|
struct Mesh;
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
struct MLoopNorSpaceArray;
|
2009-05-18 10:46:04 +02:00
|
|
|
struct BMEditMesh;
|
2009-11-22 14:44:09 +01:00
|
|
|
struct KeyBlock;
|
2005-07-26 02:45:19 +02:00
|
|
|
struct ModifierData;
|
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
|
|
|
struct MCol;
|
2007-10-31 14:56:07 +01:00
|
|
|
struct ColorBand;
|
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
|
|
|
struct GPUVertexAttribs;
|
2009-10-23 01:22:05 +02:00
|
|
|
struct GPUDrawObject;
|
2009-05-18 10:46:04 +02:00
|
|
|
struct BMEditMesh;
|
2009-10-28 07:06:05 +01:00
|
|
|
struct PBVH;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
/* number of sub-elements each mesh element has (for interpolation) */
|
|
|
|
#define SUB_ELEMS_VERT 0
|
|
|
|
#define SUB_ELEMS_EDGE 2
|
2009-06-16 22:08:40 +02:00
|
|
|
#define SUB_ELEMS_FACE 50
|
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
|
|
|
/*
|
2012-03-18 08:38:51 +01:00
|
|
|
* Note: all mface interfaces now officially operate on tessellated data.
|
2012-03-03 21:19:11 +01:00
|
|
|
* Also, the mface origindex layer indexes mpolys, not mfaces.
|
|
|
|
*/
|
(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
|
|
|
|
2012-12-15 17:13:27 +01:00
|
|
|
typedef struct DMCoNo {
|
|
|
|
float co[3];
|
|
|
|
float no[3];
|
|
|
|
} DMCoNo;
|
|
|
|
|
2012-03-06 03:40:08 +01:00
|
|
|
/* keep in sync with MFace/MPoly types */
|
|
|
|
typedef struct DMFlagMat {
|
|
|
|
short mat_nr;
|
|
|
|
char flag;
|
|
|
|
} DMFlagMat;
|
|
|
|
|
2010-01-06 13:05:46 +01:00
|
|
|
typedef enum DerivedMeshType {
|
|
|
|
DM_TYPE_CDDM,
|
2010-01-13 08:26:11 +01:00
|
|
|
DM_TYPE_EDITBMESH,
|
2010-01-06 13:05:46 +01:00
|
|
|
DM_TYPE_CCGDM
|
|
|
|
} DerivedMeshType;
|
|
|
|
|
2012-03-08 07:47:05 +01:00
|
|
|
typedef enum DMDrawOption {
|
|
|
|
/* the element is hidden or otherwise non-drawable */
|
|
|
|
DM_DRAW_OPTION_SKIP = 0,
|
|
|
|
/* normal drawing */
|
|
|
|
DM_DRAW_OPTION_NORMAL = 1,
|
|
|
|
/* draw, but don't set the color from mcol */
|
|
|
|
DM_DRAW_OPTION_NO_MCOL = 2,
|
|
|
|
/* used in drawMappedFaces, use GL stipple for the face */
|
|
|
|
DM_DRAW_OPTION_STIPPLE = 3,
|
|
|
|
} DMDrawOption;
|
|
|
|
|
2012-03-07 05:41:14 +01:00
|
|
|
/* Drawing callback types */
|
|
|
|
typedef int (*DMSetMaterial)(int mat_nr, void *attribs);
|
|
|
|
typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_index);
|
|
|
|
typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
|
2012-03-08 07:47:05 +01:00
|
|
|
typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
|
2014-11-27 20:12:46 +01:00
|
|
|
typedef DMDrawOption (*DMSetDrawOptionsMappedTex)(void *userData, int origindex, int mat_nr);
|
2014-02-03 08:55:59 +01:00
|
|
|
typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTFace *tface, const bool has_vcol, int matnr);
|
2012-03-07 13:48:52 +01:00
|
|
|
|
|
|
|
typedef enum DMDrawFlag {
|
2014-07-21 12:02:05 +02:00
|
|
|
DM_DRAW_USE_COLORS = (1 << 0),
|
|
|
|
DM_DRAW_ALWAYS_SMOOTH = (1 << 1),
|
|
|
|
DM_DRAW_USE_ACTIVE_UV = (1 << 2),
|
|
|
|
DM_DRAW_USE_TEXPAINT_UV = (1 << 3),
|
2012-03-07 13:48:52 +01:00
|
|
|
} DMDrawFlag;
|
2012-03-07 05:41:14 +01:00
|
|
|
|
2013-07-23 00:59:47 +02:00
|
|
|
typedef enum DMForeachFlag {
|
|
|
|
DM_FOREACH_NOP = 0,
|
2014-04-23 15:18:11 +02:00
|
|
|
DM_FOREACH_USE_NORMAL = (1 << 0), /* foreachMappedVert, foreachMappedLoop, foreachMappedFaceCenter */
|
2013-07-23 00:59:47 +02:00
|
|
|
} DMForeachFlag;
|
|
|
|
|
Fix [#30234] Various problems with CD layers and tesselation, related to modifiers stack.
Should also fix [#30266], [#29451], and partly [#30316].
Here are the changes made by this commit:
* It adds a "dirty" flag to DerivedMesh struct (for now, only DM_DIRTY_TESS_CDLAYERS, but more might be added as needed).
* It adds a new func, DM_update_tessface_data, which assumes tessfaces themselves are valid, but updates tessellated customdata from their poly/loop counter parts.
* At end of modstack, when valid tessellated faces are present in finaldm , but the cdlayers dirty flag is set, call that function (instead of recomputing the whole tessellation).
* Edits to the codes concerned (UVProject, DynamicPaint, and Subsurf modifiers).
* Also add to subsurf dm generation code the creation of a CD_POLYINDEX layer (mandatory for DM_update_tessface_data to work well, and imho all tessellated dm should have one).
Note: some pieces of old code are just #if 0’ed, will clean them later.
2012-03-18 23:06:57 +01:00
|
|
|
typedef enum DMDirtyFlag {
|
|
|
|
/* dm has valid tessellated faces, but tessellated CDDATA need to be updated. */
|
|
|
|
DM_DIRTY_TESS_CDLAYERS = 1 << 0,
|
2012-10-29 17:26:18 +01:00
|
|
|
/* One of the MCOL layers have been updated, force updating of GPUDrawObject's colors buffer.
|
|
|
|
* This is necessary with modern, VBO draw code, as e.g. in vpaint mode me->mcol may be updated
|
|
|
|
* without actually rebuilding dm (hence by defautl keeping same GPUDrawObject, and same colors
|
|
|
|
* buffer, which prevents update during a stroke!). */
|
|
|
|
DM_DIRTY_MCOL_UPDATE_DRAW = 1 << 1,
|
2013-05-30 19:36:43 +02:00
|
|
|
|
|
|
|
/* check this with modifier dependsOnNormals callback to see if normals need recalculation */
|
|
|
|
DM_DIRTY_NORMALS = 1 << 2,
|
|
|
|
} DMDirtyFlag;
|
Fix [#30234] Various problems with CD layers and tesselation, related to modifiers stack.
Should also fix [#30266], [#29451], and partly [#30316].
Here are the changes made by this commit:
* It adds a "dirty" flag to DerivedMesh struct (for now, only DM_DIRTY_TESS_CDLAYERS, but more might be added as needed).
* It adds a new func, DM_update_tessface_data, which assumes tessfaces themselves are valid, but updates tessellated customdata from their poly/loop counter parts.
* At end of modstack, when valid tessellated faces are present in finaldm , but the cdlayers dirty flag is set, call that function (instead of recomputing the whole tessellation).
* Edits to the codes concerned (UVProject, DynamicPaint, and Subsurf modifiers).
* Also add to subsurf dm generation code the creation of a CD_POLYINDEX layer (mandatory for DM_update_tessface_data to work well, and imho all tessellated dm should have one).
Note: some pieces of old code are just #if 0’ed, will clean them later.
2012-03-18 23:06:57 +01:00
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
typedef struct DerivedMesh DerivedMesh;
|
|
|
|
struct DerivedMesh {
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Private DerivedMesh data, only for internal DerivedMesh use */
|
(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 vertData, edgeData, faceData, loopData, polyData;
|
2011-11-30 19:03:56 +01:00
|
|
|
int numVertData, numEdgeData, numTessFaceData, numLoopData, 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
|
|
|
int needsFree; /* checked on ->release, is set to 0 for cached results */
|
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
|
|
|
int deformedOnly; /* set by modifier stack if only deformed from original */
|
2009-05-23 05:24:15 +02:00
|
|
|
BVHCache bvhCache;
|
2009-10-23 01:22:05 +02:00
|
|
|
struct GPUDrawObject *drawObject;
|
2010-01-06 13:05:46 +01:00
|
|
|
DerivedMeshType type;
|
2011-12-10 00:26:06 +01:00
|
|
|
float auto_bump_scale;
|
Fix [#30234] Various problems with CD layers and tesselation, related to modifiers stack.
Should also fix [#30266], [#29451], and partly [#30316].
Here are the changes made by this commit:
* It adds a "dirty" flag to DerivedMesh struct (for now, only DM_DIRTY_TESS_CDLAYERS, but more might be added as needed).
* It adds a new func, DM_update_tessface_data, which assumes tessfaces themselves are valid, but updates tessellated customdata from their poly/loop counter parts.
* At end of modstack, when valid tessellated faces are present in finaldm , but the cdlayers dirty flag is set, call that function (instead of recomputing the whole tessellation).
* Edits to the codes concerned (UVProject, DynamicPaint, and Subsurf modifiers).
* Also add to subsurf dm generation code the creation of a CD_POLYINDEX layer (mandatory for DM_update_tessface_data to work well, and imho all tessellated dm should have one).
Note: some pieces of old code are just #if 0’ed, will clean them later.
2012-03-18 23:06:57 +01:00
|
|
|
DMDirtyFlag dirty;
|
2014-04-09 03:03:25 +02:00
|
|
|
int totmat; /* total materials. Will be valid only before object drawing. */
|
|
|
|
struct Material **mat; /* material array. Will be valid only before object drawing */
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2013-01-10 05:43:31 +01:00
|
|
|
/* use for converting to BMesh which doesn't store bevel weight and edge crease by default */
|
|
|
|
char cd_flag;
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Calculate vert and face normals */
|
2011-11-13 16:13:59 +01:00
|
|
|
void (*calcNormals)(DerivedMesh *dm);
|
|
|
|
|
2014-04-13 12:18:51 +02:00
|
|
|
/** Calculate loop (split) normals */
|
2015-01-19 14:11:40 +01:00
|
|
|
void (*calcLoopNormals)(DerivedMesh *dm, const bool use_split_normals, const float split_angle);
|
2014-04-13 12:18:51 +02:00
|
|
|
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
/** Calculate loop (split) normals, and returns split loop normal spacearr. */
|
|
|
|
void (*calcLoopNormalsSpaceArray)(DerivedMesh *dm, const bool use_split_normals, const float split_angle,
|
|
|
|
struct MLoopNorSpaceArray *r_lnors_spacearr);
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Recalculates mesh tessellation */
|
2012-03-02 17:05:54 +01:00
|
|
|
void (*recalcTessellation)(DerivedMesh *dm);
|
2005-03-27 23:27:12 +02:00
|
|
|
|
2011-11-13 16:13:59 +01:00
|
|
|
/* Misc. Queries */
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
/* Also called in Editmode */
|
2005-03-27 23:27:12 +02:00
|
|
|
int (*getNumVerts)(DerivedMesh *dm);
|
2006-08-28 03:12:36 +02:00
|
|
|
int (*getNumEdges)(DerivedMesh *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
|
|
|
int (*getNumTessFaces)(DerivedMesh *dm);
|
2011-11-30 19:03:56 +01:00
|
|
|
int (*getNumLoops)(DerivedMesh *dm);
|
2011-11-29 14:01:51 +01:00
|
|
|
int (*getNumPolys)(DerivedMesh *dm);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Copy a single vert/edge/tessellated face from the derived mesh into
|
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
|
|
|
* *{vert/edge/face}_r. note that the current implementation
|
|
|
|
* of this function can be quite slow, iterating over all
|
2009-01-04 19:16:34 +01:00
|
|
|
* elements (editmesh)
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
2014-03-15 17:24:05 +01:00
|
|
|
void (*getVert)(DerivedMesh *dm, int index, struct MVert *r_vert);
|
|
|
|
void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *r_edge);
|
|
|
|
void (*getTessFace)(DerivedMesh *dm, int index, struct MFace *r_face);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Return a pointer to the entire array of verts/edges/face from the
|
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
|
|
|
* derived mesh. if such an array does not exist yet, it will be created,
|
|
|
|
* and freed on the next ->release(). consider using getVert/Edge/Face if
|
|
|
|
* you are only interested in a few verts/edges/faces.
|
|
|
|
*/
|
2012-05-12 22:39:39 +02:00
|
|
|
struct MVert *(*getVertArray)(DerivedMesh * dm);
|
|
|
|
struct MEdge *(*getEdgeArray)(DerivedMesh * dm);
|
|
|
|
struct MFace *(*getTessFaceArray)(DerivedMesh * dm);
|
|
|
|
struct MLoop *(*getLoopArray)(DerivedMesh * dm);
|
|
|
|
struct MPoly *(*getPolyArray)(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
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Copy all verts/edges/faces from the derived mesh into
|
2006-08-28 03:12:36 +02:00
|
|
|
* *{vert/edge/face}_r (must point to a buffer large enough)
|
|
|
|
*/
|
2014-03-15 17:24:05 +01:00
|
|
|
void (*copyVertArray)(DerivedMesh *dm, struct MVert *r_vert);
|
|
|
|
void (*copyEdgeArray)(DerivedMesh *dm, struct MEdge *r_edge);
|
|
|
|
void (*copyTessFaceArray)(DerivedMesh *dm, struct MFace *r_face);
|
|
|
|
void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *r_loop);
|
|
|
|
void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *r_poly);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Return a copy of all verts/edges/faces from the derived mesh
|
2006-08-28 03:12:36 +02:00
|
|
|
* it is the caller's responsibility to free the returned pointer
|
|
|
|
*/
|
2012-05-12 22:39:39 +02:00
|
|
|
struct MVert *(*dupVertArray)(DerivedMesh * dm);
|
|
|
|
struct MEdge *(*dupEdgeArray)(DerivedMesh * dm);
|
|
|
|
struct MFace *(*dupTessFaceArray)(DerivedMesh * dm);
|
|
|
|
struct MLoop *(*dupLoopArray)(DerivedMesh * dm);
|
|
|
|
struct MPoly *(*dupPolyArray)(DerivedMesh * dm);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Return a pointer to a single element of vert/edge/face custom data
|
2006-08-28 03:12:36 +02:00
|
|
|
* from the derived mesh (this gives a pointer to the actual data, not
|
|
|
|
* a copy)
|
|
|
|
*/
|
2013-03-29 07:25:22 +01:00
|
|
|
void *(*getVertData)(DerivedMesh *dm, int index, int type);
|
|
|
|
void *(*getEdgeData)(DerivedMesh *dm, int index, int type);
|
|
|
|
void *(*getTessFaceData)(DerivedMesh *dm, int index, int type);
|
|
|
|
void *(*getPolyData)(DerivedMesh *dm, int index, int type);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Return a pointer to the entire array of vert/edge/face custom data
|
2006-08-28 03:12:36 +02:00
|
|
|
* from the derived mesh (this gives a pointer to the actual data, not
|
|
|
|
* a copy)
|
|
|
|
*/
|
2013-03-29 07:25:22 +01:00
|
|
|
void *(*getVertDataArray)(DerivedMesh *dm, int type);
|
|
|
|
void *(*getEdgeDataArray)(DerivedMesh *dm, int type);
|
|
|
|
void *(*getTessFaceDataArray)(DerivedMesh *dm, int type);
|
2013-04-03 22:10:08 +02:00
|
|
|
void *(*getLoopDataArray)(DerivedMesh *dm, int type);
|
2013-03-29 07:25:22 +01:00
|
|
|
void *(*getPolyDataArray)(DerivedMesh *dm, int type);
|
2012-10-30 20:20:17 +01:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Retrieves the base CustomData structures for
|
2012-03-03 21:19:11 +01:00
|
|
|
* verts/edges/tessfaces/loops/facdes*/
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomData *(*getVertDataLayout)(DerivedMesh * dm);
|
|
|
|
CustomData *(*getEdgeDataLayout)(DerivedMesh * dm);
|
|
|
|
CustomData *(*getTessFaceDataLayout)(DerivedMesh * dm);
|
|
|
|
CustomData *(*getLoopDataLayout)(DerivedMesh * dm);
|
|
|
|
CustomData *(*getPolyDataLayout)(DerivedMesh * dm);
|
2009-06-23 07:35:49 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Copies all customdata for an element source into dst at index dest */
|
2009-06-23 07:35:49 +02:00
|
|
|
void (*copyFromVertCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
|
|
|
|
void (*copyFromEdgeCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
|
|
|
|
void (*copyFromFaceCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
|
2009-08-15 19:31:28 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Optional grid access for subsurf */
|
2009-11-25 14:11:44 +01:00
|
|
|
int (*getNumGrids)(DerivedMesh *dm);
|
|
|
|
int (*getGridSize)(DerivedMesh *dm);
|
2012-05-12 22:39:39 +02:00
|
|
|
struct CCGElem **(*getGridData)(DerivedMesh * dm);
|
|
|
|
int *(*getGridOffset)(DerivedMesh * dm);
|
2012-05-10 22:33:09 +02:00
|
|
|
void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key);
|
2012-05-12 22:39:39 +02:00
|
|
|
DMFlagMat *(*getGridFlagMats)(DerivedMesh * dm);
|
|
|
|
unsigned int **(*getGridHidden)(DerivedMesh * dm);
|
2012-03-06 03:40:08 +01:00
|
|
|
|
2009-11-25 14:11:44 +01:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Iterate over each mapped vertex in the derived mesh, calling the
|
2006-08-28 03:12:36 +02:00
|
|
|
* given function with the original vert and the mapped vert's new
|
|
|
|
* coordinate and normal. For historical reasons the normal can be
|
|
|
|
* passed as a float or short array, only one should be non-NULL.
|
|
|
|
*/
|
2012-04-09 09:06:06 +02:00
|
|
|
void (*foreachMappedVert)(DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int index, const float co[3],
|
|
|
|
const float no_f[3], const short no_s[3]),
|
2013-07-23 00:59:47 +02:00
|
|
|
void *userData,
|
|
|
|
DMForeachFlag flag);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Iterate over each mapped edge in the derived mesh, calling the
|
2006-08-28 03:12:36 +02:00
|
|
|
* given function with the original edge and the mapped edge's new
|
|
|
|
* coordinates.
|
|
|
|
*/
|
|
|
|
void (*foreachMappedEdge)(DerivedMesh *dm,
|
2012-04-09 09:06:06 +02:00
|
|
|
void (*func)(void *userData, int index,
|
|
|
|
const float v0co[3], const float v1co[3]),
|
|
|
|
void *userData);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2014-04-23 15:18:11 +02:00
|
|
|
/** Iterate over each mapped loop in the derived mesh, calling the given function
|
|
|
|
* with the original loop index and the mapped loops's new coordinate and normal.
|
|
|
|
*/
|
|
|
|
void (*foreachMappedLoop)(DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int vertex_index, int face_index,
|
|
|
|
const float co[3], const float no[3]),
|
|
|
|
void *userData,
|
|
|
|
DMForeachFlag flag);
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Iterate over each mapped face in the derived mesh, calling the
|
2006-08-28 03:12:36 +02:00
|
|
|
* given function with the original face and the mapped face's (or
|
|
|
|
* faces') center and normal.
|
|
|
|
*/
|
|
|
|
void (*foreachMappedFaceCenter)(DerivedMesh *dm,
|
2012-04-09 09:06:06 +02:00
|
|
|
void (*func)(void *userData, int index,
|
|
|
|
const float cent[3], const float no[3]),
|
2013-07-23 00:59:47 +02:00
|
|
|
void *userData,
|
|
|
|
DMForeachFlag flag);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Iterate over all vertex points, calling DO_MINMAX with given args.
|
2006-08-28 03:12:36 +02:00
|
|
|
*
|
|
|
|
* Also called in Editmode
|
|
|
|
*/
|
2014-03-15 17:24:05 +01:00
|
|
|
void (*getMinMax)(DerivedMesh *dm, float r_min[3], float r_max[3]);
|
2005-07-17 03:18:59 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Direct Access Operations
|
|
|
|
* - Can be undefined
|
|
|
|
* - Must be defined for modifiers that only deform however */
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Get vertex location, undefined if index is not valid */
|
2014-03-15 17:24:05 +01:00
|
|
|
void (*getVertCo)(DerivedMesh *dm, int index, float r_co[3]);
|
2005-07-17 03:18:59 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Fill the array (of length .getNumVerts()) with all vertex locations */
|
2014-03-15 17:24:05 +01:00
|
|
|
void (*getVertCos)(DerivedMesh *dm, float (*r_cos)[3]);
|
2005-07-18 21:58:23 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Get smooth vertex normal, undefined if index is not valid */
|
2014-03-15 17:24:05 +01:00
|
|
|
void (*getVertNo)(DerivedMesh *dm, int index, float r_no[3]);
|
|
|
|
void (*getPolyNo)(DerivedMesh *dm, int index, float r_no[3]);
|
2005-07-17 03:18:59 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Get a map of vertices to faces
|
2012-02-05 07:20:51 +01:00
|
|
|
*/
|
2012-03-17 05:41:36 +01:00
|
|
|
const struct MeshElemMap *(*getPolyMap)(struct Object *ob, DerivedMesh *dm);
|
2012-02-05 07:20:51 +01:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Get the BVH used for paint modes
|
2009-10-28 07:06:05 +01:00
|
|
|
*/
|
2009-11-25 14:11:44 +01:00
|
|
|
struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm);
|
2009-10-28 07:06:05 +01:00
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
/* Drawing Operations */
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw all vertices as bgl points (no options) */
|
2005-03-27 22:34:18 +02:00
|
|
|
void (*drawVerts)(DerivedMesh *dm);
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw edges in the UV mesh (if exists) */
|
2005-08-18 13:31:20 +02:00
|
|
|
void (*drawUVEdges)(DerivedMesh *dm);
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw all edges as lines (no options)
|
2006-08-28 03:12:36 +02:00
|
|
|
*
|
|
|
|
* Also called for *final* editmode DerivedMeshes
|
|
|
|
*/
|
2014-04-17 11:33:54 +02:00
|
|
|
void (*drawEdges)(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
|
2005-08-18 13:31:20 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw all loose edges (edges w/ no adjoining faces) */
|
2005-08-21 22:48:45 +02:00
|
|
|
void (*drawLooseEdges)(DerivedMesh *dm);
|
2005-08-18 13:31:20 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw all faces
|
2006-08-28 03:12:36 +02:00
|
|
|
* o Set face normal or vertex normal based on inherited face flag
|
|
|
|
* o Use inherited face material index to call setMaterial
|
|
|
|
* o Only if setMaterial returns true
|
|
|
|
*
|
|
|
|
* Also called for *final* editmode DerivedMeshes
|
|
|
|
*/
|
2009-10-28 07:06:05 +01:00
|
|
|
void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
|
2014-04-17 11:33:54 +02:00
|
|
|
bool fast, DMSetMaterial setMaterial);
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw all faces using MTFace
|
|
|
|
* - Drawing options too complicated to enumerate, look at code.
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
|
|
|
void (*drawFacesTex)(DerivedMesh *dm,
|
2012-03-07 05:41:14 +01:00
|
|
|
DMSetDrawOptionsTex setDrawOptions,
|
2012-05-12 22:39:39 +02:00
|
|
|
DMCompareDrawOptions compareDrawOptions,
|
2014-07-21 12:02:05 +02:00
|
|
|
void *userData, DMDrawFlag uvflag);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw all faces with GLSL materials
|
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
|
|
|
* o setMaterial is called for every different material nr
|
|
|
|
* o Only if setMaterial returns true
|
|
|
|
*/
|
2012-03-07 05:41:14 +01:00
|
|
|
void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial);
|
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
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw mapped faces (no color, or texture)
|
|
|
|
* - Only if !setDrawOptions or
|
2014-03-15 17:24:05 +01:00
|
|
|
* setDrawOptions(userData, mapped-face-index, r_drawSmooth)
|
2012-06-27 19:48:39 +02:00
|
|
|
* returns true
|
2006-08-28 03:12:36 +02:00
|
|
|
*
|
|
|
|
* If drawSmooth is set to true then vertex normals should be set and
|
|
|
|
* glShadeModel called with GL_SMOOTH. Otherwise the face normal should
|
|
|
|
* be set and glShadeModel called with GL_FLAT.
|
|
|
|
*
|
|
|
|
* The setDrawOptions is allowed to not set drawSmooth (for example, when
|
|
|
|
* lighting is disabled), in which case the implementation should draw as
|
|
|
|
* smooth shaded.
|
|
|
|
*/
|
|
|
|
void (*drawMappedFaces)(DerivedMesh *dm,
|
2012-05-12 22:39:39 +02:00
|
|
|
DMSetDrawOptions setDrawOptions,
|
|
|
|
DMSetMaterial setMaterial,
|
|
|
|
DMCompareDrawOptions compareDrawOptions,
|
|
|
|
void *userData,
|
|
|
|
DMDrawFlag flag);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw mapped faces using MTFace
|
|
|
|
* - Drawing options too complicated to enumerate, look at code.
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
|
|
|
void (*drawMappedFacesTex)(DerivedMesh *dm,
|
2014-11-27 19:12:48 +01:00
|
|
|
DMSetDrawOptionsMappedTex setDrawOptions,
|
2012-05-12 22:39:39 +02:00
|
|
|
DMCompareDrawOptions compareDrawOptions,
|
2014-07-21 12:02:05 +02:00
|
|
|
void *userData, DMDrawFlag uvflag);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw mapped faces with GLSL materials
|
|
|
|
* - setMaterial is called for every different material nr
|
|
|
|
* - setDrawOptions is called for every face
|
|
|
|
* - Only if setMaterial and setDrawOptions return true
|
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
|
|
|
*/
|
|
|
|
void (*drawMappedFacesGLSL)(DerivedMesh *dm,
|
2012-05-12 22:39:39 +02:00
|
|
|
DMSetMaterial setMaterial,
|
|
|
|
DMSetDrawOptions setDrawOptions,
|
|
|
|
void *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
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw mapped edges as lines
|
|
|
|
* - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge)
|
|
|
|
* returns true
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
|
|
|
void (*drawMappedEdges)(DerivedMesh *dm,
|
2012-05-12 22:39:39 +02:00
|
|
|
DMSetDrawOptions setDrawOptions,
|
|
|
|
void *userData);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw mapped edges as lines with interpolation values
|
|
|
|
* - Only if !setDrawOptions or
|
|
|
|
* setDrawOptions(userData, mapped-edge, mapped-v0, mapped-v1, t)
|
|
|
|
* returns true
|
2006-08-28 03:12:36 +02:00
|
|
|
*
|
|
|
|
* NOTE: This routine is optional!
|
|
|
|
*/
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 05:08:23 +02:00
|
|
|
void (*drawMappedEdgesInterp)(DerivedMesh *dm,
|
2012-05-12 22:39:39 +02:00
|
|
|
DMSetDrawOptions setDrawOptions,
|
|
|
|
DMSetDrawInterpOptions setDrawInterpOptions,
|
|
|
|
void *userData);
|
2005-03-28 08:46:21 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Draw all faces with materials
|
|
|
|
* - setMaterial is called for every different material nr
|
|
|
|
* - setFace is called to verify if a face must be hidden
|
2011-11-08 14:07:16 +01:00
|
|
|
*/
|
|
|
|
void (*drawMappedFacesMat)(DerivedMesh *dm,
|
2014-04-17 11:33:54 +02:00
|
|
|
void (*setMaterial)(void *userData, int matnr, void *attribs),
|
2013-07-19 12:40:52 +02:00
|
|
|
bool (*setFace)(void *userData, int index), void *userData);
|
2011-11-08 14:07:16 +01:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Release reference to the DerivedMesh. This function decides internally
|
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 the DerivedMesh will be freed, or cached for later use. */
|
2005-03-27 22:34:18 +02:00
|
|
|
void (*release)(DerivedMesh *dm);
|
|
|
|
};
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** utility function to initialize a DerivedMesh's function pointers to
|
2006-08-28 03:12:36 +02:00
|
|
|
* the default implementation (for those functions which have a default)
|
|
|
|
*/
|
|
|
|
void DM_init_funcs(DerivedMesh *dm);
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** utility function to initialize a DerivedMesh for the desired number
|
2006-08-28 03:12:36 +02:00
|
|
|
* of vertices, edges and faces (doesn't allocate memory for them, just
|
|
|
|
* sets up the custom data layers)
|
|
|
|
*/
|
2010-01-13 08:26:11 +01:00
|
|
|
void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
|
2011-11-15 03:05:32 +01:00
|
|
|
int numFaces, int numLoops, int numPolys);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** utility function to initialize a DerivedMesh for the desired number
|
2006-08-28 03:12:36 +02:00
|
|
|
* of vertices, edges and faces, with a layer setup copied from source
|
|
|
|
*/
|
|
|
|
void DM_from_template(DerivedMesh *dm, DerivedMesh *source,
|
2012-05-12 22:39:39 +02:00
|
|
|
DerivedMeshType type,
|
|
|
|
int numVerts, int numEdges, int numFaces,
|
|
|
|
int numLoops, int numPolys);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** utility function to release a DerivedMesh's layers
|
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
|
|
|
* returns 1 if DerivedMesh has to be released by the backend, 0 otherwise
|
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
|
|
|
int DM_release(DerivedMesh *dm);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** utility function to convert a DerivedMesh to a Mesh
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
2015-02-18 20:00:23 +01:00
|
|
|
void DM_to_mesh(DerivedMesh *dm, struct Mesh *me, struct Object *ob, CustomDataMask mask, bool take_ownership);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-03-11 20:58:56 +01:00
|
|
|
struct BMEditMesh *DM_to_editbmesh(struct DerivedMesh *dm,
|
2013-06-03 01:20:49 +02:00
|
|
|
struct BMEditMesh *existing, const bool do_tessellate);
|
2012-02-12 18:44:10 +01:00
|
|
|
|
|
|
|
/* conversion to bmesh only */
|
2013-06-03 01:20:49 +02:00
|
|
|
void DM_to_bmesh_ex(struct DerivedMesh *dm, struct BMesh *bm, const bool calc_face_normal);
|
|
|
|
struct BMesh *DM_to_bmesh(struct DerivedMesh *dm, const bool calc_face_normal);
|
2012-02-12 18:44:10 +01:00
|
|
|
|
2012-02-12 16:02:33 +01:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Utility function to convert a DerivedMesh to a shape key block */
|
2009-11-22 14:44:09 +01:00
|
|
|
void DM_to_meshkey(DerivedMesh *dm, struct Mesh *me, struct KeyBlock *kb);
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
|
2006-12-05 18:42:03 +01:00
|
|
|
* zero for the layer type, so only layer types specified by the mask
|
|
|
|
* will be copied
|
|
|
|
*/
|
|
|
|
void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask);
|
|
|
|
|
2006-08-28 03:12:36 +02:00
|
|
|
/* adds a vertex/edge/face custom data layer to a DerivedMesh, optionally
|
|
|
|
* backed by an external data array
|
2006-12-12 22:29:09 +01:00
|
|
|
* alloctype defines how the layer is allocated or copied, and how it is
|
|
|
|
* freed, see BKE_customdata.h for the different options
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
2006-12-12 22:29:09 +01:00
|
|
|
void DM_add_vert_layer(struct DerivedMesh *dm, int type, int alloctype,
|
2011-11-16 18:09:41 +01:00
|
|
|
void *layer);
|
2006-12-12 22:29:09 +01:00
|
|
|
void DM_add_edge_layer(struct DerivedMesh *dm, int type, int alloctype,
|
2011-11-16 18:09:41 +01:00
|
|
|
void *layer);
|
2009-08-15 19:31:28 +02:00
|
|
|
void DM_add_tessface_layer(struct DerivedMesh *dm, int type, int alloctype,
|
2011-11-16 18:09:41 +01:00
|
|
|
void *layer);
|
|
|
|
void DM_add_loop_layer(DerivedMesh *dm, int type, int alloctype,
|
2009-08-15 19:31:28 +02:00
|
|
|
void *layer);
|
2011-11-29 06:09:54 +01:00
|
|
|
void DM_add_poly_layer(struct DerivedMesh *dm, int type, int alloctype,
|
2011-11-16 18:09:41 +01:00
|
|
|
void *layer);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
/* custom data access functions
|
|
|
|
* return pointer to data from first layer which matches type
|
|
|
|
* if they return NULL for valid indices, data doesn't exist
|
|
|
|
* note these return pointers - any change modifies the internals of the mesh
|
|
|
|
*/
|
|
|
|
void *DM_get_vert_data(struct DerivedMesh *dm, int index, int type);
|
|
|
|
void *DM_get_edge_data(struct DerivedMesh *dm, int index, int type);
|
2011-11-29 06:09:54 +01:00
|
|
|
void *DM_get_tessface_data(struct DerivedMesh *dm, int index, int type);
|
2012-10-30 20:20:17 +01:00
|
|
|
void *DM_get_poly_data(struct DerivedMesh *dm, int index, int type);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
/* custom data layer access functions
|
|
|
|
* return pointer to first data layer which matches type (a flat array)
|
|
|
|
* if they return NULL, data doesn't exist
|
|
|
|
* note these return pointers - any change modifies the internals of the mesh
|
|
|
|
*/
|
|
|
|
void *DM_get_vert_data_layer(struct DerivedMesh *dm, int type);
|
|
|
|
void *DM_get_edge_data_layer(struct DerivedMesh *dm, int type);
|
2009-08-15 19:31:28 +02:00
|
|
|
void *DM_get_tessface_data_layer(struct DerivedMesh *dm, int type);
|
2011-11-29 06:09:54 +01:00
|
|
|
void *DM_get_poly_data_layer(struct DerivedMesh *dm, int type);
|
2012-02-05 12:30:26 +01:00
|
|
|
void *DM_get_loop_data_layer(struct DerivedMesh *dm, int type);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
/* custom data setting functions
|
|
|
|
* copy supplied data into first layer of type using layer's copy function
|
|
|
|
* (deep copy if appropriate)
|
|
|
|
*/
|
|
|
|
void DM_set_vert_data(struct DerivedMesh *dm, int index, int type, void *data);
|
|
|
|
void DM_set_edge_data(struct DerivedMesh *dm, int index, int type, void *data);
|
2011-11-29 06:09:54 +01:00
|
|
|
void DM_set_tessface_data(struct DerivedMesh *dm, int index, int type, void *data);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
/* custom data copy functions
|
|
|
|
* copy count elements from source_index in source to dest_index in dest
|
2006-12-05 18:42:03 +01:00
|
|
|
* these copy all layers for which the CD_FLAG_NOCOPY flag is not set
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
|
|
|
void DM_copy_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
2012-05-12 22:39:39 +02:00
|
|
|
int source_index, int dest_index, int count);
|
2006-08-28 03:12:36 +02:00
|
|
|
void DM_copy_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
(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 source_index, int dest_index, int count);
|
2012-05-12 22:39:39 +02:00
|
|
|
void DM_copy_tessface_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
|
|
|
int source_index, int dest_index, int count);
|
(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 DM_copy_loop_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
|
|
|
int source_index, int dest_index, int count);
|
2011-11-29 06:09:54 +01:00
|
|
|
void DM_copy_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
2012-05-12 22:39:39 +02:00
|
|
|
int source_index, int dest_index, int count);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
|
|
|
/* custom data free functions
|
|
|
|
* free count elements, starting at index
|
2006-12-12 22:29:09 +01:00
|
|
|
* they free all layers for which the CD_FLAG_NOCOPY flag is not set
|
2006-08-28 03:12:36 +02:00
|
|
|
*/
|
|
|
|
void DM_free_vert_data(struct DerivedMesh *dm, int index, int count);
|
|
|
|
void DM_free_edge_data(struct DerivedMesh *dm, int index, int count);
|
(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 DM_free_tessface_data(struct DerivedMesh *dm, int index, int count);
|
|
|
|
void DM_free_loop_data(struct DerivedMesh *dm, int index, int count);
|
2011-11-29 06:09:54 +01:00
|
|
|
void DM_free_poly_data(struct DerivedMesh *dm, int index, int count);
|
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
|
|
|
/*sets up mpolys for a DM based on face iterators in source*/
|
|
|
|
void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
|
|
|
|
|
2013-05-30 19:36:43 +02:00
|
|
|
void DM_ensure_normals(DerivedMesh *dm);
|
2012-01-05 13:40:09 +01:00
|
|
|
void DM_ensure_tessface(DerivedMesh *dm);
|
|
|
|
|
Fix [#30234] Various problems with CD layers and tesselation, related to modifiers stack.
Should also fix [#30266], [#29451], and partly [#30316].
Here are the changes made by this commit:
* It adds a "dirty" flag to DerivedMesh struct (for now, only DM_DIRTY_TESS_CDLAYERS, but more might be added as needed).
* It adds a new func, DM_update_tessface_data, which assumes tessfaces themselves are valid, but updates tessellated customdata from their poly/loop counter parts.
* At end of modstack, when valid tessellated faces are present in finaldm , but the cdlayers dirty flag is set, call that function (instead of recomputing the whole tessellation).
* Edits to the codes concerned (UVProject, DynamicPaint, and Subsurf modifiers).
* Also add to subsurf dm generation code the creation of a CD_POLYINDEX layer (mandatory for DM_update_tessface_data to work well, and imho all tessellated dm should have one).
Note: some pieces of old code are just #if 0’ed, will clean them later.
2012-03-18 23:06:57 +01:00
|
|
|
void DM_update_tessface_data(DerivedMesh *dm);
|
|
|
|
|
2014-04-09 03:03:25 +02:00
|
|
|
void DM_update_materials(DerivedMesh *dm, struct Object *ob);
|
2014-07-21 12:02:05 +02:00
|
|
|
struct MTFace *DM_paint_uvlayer_active_get(DerivedMesh *dm, int mat_nr);
|
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** interpolates vertex data from the vertices indexed by src_indices in the
|
2006-08-28 03:12:36 +02:00
|
|
|
* source mesh using the given weights and stores the result in the vertex
|
|
|
|
* indexed by dest_index in the dest mesh
|
|
|
|
*/
|
|
|
|
void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
2012-05-12 22:39:39 +02:00
|
|
|
int *src_indices, float *weights,
|
|
|
|
int count, int dest_index);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** interpolates edge data from the edges indexed by src_indices in the
|
2006-08-28 03:12:36 +02:00
|
|
|
* source mesh using the given weights and stores the result in the edge indexed
|
|
|
|
* by dest_index in the dest mesh.
|
|
|
|
* if weights is NULL, all weights default to 1.
|
|
|
|
* if vert_weights is non-NULL, any per-vertex edge data is interpolated using
|
|
|
|
* vert_weights[i] multiplied by weights[i].
|
|
|
|
*/
|
|
|
|
typedef float EdgeVertWeight[SUB_ELEMS_EDGE][SUB_ELEMS_EDGE];
|
|
|
|
void DM_interp_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
2012-05-12 22:39:39 +02:00
|
|
|
int *src_indices,
|
|
|
|
float *weights, EdgeVertWeight *vert_weights,
|
|
|
|
int count, int dest_index);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** interpolates face data from the faces indexed by src_indices in the
|
2006-08-28 03:12:36 +02:00
|
|
|
* source mesh using the given weights and stores the result in the face indexed
|
|
|
|
* by dest_index in the dest mesh.
|
|
|
|
* if weights is NULL, all weights default to 1.
|
|
|
|
* if vert_weights is non-NULL, any per-vertex face data is interpolated using
|
|
|
|
* vert_weights[i] multiplied by weights[i].
|
|
|
|
*/
|
|
|
|
typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE];
|
(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 DM_interp_tessface_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
2012-05-12 22:39:39 +02:00
|
|
|
int *src_indices,
|
|
|
|
float *weights, FaceVertWeight *vert_weights,
|
|
|
|
int count, int dest_index);
|
2006-08-28 03:12:36 +02:00
|
|
|
|
2010-07-19 06:44:37 +02:00
|
|
|
void DM_swap_tessface_data(struct DerivedMesh *dm, int index, const int *corner_indices);
|
(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 DM_interp_loop_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
|
|
|
int *src_indices,
|
|
|
|
float *weights, int count, int dest_index);
|
|
|
|
|
2011-11-29 06:09:54 +01:00
|
|
|
void DM_interp_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
(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 *src_indices,
|
|
|
|
float *weights, int count, int dest_index);
|
2005-11-12 11:35:14 +01:00
|
|
|
|
2007-10-31 14:56:07 +01:00
|
|
|
/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
|
2013-03-06 03:57:31 +01:00
|
|
|
void vDM_ColorBand_store(const struct ColorBand *coba, const char alert_color[4]);
|
2007-10-31 14:56:07 +01:00
|
|
|
|
2013-06-26 20:40:55 +02:00
|
|
|
/* UNUSED */
|
|
|
|
#if 0
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Simple function to get me->totvert amount of vertices/normals,
|
2012-03-03 21:19:11 +01:00
|
|
|
* correctly deformed and subsurfered. Needed especially when vertexgroups are involved.
|
2012-03-09 01:41:09 +01:00
|
|
|
* In use now by vertex/weight paint and particles */
|
2012-12-15 17:13:27 +01:00
|
|
|
DMCoNo *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
|
2013-06-26 20:40:55 +02:00
|
|
|
#endif
|
2014-09-04 09:53:10 +02:00
|
|
|
void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int totcos);
|
2005-03-29 18:43:39 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
/* */
|
2009-01-04 15:14:06 +01:00
|
|
|
DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask);
|
2009-01-04 15:14:06 +01:00
|
|
|
DerivedMesh *mesh_get_derived_deform(struct Scene *scene, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask);
|
2005-03-29 18:43:39 +02:00
|
|
|
|
2011-04-15 07:20:18 +02:00
|
|
|
DerivedMesh *mesh_create_derived_for_modifier(struct Scene *scene, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
struct ModifierData *md, int build_shapekey_layers);
|
2005-07-26 02:45:19 +02:00
|
|
|
|
2009-01-04 15:14:06 +01:00
|
|
|
DerivedMesh *mesh_create_derived_render(struct Scene *scene, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask);
|
2008-07-28 13:01:34 +02:00
|
|
|
|
2009-05-18 10:46:04 +02:00
|
|
|
DerivedMesh *getEditDerivedBMesh(struct BMEditMesh *em, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
float (*vertexCos)[3]);
|
2009-05-16 18:18:08 +02:00
|
|
|
|
2009-01-04 15:14:06 +01:00
|
|
|
DerivedMesh *mesh_create_derived_index_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index);
|
2008-07-28 13:01:34 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
/* same as above but wont use render settings */
|
2013-12-25 22:26:41 +01:00
|
|
|
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
|
2009-01-04 15:14:06 +01:00
|
|
|
DerivedMesh *mesh_create_derived_view(struct Scene *scene, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask);
|
2009-01-04 15:14:06 +01:00
|
|
|
DerivedMesh *mesh_create_derived_no_deform(struct Scene *scene, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
float (*vertCos)[3],
|
|
|
|
CustomDataMask dataMask);
|
2009-01-04 15:14:06 +01:00
|
|
|
DerivedMesh *mesh_create_derived_no_deform_render(struct Scene *scene, struct Object *ob,
|
2012-05-12 22:39:39 +02:00
|
|
|
float (*vertCos)[3],
|
|
|
|
CustomDataMask dataMask);
|
2009-06-08 22:08:19 +02:00
|
|
|
/* for gameengine */
|
|
|
|
DerivedMesh *mesh_create_derived_no_virtual(struct Scene *scene, struct Object *ob, float (*vertCos)[3],
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask);
|
2011-01-23 18:17:21 +01:00
|
|
|
DerivedMesh *mesh_create_derived_physics(struct Scene *scene, struct Object *ob, float (*vertCos)[3],
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask);
|
2005-07-18 21:58:23 +02:00
|
|
|
|
2009-05-18 10:46:04 +02:00
|
|
|
DerivedMesh *editbmesh_get_derived_base(struct Object *, struct BMEditMesh *em);
|
2009-05-16 18:18:08 +02:00
|
|
|
DerivedMesh *editbmesh_get_derived_cage(struct Scene *scene, struct Object *,
|
2012-05-12 22:39:39 +02:00
|
|
|
struct BMEditMesh *em, CustomDataMask dataMask);
|
2009-05-16 18:18:08 +02:00
|
|
|
DerivedMesh *editbmesh_get_derived_cage_and_final(struct Scene *scene, struct Object *,
|
2014-03-15 17:24:05 +01:00
|
|
|
struct BMEditMesh *em, DerivedMesh **r_final,
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask);
|
2014-08-01 15:42:17 +02:00
|
|
|
|
|
|
|
DerivedMesh *object_get_derived_final(struct Object *ob, const bool for_render);
|
|
|
|
|
2014-03-15 17:24:05 +01:00
|
|
|
float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
|
2014-02-03 08:55:59 +01:00
|
|
|
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
|
2011-04-15 07:20:18 +02:00
|
|
|
void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
|
2012-05-12 22:39:39 +02:00
|
|
|
CustomDataMask dataMask, int build_shapekey_layers);
|
2005-03-28 07:58:43 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** returns an array of deform matrices for crazyspace correction, and the
|
2012-03-03 21:19:11 +01:00
|
|
|
* number of modifiers left */
|
2010-03-11 19:27:45 +01:00
|
|
|
int editbmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct BMEditMesh *em,
|
2012-05-12 22:39:39 +02:00
|
|
|
float (**deformmats)[3][3], float (**deformcos)[3]);
|
2007-07-28 23:04:30 +02:00
|
|
|
|
2011-11-26 04:13:54 +01:00
|
|
|
void weight_to_rgb(float r_rgb[3], const float weight);
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Update the weight MCOL preview layer.
|
Add weight preview to WeightVG modifiers, and first, simple/basic refactor of how modifiers can generate preview.
User side:
* Preview for DynamicPaint should keep the same behavior (for now). Weight preview should be somawhat quicker, though.
* Preview for WeightVG modifiers is only active in WeightPaint mode, and if the affected vgroup is the active one.
* Last active preview modifier in stack wins!
Note: that modifier preview topic is yet to be further refined, quite raw/incomplete for now.
Dev side:
* In draw code, renamed DRAW_DYNAMIC_PAINT_PREVIEW flag to DRAW_MODIFIERS_PREVIEW
* Removed use of MOD_DPAINT_PREVIEW_READY in DynamicPaint code (seems unecessary, and if it was, should be of more general scope).
* Added eModifierTypeFlag_UsesPreview to ModifierTypeFlag, for modifiers that can generate some preview data.
* Added three new modifier funcs, to handle preview modifiers in draw code / mod stack.
* For weights preview: added the generic DM_update_weight_mcol func, which can update WEIGHT_MCOL layer with either a given array of weights (currently used by DynamicPaint only), or from current active vgroup(s).
So now, draw code is fully generic (i.e. no more modifier-type checking in it). Mod stack code is generic to some extent, but will need more work.
2012-01-22 18:54:23 +01:00
|
|
|
* If weights are NULL, use object's active vgroup(s).
|
|
|
|
* Else, weights must be an array of weight float values.
|
|
|
|
* If indices is NULL, it must be of numVerts length.
|
|
|
|
* Else, it must be of num length, as indices, which contains vertices' idx to apply weights to.
|
|
|
|
* (other vertices are assumed zero weight).
|
|
|
|
*/
|
|
|
|
void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const draw_flag,
|
|
|
|
float *weights, int num, const int *indices);
|
2006-09-03 14:16:14 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** convert layers requested by a GLSL material to actually available layers in
|
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
|
|
|
* the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
|
|
|
|
typedef struct DMVertexAttribs {
|
|
|
|
struct {
|
|
|
|
struct MTFace *array;
|
2012-05-04 13:50:11 +02:00
|
|
|
int em_offset, gl_index, gl_texco;
|
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
|
|
|
} tface[MAX_MTFACE];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct MCol *array;
|
2012-05-04 13:50:11 +02:00
|
|
|
int em_offset, gl_index;
|
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
|
|
|
} mcol[MAX_MCOL];
|
|
|
|
|
|
|
|
struct {
|
2011-02-14 19:18:46 +01:00
|
|
|
float (*array)[4];
|
2012-05-04 13:50:11 +02:00
|
|
|
int em_offset, gl_index;
|
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
|
|
|
} tang;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
float (*array)[3];
|
2012-05-04 13:50:11 +02:00
|
|
|
int em_offset, gl_index, gl_texco;
|
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
|
|
|
} orco;
|
|
|
|
|
|
|
|
int tottface, totmcol, tottang, totorco;
|
|
|
|
} DMVertexAttribs;
|
|
|
|
|
|
|
|
void DM_vertex_attributes_from_gpu(DerivedMesh *dm,
|
2012-05-12 22:39:39 +02:00
|
|
|
struct GPUVertexAttribs *gattribs, DMVertexAttribs *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
|
|
|
|
2015-01-20 14:17:08 +01:00
|
|
|
void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert);
|
|
|
|
|
2008-07-29 17:48:31 +02:00
|
|
|
void DM_add_tangent_layer(DerivedMesh *dm);
|
2011-12-10 00:26:06 +01:00
|
|
|
void DM_calc_auto_bump_scale(DerivedMesh *dm);
|
2008-07-29 17:48:31 +02:00
|
|
|
|
2012-06-27 19:48:39 +02:00
|
|
|
/** Set object's bounding box based on DerivedMesh min/max data */
|
2010-03-05 17:47:52 +01:00
|
|
|
void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm);
|
|
|
|
|
2012-02-05 12:30:26 +01:00
|
|
|
void DM_init_origspace(DerivedMesh *dm);
|
|
|
|
|
2012-01-19 01:18:25 +01:00
|
|
|
/* debug only */
|
|
|
|
#ifndef NDEBUG
|
|
|
|
char *DM_debug_info(DerivedMesh *dm);
|
|
|
|
void DM_debug_print(DerivedMesh *dm);
|
2012-09-03 04:41:12 +02:00
|
|
|
void DM_debug_print_cdlayers(CustomData *cdata);
|
2013-09-04 03:29:34 +02:00
|
|
|
|
|
|
|
bool DM_is_valid(DerivedMesh *dm);
|
2005-03-27 22:34:18 +02:00
|
|
|
#endif
|
|
|
|
|
2013-09-01 17:01:15 +02:00
|
|
|
BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i) ATTR_NONNULL(1);
|
2012-11-26 11:15:32 +01:00
|
|
|
|
2012-10-30 20:20:17 +01:00
|
|
|
BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i)
|
|
|
|
{
|
|
|
|
const int j = index_mf_to_mpoly[i];
|
2012-11-26 11:15:32 +01:00
|
|
|
return (j != ORIGINDEX_NONE) ? (index_mp_to_orig ? index_mp_to_orig[j] : j) : ORIGINDEX_NONE;
|
2012-10-30 20:20:17 +01:00
|
|
|
}
|
|
|
|
|
2014-05-03 15:58:37 +02:00
|
|
|
struct MVert *DM_get_vert_array(struct DerivedMesh *dm, bool *allocated);
|
|
|
|
struct MEdge *DM_get_edge_array(struct DerivedMesh *dm, bool *allocated);
|
|
|
|
struct MLoop *DM_get_loop_array(struct DerivedMesh *dm, bool *allocated);
|
|
|
|
struct MPoly *DM_get_poly_array(struct DerivedMesh *dm, bool *allocated);
|
|
|
|
struct MFace *DM_get_tessface_array(struct DerivedMesh *dm, bool *allocated);
|
|
|
|
|
2013-01-24 22:57:13 +01:00
|
|
|
#endif /* __BKE_DERIVEDMESH_H__ */
|