2006-08-28 01:12:36 +00:00
|
|
|
/*
|
2011-10-10 09:38:02 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): Ben Batt <benbatt@gmail.com>
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* Implementation of CustomData.
|
|
|
|
*
|
|
|
|
* BKE_customdata.h contains the function prototypes for this file.
|
|
|
|
*
|
|
|
|
*/
|
2011-02-27 20:40:57 +00:00
|
|
|
|
|
|
|
/** \file blender/blenkernel/intern/customdata.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2009-11-25 14:27:50 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
2010-11-07 08:49:07 +00:00
|
|
|
#include <assert.h>
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2009-11-25 14:27:50 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
2009-11-25 14:27:50 +00:00
|
|
|
#include "DNA_ID.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2011-05-09 04:06:48 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-11-25 14:27:50 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_linklist.h"
|
2010-09-30 22:27:37 +00:00
|
|
|
#include "BLI_math.h"
|
2009-11-25 14:27:50 +00:00
|
|
|
#include "BLI_mempool.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2009-11-25 14:27:50 +00:00
|
|
|
#include "BKE_customdata.h"
|
2009-12-10 14:26:06 +00:00
|
|
|
#include "BKE_customdata_file.h"
|
2009-11-25 14:27:50 +00:00
|
|
|
#include "BKE_global.h"
|
2010-10-18 06:41:16 +00:00
|
|
|
#include "BKE_main.h"
|
2010-11-04 16:00:28 +00:00
|
|
|
#include "BKE_multires.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
#include "bmesh.h"
|
|
|
|
|
2009-01-06 18:59:03 +00:00
|
|
|
#include <math.h>
|
2006-08-28 01:12:36 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* number of layers to add when growing a CustomData object */
|
|
|
|
#define CUSTOMDATA_GROW 5
|
|
|
|
|
2012-10-25 04:44:46 +00:00
|
|
|
/* ensure typemap size is ok */
|
|
|
|
BLI_STATIC_ASSERT(sizeof(((CustomData *)NULL)->typemap) /
|
|
|
|
sizeof(((CustomData *)NULL)->typemap[0]) == CD_NUMTYPES,
|
|
|
|
"size mismatch");
|
|
|
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/********************* Layer type information **********************/
|
|
|
|
typedef struct LayerTypeInfo {
|
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 04:28:02 +00:00
|
|
|
int size; /* the memory size of one element of this layer's data */
|
2012-10-30 19:20:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* name of the struct used, for file writing */
|
|
|
|
const char *structname;
|
|
|
|
/**
|
|
|
|
* number of structs per element, for file writing
|
|
|
|
* (set to zero skips writing this data to disk/undo) */
|
|
|
|
int structnum;
|
2012-04-30 18:54:14 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/**
|
|
|
|
* default layer name.
|
2012-04-30 18:54:14 +00:00
|
|
|
* note! when NULL this is a way to ensure there is only ever one item
|
|
|
|
* see: CustomData_layertype_is_singleton() */
|
|
|
|
const char *defaultname;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/**
|
|
|
|
* a function to copy count elements of this layer's data
|
2006-08-28 01:12:36 +00:00
|
|
|
* (deep copy if appropriate)
|
|
|
|
* if NULL, memcpy is used
|
|
|
|
*/
|
2006-12-12 21:29:09 +00:00
|
|
|
void (*copy)(const void *source, void *dest, int count);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/**
|
|
|
|
* a function to free any dynamically allocated components of this
|
2006-08-28 01:12:36 +00:00
|
|
|
* layer's data (note the data pointer itself should not be freed)
|
|
|
|
* size should be the size of one element of this layer's data (e.g.
|
|
|
|
* LayerTypeInfo.size)
|
|
|
|
*/
|
|
|
|
void (*free)(void *data, int count, int size);
|
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/**
|
|
|
|
* a function to interpolate between count source elements of this
|
2006-08-28 01:12:36 +00:00
|
|
|
* layer's data and store the result in dest
|
|
|
|
* if weights == NULL or sub_weights == NULL, they should default to 1
|
|
|
|
*
|
|
|
|
* weights gives the weight for each element in sources
|
|
|
|
* sub_weights gives the sub-element weights for each element in sources
|
|
|
|
* (there should be (sub element count)^2 weights per element)
|
|
|
|
* count gives the number of elements in sources
|
2012-08-24 17:01:35 +00:00
|
|
|
*
|
|
|
|
* \note in some cases \a dest pointer is in \a sources
|
|
|
|
* so all functions have to take this into account and delay
|
|
|
|
* applying changes while reading from sources.
|
|
|
|
* See bug [#32395] - Campbell.
|
2006-08-28 01:12:36 +00:00
|
|
|
*/
|
2012-08-23 09:54:15 +00:00
|
|
|
void (*interp)(void **sources, const float *weights, const float *sub_weights,
|
2011-11-11 13:09:14 +00:00
|
|
|
int count, void *dest);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/** a function to swap the data in corners of the element */
|
2010-04-10 22:12:10 +00:00
|
|
|
void (*swap)(void *data, const int *corner_indices);
|
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 04:28:02 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/**
|
|
|
|
* a function to set a layer's data to default values. if NULL, the
|
2012-03-03 20:19:11 +00:00
|
|
|
* default is assumed to be all zeros */
|
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 04:28:02 +00:00
|
|
|
void (*set_default)(void *data, int count);
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/** functions necessary for geometry collapse */
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
int (*equal)(void *data1, void *data2);
|
|
|
|
void (*multiply)(void *data, float fac);
|
|
|
|
void (*initminmax)(void *min, void *max);
|
|
|
|
void (*add)(void *data1, void *data2);
|
|
|
|
void (*dominmax)(void *data1, void *min, void *max);
|
2009-08-12 03:51:28 +00:00
|
|
|
void (*copyvalue)(void *source, void *dest);
|
2010-01-05 22:33:41 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/** a function to read data from a cdf file */
|
2009-12-10 14:26:06 +00:00
|
|
|
int (*read)(CDataFile *cdf, void *data, int count);
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/** a function to write data to a cdf file */
|
2009-12-10 14:26:06 +00:00
|
|
|
int (*write)(CDataFile *cdf, void *data, int count);
|
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/** a function to determine file size */
|
2009-12-10 14:26:06 +00:00
|
|
|
size_t (*filesize)(CDataFile *cdf, void *data, int count);
|
2006-11-11 16:38:37 +00:00
|
|
|
} LayerTypeInfo;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
static void layerCopy_mdeformvert(const void *source, void *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
int count)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
int i, size = sizeof(MDeformVert);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
memcpy(dest, source, count * size);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dvert->totweight) {
|
2012-01-25 20:18:12 +00:00
|
|
|
MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw),
|
2012-05-12 16:11:34 +00:00
|
|
|
"layerCopy_mdeformvert dw");
|
2008-04-15 18:07:04 +00:00
|
|
|
|
|
|
|
memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw));
|
|
|
|
dvert->dw = dw;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dvert->dw = NULL;
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerFree_mdeformvert(void *data, int count, int size)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformVert *dvert = (MDeformVert *)((char *)data + i * size);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dvert->dw) {
|
2012-01-25 20:18:12 +00:00
|
|
|
MEM_freeN(dvert->dw);
|
2006-08-28 01:12:36 +00:00
|
|
|
dvert->dw = NULL;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
dvert->totweight = 0;
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 16:08:30 +00:00
|
|
|
/* copy just zeros in this case */
|
|
|
|
static void layerCopy_bmesh_elem_py_ptr(const void *UNUSED(source), void *dest,
|
|
|
|
int count)
|
|
|
|
{
|
|
|
|
int i, size = sizeof(void *);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-04-24 22:50:49 +00:00
|
|
|
void **ptr = (void **)((char *)dest + i * size);
|
2012-02-22 16:08:30 +00:00
|
|
|
*ptr = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-08 03:25:53 +00:00
|
|
|
#ifndef WITH_PYTHON
|
|
|
|
void bpy_bm_generic_invalidate(void *UNUSED(self))
|
|
|
|
{
|
|
|
|
/* dummy */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-22 16:08:30 +00:00
|
|
|
static void layerFree_bmesh_elem_py_ptr(void *data, int count, int size)
|
|
|
|
{
|
|
|
|
extern void bpy_bm_generic_invalidate(void *self);
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-02-22 16:08:30 +00:00
|
|
|
void **ptr = (void *)((char *)data + i * size);
|
|
|
|
if (*ptr) {
|
|
|
|
bpy_bm_generic_invalidate(*ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
static void linklist_free_simple(void *link)
|
|
|
|
{
|
2012-01-25 20:18:12 +00:00
|
|
|
MEM_freeN(link);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_mdeformvert(void **sources, const float *weights,
|
|
|
|
const float *UNUSED(sub_weights), int count, void *dest)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
|
|
|
MDeformVert *dvert = dest;
|
|
|
|
LinkNode *dest_dw = NULL; /* a list of lists of MDeformWeight pointers */
|
|
|
|
LinkNode *node;
|
|
|
|
int i, j, totweight;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count <= 0) return;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* build a list of unique def_nrs for dest */
|
|
|
|
totweight = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformVert *source = sources[i];
|
|
|
|
float interp_weight = weights ? weights[i] : 1.0f;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < source->totweight; ++j) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformWeight *dw = &source->dw[j];
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node = dest_dw; node; node = node->next) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformWeight *tmp_dw = (MDeformWeight *)node->link;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tmp_dw->def_nr == dw->def_nr) {
|
2006-08-28 01:12:36 +00:00
|
|
|
tmp_dw->weight += dw->weight * interp_weight;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if this def_nr is not in the list, add it */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!node) {
|
2012-01-25 20:18:12 +00:00
|
|
|
MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw),
|
2012-05-12 16:11:34 +00:00
|
|
|
"layerInterp_mdeformvert tmp_dw");
|
2006-08-28 01:12:36 +00:00
|
|
|
tmp_dw->def_nr = dw->def_nr;
|
|
|
|
tmp_dw->weight = dw->weight * interp_weight;
|
|
|
|
BLI_linklist_prepend(&dest_dw, tmp_dw);
|
|
|
|
totweight++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/* delay writing to the destination incase dest is in sources */
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* now we know how many unique deform weights there are, so realloc */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dvert->dw) MEM_freeN(dvert->dw);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (totweight) {
|
2012-01-25 20:18:12 +00:00
|
|
|
dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight,
|
2012-05-12 16:11:34 +00:00
|
|
|
"layerInterp_mdeformvert dvert->dw");
|
2006-11-11 23:23:15 +00:00
|
|
|
dvert->totweight = totweight;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0, node = dest_dw; node; node = node->next, ++i)
|
2006-11-11 23:23:15 +00:00
|
|
|
dvert->dw[i] = *((MDeformWeight *)node->link);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
memset(dvert, 0, sizeof(*dvert));
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
BLI_linklist_free(dest_dw, linklist_free_simple);
|
|
|
|
}
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
static void layerCopy_tface(const void *source, void *dest, int count)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
const MTFace *source_tf = (const MTFace *)source;
|
|
|
|
MTFace *dest_tf = (MTFace *)dest;
|
2006-11-11 16:38:37 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i)
|
2006-11-11 16:38:37 +00:00
|
|
|
dest_tf[i] = source_tf[i];
|
|
|
|
}
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_tface(void **sources, const float *weights,
|
|
|
|
const float *sub_weights, int count, void *dest)
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
MTFace *tf = dest;
|
2006-08-28 01:12:36 +00:00
|
|
|
int i, j, k;
|
2011-12-29 11:18:12 +00:00
|
|
|
float uv[4][2] = {{0.0f}};
|
2012-08-23 09:54:15 +00:00
|
|
|
const float *sub_weight;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count <= 0) return;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
sub_weight = sub_weights;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2006-08-28 01:12:36 +00:00
|
|
|
float weight = weights ? weights[i] : 1;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
MTFace *src = sources[i];
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < 4; ++j) {
|
|
|
|
if (sub_weights) {
|
|
|
|
for (k = 0; k < 4; ++k, ++sub_weight) {
|
2011-12-29 11:18:12 +00:00
|
|
|
madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * weight);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
2011-12-29 11:18:12 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
madd_v2_v2fl(uv[j], src->uv[j], weight);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/* delay writing to the destination incase dest is in sources */
|
2011-12-29 11:18:12 +00:00
|
|
|
*tf = *(MTFace *)(*sources);
|
|
|
|
memcpy(tf->uv, uv, sizeof(tf->uv));
|
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 04:28:02 +00:00
|
|
|
}
|
|
|
|
|
2010-04-10 22:12:10 +00:00
|
|
|
static void layerSwap_tface(void *data, const int *corner_indices)
|
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 04:28:02 +00:00
|
|
|
{
|
|
|
|
MTFace *tf = data;
|
|
|
|
float uv[4][2];
|
2012-05-12 16:11:34 +00:00
|
|
|
static const short pin_flags[4] = { TF_PIN1, TF_PIN2, TF_PIN3, TF_PIN4 };
|
|
|
|
static const char sel_flags[4] = { TF_SEL1, TF_SEL2, TF_SEL3, TF_SEL4 };
|
2008-08-04 14:49:55 +00:00
|
|
|
short unwrap = tf->unwrap & ~(TF_PIN1 | TF_PIN2 | TF_PIN3 | TF_PIN4);
|
|
|
|
char flag = tf->flag & ~(TF_SEL1 | TF_SEL2 | TF_SEL3 | TF_SEL4);
|
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 04:28:02 +00:00
|
|
|
int j;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < 4; ++j) {
|
2011-12-29 11:18:12 +00:00
|
|
|
const int source_index = corner_indices[j];
|
2008-08-04 14:49:55 +00:00
|
|
|
|
2011-12-29 11:18:12 +00:00
|
|
|
copy_v2_v2(uv[j], tf->uv[source_index]);
|
2008-08-04 14:49:55 +00:00
|
|
|
|
2012-07-07 22:51:57 +00:00
|
|
|
/* swap pinning flags around */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tf->unwrap & pin_flags[source_index]) {
|
2008-08-04 14:49:55 +00:00
|
|
|
unwrap |= pin_flags[j];
|
|
|
|
}
|
|
|
|
|
2012-07-07 22:51:57 +00:00
|
|
|
/* swap selection flags around */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tf->flag & sel_flags[source_index]) {
|
2008-08-04 14:49:55 +00:00
|
|
|
flag |= sel_flags[j];
|
|
|
|
}
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
|
|
|
|
memcpy(tf->uv, uv, sizeof(tf->uv));
|
2008-08-04 14:49:55 +00:00
|
|
|
tf->unwrap = unwrap;
|
|
|
|
tf->flag = flag;
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
static void layerDefault_tface(void *data, int count)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, NULL,
|
2012-05-12 16:11:34 +00:00
|
|
|
0, 0, TF_DYNAMIC | TF_CONVERTED, 0, 0};
|
|
|
|
MTFace *tf = (MTFace *)data;
|
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 04:28:02 +00:00
|
|
|
int i;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; i++)
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
tf[i] = default_tf;
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
|
2011-04-16 13:00:41 +00:00
|
|
|
static void layerCopy_propFloat(const void *source, void *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
int count)
|
2011-04-16 13:00:41 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
memcpy(dest, source, sizeof(MFloatProperty) * count);
|
2011-04-16 13:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void layerCopy_propInt(const void *source, void *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
int count)
|
2011-04-16 13:00:41 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
memcpy(dest, source, sizeof(MIntProperty) * count);
|
2011-04-16 13:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void layerCopy_propString(const void *source, void *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
int count)
|
2011-04-16 13:00:41 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
memcpy(dest, source, sizeof(MStringProperty) * count);
|
2011-04-16 13:00:41 +00:00
|
|
|
}
|
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
static void layerCopy_origspace_face(const void *source, void *dest, int count)
|
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
const OrigSpaceFace *source_tf = (const OrigSpaceFace *)source;
|
|
|
|
OrigSpaceFace *dest_tf = (OrigSpaceFace *)dest;
|
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 22:09:57 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i)
|
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 22:09:57 +00:00
|
|
|
dest_tf[i] = source_tf[i];
|
|
|
|
}
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_origspace_face(void **sources, const float *weights,
|
|
|
|
const float *sub_weights, int count, void *dest)
|
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 22:09:57 +00:00
|
|
|
{
|
|
|
|
OrigSpaceFace *osf = dest;
|
|
|
|
int i, j, k;
|
2011-12-29 11:18:12 +00:00
|
|
|
float uv[4][2] = {{0.0f}};
|
2012-08-23 09:54:15 +00:00
|
|
|
const float *sub_weight;
|
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 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count <= 0) return;
|
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 22:09:57 +00:00
|
|
|
|
|
|
|
sub_weight = sub_weights;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
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 22:09:57 +00:00
|
|
|
float weight = weights ? weights[i] : 1;
|
|
|
|
OrigSpaceFace *src = sources[i];
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < 4; ++j) {
|
|
|
|
if (sub_weights) {
|
|
|
|
for (k = 0; k < 4; ++k, ++sub_weight) {
|
2011-12-29 11:18:12 +00:00
|
|
|
madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * weight);
|
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 22:09:57 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-12-29 11:18:12 +00:00
|
|
|
madd_v2_v2fl(uv[j], src->uv[j], weight);
|
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 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/* delay writing to the destination incase dest is in sources */
|
|
|
|
|
2011-12-29 11:18:12 +00:00
|
|
|
#if 0 /* no need, this ONLY contains UV's */
|
|
|
|
*osf = *(OrigSpaceFace *)(*sources);
|
|
|
|
#endif
|
|
|
|
memcpy(osf->uv, uv, sizeof(osf->uv));
|
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 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2010-04-10 22:12:10 +00:00
|
|
|
static void layerSwap_origspace_face(void *data, const int *corner_indices)
|
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 22:09:57 +00:00
|
|
|
{
|
|
|
|
OrigSpaceFace *osf = data;
|
|
|
|
float uv[4][2];
|
|
|
|
int j;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < 4; ++j) {
|
2011-12-29 11:18:12 +00:00
|
|
|
copy_v2_v2(uv[j], osf->uv[corner_indices[j]]);
|
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 22:09:57 +00:00
|
|
|
}
|
|
|
|
memcpy(osf->uv, uv, sizeof(osf->uv));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerDefault_origspace_face(void *data, int count)
|
|
|
|
{
|
|
|
|
static OrigSpaceFace default_osf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
|
2012-05-12 16:11:34 +00:00
|
|
|
OrigSpaceFace *osf = (OrigSpaceFace *)data;
|
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 22:09:57 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; i++)
|
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 22:09:57 +00:00
|
|
|
osf[i] = default_osf;
|
|
|
|
}
|
2009-01-06 18:59:03 +00:00
|
|
|
|
2010-04-17 15:47:00 +00:00
|
|
|
static void layerSwap_mdisps(void *data, const int *ci)
|
2009-01-06 18:59:03 +00:00
|
|
|
{
|
|
|
|
MDisps *s = data;
|
|
|
|
float (*d)[3] = NULL;
|
2009-12-07 19:11:37 +00:00
|
|
|
int corners, cornersize, S;
|
2009-01-06 18:59:03 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (s->disps) {
|
2012-05-12 16:11:34 +00:00
|
|
|
int nverts = (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */
|
|
|
|
corners = multires_mdisp_corners(s);
|
|
|
|
cornersize = s->totdisp / corners;
|
2009-01-06 18:59:03 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
if (corners != nverts) {
|
2010-10-16 20:43:16 +00:00
|
|
|
/* happens when face changed vertex count in edit mode
|
2012-03-03 20:19:11 +00:00
|
|
|
* if it happened, just forgot displacement */
|
2009-01-06 18:59:03 +00:00
|
|
|
|
2012-01-25 20:18:12 +00:00
|
|
|
MEM_freeN(s->disps);
|
2012-05-12 16:11:34 +00:00
|
|
|
s->totdisp = (s->totdisp / corners) * nverts;
|
|
|
|
s->disps = MEM_callocN(s->totdisp * sizeof(float) * 3, "mdisp swap");
|
2010-10-16 20:43:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
d = MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
|
2009-01-06 18:59:03 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (S = 0; S < corners; S++)
|
2012-05-12 16:11:34 +00:00
|
|
|
memcpy(d + cornersize * S, s->disps + cornersize * ci[S], cornersize * 3 * sizeof(float));
|
2010-09-30 22:27:37 +00:00
|
|
|
|
2012-01-25 20:18:12 +00:00
|
|
|
MEM_freeN(s->disps);
|
2012-05-12 16:11:34 +00:00
|
|
|
s->disps = d;
|
2010-09-30 22:27:37 +00:00
|
|
|
}
|
2009-01-06 18:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void layerCopy_mdisps(const void *source, void *dest, int count)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const MDisps *s = source;
|
|
|
|
MDisps *d = dest;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
if (s[i].disps) {
|
2012-01-25 20:18:12 +00:00
|
|
|
d[i].disps = MEM_dupallocN(s[i].disps);
|
2012-03-14 06:31:38 +00:00
|
|
|
d[i].hidden = MEM_dupallocN(s[i].hidden);
|
2009-01-06 18:59:03 +00:00
|
|
|
d[i].totdisp = s[i].totdisp;
|
2012-03-14 03:10:18 +00:00
|
|
|
d[i].level = s[i].level;
|
2009-01-06 18:59:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
d[i].disps = NULL;
|
2012-03-20 11:51:04 +00:00
|
|
|
d[i].hidden = NULL;
|
2009-01-06 18:59:03 +00:00
|
|
|
d[i].totdisp = 0;
|
2012-03-14 03:10:18 +00:00
|
|
|
d[i].level = 0;
|
2009-01-06 18:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-17 06:38:56 +00:00
|
|
|
static void layerFree_mdisps(void *data, int count, int UNUSED(size))
|
2009-01-06 18:59:03 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
MDisps *d = data;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
if (d[i].disps)
|
2012-01-25 20:18:12 +00:00
|
|
|
MEM_freeN(d[i].disps);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (d[i].hidden)
|
2012-03-14 06:31:38 +00:00
|
|
|
MEM_freeN(d[i].hidden);
|
2009-01-06 18:59:03 +00:00
|
|
|
d[i].disps = NULL;
|
2012-03-14 06:31:38 +00:00
|
|
|
d[i].hidden = NULL;
|
2009-01-06 18:59:03 +00:00
|
|
|
d[i].totdisp = 0;
|
2012-03-14 03:10:18 +00:00
|
|
|
d[i].level = 0;
|
2009-01-06 18:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
|
|
|
MDisps *d = data;
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
if (!d[i].disps)
|
2012-05-12 16:11:34 +00:00
|
|
|
d[i].disps = MEM_callocN(sizeof(float) * 3 * d[i].totdisp, "mdisps read");
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
if (!cdf_read_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
|
2010-05-07 09:48:40 +00:00
|
|
|
printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp);
|
2009-11-25 14:27:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
static int layerWrite_mdisps(CDataFile *cdf, void *data, int count)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
|
|
|
MDisps *d = data;
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-05-12 16:11:34 +00:00
|
|
|
if (!cdf_write_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
|
2010-05-07 09:48:40 +00:00
|
|
|
printf("failed to write multires displacement %d/%d %d\n", i, count, d[i].totdisp);
|
2009-11-25 14:27:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-10-17 06:38:56 +00:00
|
|
|
static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), void *data, int count)
|
2009-12-10 14:26:06 +00:00
|
|
|
{
|
|
|
|
MDisps *d = data;
|
|
|
|
size_t size = 0;
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i)
|
2012-05-12 16:11:34 +00:00
|
|
|
size += d[i].totdisp * 3 * sizeof(float);
|
2009-12-10 14:26:06 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2012-05-10 20:33:24 +00:00
|
|
|
static void layerCopy_grid_paint_mask(const void *source, void *dest, int count)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const GridPaintMask *s = source;
|
|
|
|
GridPaintMask *d = dest;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
if (s[i].data) {
|
2012-05-10 20:33:24 +00:00
|
|
|
d[i].data = MEM_dupallocN(s[i].data);
|
|
|
|
d[i].level = s[i].level;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
d[i].data = NULL;
|
|
|
|
d[i].level = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerFree_grid_paint_mask(void *data, int count, int UNUSED(size))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GridPaintMask *gpm = data;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
if (gpm[i].data)
|
2012-05-10 20:33:24 +00:00
|
|
|
MEM_freeN(gpm[i].data);
|
|
|
|
gpm[i].data = NULL;
|
|
|
|
gpm[i].level = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 22:09:57 +00:00
|
|
|
/* --------- */
|
2009-08-12 03:51:28 +00:00
|
|
|
static void layerCopyValue_mloopcol(void *source, void *dest)
|
|
|
|
{
|
|
|
|
MLoopCol *m1 = source, *m2 = dest;
|
|
|
|
|
|
|
|
m2->r = m1->r;
|
|
|
|
m2->g = m1->g;
|
|
|
|
m2->b = m1->b;
|
|
|
|
m2->a = m1->a;
|
|
|
|
}
|
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 22:09:57 +00:00
|
|
|
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
static int layerEqual_mloopcol(void *data1, void *data2)
|
|
|
|
{
|
|
|
|
MLoopCol *m1 = data1, *m2 = data2;
|
|
|
|
float r, g, b, a;
|
|
|
|
|
|
|
|
r = m1->r - m2->r;
|
|
|
|
g = m1->g - m2->g;
|
|
|
|
b = m1->b - m2->b;
|
|
|
|
a = m1->a - m2->a;
|
|
|
|
|
2012-05-03 21:35:04 +00:00
|
|
|
return r * r + g * g + b * b + a * a < 0.001f;
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void layerMultiply_mloopcol(void *data, float fac)
|
|
|
|
{
|
|
|
|
MLoopCol *m = data;
|
|
|
|
|
|
|
|
m->r = (float)m->r * fac;
|
|
|
|
m->g = (float)m->g * fac;
|
|
|
|
m->b = (float)m->b * fac;
|
|
|
|
m->a = (float)m->a * fac;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerAdd_mloopcol(void *data1, void *data2)
|
|
|
|
{
|
|
|
|
MLoopCol *m = data1, *m2 = data2;
|
|
|
|
|
|
|
|
m->r += m2->r;
|
|
|
|
m->g += m2->g;
|
|
|
|
m->b += m2->b;
|
|
|
|
m->a += m2->a;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerDoMinMax_mloopcol(void *data, void *vmin, void *vmax)
|
|
|
|
{
|
|
|
|
MLoopCol *m = data;
|
|
|
|
MLoopCol *min = vmin, *max = vmax;
|
|
|
|
|
|
|
|
if (m->r < min->r) min->r = m->r;
|
|
|
|
if (m->g < min->g) min->g = m->g;
|
|
|
|
if (m->b < min->b) min->b = m->b;
|
|
|
|
if (m->a < min->a) min->a = m->a;
|
|
|
|
|
|
|
|
if (m->r > max->r) max->r = m->r;
|
|
|
|
if (m->g > max->g) max->g = m->g;
|
|
|
|
if (m->b > max->b) max->b = m->b;
|
|
|
|
if (m->a > max->a) max->a = m->a;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerInitMinMax_mloopcol(void *vmin, void *vmax)
|
|
|
|
{
|
|
|
|
MLoopCol *min = vmin, *max = vmax;
|
|
|
|
|
|
|
|
min->r = 255;
|
|
|
|
min->g = 255;
|
|
|
|
min->b = 255;
|
|
|
|
min->a = 255;
|
|
|
|
|
|
|
|
max->r = 0;
|
|
|
|
max->g = 0;
|
|
|
|
max->b = 0;
|
|
|
|
max->a = 0;
|
|
|
|
}
|
|
|
|
|
2008-07-08 02:22:37 +00:00
|
|
|
static void layerDefault_mloopcol(void *data, int count)
|
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
MLoopCol default_mloopcol = {255, 255, 255, 255};
|
2012-05-12 16:11:34 +00:00
|
|
|
MLoopCol *mlcol = (MLoopCol *)data;
|
2008-07-08 02:22:37 +00:00
|
|
|
int i;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; i++)
|
2008-07-08 02:22:37 +00:00
|
|
|
mlcol[i] = default_mloopcol;
|
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 22:09:57 +00:00
|
|
|
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_mloopcol(void **sources, const float *weights,
|
|
|
|
const float *sub_weights, int count, void *dest)
|
2008-07-08 02:22:37 +00:00
|
|
|
{
|
|
|
|
MLoopCol *mc = dest;
|
|
|
|
int i;
|
2012-08-23 09:54:15 +00:00
|
|
|
const float *sub_weight;
|
2008-07-08 02:22:37 +00:00
|
|
|
struct {
|
|
|
|
float a;
|
|
|
|
float r;
|
|
|
|
float g;
|
|
|
|
float b;
|
|
|
|
} col;
|
|
|
|
col.a = col.r = col.g = col.b = 0;
|
|
|
|
|
|
|
|
sub_weight = sub_weights;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2008-07-08 02:22:37 +00:00
|
|
|
float weight = weights ? weights[i] : 1;
|
|
|
|
MLoopCol *src = sources[i];
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sub_weights) {
|
2008-07-08 02:22:37 +00:00
|
|
|
col.r += src->r * (*sub_weight) * weight;
|
|
|
|
col.g += src->g * (*sub_weight) * weight;
|
|
|
|
col.b += src->b * (*sub_weight) * weight;
|
2012-03-17 20:39:28 +00:00
|
|
|
col.a += src->a * (*sub_weight) * weight;
|
2011-12-29 11:18:12 +00:00
|
|
|
sub_weight++;
|
2012-02-23 02:17:50 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-07-08 02:22:37 +00:00
|
|
|
col.r += src->r * weight;
|
|
|
|
col.g += src->g * weight;
|
|
|
|
col.b += src->b * weight;
|
2012-03-17 20:39:28 +00:00
|
|
|
col.a += src->a * weight;
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-08 20:08:19 +00:00
|
|
|
|
|
|
|
/* Subdivide smooth or fractal can cause problems without clamping
|
|
|
|
* although weights should also not cause this situation */
|
|
|
|
CLAMP(col.a, 0.0f, 255.0f);
|
|
|
|
CLAMP(col.r, 0.0f, 255.0f);
|
|
|
|
CLAMP(col.g, 0.0f, 255.0f);
|
|
|
|
CLAMP(col.b, 0.0f, 255.0f);
|
2012-08-24 17:01:35 +00:00
|
|
|
|
|
|
|
/* delay writing to the destination incase dest is in sources */
|
2008-07-08 02:22:37 +00:00
|
|
|
mc->r = (int)col.r;
|
|
|
|
mc->g = (int)col.g;
|
|
|
|
mc->b = (int)col.b;
|
2012-03-17 20:39:28 +00:00
|
|
|
mc->a = (int)col.a;
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
|
2009-08-12 03:51:28 +00:00
|
|
|
static void layerCopyValue_mloopuv(void *source, void *dest)
|
|
|
|
{
|
|
|
|
MLoopUV *luv1 = source, *luv2 = dest;
|
2011-12-29 11:18:12 +00:00
|
|
|
|
|
|
|
copy_v2_v2(luv2->uv, luv1->uv);
|
2009-08-12 03:51:28 +00:00
|
|
|
}
|
|
|
|
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
static int layerEqual_mloopuv(void *data1, void *data2)
|
|
|
|
{
|
|
|
|
MLoopUV *luv1 = data1, *luv2 = data2;
|
|
|
|
|
2011-12-29 11:18:12 +00:00
|
|
|
return len_squared_v2v2(luv1->uv, luv2->uv) < 0.00001f;
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void layerMultiply_mloopuv(void *data, float fac)
|
|
|
|
{
|
|
|
|
MLoopUV *luv = data;
|
|
|
|
|
2011-12-29 11:18:12 +00:00
|
|
|
mul_v2_fl(luv->uv, fac);
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void layerInitMinMax_mloopuv(void *vmin, void *vmax)
|
|
|
|
{
|
|
|
|
MLoopUV *min = vmin, *max = vmax;
|
|
|
|
|
|
|
|
INIT_MINMAX2(min->uv, max->uv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerDoMinMax_mloopuv(void *data, void *vmin, void *vmax)
|
|
|
|
{
|
|
|
|
MLoopUV *min = vmin, *max = vmax, *luv = data;
|
|
|
|
|
|
|
|
DO_MINMAX2(luv->uv, min->uv, max->uv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerAdd_mloopuv(void *data1, void *data2)
|
|
|
|
{
|
|
|
|
MLoopUV *l1 = data1, *l2 = data2;
|
|
|
|
|
2011-12-29 11:18:12 +00:00
|
|
|
add_v2_v2(l1->uv, l2->uv);
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_mloopuv(void **sources, const float *weights,
|
|
|
|
const float *sub_weights, int count, void *dest)
|
2008-07-08 02:22:37 +00:00
|
|
|
{
|
2012-08-24 17:01:35 +00:00
|
|
|
float uv[2];
|
2008-07-08 02:22:37 +00:00
|
|
|
int i;
|
|
|
|
|
2011-12-29 11:18:12 +00:00
|
|
|
zero_v2(uv);
|
|
|
|
|
|
|
|
if (sub_weights) {
|
|
|
|
const float *sub_weight = sub_weights;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
2011-12-29 11:18:12 +00:00
|
|
|
float weight = weights ? weights[i] : 1.0f;
|
|
|
|
MLoopUV *src = sources[i];
|
|
|
|
madd_v2_v2fl(uv, src->uv, (*sub_weight) * weight);
|
|
|
|
sub_weight++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
2011-12-29 11:18:12 +00:00
|
|
|
float weight = weights ? weights[i] : 1;
|
|
|
|
MLoopUV *src = sources[i];
|
|
|
|
madd_v2_v2fl(uv, src->uv, weight);
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-24 17:01:35 +00:00
|
|
|
|
|
|
|
/* delay writing to the destination incase dest is in sources */
|
|
|
|
copy_v2_v2(((MLoopUV *)dest)->uv, uv);
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-02-05 11:30:26 +00:00
|
|
|
/* origspace is almost exact copy of mloopuv's, keep in sync */
|
|
|
|
static void layerCopyValue_mloop_origspace(void *source, void *dest)
|
|
|
|
{
|
|
|
|
OrigSpaceLoop *luv1 = source, *luv2 = dest;
|
|
|
|
|
|
|
|
copy_v2_v2(luv2->uv, luv1->uv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int layerEqual_mloop_origspace(void *data1, void *data2)
|
|
|
|
{
|
|
|
|
OrigSpaceLoop *luv1 = data1, *luv2 = data2;
|
|
|
|
|
|
|
|
return len_squared_v2v2(luv1->uv, luv2->uv) < 0.00001f;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerMultiply_mloop_origspace(void *data, float fac)
|
|
|
|
{
|
|
|
|
OrigSpaceLoop *luv = data;
|
|
|
|
|
|
|
|
mul_v2_fl(luv->uv, fac);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerInitMinMax_mloop_origspace(void *vmin, void *vmax)
|
|
|
|
{
|
|
|
|
OrigSpaceLoop *min = vmin, *max = vmax;
|
|
|
|
|
|
|
|
INIT_MINMAX2(min->uv, max->uv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerDoMinMax_mloop_origspace(void *data, void *vmin, void *vmax)
|
|
|
|
{
|
|
|
|
OrigSpaceLoop *min = vmin, *max = vmax, *luv = data;
|
|
|
|
|
|
|
|
DO_MINMAX2(luv->uv, min->uv, max->uv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerAdd_mloop_origspace(void *data1, void *data2)
|
|
|
|
{
|
|
|
|
OrigSpaceLoop *l1 = data1, *l2 = data2;
|
|
|
|
|
|
|
|
add_v2_v2(l1->uv, l2->uv);
|
|
|
|
}
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_mloop_origspace(void **sources, const float *weights,
|
|
|
|
const float *sub_weights, int count, void *dest)
|
2012-02-05 11:30:26 +00:00
|
|
|
{
|
2012-08-24 17:01:35 +00:00
|
|
|
float uv[2];
|
2012-02-05 11:30:26 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
zero_v2(uv);
|
|
|
|
|
|
|
|
if (sub_weights) {
|
|
|
|
const float *sub_weight = sub_weights;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
2012-02-05 11:30:26 +00:00
|
|
|
float weight = weights ? weights[i] : 1.0f;
|
|
|
|
OrigSpaceLoop *src = sources[i];
|
|
|
|
madd_v2_v2fl(uv, src->uv, (*sub_weight) * weight);
|
|
|
|
sub_weight++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
2012-08-24 17:01:35 +00:00
|
|
|
float weight = weights ? weights[i] : 1.0f;
|
2012-02-05 11:30:26 +00:00
|
|
|
OrigSpaceLoop *src = sources[i];
|
|
|
|
madd_v2_v2fl(uv, src->uv, weight);
|
|
|
|
}
|
|
|
|
}
|
2012-08-24 17:01:35 +00:00
|
|
|
|
|
|
|
/* delay writing to the destination incase dest is in sources */
|
|
|
|
copy_v2_v2(((OrigSpaceLoop *)dest)->uv, uv);
|
2012-02-05 11:30:26 +00:00
|
|
|
}
|
|
|
|
/* --- end copy */
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_mcol(void **sources, const float *weights,
|
|
|
|
const float *sub_weights, int count, void *dest)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
|
|
|
MCol *mc = dest;
|
|
|
|
int i, j, k;
|
|
|
|
struct {
|
|
|
|
float a;
|
|
|
|
float r;
|
|
|
|
float g;
|
|
|
|
float b;
|
2011-12-29 11:18:12 +00:00
|
|
|
} col[4] = {{0.0f}};
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
const float *sub_weight;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count <= 0) return;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
sub_weight = sub_weights;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2006-08-28 01:12:36 +00:00
|
|
|
float weight = weights ? weights[i] : 1;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < 4; ++j) {
|
|
|
|
if (sub_weights) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MCol *src = sources[i];
|
2012-03-24 06:18:31 +00:00
|
|
|
for (k = 0; k < 4; ++k, ++sub_weight, ++src) {
|
2012-05-12 16:11:34 +00:00
|
|
|
const float w = (*sub_weight) * weight;
|
2011-12-29 11:18:12 +00:00
|
|
|
col[j].a += src->a * w;
|
|
|
|
col[j].r += src->r * w;
|
|
|
|
col[j].g += src->g * w;
|
|
|
|
col[j].b += src->b * w;
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-08-28 01:12:36 +00:00
|
|
|
MCol *src = sources[i];
|
|
|
|
col[j].a += src[j].a * weight;
|
|
|
|
col[j].r += src[j].r * weight;
|
|
|
|
col[j].g += src[j].g * weight;
|
|
|
|
col[j].b += src[j].b * weight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/* delay writing to the destination incase dest is in sources */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < 4; ++j) {
|
2009-06-08 20:08:19 +00:00
|
|
|
|
|
|
|
/* Subdivide smooth or fractal can cause problems without clamping
|
|
|
|
* although weights should also not cause this situation */
|
|
|
|
CLAMP(col[j].a, 0.0f, 255.0f);
|
|
|
|
CLAMP(col[j].r, 0.0f, 255.0f);
|
|
|
|
CLAMP(col[j].g, 0.0f, 255.0f);
|
|
|
|
CLAMP(col[j].b, 0.0f, 255.0f);
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
mc[j].a = (int)col[j].a;
|
|
|
|
mc[j].r = (int)col[j].r;
|
|
|
|
mc[j].g = (int)col[j].g;
|
|
|
|
mc[j].b = (int)col[j].b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-10 22:12:10 +00:00
|
|
|
static void layerSwap_mcol(void *data, const int *corner_indices)
|
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 04:28:02 +00:00
|
|
|
{
|
|
|
|
MCol *mcol = data;
|
|
|
|
MCol col[4];
|
|
|
|
int j;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j = 0; j < 4; ++j)
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
col[j] = mcol[corner_indices[j]];
|
|
|
|
|
|
|
|
memcpy(mcol, col, sizeof(col));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerDefault_mcol(void *data, int count)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
|
|
|
static MCol default_mcol = {255, 255, 255, 255};
|
2012-05-12 16:11:34 +00:00
|
|
|
MCol *mcol = (MCol *)data;
|
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 04:28:02 +00:00
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < 4 * count; i++) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
mcol[i] = default_mcol;
|
2011-12-28 13:11:46 +00: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 04:28:02 +00:00
|
|
|
}
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_bweight(void **sources, const float *weights,
|
|
|
|
const float *UNUSED(sub_weights), int count, void *dest)
|
2010-07-14 22:06:10 +00:00
|
|
|
{
|
2012-08-24 17:01:35 +00:00
|
|
|
float f;
|
2011-05-09 05:09:07 +00:00
|
|
|
float **in = (float **)sources;
|
2010-07-14 22:06:10 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count <= 0) return;
|
2010-07-14 22:06:10 +00:00
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
f = 0.0f;
|
2011-12-28 13:11:46 +00:00
|
|
|
|
|
|
|
if (weights) {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-08-24 17:01:35 +00:00
|
|
|
f += *in[i] * weights[i];
|
2011-12-28 13:11:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-08-24 17:01:35 +00:00
|
|
|
f += *in[i];
|
2011-12-28 13:11:46 +00:00
|
|
|
}
|
2010-07-14 22:06:10 +00:00
|
|
|
}
|
2012-08-24 17:01:35 +00:00
|
|
|
|
|
|
|
/* delay writing to the destination incase dest is in sources */
|
|
|
|
*((float *)dest) = f;
|
2010-07-14 22:06:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_shapekey(void **sources, const float *weights,
|
|
|
|
const float *UNUSED(sub_weights), int count, void *dest)
|
2009-11-01 00:06:53 +00:00
|
|
|
{
|
2012-08-24 17:01:35 +00:00
|
|
|
float co[3];
|
2011-05-09 14:32:55 +00:00
|
|
|
float **in = (float **)sources;
|
2011-05-13 13:17:30 +00:00
|
|
|
int i;
|
2008-07-08 02:22:37 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count <= 0) return;
|
2009-11-01 00:06:53 +00:00
|
|
|
|
2011-12-28 13:11:46 +00:00
|
|
|
zero_v3(co);
|
|
|
|
|
|
|
|
if (weights) {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2011-12-28 13:11:46 +00:00
|
|
|
madd_v3_v3fl(co, in[i], weights[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2011-12-28 13:11:46 +00:00
|
|
|
add_v3_v3(co, in[i]);
|
|
|
|
}
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2012-08-24 17:01:35 +00:00
|
|
|
|
|
|
|
/* delay writing to the destination incase dest is in sources */
|
|
|
|
copy_v3_v3((float *)dest, co);
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2008-07-08 02:22:37 +00:00
|
|
|
|
2012-05-22 15:18:43 +00:00
|
|
|
static void layerDefault_mvert_skin(void *data, int count)
|
|
|
|
{
|
|
|
|
MVertSkin *vs = data;
|
|
|
|
int i;
|
|
|
|
|
2012-05-22 22:03:41 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
2012-05-22 15:18:43 +00:00
|
|
|
copy_v3_fl(vs[i].radius, 0.25f);
|
|
|
|
vs[i].flag = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-05-22 22:03:41 +00:00
|
|
|
|
2012-08-23 09:54:15 +00:00
|
|
|
static void layerInterp_mvert_skin(void **sources, const float *weights,
|
|
|
|
const float *UNUSED(sub_weights),
|
2012-05-22 22:03:41 +00:00
|
|
|
int count, void *dest)
|
2012-05-22 15:18:43 +00:00
|
|
|
{
|
|
|
|
float radius[3], w;
|
|
|
|
MVertSkin *vs;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
zero_v3(radius);
|
2012-05-22 22:03:41 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
2012-05-22 15:18:43 +00:00
|
|
|
w = weights ? weights[i] : 1.0f;
|
|
|
|
vs = sources[i];
|
|
|
|
|
|
|
|
madd_v3_v3fl(radius, vs->radius, w);
|
|
|
|
}
|
|
|
|
|
2012-08-24 17:01:35 +00:00
|
|
|
/* delay writing to the destination incase dest is in sources */
|
2012-05-22 15:18:43 +00:00
|
|
|
vs = dest;
|
|
|
|
copy_v3_v3(vs->radius, radius);
|
|
|
|
vs->flag &= ~MVERT_SKIN_ROOT;
|
|
|
|
}
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 0: CD_MVERT */
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
2012-09-21 11:37:51 +00:00
|
|
|
/* 1: CD_MSTICKY */ /* DEPRECATED */
|
|
|
|
{sizeof(float) * 2, "", 1, NULL, NULL, NULL, NULL, NULL,
|
2006-12-12 21:29:09 +00:00
|
|
|
NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 2: CD_MDEFORMVERT */
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(MDeformVert), "MDeformVert", 1, NULL, layerCopy_mdeformvert,
|
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 04:28:02 +00:00
|
|
|
layerFree_mdeformvert, layerInterp_mdeformvert, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 3: CD_MEDGE */
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(MEdge), "MEdge", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 4: CD_MFACE */
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(MFace), "MFace", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 5: CD_MTFACE */
|
2011-11-23 17:25:25 +00:00
|
|
|
{sizeof(MTFace), "MTFace", 1, "UVMap", layerCopy_tface, NULL,
|
2006-12-12 21:29:09 +00:00
|
|
|
layerInterp_tface, layerSwap_tface, layerDefault_tface},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 6: CD_MCOL */
|
2006-11-11 16:38:37 +00:00
|
|
|
/* 4 MCol structs per face */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(MCol) * 4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol,
|
2006-12-12 21:29:09 +00:00
|
|
|
layerSwap_mcol, layerDefault_mcol},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 7: CD_ORIGINDEX */
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 8: CD_NORMAL */
|
2006-11-11 16:38:37 +00:00
|
|
|
/* 3 floats per normal vector */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(float) * 3, "vec3f", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
2012-10-30 19:20:17 +00:00
|
|
|
/* 9: CD_POLYINDEX (deprecated) */
|
|
|
|
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 10: CD_PROP_FLT */
|
2012-04-29 15:47:02 +00:00
|
|
|
{sizeof(MFloatProperty), "MFloatProperty", 1, "Float", layerCopy_propFloat, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 11: CD_PROP_INT */
|
2012-04-29 15:47:02 +00:00
|
|
|
{sizeof(MIntProperty), "MIntProperty", 1, "Int", layerCopy_propInt, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 12: CD_PROP_STR */
|
2012-04-29 15:47:02 +00:00
|
|
|
{sizeof(MStringProperty), "MStringProperty", 1, "String", layerCopy_propString, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 13: CD_ORIGSPACE */
|
2011-11-23 17:25:25 +00:00
|
|
|
{sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVMap", layerCopy_origspace_face, NULL,
|
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 22:09:57 +00:00
|
|
|
layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 14: CD_ORCO */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 15: CD_MTEXPOLY */
|
2012-02-24 12:10:41 +00:00
|
|
|
/* note, when we expose the UV Map / TexFace split to the user, change this back to face Texture */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(MTexPoly), "MTexPoly", 1, "UVMap" /* "Face Texture" */, NULL, NULL, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 16: CD_MLOOPUV */
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
{sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL,
|
|
|
|
layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv,
|
2009-08-12 03:51:28 +00:00
|
|
|
layerAdd_mloopuv, layerDoMinMax_mloopuv, layerCopyValue_mloopuv},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 17: CD_MLOOPCOL */
|
2012-10-21 05:46:41 +00:00
|
|
|
{sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL,
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
|
2009-08-12 03:51:28 +00:00
|
|
|
layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol},
|
2011-12-28 13:24:49 +00:00
|
|
|
/* 18: CD_TANGENT */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(float) * 4 * 4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 19: CD_MDISPS */
|
2009-01-06 18:59:03 +00:00
|
|
|
{sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps,
|
2012-02-21 17:24:21 +00:00
|
|
|
layerFree_mdisps, NULL, layerSwap_mdisps, NULL,
|
2010-01-05 22:33:41 +00:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
2012-02-21 17:24:21 +00:00
|
|
|
layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps},
|
2012-03-22 08:41:50 +00:00
|
|
|
/* 20: CD_PREVIEW_MCOL */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(MCol) * 4, "MCol", 4, "PreviewCol", NULL, NULL, layerInterp_mcol,
|
2009-05-23 03:24:15 +00:00
|
|
|
layerSwap_mcol, layerDefault_mcol},
|
2011-09-03 08:18:43 +00:00
|
|
|
/* 21: CD_ID_MCOL */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(MCol) * 4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol,
|
2009-10-22 23:22:05 +00:00
|
|
|
layerSwap_mcol, layerDefault_mcol},
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 22: CD_TEXTURE_MCOL */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(MCol) * 4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol,
|
2009-10-22 23:22:05 +00:00
|
|
|
layerSwap_mcol, layerDefault_mcol},
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 23: CD_CLOTH_ORCO */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 24: CD_RECAST */
|
2012-05-01 20:08:23 +00:00
|
|
|
{sizeof(MRecast), "MRecast", 1, "Recast", NULL, NULL, NULL, NULL},
|
2011-12-28 13:11:46 +00:00
|
|
|
|
|
|
|
/* BMESH ONLY */
|
|
|
|
/* 25: CD_MPOLY */
|
|
|
|
{sizeof(MPoly), "MPoly", 1, "NGon Face", NULL, NULL, NULL, NULL, NULL},
|
|
|
|
/* 26: CD_MLOOP */
|
|
|
|
{sizeof(MLoop), "MLoop", 1, "NGon Face-Vertex", NULL, NULL, NULL, NULL, NULL},
|
|
|
|
/* 27: CD_SHAPE_KEYINDEX */
|
2009-11-01 00:06:53 +00:00
|
|
|
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 28: CD_SHAPEKEY */
|
2012-05-12 16:11:34 +00:00
|
|
|
{sizeof(float) * 3, "", 0, "ShapeKey", NULL, NULL, layerInterp_shapekey},
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 29: CD_BWEIGHT */
|
2010-07-14 22:06:10 +00:00
|
|
|
{sizeof(float), "", 0, "BevelWeight", NULL, NULL, layerInterp_bweight},
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 30: CD_CREASE */
|
2010-07-14 22:06:10 +00:00
|
|
|
{sizeof(float), "", 0, "SubSurfCrease", NULL, NULL, layerInterp_bweight},
|
2012-05-01 17:51:03 +00:00
|
|
|
/* 31: CD_ORIGSPACE_MLOOP */
|
2012-02-05 11:30:26 +00:00
|
|
|
{sizeof(OrigSpaceLoop), "OrigSpaceLoop", 1, "OS Loop", NULL, NULL, layerInterp_mloop_origspace, NULL, NULL,
|
|
|
|
layerEqual_mloop_origspace, layerMultiply_mloop_origspace, layerInitMinMax_mloop_origspace,
|
|
|
|
layerAdd_mloop_origspace, layerDoMinMax_mloop_origspace, layerCopyValue_mloop_origspace},
|
2012-03-22 08:41:50 +00:00
|
|
|
/* 32: CD_PREVIEW_MLOOPCOL */
|
|
|
|
{sizeof(MLoopCol), "MLoopCol", 1, "PreviewLoopCol", NULL, NULL, layerInterp_mloopcol, NULL,
|
2010-07-19 04:44:37 +00:00
|
|
|
layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
|
|
|
|
layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol},
|
2012-02-22 16:08:30 +00:00
|
|
|
/* 33: CD_BM_ELEM_PYPTR */
|
|
|
|
{sizeof(void *), "", 1, NULL, layerCopy_bmesh_elem_py_ptr,
|
|
|
|
layerFree_bmesh_elem_py_ptr, NULL, NULL, NULL},
|
|
|
|
|
2011-12-28 13:11:46 +00:00
|
|
|
/* END BMESH ONLY */
|
|
|
|
|
2012-05-10 20:33:24 +00:00
|
|
|
/* 34: CD_PAINT_MASK */
|
|
|
|
{sizeof(float), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
|
|
|
/* 35: CD_GRID_PAINT_MASK */
|
|
|
|
{sizeof(GridPaintMask), "GridPaintMask", 1, NULL, layerCopy_grid_paint_mask,
|
2012-05-22 15:18:43 +00:00
|
|
|
layerFree_grid_paint_mask, NULL, NULL, NULL},
|
|
|
|
/* 36: CD_SKIN_NODE */
|
2012-09-21 06:14:22 +00:00
|
|
|
{sizeof(MVertSkin), "MVertSkin", 1, NULL, NULL, NULL,
|
2012-05-22 15:18:43 +00:00
|
|
|
layerInterp_mvert_skin, NULL, layerDefault_mvert_skin}
|
2006-11-11 16:38:37 +00:00
|
|
|
};
|
|
|
|
|
2011-09-10 23:49:39 +00:00
|
|
|
/* note, numbers are from trunk and need updating for bmesh */
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace",
|
|
|
|
/* 5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags",
|
2012-04-29 15:47:02 +00:00
|
|
|
/* 10-14 */ "CDMFloatProperty", "CDMIntProperty", "CDMStringProperty", "CDOrigSpace", "CDOrco",
|
2011-12-28 13:11:46 +00:00
|
|
|
/* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps",
|
2012-05-12 16:11:34 +00:00
|
|
|
/* 20-24 */ "CDPreviewMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast",
|
2011-12-28 13:11:46 +00:00
|
|
|
|
|
|
|
/* BMESH ONLY */
|
|
|
|
/* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight",
|
2012-05-10 20:33:24 +00:00
|
|
|
/* 30-34 */ "CDSubSurfCrease", "CDOrigSpaceLoop", "CDPreviewLoopCol", "CDBMElemPyPtr", "CDPaintMask",
|
2012-05-22 15:18:43 +00:00
|
|
|
/* 35-36 */ "CDGridPaintMask", "CDMVertSkin"
|
2010-05-27 08:42:59 +00: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 04:28:02 +00:00
|
|
|
|
|
|
|
|
2006-12-05 17:42:03 +00:00
|
|
|
const CustomDataMask CD_MASK_BAREMESH =
|
2012-05-12 16:11:34 +00:00
|
|
|
CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE | CD_MASK_MLOOP | CD_MASK_MPOLY | CD_MASK_BWEIGHT;
|
2006-12-05 17:42:03 +00:00
|
|
|
const CustomDataMask CD_MASK_MESH =
|
2012-05-12 16:11:34 +00:00
|
|
|
CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
|
|
|
|
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL |
|
|
|
|
CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS |
|
|
|
|
CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MPOLY | CD_MASK_MLOOP |
|
|
|
|
CD_MASK_MTEXPOLY | CD_MASK_NORMAL | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
|
2012-05-22 15:18:43 +00:00
|
|
|
CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN;
|
2006-12-05 17:42:03 +00:00
|
|
|
const CustomDataMask CD_MASK_EDITMESH =
|
2012-05-12 16:11:34 +00:00
|
|
|
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MLOOPUV |
|
|
|
|
CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_SHAPE_KEYINDEX |
|
|
|
|
CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR |
|
|
|
|
CD_MASK_MDISPS | CD_MASK_SHAPEKEY | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
|
2012-05-22 15:29:27 +00:00
|
|
|
CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN;
|
2006-12-05 17:42:03 +00:00
|
|
|
const CustomDataMask CD_MASK_DERIVEDMESH =
|
2012-05-12 16:11:34 +00:00
|
|
|
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
|
|
|
|
CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_CLOTH_ORCO |
|
|
|
|
CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_PREVIEW_MLOOPCOL |
|
|
|
|
CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORCO | CD_MASK_TANGENT |
|
|
|
|
CD_MASK_PREVIEW_MCOL | CD_MASK_NORMAL | CD_MASK_SHAPEKEY | CD_MASK_RECAST |
|
2012-10-30 19:20:17 +00:00
|
|
|
CD_MASK_ORIGINDEX | CD_MASK_MVERT_SKIN;
|
2012-05-12 16:11:34 +00:00
|
|
|
const CustomDataMask CD_MASK_BMESH =
|
|
|
|
CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
|
|
|
|
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
|
|
|
|
CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
|
|
|
|
CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
|
2012-05-22 15:18:43 +00:00
|
|
|
CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN;
|
2008-07-08 02:22:37 +00:00
|
|
|
const CustomDataMask CD_MASK_FACECORNERS =
|
2012-05-12 16:11:34 +00:00
|
|
|
CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
|
|
|
|
CD_MASK_MLOOPCOL;
|
2008-07-08 02:22:37 +00:00
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
static const LayerTypeInfo *layerType_getInfo(int type)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (type < 0 || type >= CD_NUMTYPES) return NULL;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
return &LAYERTYPEINFO[type];
|
|
|
|
}
|
|
|
|
|
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 04:28:02 +00:00
|
|
|
static const char *layerType_getName(int type)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (type < 0 || type >= CD_NUMTYPES) return NULL;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
|
|
|
|
return LAYERTYPENAMES[type];
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 21:02:44 +00:00
|
|
|
void customData_mask_layers__print(CustomDataMask mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-28 21:25:17 +00:00
|
|
|
printf("mask=0x%lx:\n", (long unsigned int)mask);
|
2012-05-28 21:02:44 +00:00
|
|
|
for (i = 0; i < CD_NUMTYPES; i++) {
|
2012-05-28 21:25:17 +00:00
|
|
|
if (mask & CD_TYPE_AS_MASK(i)) {
|
2012-05-28 21:02:44 +00:00
|
|
|
printf(" %s\n", layerType_getName(i));
|
2012-05-28 21:25:17 +00:00
|
|
|
}
|
2012-05-28 21:02:44 +00: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 04:28:02 +00:00
|
|
|
/********************* CustomData functions *********************/
|
2006-12-12 21:29:09 +00:00
|
|
|
static void customData_update_offsets(CustomData *data);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
static CustomDataLayer *customData_add_layer__internal(CustomData *data,
|
2012-05-12 16:11:34 +00:00
|
|
|
int type, int alloctype, void *layerdata, int totelem, const char *name);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2011-05-11 02:14:43 +00:00
|
|
|
void CustomData_update_typemap(CustomData *data)
|
2009-09-15 15:32:09 +00:00
|
|
|
{
|
|
|
|
int i, lasttype = -1;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < CD_NUMTYPES; i++) {
|
2009-09-15 15:32:09 +00:00
|
|
|
data->typemap[i] = -1;
|
|
|
|
}
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2009-09-15 15:32:09 +00:00
|
|
|
if (data->layers[i].type != lasttype) {
|
|
|
|
data->typemap[data->layers[i].type] = i;
|
|
|
|
}
|
|
|
|
lasttype = data->layers[i].type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 09:50:24 +00:00
|
|
|
static int customdata_typemap_is_valid(const CustomData *data)
|
|
|
|
{
|
|
|
|
CustomData data_copy = *data;
|
|
|
|
CustomData_update_typemap(&data_copy);
|
|
|
|
return (memcmp(data->typemap, data_copy.typemap, sizeof(data->typemap)) == 0);
|
|
|
|
}
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataMask mask, int alloctype, int totelem)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2011-01-13 04:53:55 +00:00
|
|
|
/*const LayerTypeInfo *typeInfo;*/
|
2006-12-12 21:29:09 +00:00
|
|
|
CustomDataLayer *layer, *newlayer;
|
2011-10-31 00:10:51 +00:00
|
|
|
void *data;
|
2010-03-30 12:01:17 +00:00
|
|
|
int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0, lastflag = 0;
|
2011-05-09 04:06:48 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < source->totlayer; ++i) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
layer = &source->layers[i];
|
2011-01-13 04:53:55 +00:00
|
|
|
/*typeInfo = layerType_getInfo(layer->type);*/ /*UNUSED*/
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
type = layer->type;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if (type != lasttype) {
|
|
|
|
number = 0;
|
|
|
|
lastactive = layer->active;
|
2007-05-02 00:01:23 +00:00
|
|
|
lastrender = layer->active_rnd;
|
2008-12-14 17:32:24 +00:00
|
|
|
lastclone = layer->active_clone;
|
|
|
|
lastmask = layer->active_mask;
|
2006-12-12 21:29:09 +00:00
|
|
|
lasttype = type;
|
2010-03-30 12:01:17 +00:00
|
|
|
lastflag = layer->flag;
|
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 04:28:02 +00:00
|
|
|
}
|
2006-12-12 21:29:09 +00:00
|
|
|
else
|
|
|
|
number++;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (lastflag & CD_FLAG_NOCOPY) continue;
|
|
|
|
else if (!(mask & CD_TYPE_AS_MASK(type))) continue;
|
|
|
|
else if (number < CustomData_number_of_layers(dest, type)) continue;
|
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 04:28:02 +00:00
|
|
|
|
2011-10-31 00:10:51 +00:00
|
|
|
switch (alloctype) {
|
|
|
|
case CD_ASSIGN:
|
|
|
|
case CD_REFERENCE:
|
|
|
|
case CD_DUPLICATE:
|
|
|
|
data = layer->data;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
data = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((alloctype == CD_ASSIGN) && (lastflag & CD_FLAG_NOFREE))
|
2006-12-12 21:29:09 +00:00
|
|
|
newlayer = customData_add_layer__internal(dest, type, CD_REFERENCE,
|
2012-05-12 16:11:34 +00:00
|
|
|
data, totelem, layer->name);
|
2006-12-12 21:29:09 +00:00
|
|
|
else
|
|
|
|
newlayer = customData_add_layer__internal(dest, type, alloctype,
|
2012-05-12 16:11:34 +00:00
|
|
|
data, totelem, layer->name);
|
2006-12-12 21:29:09 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newlayer) {
|
2011-04-15 05:20:18 +00:00
|
|
|
newlayer->uid = layer->uid;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
newlayer->active = lastactive;
|
2007-05-02 00:01:23 +00:00
|
|
|
newlayer->active_rnd = lastrender;
|
2008-12-14 17:32:24 +00:00
|
|
|
newlayer->active_clone = lastclone;
|
|
|
|
newlayer->active_mask = lastmask;
|
2012-05-12 16:11:34 +00:00
|
|
|
newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY);
|
2007-05-02 00:01:23 +00:00
|
|
|
}
|
2006-12-12 21:29:09 +00:00
|
|
|
}
|
2009-09-15 15:32:09 +00:00
|
|
|
|
2011-05-11 02:14:43 +00:00
|
|
|
CustomData_update_typemap(dest);
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataMask mask, int alloctype, int totelem)
|
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 04:28:02 +00:00
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
CustomData_reset(dest);
|
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 04:28:02 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (source->external)
|
2012-05-12 16:11:34 +00:00
|
|
|
dest->external = MEM_dupallocN(source->external);
|
2010-03-30 12:01:17 +00: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 04:28:02 +00:00
|
|
|
CustomData_merge(source, dest, mask, alloctype, totelem);
|
|
|
|
}
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
static void customData_free_layer__internal(CustomDataLayer *layer, int totelem)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(layer->flag & CD_FLAG_NOFREE) && layer->data) {
|
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 04:28:02 +00:00
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->free)
|
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 04:28:02 +00:00
|
|
|
typeInfo->free(layer->data, totelem, typeInfo->size);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer->data)
|
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 04:28:02 +00:00
|
|
|
MEM_freeN(layer->data);
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2009-11-25 14:27:50 +00:00
|
|
|
static void CustomData_external_free(CustomData *data)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->external) {
|
2009-11-25 14:27:50 +00:00
|
|
|
MEM_freeN(data->external);
|
2012-05-12 16:11:34 +00:00
|
|
|
data->external = NULL;
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 09:50:24 +00:00
|
|
|
void CustomData_reset(CustomData *data)
|
|
|
|
{
|
|
|
|
memset(data, 0, sizeof(*data));
|
|
|
|
fill_vn_i(data->typemap, CD_NUMTYPES, -1);
|
|
|
|
}
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
void CustomData_free(CustomData *data, int totelem)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2006-12-12 21:29:09 +00:00
|
|
|
customData_free_layer__internal(&data->layers[i], totelem);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers)
|
2006-08-28 01:12:36 +00:00
|
|
|
MEM_freeN(data->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 04:28:02 +00:00
|
|
|
|
2009-11-25 14:27:50 +00:00
|
|
|
CustomData_external_free(data);
|
2012-10-31 09:50:24 +00:00
|
|
|
CustomData_reset(data);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
static void customData_update_offsets(CustomData *data)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i, offset = 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
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 04:28:02 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
data->layers[i].offset = offset;
|
|
|
|
offset += typeInfo->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->totsize = offset;
|
2011-05-11 02:14:43 +00:00
|
|
|
CustomData_update_typemap(data);
|
2006-12-12 21:29:09 +00:00
|
|
|
}
|
|
|
|
|
2012-10-31 09:50:24 +00:00
|
|
|
/* to use when we're in the middle of modifying layers */
|
|
|
|
static int CustomData_get_layer_index__notypemap(const CustomData *data, int type)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
int i;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2006-12-12 21:29:09 +00:00
|
|
|
return i;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-31 09:50:24 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* index values to access the layers (offset from the layer start) */
|
|
|
|
|
|
|
|
int CustomData_get_layer_index(const CustomData *data, int type)
|
|
|
|
{
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return data->typemap[type];
|
|
|
|
}
|
|
|
|
|
2009-11-02 06:31:23 +00:00
|
|
|
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n)
|
|
|
|
{
|
2011-11-20 16:19:56 +00:00
|
|
|
int i = CustomData_get_layer_index(data, type);
|
2009-11-02 06:31:23 +00:00
|
|
|
|
2011-11-20 16:19:56 +00:00
|
|
|
if (i != -1) {
|
2012-10-31 09:50:24 +00:00
|
|
|
BLI_assert(i + n < data->totlayer);
|
2011-11-20 16:19:56 +00:00
|
|
|
i = (data->layers[i + n].type == type) ? (i + n) : (-1);
|
|
|
|
}
|
2009-11-02 06:31:23 +00:00
|
|
|
|
2011-11-20 16:19:56 +00:00
|
|
|
return i;
|
2009-11-02 06:31:23 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
int CustomData_get_named_layer_index(const CustomData *data, int type, const char *name)
|
2006-12-23 23:33:03 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
|
|
|
if (data->layers[i].type == type && strcmp(data->layers[i].name, name) == 0)
|
2006-12-23 23:33:03 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-12-13 00:50:02 +00:00
|
|
|
int CustomData_get_active_layer_index(const CustomData *data, int type)
|
2006-12-12 21:29:09 +00:00
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? layer_index + data->layers[layer_index].active: -1;
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
|
2007-05-02 00:01:23 +00:00
|
|
|
int CustomData_get_render_layer_index(const CustomData *data, int type)
|
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? layer_index + data->layers[layer_index].active_rnd : -1;
|
2007-05-02 00:01:23 +00:00
|
|
|
}
|
|
|
|
|
2008-12-14 17:32:24 +00:00
|
|
|
int CustomData_get_clone_layer_index(const CustomData *data, int type)
|
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? layer_index + data->layers[layer_index].active_clone : -1;
|
2008-12-14 17:32:24 +00:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:48:13 +00:00
|
|
|
int CustomData_get_stencil_layer_index(const CustomData *data, int type)
|
2008-12-14 17:32:24 +00:00
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? layer_index + data->layers[layer_index].active_mask : -1;
|
|
|
|
}
|
2008-12-14 17:32:24 +00:00
|
|
|
|
|
|
|
|
2012-10-31 09:50:24 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* index values per layer type */
|
2008-12-14 17:32:24 +00:00
|
|
|
|
2007-09-18 19:39:25 +00:00
|
|
|
int CustomData_get_active_layer(const CustomData *data, int type)
|
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? data->layers[layer_index].active : -1;
|
2007-09-18 19:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CustomData_get_render_layer(const CustomData *data, int type)
|
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? data->layers[layer_index].active_rnd : -1;
|
2007-09-18 19:39:25 +00:00
|
|
|
}
|
|
|
|
|
2008-12-14 17:32:24 +00:00
|
|
|
int CustomData_get_clone_layer(const CustomData *data, int type)
|
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? data->layers[layer_index].active_clone : -1;
|
2008-12-14 17:32:24 +00:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:48:13 +00:00
|
|
|
int CustomData_get_stencil_layer(const CustomData *data, int type)
|
2008-12-14 17:32:24 +00:00
|
|
|
{
|
2012-10-31 09:50:24 +00:00
|
|
|
const int layer_index = data->typemap[type];
|
|
|
|
BLI_assert(customdata_typemap_is_valid(data));
|
|
|
|
return (layer_index != -1) ? data->layers[layer_index].active_mask : -1;
|
2008-12-14 17:32:24 +00:00
|
|
|
}
|
2007-09-18 19:39:25 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
void CustomData_set_layer_active(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2006-12-12 21:29:09 +00:00
|
|
|
data->layers[i].active = n;
|
|
|
|
}
|
|
|
|
|
2007-05-02 00:01:23 +00:00
|
|
|
void CustomData_set_layer_render(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2007-05-02 00:01:23 +00:00
|
|
|
data->layers[i].active_rnd = n;
|
|
|
|
}
|
|
|
|
|
2008-12-14 17:32:24 +00:00
|
|
|
void CustomData_set_layer_clone(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2008-12-14 17:32:24 +00:00
|
|
|
data->layers[i].active_clone = n;
|
|
|
|
}
|
|
|
|
|
2009-12-22 10:48:13 +00:00
|
|
|
void CustomData_set_layer_stencil(CustomData *data, int type, int n)
|
2008-12-14 17:32:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2008-12-14 17:32:24 +00:00
|
|
|
data->layers[i].active_mask = n;
|
|
|
|
}
|
|
|
|
|
2007-09-12 02:13:35 +00:00
|
|
|
/* for using with an index from CustomData_get_active_layer_index and CustomData_get_render_layer_index */
|
|
|
|
void CustomData_set_layer_active_index(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2012-05-12 16:11:34 +00:00
|
|
|
data->layers[i].active = n - i;
|
2007-09-12 02:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_set_layer_render_index(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2012-05-12 16:11:34 +00:00
|
|
|
data->layers[i].active_rnd = n - i;
|
2007-09-12 02:13:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-14 17:32:24 +00:00
|
|
|
void CustomData_set_layer_clone_index(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2012-05-12 16:11:34 +00:00
|
|
|
data->layers[i].active_clone = n - i;
|
2008-12-14 17:32:24 +00:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:48:13 +00:00
|
|
|
void CustomData_set_layer_stencil_index(CustomData *data, int type, int n)
|
2008-12-14 17:32:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2012-05-12 16:11:34 +00:00
|
|
|
data->layers[i].active_mask = n - i;
|
2008-12-14 17:32:24 +00:00
|
|
|
}
|
2007-05-02 00:01:23 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
void CustomData_set_layer_flag(struct CustomData *data, int type, int flag)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].type == type)
|
2006-12-12 21:29:09 +00:00
|
|
|
data->layers[i].flag |= flag;
|
|
|
|
}
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
static int customData_resize(CustomData *data, int amount)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataLayer *tmp = MEM_callocN(sizeof(*tmp) * (data->maxlayer + amount),
|
|
|
|
"CustomData->layers");
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!tmp) return 0;
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
data->maxlayer += amount;
|
|
|
|
if (data->layers) {
|
|
|
|
memcpy(tmp, data->layers, sizeof(*tmp) * data->totlayer);
|
|
|
|
MEM_freeN(data->layers);
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
data->layers = tmp;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
static CustomDataLayer *customData_add_layer__internal(CustomData *data,
|
2012-05-12 16:11:34 +00:00
|
|
|
int type, int alloctype, void *layerdata, int totelem, const char *name)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
2006-12-12 21:29:09 +00:00
|
|
|
int size = typeInfo->size * totelem, flag = 0, index = data->totlayer;
|
2011-11-20 16:19:56 +00:00
|
|
|
void *newlayerdata = NULL;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2011-10-31 00:10:51 +00:00
|
|
|
/* Passing a layerdata to copy from with an alloctype that won't copy is
|
2012-03-03 20:19:11 +00:00
|
|
|
* most likely a bug */
|
2011-10-31 00:10:51 +00:00
|
|
|
BLI_assert(!layerdata ||
|
|
|
|
(alloctype == CD_ASSIGN) ||
|
|
|
|
(alloctype == CD_DUPLICATE) ||
|
|
|
|
(alloctype == CD_REFERENCE));
|
|
|
|
|
2011-05-09 04:06:48 +00:00
|
|
|
if (!typeInfo->defaultname && CustomData_has_layer(data, type))
|
2007-01-06 20:16:06 +00:00
|
|
|
return &data->layers[CustomData_get_layer_index(data, type)];
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) {
|
2006-12-12 21:29:09 +00:00
|
|
|
newlayerdata = layerdata;
|
|
|
|
}
|
2011-11-20 16:19:56 +00:00
|
|
|
else if (size > 0) {
|
2006-12-12 21:29:09 +00:00
|
|
|
newlayerdata = MEM_callocN(size, layerType_getName(type));
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!newlayerdata)
|
2006-12-12 21:29:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-27 02:56:41 +00:00
|
|
|
if (alloctype == CD_DUPLICATE && layerdata) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo->copy(layerdata, newlayerdata, totelem);
|
|
|
|
else
|
|
|
|
memcpy(newlayerdata, layerdata, size);
|
|
|
|
}
|
|
|
|
else if (alloctype == CD_DEFAULT) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->set_default)
|
2012-05-12 16:11:34 +00:00
|
|
|
typeInfo->set_default((char *)newlayerdata, totelem);
|
2006-12-12 21:29:09 +00:00
|
|
|
}
|
|
|
|
else if (alloctype == CD_REFERENCE)
|
|
|
|
flag |= CD_FLAG_NOFREE;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (index >= data->maxlayer) {
|
|
|
|
if (!customData_resize(data, CUSTOMDATA_GROW)) {
|
|
|
|
if (newlayerdata != layerdata)
|
2006-12-12 21:29:09 +00:00
|
|
|
MEM_freeN(newlayerdata);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-21 13:47:27 +00:00
|
|
|
data->totlayer++;
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* keep layers ordered by type */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (; index > 0 && data->layers[index - 1].type > type; --index)
|
2006-08-28 01:12:36 +00:00
|
|
|
data->layers[index] = data->layers[index - 1];
|
|
|
|
|
|
|
|
data->layers[index].type = type;
|
|
|
|
data->layers[index].flag = flag;
|
2006-12-12 21:29:09 +00:00
|
|
|
data->layers[index].data = newlayerdata;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
if (name || (name = typeInfo->defaultname)) {
|
2012-01-11 08:51:06 +00:00
|
|
|
BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name));
|
2006-12-21 13:47:27 +00:00
|
|
|
CustomData_set_layer_unique_name(data, index);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
data->layers[index].name[0] = '\0';
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
if (index > 0 && data->layers[index - 1].type == type) {
|
|
|
|
data->layers[index].active = data->layers[index - 1].active;
|
|
|
|
data->layers[index].active_rnd = data->layers[index - 1].active_rnd;
|
|
|
|
data->layers[index].active_clone = data->layers[index - 1].active_clone;
|
|
|
|
data->layers[index].active_mask = data->layers[index - 1].active_mask;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-12-12 21:29:09 +00:00
|
|
|
data->layers[index].active = 0;
|
2007-05-02 00:01:23 +00:00
|
|
|
data->layers[index].active_rnd = 0;
|
2008-12-14 17:32:24 +00:00
|
|
|
data->layers[index].active_clone = 0;
|
|
|
|
data->layers[index].active_mask = 0;
|
2007-05-02 00:01:23 +00:00
|
|
|
}
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
customData_update_offsets(data);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
return &data->layers[index];
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
void *CustomData_add_layer(CustomData *data, int type, int alloctype,
|
2012-05-12 16:11:34 +00:00
|
|
|
void *layerdata, int totelem)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
CustomDataLayer *layer;
|
2012-05-12 16:11:34 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
2006-12-12 21:29:09 +00:00
|
|
|
|
|
|
|
layer = customData_add_layer__internal(data, type, alloctype, layerdata,
|
2012-05-12 16:11:34 +00:00
|
|
|
totelem, typeInfo->defaultname);
|
2011-05-11 02:14:43 +00:00
|
|
|
CustomData_update_typemap(data);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer)
|
2006-12-12 21:29:09 +00:00
|
|
|
return layer->data;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
return NULL;
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
2006-12-24 11:15:54 +00:00
|
|
|
/*same as above but accepts a name*/
|
|
|
|
void *CustomData_add_layer_named(CustomData *data, int type, int alloctype,
|
2012-05-12 16:11:34 +00:00
|
|
|
void *layerdata, int totelem, const char *name)
|
2006-12-24 11:15:54 +00:00
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
|
|
|
|
layer = customData_add_layer__internal(data, type, alloctype, layerdata,
|
2012-05-12 16:11:34 +00:00
|
|
|
totelem, name);
|
2011-05-11 02:14:43 +00:00
|
|
|
CustomData_update_typemap(data);
|
2006-12-24 11:15:54 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer)
|
2006-12-24 11:15:54 +00:00
|
|
|
return layer->data;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-23 17:07:02 +00:00
|
|
|
int CustomData_free_layer(CustomData *data, int type, int totelem, int index)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
2006-12-23 17:07:02 +00:00
|
|
|
int i;
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
if (index < 0) return 0;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
customData_free_layer__internal(&data->layers[index], totelem);
|
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 04:28:02 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = index + 1; i < data->totlayer; ++i)
|
|
|
|
data->layers[i - 1] = data->layers[i];
|
2006-11-11 16:38:37 +00: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 04:28:02 +00:00
|
|
|
data->totlayer--;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
/* if layer was last of type in array, set new active layer */
|
|
|
|
if ((index >= data->totlayer) || (data->layers[index].type != type)) {
|
2012-10-31 09:50:24 +00:00
|
|
|
i = CustomData_get_layer_index__notypemap(data, type);
|
2006-12-12 21:29:09 +00:00
|
|
|
|
|
|
|
if (i >= 0)
|
2007-05-02 00:01:23 +00:00
|
|
|
for (; i < data->totlayer && data->layers[i].type == type; i++) {
|
2006-12-12 21:29:09 +00:00
|
|
|
data->layers[i].active--;
|
2007-05-02 00:01:23 +00:00
|
|
|
data->layers[i].active_rnd--;
|
2008-12-14 17:32:24 +00:00
|
|
|
data->layers[i].active_clone--;
|
|
|
|
data->layers[i].active_mask--;
|
2007-05-02 00:01:23 +00:00
|
|
|
}
|
2006-12-12 21:29:09 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
|
2006-11-11 16:38:37 +00:00
|
|
|
customData_resize(data, -CUSTOMDATA_GROW);
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
customData_update_offsets(data);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-12-23 17:07:02 +00:00
|
|
|
int CustomData_free_layer_active(CustomData *data, int type, int totelem)
|
|
|
|
{
|
|
|
|
int index = 0;
|
|
|
|
index = CustomData_get_active_layer_index(data, type);
|
|
|
|
if (index < 0) return 0;
|
|
|
|
return CustomData_free_layer(data, type, totelem, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
void CustomData_free_layers(CustomData *data, int type, int totelem)
|
|
|
|
{
|
|
|
|
while (CustomData_has_layer(data, type))
|
2006-12-23 17:07:02 +00:00
|
|
|
CustomData_free_layer_active(data, type, totelem);
|
2006-12-12 21:29:09 +00: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 04:28:02 +00:00
|
|
|
int CustomData_has_layer(const CustomData *data, int type)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
return (CustomData_get_layer_index(data, type) != -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CustomData_number_of_layers(const CustomData *data, int type)
|
|
|
|
{
|
|
|
|
int i, number = 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++)
|
|
|
|
if (data->layers[i].type == type)
|
2006-12-12 21:29:09 +00:00
|
|
|
number++;
|
|
|
|
|
|
|
|
return number;
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 08:26:53 +00:00
|
|
|
void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int type, const int totelem)
|
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 04:28:02 +00:00
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
/* get the layer index of the first layer of type */
|
2006-12-12 21:29:09 +00:00
|
|
|
layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
|
|
|
|
if (layer->flag & CD_FLAG_NOFREE) {
|
2012-03-01 12:20:18 +00:00
|
|
|
/* MEM_dupallocN won't work in case of complex layers, like e.g.
|
2011-12-19 08:26:53 +00:00
|
|
|
* CD_MDEFORMVERT, which has pointers to allocated data...
|
|
|
|
* So in case a custom copy function is defined, use it!
|
|
|
|
*/
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy) {
|
2011-12-19 08:26:53 +00:00
|
|
|
char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
|
|
|
|
typeInfo->copy(layer->data, dest_data, totelem);
|
|
|
|
layer->data = dest_data;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
layer->data = MEM_dupallocN(layer->data);
|
|
|
|
|
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 04:28:02 +00:00
|
|
|
layer->flag &= ~CD_FLAG_NOFREE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return layer->data;
|
|
|
|
}
|
|
|
|
|
2007-01-29 15:10:55 +00:00
|
|
|
void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
|
2012-05-12 16:11:34 +00:00
|
|
|
const int type, const char *name, const int totelem)
|
2007-01-29 15:10:55 +00:00
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
/* get the layer index of the desired layer */
|
|
|
|
layer_index = CustomData_get_named_layer_index(data, type, name);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2007-01-29 15:10:55 +00:00
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
|
|
|
|
if (layer->flag & CD_FLAG_NOFREE) {
|
2012-03-01 12:20:18 +00:00
|
|
|
/* MEM_dupallocN won't work in case of complex layers, like e.g.
|
2011-12-19 08:26:53 +00:00
|
|
|
* CD_MDEFORMVERT, which has pointers to allocated data...
|
|
|
|
* So in case a custom copy function is defined, use it!
|
|
|
|
*/
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy) {
|
2011-12-19 08:26:53 +00:00
|
|
|
char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
|
|
|
|
typeInfo->copy(layer->data, dest_data, totelem);
|
|
|
|
layer->data = dest_data;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
layer->data = MEM_dupallocN(layer->data);
|
|
|
|
|
2007-01-29 15:10:55 +00:00
|
|
|
layer->flag &= ~CD_FLAG_NOFREE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return layer->data;
|
|
|
|
}
|
|
|
|
|
2011-12-06 22:55:41 +00:00
|
|
|
int CustomData_is_referenced_layer(struct CustomData *data, int type)
|
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
/* get the layer index of the first layer of type */
|
|
|
|
layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return 0;
|
2011-12-06 22:55:41 +00:00
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
|
|
|
|
return (layer->flag & CD_FLAG_NOFREE) != 0;
|
|
|
|
}
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
void CustomData_free_temporary(CustomData *data, int totelem)
|
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
int i, j;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0, j = 0; i < data->totlayer; ++i) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
|
|
|
|
if (i != j)
|
|
|
|
data->layers[j] = data->layers[i];
|
2011-05-09 04:06:48 +00:00
|
|
|
|
|
|
|
if ((layer->flag & CD_FLAG_TEMPORARY) == CD_FLAG_TEMPORARY)
|
2006-12-12 21:29:09 +00:00
|
|
|
customData_free_layer__internal(layer, totelem);
|
2011-05-09 04:06:48 +00:00
|
|
|
else
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->totlayer = j;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
|
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 04:28:02 +00:00
|
|
|
customData_resize(data, -CUSTOMDATA_GROW);
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
customData_update_offsets(data);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
2006-12-05 17:42:03 +00:00
|
|
|
void CustomData_set_only_copy(const struct CustomData *data,
|
2011-10-27 12:17:02 +00:00
|
|
|
CustomDataMask mask)
|
2006-12-05 17:42:03 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i)
|
|
|
|
if (!(mask & CD_TYPE_AS_MASK(data->layers[i].type)))
|
2006-12-05 17:42:03 +00:00
|
|
|
data->layers[i].flag |= CD_FLAG_NOCOPY;
|
|
|
|
}
|
|
|
|
|
2009-08-18 20:05:08 +00:00
|
|
|
void CustomData_copy_elements(int type, void *source, void *dest, int count)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
|
|
|
if (typeInfo->copy)
|
|
|
|
typeInfo->copy(source, dest, count);
|
|
|
|
else
|
2012-05-12 16:11:34 +00:00
|
|
|
memcpy(dest, source, typeInfo->size * count);
|
2009-08-18 20:05:08 +00: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 04:28:02 +00:00
|
|
|
void CustomData_copy_data(const CustomData *source, CustomData *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
int source_index, int dest_index, int count)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo;
|
2006-08-28 01:12:36 +00:00
|
|
|
int src_i, dest_i;
|
|
|
|
int src_offset;
|
|
|
|
int dest_offset;
|
|
|
|
|
|
|
|
/* copies a layer at a time */
|
|
|
|
dest_i = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (src_i = 0; src_i < source->totlayer; ++src_i) {
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
2012-04-21 15:11:03 +00:00
|
|
|
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest_i >= dest->totlayer) return;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest->layers[dest_i].type == source->layers[src_i].type) {
|
2006-08-28 01:12:36 +00:00
|
|
|
char *src_data = source->layers[src_i].data;
|
|
|
|
char *dest_data = dest->layers[dest_i].data;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo = layerType_getInfo(source->layers[src_i].type);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
src_offset = source_index * typeInfo->size;
|
|
|
|
dest_offset = dest_index * typeInfo->size;
|
2011-03-03 07:10:42 +00:00
|
|
|
|
|
|
|
if (!src_data || !dest_data) {
|
2012-03-24 07:36:32 +00:00
|
|
|
if (src_data != NULL && dest_data != NULL) {
|
|
|
|
printf("%s: warning null data for %s type (%p --> %p), skipping\n",
|
|
|
|
__func__, layerType_getName(source->layers[src_i].type),
|
|
|
|
(void *)src_data, (void *)dest_data);
|
|
|
|
}
|
2011-03-03 07:10:42 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo->copy(src_data + src_offset,
|
2012-05-12 16:11:34 +00:00
|
|
|
dest_data + dest_offset,
|
|
|
|
count);
|
2006-08-28 01:12:36 +00:00
|
|
|
else
|
|
|
|
memcpy(dest_data + dest_offset,
|
2012-05-12 16:11:34 +00:00
|
|
|
src_data + src_offset,
|
|
|
|
count * typeInfo->size);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* if there are multiple source & dest layers of the same type,
|
|
|
|
* we don't want to copy all source layers to the same dest, so
|
|
|
|
* increment dest_i
|
|
|
|
*/
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2006-08-28 01:12:36 +00: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 04:28:02 +00:00
|
|
|
void CustomData_free_elem(CustomData *data, int index, int count)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
|
|
|
if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
|
2006-08-28 01:12:36 +00:00
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->free) {
|
2006-08-28 01:12:36 +00:00
|
|
|
int offset = typeInfo->size * index;
|
|
|
|
|
|
|
|
typeInfo->free((char *)data->layers[i].data + offset,
|
2012-05-12 16:11:34 +00:00
|
|
|
count, typeInfo->size);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SOURCE_BUF_SIZE 100
|
|
|
|
|
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 04:28:02 +00:00
|
|
|
void CustomData_interp(const CustomData *source, CustomData *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
int *src_indices, float *weights, float *sub_weights,
|
|
|
|
int count, int dest_index)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
|
|
|
int src_i, dest_i;
|
|
|
|
int dest_offset;
|
|
|
|
int j;
|
|
|
|
void *source_buf[SOURCE_BUF_SIZE];
|
|
|
|
void **sources = source_buf;
|
|
|
|
|
|
|
|
/* slow fallback in case we're interpolating a ridiculous number of
|
|
|
|
* elements
|
|
|
|
*/
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count > SOURCE_BUF_SIZE)
|
2006-08-28 01:12:36 +00:00
|
|
|
sources = MEM_callocN(sizeof(*sources) * count,
|
2012-05-12 16:11:34 +00:00
|
|
|
"CustomData_interp sources");
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* interpolates a layer at a time */
|
2006-12-12 21:29:09 +00:00
|
|
|
dest_i = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (src_i = 0; src_i < source->totlayer; ++src_i) {
|
2012-05-12 16:11:34 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!typeInfo->interp) continue;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
2012-04-21 15:11:03 +00:00
|
|
|
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2006-12-12 21:29:09 +00:00
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
2012-10-01 14:15:05 +00:00
|
|
|
if (dest_i >= dest->totlayer) break;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
/* if we found a matching layer, copy the data */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest->layers[dest_i].type == source->layers[src_i].type) {
|
2006-12-12 21:29:09 +00:00
|
|
|
void *src_data = source->layers[src_i].data;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-08-23 17:16:11 +00:00
|
|
|
for (j = 0; j < count; ++j) {
|
2012-05-09 09:24:15 +00:00
|
|
|
sources[j] = (char *)src_data + typeInfo->size * src_indices[j];
|
2012-08-23 17:16:11 +00:00
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
dest_offset = dest_index * typeInfo->size;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo->interp(sources, weights, sub_weights, count,
|
2012-05-12 16:11:34 +00:00
|
|
|
(char *)dest->layers[dest_i].data + dest_offset);
|
2006-12-12 21:29:09 +00:00
|
|
|
|
|
|
|
/* if there are multiple source & dest layers of the same type,
|
|
|
|
* we don't want to copy all source layers to the same dest, so
|
|
|
|
* increment dest_i
|
|
|
|
*/
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count > SOURCE_BUF_SIZE) MEM_freeN(sources);
|
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 04:28:02 +00:00
|
|
|
}
|
|
|
|
|
2010-04-10 22:12:10 +00:00
|
|
|
void CustomData_swap(struct CustomData *data, int index, const int *corner_indices)
|
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 04:28:02 +00:00
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->swap) {
|
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 04:28:02 +00:00
|
|
|
int offset = typeInfo->size * index;
|
|
|
|
|
|
|
|
typeInfo->swap((char *)data->layers[i].data + offset, corner_indices);
|
|
|
|
}
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *CustomData_get(const CustomData *data, int index, int type)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
int layer_index;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
/* get the layer index of the active layer of type */
|
|
|
|
layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* get the offset of the desired element */
|
|
|
|
offset = layerType_getInfo(type)->size * index;
|
|
|
|
|
|
|
|
return (char *)data->layers[layer_index].data + offset;
|
|
|
|
}
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
void *CustomData_get_n(const CustomData *data, int type, int index, int n)
|
|
|
|
{
|
|
|
|
int layer_index;
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
/* get the layer index of the first layer of type */
|
2009-09-15 15:32:09 +00:00
|
|
|
layer_index = data->typemap[type];
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2011-11-20 16:19:56 +00:00
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
offset = layerType_getInfo(type)->size * index;
|
2012-05-12 16:11:34 +00:00
|
|
|
return (char *)data->layers[layer_index + n].data + offset;
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
void *CustomData_get_layer(const CustomData *data, int type)
|
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
/* get the layer index of the active layer of type */
|
|
|
|
int layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
return data->layers[layer_index].data;
|
|
|
|
}
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
void *CustomData_get_layer_n(const CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
/* get the layer index of the active layer of type */
|
2011-11-20 16:19:56 +00:00
|
|
|
int layer_index = CustomData_get_layer_index_n(data, type, n);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2006-12-12 21:29:09 +00:00
|
|
|
|
2011-11-20 16:19:56 +00:00
|
|
|
return data->layers[layer_index].data;
|
2006-12-12 21:29:09 +00:00
|
|
|
}
|
|
|
|
|
2007-01-29 15:10:55 +00:00
|
|
|
void *CustomData_get_layer_named(const struct CustomData *data, int type,
|
2012-05-12 16:11:34 +00:00
|
|
|
const char *name)
|
2007-01-29 15:10:55 +00:00
|
|
|
{
|
|
|
|
int layer_index = CustomData_get_named_layer_index(data, type, name);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2007-01-29 15:10:55 +00:00
|
|
|
|
|
|
|
return data->layers[layer_index].data;
|
|
|
|
}
|
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
|
|
|
|
int CustomData_set_layer_name(const CustomData *data, int type, int n, const char *name)
|
|
|
|
{
|
|
|
|
/* get the layer index of the first layer of type */
|
|
|
|
int layer_index = CustomData_get_layer_index_n(data, type, n);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return 0;
|
2011-05-10 17:01:26 +00:00
|
|
|
if (!name) return 0;
|
|
|
|
|
|
|
|
strcpy(data->layers[layer_index].name, name);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
void *CustomData_set_layer(const CustomData *data, int type, void *ptr)
|
|
|
|
{
|
|
|
|
/* get the layer index of the first layer of type */
|
2006-12-12 21:29:09 +00:00
|
|
|
int layer_index = CustomData_get_active_layer_index(data, type);
|
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 04:28:02 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
|
|
|
|
data->layers[layer_index].data = ptr;
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2007-01-10 06:09:10 +00:00
|
|
|
void *CustomData_set_layer_n(const struct CustomData *data, int type, int n, void *ptr)
|
|
|
|
{
|
|
|
|
/* get the layer index of the first layer of type */
|
2011-11-20 16:19:56 +00:00
|
|
|
int layer_index = CustomData_get_layer_index_n(data, type, n);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2007-01-10 06:09:10 +00:00
|
|
|
|
2011-11-20 16:19:56 +00:00
|
|
|
data->layers[layer_index].data = ptr;
|
2007-01-10 06:09:10 +00:00
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
void CustomData_set(const CustomData *data, int index, int type, void *source)
|
|
|
|
{
|
|
|
|
void *dest = CustomData_get(data, index, type);
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!dest) return;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo->copy(source, dest, 1);
|
2006-08-28 01:12:36 +00:00
|
|
|
else
|
2006-12-12 21:29:09 +00:00
|
|
|
memcpy(dest, source, typeInfo->size);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2012-08-17 14:43:20 +00:00
|
|
|
/* BMesh functions */
|
|
|
|
/* needed to convert to/from different face reps */
|
2009-07-14 06:13:43 +00:00
|
|
|
void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata,
|
2012-04-21 13:37:26 +00:00
|
|
|
int totloop, int totpoly)
|
2008-07-08 02:22:37 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < fdata->totlayer; i++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (fdata->layers[i].type == CD_MTFACE) {
|
2011-10-31 00:10:51 +00:00
|
|
|
CustomData_add_layer_named(pdata, CD_MTEXPOLY, CD_CALLOC, NULL, totpoly, fdata->layers[i].name);
|
|
|
|
CustomData_add_layer_named(ldata, CD_MLOOPUV, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
2011-11-20 16:19:56 +00:00
|
|
|
else if (fdata->layers[i].type == CD_MCOL) {
|
2011-10-31 00:10:51 +00:00
|
|
|
CustomData_add_layer_named(ldata, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
|
2011-11-20 16:19:56 +00:00
|
|
|
}
|
|
|
|
else if (fdata->layers[i].type == CD_MDISPS) {
|
2011-10-31 00:10:51 +00:00
|
|
|
CustomData_add_layer_named(ldata, CD_MDISPS, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
|
2011-11-20 16:19:56 +00:00
|
|
|
}
|
2009-09-15 15:32:09 +00:00
|
|
|
}
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
2011-11-20 16:19:56 +00:00
|
|
|
|
2011-11-07 09:02:10 +00:00
|
|
|
void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total)
|
|
|
|
{
|
2008-07-08 02:22:37 +00:00
|
|
|
int i;
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < pdata->totlayer; i++) {
|
2011-11-20 16:19:56 +00:00
|
|
|
if (pdata->layers[i].type == CD_MTEXPOLY) {
|
2011-05-10 17:01:26 +00:00
|
|
|
CustomData_add_layer_named(fdata, CD_MTFACE, CD_CALLOC, NULL, total, pdata->layers[i].name);
|
2011-11-20 16:19:56 +00:00
|
|
|
}
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < ldata->totlayer; i++) {
|
2011-11-20 16:19:56 +00:00
|
|
|
if (ldata->layers[i].type == CD_MLOOPCOL) {
|
2011-05-10 17:01:26 +00:00
|
|
|
CustomData_add_layer_named(fdata, CD_MCOL, CD_CALLOC, NULL, total, ldata->layers[i].name);
|
2011-11-20 16:19:56 +00:00
|
|
|
}
|
2012-03-22 08:41:50 +00:00
|
|
|
else if (ldata->layers[i].type == CD_PREVIEW_MLOOPCOL) {
|
|
|
|
CustomData_add_layer_named(fdata, CD_PREVIEW_MCOL, CD_CALLOC, NULL, total, ldata->layers[i].name);
|
2011-11-20 16:19:56 +00:00
|
|
|
}
|
2012-02-05 11:30:26 +00:00
|
|
|
else if (ldata->layers[i].type == CD_ORIGSPACE_MLOOP) {
|
|
|
|
CustomData_add_layer_named(fdata, CD_ORIGSPACE, CD_CALLOC, NULL, total, ldata->layers[i].name);
|
|
|
|
}
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
2012-04-10 14:58:21 +00:00
|
|
|
|
|
|
|
CustomData_bmesh_update_active_layers(fdata, pdata, ldata);
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 09:49:27 +00:00
|
|
|
void CustomData_bmesh_update_active_layers(CustomData *fdata, CustomData *pdata, CustomData *ldata)
|
|
|
|
{
|
|
|
|
int act;
|
|
|
|
|
|
|
|
if (CustomData_has_layer(pdata, CD_MTEXPOLY)) {
|
|
|
|
act = CustomData_get_active_layer(pdata, CD_MTEXPOLY);
|
|
|
|
CustomData_set_layer_active(ldata, CD_MLOOPUV, act);
|
|
|
|
CustomData_set_layer_active(fdata, CD_MTFACE, act);
|
|
|
|
|
|
|
|
act = CustomData_get_render_layer(pdata, CD_MTEXPOLY);
|
|
|
|
CustomData_set_layer_render(ldata, CD_MLOOPUV, act);
|
|
|
|
CustomData_set_layer_render(fdata, CD_MTFACE, act);
|
|
|
|
|
|
|
|
act = CustomData_get_clone_layer(pdata, CD_MTEXPOLY);
|
|
|
|
CustomData_set_layer_clone(ldata, CD_MLOOPUV, act);
|
|
|
|
CustomData_set_layer_clone(fdata, CD_MTFACE, act);
|
|
|
|
|
|
|
|
act = CustomData_get_stencil_layer(pdata, CD_MTEXPOLY);
|
|
|
|
CustomData_set_layer_stencil(ldata, CD_MLOOPUV, act);
|
|
|
|
CustomData_set_layer_stencil(fdata, CD_MTFACE, act);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CustomData_has_layer(ldata, CD_MLOOPCOL)) {
|
|
|
|
act = CustomData_get_active_layer(ldata, CD_MLOOPCOL);
|
|
|
|
CustomData_set_layer_active(fdata, CD_MCOL, act);
|
|
|
|
|
|
|
|
act = CustomData_get_render_layer(ldata, CD_MLOOPCOL);
|
|
|
|
CustomData_set_layer_render(fdata, CD_MCOL, act);
|
|
|
|
|
|
|
|
act = CustomData_get_clone_layer(ldata, CD_MLOOPCOL);
|
|
|
|
CustomData_set_layer_clone(fdata, CD_MCOL, act);
|
|
|
|
|
|
|
|
act = CustomData_get_stencil_layer(ldata, CD_MLOOPCOL);
|
|
|
|
CustomData_set_layer_stencil(fdata, CD_MCOL, act);
|
|
|
|
}
|
|
|
|
}
|
2008-07-08 02:22:37 +00:00
|
|
|
|
2012-06-07 09:11:16 +00:00
|
|
|
/* update active indices for active/render/clone/stencil custom data layers
|
|
|
|
* based on indices from fdata layers
|
|
|
|
* used by do_versions in readfile.c when creating pdata and ldata for pre-bmesh
|
|
|
|
* meshes and needed to preserve active/render/clone/stencil flags set in pre-bmesh files
|
|
|
|
*/
|
|
|
|
void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata, CustomData *pdata, CustomData *ldata)
|
|
|
|
{
|
|
|
|
int act;
|
|
|
|
|
|
|
|
if (CustomData_has_layer(fdata, CD_MTFACE)) {
|
|
|
|
act = CustomData_get_active_layer(fdata, CD_MTFACE);
|
|
|
|
CustomData_set_layer_active(pdata, CD_MTEXPOLY, act);
|
|
|
|
CustomData_set_layer_active(ldata, CD_MLOOPUV, act);
|
|
|
|
|
|
|
|
act = CustomData_get_render_layer(fdata, CD_MTFACE);
|
|
|
|
CustomData_set_layer_render(pdata, CD_MTEXPOLY, act);
|
|
|
|
CustomData_set_layer_render(ldata, CD_MLOOPUV, act);
|
|
|
|
|
|
|
|
act = CustomData_get_clone_layer(fdata, CD_MTFACE);
|
|
|
|
CustomData_set_layer_clone(pdata, CD_MTEXPOLY, act);
|
|
|
|
CustomData_set_layer_clone(ldata, CD_MLOOPUV, act);
|
|
|
|
|
|
|
|
act = CustomData_get_stencil_layer(fdata, CD_MTFACE);
|
|
|
|
CustomData_set_layer_stencil(pdata, CD_MTEXPOLY, act);
|
|
|
|
CustomData_set_layer_stencil(ldata, CD_MLOOPUV, act);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CustomData_has_layer(fdata, CD_MCOL)) {
|
|
|
|
act = CustomData_get_active_layer(fdata, CD_MCOL);
|
|
|
|
CustomData_set_layer_active(ldata, CD_MLOOPCOL, act);
|
|
|
|
|
|
|
|
act = CustomData_get_render_layer(fdata, CD_MCOL);
|
|
|
|
CustomData_set_layer_render(ldata, CD_MLOOPCOL, act);
|
|
|
|
|
|
|
|
act = CustomData_get_clone_layer(fdata, CD_MCOL);
|
|
|
|
CustomData_set_layer_clone(ldata, CD_MLOOPCOL, act);
|
|
|
|
|
|
|
|
act = CustomData_get_stencil_layer(fdata, CD_MCOL);
|
|
|
|
CustomData_set_layer_stencil(ldata, CD_MLOOPCOL, act);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-01 22:17:04 +00:00
|
|
|
void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype)
|
2011-11-07 09:02:10 +00:00
|
|
|
{
|
2012-03-01 22:17:04 +00:00
|
|
|
int chunksize;
|
|
|
|
|
2011-10-26 13:24:58 +00:00
|
|
|
/* Dispose old pools before calling here to avoid leaks */
|
|
|
|
BLI_assert(data->pool == NULL);
|
|
|
|
|
2012-03-01 22:17:04 +00:00
|
|
|
switch (htype) {
|
2012-03-01 23:59:34 +00:00
|
|
|
case BM_VERT: chunksize = bm_mesh_chunksize_default.totvert; break;
|
|
|
|
case BM_EDGE: chunksize = bm_mesh_chunksize_default.totedge; break;
|
|
|
|
case BM_LOOP: chunksize = bm_mesh_chunksize_default.totloop; break;
|
|
|
|
case BM_FACE: chunksize = bm_mesh_chunksize_default.totface; break;
|
2012-03-01 22:17:04 +00:00
|
|
|
default:
|
|
|
|
BLI_assert(0);
|
|
|
|
chunksize = 512;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-10-26 13:24:58 +00:00
|
|
|
/* If there are no layers, no pool is needed just yet */
|
|
|
|
if (data->totlayer) {
|
2012-03-01 22:59:18 +00:00
|
|
|
data->pool = BLI_mempool_create(data->totsize, totelem, chunksize, BLI_MEMPOOL_SYSMALLOC);
|
2011-10-26 13:24:58 +00:00
|
|
|
}
|
2008-07-08 02:22:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
|
2012-04-09 02:14:55 +00:00
|
|
|
CustomDataMask mask, int alloctype, BMesh *bm, const char htype)
|
2009-06-23 05:35:49 +00:00
|
|
|
{
|
|
|
|
BMHeader *h;
|
|
|
|
BMIter iter;
|
2012-04-09 02:14:55 +00:00
|
|
|
CustomData destold;
|
2009-06-23 05:35:49 +00:00
|
|
|
void *tmp;
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
int t;
|
2012-04-09 02:14:55 +00:00
|
|
|
|
|
|
|
/* copy old layer description so that old data can be copied into
|
2012-04-22 11:54:53 +00:00
|
|
|
* the new allocation */
|
2012-04-09 02:14:55 +00:00
|
|
|
destold = *dest;
|
|
|
|
if (destold.layers) destold.layers = MEM_dupallocN(destold.layers);
|
2009-06-23 05:35:49 +00:00
|
|
|
|
|
|
|
CustomData_merge(source, dest, mask, alloctype, 0);
|
2012-03-29 11:31:44 +00:00
|
|
|
dest->pool = NULL;
|
2012-03-01 22:17:04 +00:00
|
|
|
CustomData_bmesh_init_pool(dest, 512, htype);
|
2009-06-23 05:35:49 +00:00
|
|
|
|
2012-03-01 22:17:04 +00:00
|
|
|
switch (htype) {
|
2009-06-23 05:35:49 +00:00
|
|
|
case BM_VERT:
|
|
|
|
t = BM_VERTS_OF_MESH; break;
|
|
|
|
case BM_EDGE:
|
|
|
|
t = BM_EDGES_OF_MESH; break;
|
|
|
|
case BM_LOOP:
|
|
|
|
t = BM_LOOPS_OF_FACE; break;
|
|
|
|
case BM_FACE:
|
|
|
|
t = BM_FACES_OF_MESH; break;
|
2011-05-10 23:48:09 +00:00
|
|
|
default: /* should never happen */
|
|
|
|
BLI_assert(!"invalid type given");
|
|
|
|
t = BM_VERTS_OF_MESH;
|
2009-06-23 05:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (t != BM_LOOPS_OF_FACE) {
|
|
|
|
/*ensure all current elements follow new customdata layout*/
|
2012-04-19 12:45:56 +00:00
|
|
|
BM_ITER_MESH (h, &iter, bm, t) {
|
2012-03-29 10:49:17 +00:00
|
|
|
tmp = NULL;
|
2009-06-23 05:35:49 +00:00
|
|
|
CustomData_bmesh_copy_data(&destold, dest, h->data, &tmp);
|
|
|
|
CustomData_bmesh_free_block(&destold, &h->data);
|
|
|
|
h->data = tmp;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-06-23 05:35:49 +00:00
|
|
|
BMFace *f;
|
|
|
|
BMLoop *l;
|
|
|
|
BMIter liter;
|
|
|
|
|
|
|
|
/*ensure all current elements follow new customdata layout*/
|
2012-04-19 13:47:58 +00:00
|
|
|
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
|
|
|
|
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
|
2012-03-29 11:31:44 +00:00
|
|
|
tmp = NULL;
|
2009-08-12 03:51:28 +00:00
|
|
|
CustomData_bmesh_copy_data(&destold, dest, l->head.data, &tmp);
|
|
|
|
CustomData_bmesh_free_block(&destold, &l->head.data);
|
|
|
|
l->head.data = tmp;
|
2009-06-23 05:35:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (destold.pool) BLI_mempool_destroy(destold.pool);
|
2012-04-09 02:14:55 +00:00
|
|
|
if (destold.layers) MEM_freeN(destold.layers);
|
2009-06-23 05:35:49 +00:00
|
|
|
}
|
|
|
|
|
2008-07-04 17:59:16 +00:00
|
|
|
void CustomData_bmesh_free_block(CustomData *data, void **block)
|
|
|
|
{
|
2010-03-22 09:30:00 +00:00
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
2012-10-10 23:44:07 +00:00
|
|
|
if (*block == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
|
|
|
if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
|
2010-03-22 09:30:00 +00:00
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
2008-07-04 17:59:16 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->free) {
|
2008-07-04 17:59:16 +00:00
|
|
|
int offset = data->layers[i].offset;
|
2012-05-12 16:11:34 +00:00
|
|
|
typeInfo->free((char *)*block + offset, 1, typeInfo->size);
|
2008-07-04 17:59:16 +00:00
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-04 17:59:16 +00:00
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
if (data->totsize)
|
|
|
|
BLI_mempool_free(data->pool, *block);
|
|
|
|
|
2008-07-04 17:59:16 +00:00
|
|
|
*block = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (*block)
|
|
|
|
CustomData_bmesh_free_block(data, block);
|
|
|
|
|
|
|
|
if (data->totsize > 0)
|
2010-07-14 22:06:10 +00:00
|
|
|
*block = BLI_mempool_alloc(data->pool);
|
2008-07-04 17:59:16 +00:00
|
|
|
else
|
|
|
|
*block = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
void *src_block, void **dest_block)
|
2008-07-04 17:59:16 +00:00
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int dest_i, src_i;
|
|
|
|
|
2012-10-10 23:44:07 +00:00
|
|
|
if (*dest_block == NULL) {
|
2008-07-04 17:59:16 +00:00
|
|
|
CustomData_bmesh_alloc_block(dest, dest_block);
|
2012-04-04 16:35:13 +00:00
|
|
|
if (*dest_block)
|
|
|
|
memset(*dest_block, 0, dest->totsize);
|
|
|
|
}
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* copies a layer at a time */
|
|
|
|
dest_i = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (src_i = 0; src_i < source->totlayer; ++src_i) {
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
2012-04-21 15:11:03 +00:00
|
|
|
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest_i >= dest->totlayer) return;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest->layers[dest_i].type == source->layers[src_i].type &&
|
2012-05-20 19:49:27 +00:00
|
|
|
strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0)
|
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
char *src_data = (char *)src_block + source->layers[src_i].offset;
|
|
|
|
char *dest_data = (char *)*dest_block + dest->layers[dest_i].offset;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
typeInfo = layerType_getInfo(source->layers[src_i].type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2008-07-04 17:59:16 +00:00
|
|
|
typeInfo->copy(src_data, dest_data, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest_data, src_data, typeInfo->size);
|
|
|
|
|
|
|
|
/* if there are multiple source & dest layers of the same type,
|
|
|
|
* we don't want to copy all source layers to the same dest, so
|
|
|
|
* increment dest_i
|
|
|
|
*/
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2008-07-04 17:59:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Bmesh Custom Data Functions. Should replace editmesh ones with these as well, due to more effecient memory alloc*/
|
|
|
|
void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
|
|
|
|
{
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
/* get the layer index of the first layer of type */
|
|
|
|
layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
return (char *)block + data->layers[layer_index].offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int n)
|
|
|
|
{
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
/* get the layer index of the first layer of type */
|
|
|
|
layer_index = CustomData_get_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return NULL;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
return (char *)block + data->layers[layer_index + n].offset;
|
2008-07-04 17:59:16 +00:00
|
|
|
}
|
|
|
|
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
/*gets from the layer at physical index n, note: doesn't check type.*/
|
|
|
|
void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (n < 0 || n >= data->totlayer) return NULL;
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
|
|
|
|
return (char *)block + data->layers[n].offset;
|
|
|
|
}
|
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
int CustomData_layer_has_math(struct CustomData *data, int layer_n)
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
{
|
2012-03-18 07:38:51 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type);
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
|
|
|
|
if (typeInfo->equal && typeInfo->add && typeInfo->multiply &&
|
2012-04-28 06:31:57 +00:00
|
|
|
typeInfo->initminmax && typeInfo->dominmax)
|
|
|
|
{
|
2012-10-20 17:31:07 +00:00
|
|
|
return TRUE;
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
|
2012-10-20 17:31:07 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-10-20 17:39:56 +00:00
|
|
|
int CustomData_layer_has_interp(struct CustomData *data, int layer_n)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type);
|
|
|
|
|
|
|
|
if (typeInfo->interp) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-10-20 17:31:07 +00:00
|
|
|
int CustomData_has_math(struct CustomData *data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* interpolates a layer at a time */
|
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
|
|
|
if (CustomData_layer_has_math(data, i)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 17:39:56 +00:00
|
|
|
int CustomData_has_interp(struct CustomData *data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* interpolates a layer at a time */
|
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
|
|
|
if (CustomData_layer_has_interp(data, i)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-03 20:19:11 +00:00
|
|
|
/* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
|
|
|
|
* another, while not overwriting anything else (e.g. flags)*/
|
2009-08-12 03:51:28 +00:00
|
|
|
void CustomData_data_copy_value(int type, void *source, void *dest)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!dest) return;
|
2009-08-12 03:51:28 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copyvalue)
|
2009-08-12 03:51:28 +00:00
|
|
|
typeInfo->copyvalue(source, dest);
|
|
|
|
else
|
|
|
|
memcpy(dest, source, typeInfo->size);
|
|
|
|
}
|
|
|
|
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
int CustomData_data_equals(int type, void *data1, void *data2)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
|
|
|
if (typeInfo->equal)
|
|
|
|
return typeInfo->equal(data1, data2);
|
|
|
|
else return !memcmp(data1, data2, typeInfo->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_data_initminmax(int type, void *min, void *max)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
2009-08-12 03:51:28 +00:00
|
|
|
if (typeInfo->initminmax)
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
typeInfo->initminmax(min, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CustomData_data_dominmax(int type, void *data, void *min, void *max)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
2009-08-12 03:51:28 +00:00
|
|
|
if (typeInfo->dominmax)
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
typeInfo->dominmax(data, min, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CustomData_data_multiply(int type, void *data, float fac)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
2009-08-12 03:51:28 +00:00
|
|
|
if (typeInfo->multiply)
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
typeInfo->multiply(data, fac);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CustomData_data_add(int type, void *data1, void *data2)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
2009-08-12 03:51:28 +00:00
|
|
|
if (typeInfo->add)
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
typeInfo->add(data1, data2);
|
|
|
|
}
|
|
|
|
|
2008-07-04 22:32:06 +00:00
|
|
|
void CustomData_bmesh_set(const CustomData *data, void *block, int type, void *source)
|
2008-07-04 17:59:16 +00:00
|
|
|
{
|
|
|
|
void *dest = CustomData_bmesh_get(data, block, type);
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!dest) return;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2008-07-04 17:59:16 +00:00
|
|
|
typeInfo->copy(source, dest, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest, source, typeInfo->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_bmesh_set_n(CustomData *data, void *block, int type, int n, void *source)
|
|
|
|
{
|
|
|
|
void *dest = CustomData_bmesh_get_n(data, block, type, n);
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!dest) return;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2008-07-04 17:59:16 +00:00
|
|
|
typeInfo->copy(source, dest, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest, source, typeInfo->size);
|
|
|
|
}
|
|
|
|
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, void *source)
|
|
|
|
{
|
|
|
|
void *dest = CustomData_bmesh_get_layer_n(data, block, n);
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[n].type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!dest) return;
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
typeInfo->copy(source, dest, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest, source, typeInfo->size);
|
|
|
|
}
|
|
|
|
|
2012-10-20 17:31:07 +00:00
|
|
|
void CustomData_bmesh_interp(CustomData *data, void **src_blocks, const float *weights,
|
|
|
|
const float *sub_weights, int count, void *dest_block)
|
2008-07-04 17:59:16 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
void *source_buf[SOURCE_BUF_SIZE];
|
|
|
|
void **sources = source_buf;
|
|
|
|
|
|
|
|
/* slow fallback in case we're interpolating a ridiculous number of
|
|
|
|
* elements
|
|
|
|
*/
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count > SOURCE_BUF_SIZE)
|
2008-07-04 17:59:16 +00:00
|
|
|
sources = MEM_callocN(sizeof(*sources) * count,
|
2012-05-12 16:11:34 +00:00
|
|
|
"CustomData_interp sources");
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* interpolates a layer at a time */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
2008-07-04 17:59:16 +00:00
|
|
|
CustomDataLayer *layer = &data->layers[i];
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->interp) {
|
2012-08-23 17:16:11 +00:00
|
|
|
for (j = 0; j < count; ++j) {
|
2008-07-04 17:59:16 +00:00
|
|
|
sources[j] = (char *)src_blocks[j] + layer->offset;
|
2012-08-23 17:16:11 +00:00
|
|
|
}
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
typeInfo->interp(sources, weights, sub_weights, count,
|
2012-05-12 16:11:34 +00:00
|
|
|
(char *)dest_block + layer->offset);
|
2008-07-04 17:59:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (count > SOURCE_BUF_SIZE) MEM_freeN(sources);
|
2008-07-04 17:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_bmesh_set_default(CustomData *data, void **block)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
|
|
|
|
2012-10-10 23:44:07 +00:00
|
|
|
if (*block == NULL)
|
2008-07-04 17:59:16 +00:00
|
|
|
CustomData_bmesh_alloc_block(data, block);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < data->totlayer; ++i) {
|
2008-07-04 17:59:16 +00:00
|
|
|
int offset = data->layers[i].offset;
|
|
|
|
|
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->set_default)
|
2012-05-12 16:11:34 +00:00
|
|
|
typeInfo->set_default((char *)*block + offset, 1);
|
|
|
|
else memset((char *)*block + offset, 0, typeInfo->size);
|
2008-07-04 17:59:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
int src_index, void **dest_block)
|
2008-07-04 17:59:16 +00:00
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int dest_i, src_i, src_offset;
|
|
|
|
|
2012-10-10 23:44:07 +00:00
|
|
|
if (*dest_block == NULL)
|
2008-07-04 17:59:16 +00:00
|
|
|
CustomData_bmesh_alloc_block(dest, dest_block);
|
|
|
|
|
|
|
|
/* copies a layer at a time */
|
|
|
|
dest_i = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (src_i = 0; src_i < source->totlayer; ++src_i) {
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
2012-04-21 15:11:03 +00:00
|
|
|
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest_i >= dest->totlayer) return;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest->layers[dest_i].type == source->layers[src_i].type) {
|
2008-07-04 17:59:16 +00:00
|
|
|
int offset = dest->layers[dest_i].offset;
|
|
|
|
char *src_data = source->layers[src_i].data;
|
2012-05-12 16:11:34 +00:00
|
|
|
char *dest_data = (char *)*dest_block + offset;
|
2008-07-04 17:59:16 +00:00
|
|
|
|
|
|
|
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
|
|
|
|
src_offset = src_index * typeInfo->size;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2008-07-04 17:59:16 +00:00
|
|
|
typeInfo->copy(src_data + src_offset, dest_data, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest_data, src_data + src_offset, typeInfo->size);
|
|
|
|
|
|
|
|
/* if there are multiple source & dest layers of the same type,
|
|
|
|
* we don't want to copy all source layers to the same dest, so
|
|
|
|
* increment dest_i
|
|
|
|
*/
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2008-07-04 17:59:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
|
2012-05-12 16:11:34 +00:00
|
|
|
void *src_block, int dest_index)
|
2008-07-04 17:59:16 +00:00
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int dest_i, src_i, dest_offset;
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
/* copies a layer at a time */
|
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 04:28:02 +00:00
|
|
|
dest_i = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (src_i = 0; src_i < source->totlayer; ++src_i) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
2012-04-21 15:11:03 +00:00
|
|
|
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2006-11-11 16:38:37 +00: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 04:28:02 +00:00
|
|
|
/* if there are no more dest layers, we're done */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest_i >= dest->totlayer) return;
|
2006-11-11 16:38:37 +00: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 04:28:02 +00:00
|
|
|
/* if we found a matching layer, copy the data */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dest->layers[dest_i].type == source->layers[src_i].type) {
|
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 04:28:02 +00:00
|
|
|
int offset = source->layers[src_i].offset;
|
2012-05-12 16:11:34 +00:00
|
|
|
char *src_data = (char *)src_block + offset;
|
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 04:28:02 +00:00
|
|
|
char *dest_data = dest->layers[dest_i].data;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
|
|
|
|
dest_offset = dest_index * typeInfo->size;
|
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 04:28:02 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (typeInfo->copy)
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo->copy(src_data, dest_data + dest_offset, 1);
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
else
|
2006-12-12 21:29:09 +00:00
|
|
|
memcpy(dest_data + dest_offset, src_data, typeInfo->size);
|
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 04:28:02 +00:00
|
|
|
|
|
|
|
/* if there are multiple source & dest layers of the same type,
|
|
|
|
* we don't want to copy all source layers to the same dest, so
|
|
|
|
* increment dest_i
|
|
|
|
*/
|
2012-08-18 13:07:48 +00:00
|
|
|
dest_i++;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
}
|
2006-11-11 16:38:37 +00: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 04:28:02 +00:00
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
void CustomData_file_write_info(int type, const char **structname, int *structnum)
|
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 04:28:02 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
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 04:28:02 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
*structname = typeInfo->structname;
|
|
|
|
*structnum = typeInfo->structnum;
|
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 04:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CustomData_sizeof(int type)
|
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
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 04:28:02 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
return typeInfo->size;
|
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 04:28:02 +00:00
|
|
|
}
|
2006-12-05 17:42:03 +00:00
|
|
|
|
|
|
|
const char *CustomData_layertype_name(int type)
|
|
|
|
{
|
|
|
|
return layerType_getName(type);
|
|
|
|
}
|
2006-12-21 13:47:27 +00:00
|
|
|
|
2012-04-30 18:54:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Can only ever be one of these.
|
|
|
|
*/
|
|
|
|
int CustomData_layertype_is_singleton(int type)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
2012-05-04 13:28:02 +00:00
|
|
|
return typeInfo->defaultname == NULL;
|
2012-04-30 18:54:14 +00:00
|
|
|
}
|
|
|
|
|
2007-06-04 19:18:19 +00:00
|
|
|
static int CustomData_is_property_layer(int type)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR))
|
2007-06-04 19:18:19 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-01 07:19:41 +00:00
|
|
|
static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int index)
|
2006-12-21 13:47:27 +00:00
|
|
|
{
|
2010-11-01 07:19:41 +00:00
|
|
|
int i;
|
2006-12-21 13:47:27 +00:00
|
|
|
/* see if there is a duplicate */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (i != index) {
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataLayer *layer = &data->layers[i];
|
2006-12-21 13:47:27 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (CustomData_is_property_layer(type)) {
|
2012-05-12 16:11:34 +00:00
|
|
|
if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name) == 0) {
|
2010-11-01 07:19:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2007-06-04 19:18:19 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-05-12 16:11:34 +00:00
|
|
|
if (i != index && layer->type == type && strcmp(layer->name, name) == 0) {
|
2010-11-01 07:19:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2007-06-04 19:18:19 +00:00
|
|
|
}
|
2006-12-21 13:47:27 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-01 07:19:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-12-21 13:47:27 +00:00
|
|
|
|
2010-11-07 08:49:07 +00:00
|
|
|
static int customdata_unique_check(void *arg, const char *name)
|
2010-11-01 07:19:41 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
struct {CustomData *data; int type; int index; } *data_arg = arg;
|
2010-11-07 08:49:07 +00:00
|
|
|
return cd_layer_find_dupe(data_arg->data, name, data_arg->type, data_arg->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_set_layer_unique_name(CustomData *data, int index)
|
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataLayer *nlayer = &data->layers[index];
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(nlayer->type);
|
2006-12-21 13:47:27 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
struct {CustomData *data; int type; int index; } data_arg;
|
|
|
|
data_arg.data = data;
|
|
|
|
data_arg.type = nlayer->type;
|
|
|
|
data_arg.index = index;
|
2010-11-07 08:49:07 +00:00
|
|
|
|
2010-11-01 07:19:41 +00:00
|
|
|
if (!typeInfo->defaultname)
|
|
|
|
return;
|
2010-11-07 08:49:07 +00:00
|
|
|
|
|
|
|
BLI_uniquename_cb(customdata_unique_check, &data_arg, typeInfo->defaultname, '.', nlayer->name, sizeof(nlayer->name));
|
2006-12-21 13:47:27 +00:00
|
|
|
}
|
|
|
|
|
2012-08-03 22:12:57 +00:00
|
|
|
void CustomData_validate_layer_name(const CustomData *data, int type, const char *name, char *outname)
|
2011-10-13 20:00:22 +00:00
|
|
|
{
|
|
|
|
int index = -1;
|
|
|
|
|
|
|
|
/* if a layer name was given, try to find that layer */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (name[0])
|
2011-10-13 20:00:22 +00:00
|
|
|
index = CustomData_get_named_layer_index(data, type, name);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (index < 0) {
|
2011-10-13 20:00:22 +00:00
|
|
|
/* either no layer was specified, or the layer we want has been
|
2012-03-03 20:19:11 +00:00
|
|
|
* deleted, so assign the active layer to name
|
|
|
|
*/
|
2011-10-13 20:00:22 +00:00
|
|
|
index = CustomData_get_active_layer_index(data, type);
|
|
|
|
strcpy(outname, data->layers[index].name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(outname, name);
|
|
|
|
}
|
|
|
|
|
2007-01-06 20:16:06 +00:00
|
|
|
int CustomData_verify_versions(struct CustomData *data, int index)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
CustomDataLayer *layer = &data->layers[index];
|
|
|
|
int i, keeplayer = 1;
|
|
|
|
|
|
|
|
if (layer->type >= CD_NUMTYPES) {
|
|
|
|
keeplayer = 0; /* unknown layer type from future version */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
|
|
|
if (!typeInfo->defaultname && (index > 0) &&
|
2012-05-12 16:11:34 +00:00
|
|
|
data->layers[index - 1].type == layer->type)
|
2012-04-28 06:31:57 +00:00
|
|
|
{
|
2007-01-06 20:16:06 +00:00
|
|
|
keeplayer = 0; /* multiple layers of which we only support one */
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
2007-01-06 20:16:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!keeplayer) {
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = index + 1; i < data->totlayer; ++i)
|
|
|
|
data->layers[i - 1] = data->layers[i];
|
2007-01-06 20:16:06 +00:00
|
|
|
data->totlayer--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return keeplayer;
|
|
|
|
}
|
|
|
|
|
2009-11-25 14:27:50 +00:00
|
|
|
/****************************** External Files *******************************/
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
|
|
|
BLI_strncpy(filename, external->filename, FILE_MAX);
|
2011-10-08 11:11:54 +00:00
|
|
|
BLI_path_abs(filename, ID_BLEND_PATH(G.main, id));
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2010-10-17 06:38:56 +00:00
|
|
|
void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask mask, int totelem)
|
2010-06-01 19:26:35 +00:00
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2010-06-01 19:26:35 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-10-07 09:48:59 +00:00
|
|
|
if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
|
|
|
|
/* pass */
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
|
|
|
|
if (typeInfo->free)
|
2010-06-01 19:26:35 +00:00
|
|
|
typeInfo->free(layer->data, totelem, typeInfo->size);
|
|
|
|
layer->flag &= ~CD_FLAG_IN_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int totelem)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataExternal *external = data->external;
|
2009-11-25 14:27:50 +00:00
|
|
|
CustomDataLayer *layer;
|
2009-12-10 14:26:06 +00:00
|
|
|
CDataFile *cdf;
|
|
|
|
CDataFileLayer *blay;
|
2009-11-25 14:27:50 +00:00
|
|
|
char filename[FILE_MAX];
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i, update = 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!external)
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2009-11-25 14:27:50 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-10-07 09:48:59 +00:00
|
|
|
if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if (layer->flag & CD_FLAG_IN_MEMORY) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
|
2012-05-12 16:11:34 +00:00
|
|
|
update = 1;
|
2012-10-07 09:48:59 +00:00
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!update)
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
customdata_external_filename(filename, id, external);
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
cdf = cdf_create(CDF_TYPE_MESH);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!cdf_read_open(cdf, filename)) {
|
2010-01-19 15:15:48 +00:00
|
|
|
fprintf(stderr, "Failed to read %s layer from %s.\n", layerType_getName(layer->type), filename);
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
2010-01-19 15:15:48 +00:00
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2009-11-25 14:27:50 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-10-07 09:48:59 +00:00
|
|
|
if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if (layer->flag & CD_FLAG_IN_MEMORY) {
|
|
|
|
/* pass */
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
|
2012-05-12 16:11:34 +00:00
|
|
|
blay = cdf_layer_find(cdf, layer->type, layer->name);
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (blay) {
|
|
|
|
if (cdf_read_layer(cdf, blay)) {
|
2012-10-07 09:48:59 +00:00
|
|
|
if (typeInfo->read(cdf, layer->data, totelem)) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
layer->flag |= CD_FLAG_IN_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
cdf_read_close(cdf);
|
|
|
|
cdf_free(cdf);
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, int totelem, int free)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataExternal *external = data->external;
|
2009-11-25 14:27:50 +00:00
|
|
|
CustomDataLayer *layer;
|
2009-12-10 14:26:06 +00:00
|
|
|
CDataFile *cdf;
|
|
|
|
CDataFileLayer *blay;
|
2009-11-25 14:27:50 +00:00
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i, update = 0;
|
|
|
|
char filename[FILE_MAX];
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!external)
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2010-01-19 15:15:48 +00:00
|
|
|
/* test if there is anything to write */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2009-11-25 14:27:50 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-10-07 09:48:59 +00:00
|
|
|
if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
|
2012-05-12 16:11:34 +00:00
|
|
|
update = 1;
|
2012-10-07 09:48:59 +00:00
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!update)
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2010-01-19 15:15:48 +00:00
|
|
|
/* make sure data is read before we try to write */
|
2009-12-10 14:26:06 +00:00
|
|
|
CustomData_external_read(data, id, mask, totelem);
|
2010-01-19 15:15:48 +00:00
|
|
|
customdata_external_filename(filename, id, external);
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
cdf = cdf_create(CDF_TYPE_MESH);
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2009-11-25 14:27:50 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->filesize) {
|
|
|
|
if (layer->flag & CD_FLAG_IN_MEMORY) {
|
2010-01-19 15:15:48 +00:00
|
|
|
cdf_layer_add(cdf, layer->type, layer->name,
|
2012-05-12 16:11:34 +00:00
|
|
|
typeInfo->filesize(cdf, layer->data, totelem));
|
2010-01-19 15:15:48 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
cdf_free(cdf);
|
|
|
|
return; /* read failed for a layer! */
|
|
|
|
}
|
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!cdf_write_open(cdf, filename)) {
|
2010-01-19 15:15:48 +00:00
|
|
|
fprintf(stderr, "Failed to open %s for writing.\n", filename);
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
2010-01-19 15:15:48 +00:00
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2009-11-25 14:27:50 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
|
2012-05-12 16:11:34 +00:00
|
|
|
blay = cdf_layer_find(cdf, layer->type, layer->name);
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cdf_write_layer(cdf, blay)) {
|
2012-10-07 09:48:59 +00:00
|
|
|
if (typeInfo->write(cdf, layer->data, totelem)) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
2012-10-07 09:48:59 +00:00
|
|
|
else {
|
2009-11-25 14:27:50 +00:00
|
|
|
break;
|
2012-10-07 09:48:59 +00:00
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (i != data->totlayer) {
|
2010-01-19 15:15:48 +00:00
|
|
|
fprintf(stderr, "Failed to write data to %s.\n", filename);
|
2009-12-10 14:26:06 +00:00
|
|
|
cdf_free(cdf);
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2009-11-25 14:27:50 +00:00
|
|
|
layer = &data->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
|
|
|
|
if (free) {
|
|
|
|
if (typeInfo->free)
|
2009-11-25 14:27:50 +00:00
|
|
|
typeInfo->free(layer->data, totelem, typeInfo->size);
|
|
|
|
layer->flag &= ~CD_FLAG_IN_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
cdf_write_close(cdf);
|
|
|
|
cdf_free(cdf);
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2010-10-17 06:38:56 +00:00
|
|
|
void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNUSED(totelem), const char *filename)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataExternal *external = data->external;
|
2009-11-25 14:27:50 +00:00
|
|
|
CustomDataLayer *layer;
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return;
|
2009-11-25 14:27:50 +00:00
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer->flag & CD_FLAG_EXTERNAL)
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!external) {
|
2012-05-12 16:11:34 +00:00
|
|
|
external = MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal");
|
|
|
|
data->external = external;
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
2010-05-07 09:41:26 +00:00
|
|
|
BLI_strncpy(external->filename, filename, sizeof(external->filename));
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY;
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataExternal *external = data->external;
|
2009-11-25 14:27:50 +00:00
|
|
|
CustomDataLayer *layer;
|
2009-12-10 14:26:06 +00:00
|
|
|
//char filename[FILE_MAX];
|
|
|
|
int layer_index; // i, remove_file;
|
2009-11-25 14:27:50 +00:00
|
|
|
|
|
|
|
layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return;
|
2009-11-25 14:27:50 +00:00
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!external)
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer->flag & CD_FLAG_EXTERNAL) {
|
|
|
|
if (!(layer->flag & CD_FLAG_IN_MEMORY))
|
2011-12-23 20:30:23 +00:00
|
|
|
CustomData_external_read(data, id, CD_TYPE_AS_MASK(layer->type), totelem);
|
2009-11-25 14:27:50 +00:00
|
|
|
|
|
|
|
layer->flag &= ~CD_FLAG_EXTERNAL;
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
#if 0
|
2012-05-12 16:11:34 +00:00
|
|
|
remove_file = 1;
|
|
|
|
for (i = 0; i < data->totlayer; i++)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->layers[i].flag & CD_FLAG_EXTERNAL)
|
2012-05-12 16:11:34 +00:00
|
|
|
remove_file = 0;
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (remove_file) {
|
2009-12-10 14:26:06 +00:00
|
|
|
customdata_external_filename(filename, id, external);
|
|
|
|
cdf_remove(filename);
|
2009-11-25 14:27:50 +00:00
|
|
|
CustomData_external_free(data);
|
|
|
|
}
|
2009-12-10 14:26:06 +00:00
|
|
|
#endif
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int CustomData_external_test(CustomData *data, int type)
|
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
layer_index = CustomData_get_active_layer_index(data, type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (layer_index < 0) return 0;
|
2009-11-25 14:27:50 +00:00
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
return (layer->flag & CD_FLAG_EXTERNAL);
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
#if 0
|
|
|
|
void CustomData_external_remove_object(CustomData *data, ID *id)
|
2009-11-25 14:27:50 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
CustomDataExternal *external = data->external;
|
2009-11-25 14:27:50 +00:00
|
|
|
char filename[FILE_MAX];
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!external)
|
2009-11-25 14:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
customdata_external_filename(filename, id, external);
|
|
|
|
cdf_remove(filename);
|
2009-11-25 14:27:50 +00:00
|
|
|
CustomData_external_free(data);
|
|
|
|
}
|
2009-12-10 14:26:06 +00:00
|
|
|
#endif
|
2009-11-25 14:27:50 +00:00
|
|
|
|