2006-08-28 01:12:36 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "BKE_customdata.h"
|
|
|
|
|
2006-12-21 13:47:27 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
#include "BLI_linklist.h"
|
2008-07-04 17:59:16 +00:00
|
|
|
#include "BLI_mempool.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
#include "DNA_customdata_types.h"
|
2006-11-20 05:24:13 +00:00
|
|
|
#include "DNA_listBase.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* number of layers to add when growing a CustomData object */
|
|
|
|
#define CUSTOMDATA_GROW 5
|
|
|
|
|
|
|
|
/********************* 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 */
|
|
|
|
char *structname; /* name of the struct used, for file writing */
|
|
|
|
int structnum; /* number of structs per element, for file writing */
|
2006-12-21 13:47:27 +00:00
|
|
|
char *defaultname; /* default layer name */
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* a function to copy count elements of this layer's data
|
|
|
|
* (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
|
|
|
|
|
|
|
/* a function to free any dynamically allocated components of this
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
/* a function to interpolate between count source elements of this
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
void (*interp)(void **sources, float *weights, float *sub_weights,
|
|
|
|
int count, void *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
|
|
|
/* a function to swap the data in corners of the element */
|
|
|
|
void (*swap)(void *data, int *corner_indices);
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
/* a function to set a layer's data to default values. if NULL, the
|
|
|
|
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);
|
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,
|
2006-12-12 21:29:09 +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);
|
|
|
|
|
|
|
|
for(i = 0; i < count; ++i) {
|
|
|
|
MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size);
|
|
|
|
|
2008-04-15 18:07:04 +00:00
|
|
|
if(dvert->totweight) {
|
|
|
|
MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw),
|
|
|
|
"layerCopy_mdeformvert dw");
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
for(i = 0; i < count; ++i) {
|
|
|
|
MDeformVert *dvert = (MDeformVert *)((char *)data + i * size);
|
|
|
|
|
|
|
|
if(dvert->dw) {
|
|
|
|
MEM_freeN(dvert->dw);
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void linklist_free_simple(void *link)
|
|
|
|
{
|
|
|
|
MEM_freeN(link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerInterp_mdeformvert(void **sources, float *weights,
|
|
|
|
float *sub_weights, int count, void *dest)
|
|
|
|
{
|
|
|
|
MDeformVert *dvert = dest;
|
|
|
|
LinkNode *dest_dw = NULL; /* a list of lists of MDeformWeight pointers */
|
|
|
|
LinkNode *node;
|
|
|
|
int i, j, totweight;
|
|
|
|
|
|
|
|
if(count <= 0) return;
|
|
|
|
|
|
|
|
/* build a list of unique def_nrs for dest */
|
|
|
|
totweight = 0;
|
|
|
|
for(i = 0; i < count; ++i) {
|
|
|
|
MDeformVert *source = sources[i];
|
|
|
|
float interp_weight = weights ? weights[i] : 1.0f;
|
|
|
|
|
|
|
|
for(j = 0; j < source->totweight; ++j) {
|
|
|
|
MDeformWeight *dw = &source->dw[j];
|
|
|
|
|
|
|
|
for(node = dest_dw; node; node = node->next) {
|
|
|
|
MDeformWeight *tmp_dw = (MDeformWeight *)node->link;
|
|
|
|
|
|
|
|
if(tmp_dw->def_nr == dw->def_nr) {
|
|
|
|
tmp_dw->weight += dw->weight * interp_weight;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if this def_nr is not in the list, add it */
|
|
|
|
if(!node) {
|
|
|
|
MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw),
|
|
|
|
"layerInterp_mdeformvert tmp_dw");
|
|
|
|
tmp_dw->def_nr = dw->def_nr;
|
|
|
|
tmp_dw->weight = dw->weight * interp_weight;
|
|
|
|
BLI_linklist_prepend(&dest_dw, tmp_dw);
|
|
|
|
totweight++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now we know how many unique deform weights there are, so realloc */
|
|
|
|
if(dvert->dw) MEM_freeN(dvert->dw);
|
|
|
|
|
2006-11-11 23:23:15 +00:00
|
|
|
if(totweight) {
|
|
|
|
dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight,
|
|
|
|
"layerInterp_mdeformvert dvert->dw");
|
|
|
|
dvert->totweight = totweight;
|
|
|
|
|
|
|
|
for(i = 0, node = dest_dw; node; node = node->next, ++i)
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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 layerInterp_msticky(void **sources, float *weights,
|
|
|
|
float *sub_weights, int count, void *dest)
|
|
|
|
{
|
|
|
|
float co[2], w;
|
|
|
|
MSticky *mst;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
co[0] = co[1] = 0.0f;
|
|
|
|
for(i = 0; i < count; i++) {
|
|
|
|
w = weights ? weights[i] : 1.0f;
|
|
|
|
mst = (MSticky*)sources[i];
|
|
|
|
|
|
|
|
co[0] += w*mst->co[0];
|
|
|
|
co[1] += w*mst->co[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
mst = (MSticky*)dest;
|
|
|
|
mst->co[0] = co[0];
|
|
|
|
mst->co[1] = co[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
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 MTFace *source_tf = (const MTFace*)source;
|
|
|
|
MTFace *dest_tf = (MTFace*)dest;
|
2006-11-11 16:38:37 +00:00
|
|
|
int i;
|
|
|
|
|
2006-12-22 07:45:01 +00:00
|
|
|
for(i = 0; i < count; ++i)
|
2006-11-11 16:38:37 +00:00
|
|
|
dest_tf[i] = source_tf[i];
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
static void layerInterp_tface(void **sources, float *weights,
|
|
|
|
float *sub_weights, int count, void *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
|
|
|
MTFace *tf = dest;
|
2006-08-28 01:12:36 +00:00
|
|
|
int i, j, k;
|
|
|
|
float uv[4][2];
|
2006-11-11 16:38:37 +00:00
|
|
|
float *sub_weight;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
if(count <= 0) return;
|
|
|
|
|
|
|
|
memset(uv, 0, sizeof(uv));
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
sub_weight = sub_weights;
|
2006-08-28 01:12:36 +00:00
|
|
|
for(i = 0; i < count; ++i) {
|
|
|
|
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
|
|
|
|
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
if(sub_weights) {
|
2006-11-11 16:38:37 +00:00
|
|
|
for(k = 0; k < 4; ++k, ++sub_weight) {
|
|
|
|
float w = (*sub_weight) * weight;
|
2006-08-28 01:12:36 +00:00
|
|
|
float *tmp_uv = src->uv[k];
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
uv[j][0] += tmp_uv[0] * w;
|
|
|
|
uv[j][1] += tmp_uv[1] * w;
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uv[j][0] += src->uv[j][0] * weight;
|
|
|
|
uv[j][1] += src->uv[j][1] * weight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 = *(MTFace *)sources[0];
|
2006-08-28 01:12:36 +00:00
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
tf->uv[j][0] = uv[j][0];
|
|
|
|
tf->uv[j][1] = uv[j][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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerSwap_tface(void *data, int *corner_indices)
|
|
|
|
{
|
|
|
|
MTFace *tf = data;
|
|
|
|
float uv[4][2];
|
|
|
|
int 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
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
uv[j][0] = tf->uv[corner_indices[j]][0];
|
|
|
|
uv[j][1] = tf->uv[corner_indices[j]][1];
|
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));
|
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,
|
2007-04-29 13:39:46 +00:00
|
|
|
0, 0, TF_DYNAMIC, 0, 0};
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
MTFace *tf = (MTFace*)data;
|
|
|
|
int 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
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
tf[i] = default_tf;
|
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 void layerCopy_origspace_face(const void *source, void *dest, int count)
|
|
|
|
{
|
|
|
|
const OrigSpaceFace *source_tf = (const OrigSpaceFace*)source;
|
|
|
|
OrigSpaceFace *dest_tf = (OrigSpaceFace*)dest;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < count; ++i)
|
|
|
|
dest_tf[i] = source_tf[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerInterp_origspace_face(void **sources, float *weights,
|
|
|
|
float *sub_weights, int count, void *dest)
|
|
|
|
{
|
|
|
|
OrigSpaceFace *osf = dest;
|
|
|
|
int i, j, k;
|
|
|
|
float uv[4][2];
|
|
|
|
float *sub_weight;
|
|
|
|
|
|
|
|
if(count <= 0) return;
|
|
|
|
|
|
|
|
memset(uv, 0, sizeof(uv));
|
|
|
|
|
|
|
|
sub_weight = sub_weights;
|
|
|
|
for(i = 0; i < count; ++i) {
|
|
|
|
float weight = weights ? weights[i] : 1;
|
|
|
|
OrigSpaceFace *src = sources[i];
|
|
|
|
|
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
if(sub_weights) {
|
|
|
|
for(k = 0; k < 4; ++k, ++sub_weight) {
|
|
|
|
float w = (*sub_weight) * weight;
|
|
|
|
float *tmp_uv = src->uv[k];
|
|
|
|
|
|
|
|
uv[j][0] += tmp_uv[0] * w;
|
|
|
|
uv[j][1] += tmp_uv[1] * w;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uv[j][0] += src->uv[j][0] * weight;
|
|
|
|
uv[j][1] += src->uv[j][1] * weight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*osf = *(OrigSpaceFace *)sources[0];
|
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
osf->uv[j][0] = uv[j][0];
|
|
|
|
osf->uv[j][1] = uv[j][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layerSwap_origspace_face(void *data, int *corner_indices)
|
|
|
|
{
|
|
|
|
OrigSpaceFace *osf = data;
|
|
|
|
float uv[4][2];
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
uv[j][0] = osf->uv[corner_indices[j]][0];
|
|
|
|
uv[j][1] = osf->uv[corner_indices[j]][1];
|
|
|
|
}
|
|
|
|
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}}};
|
|
|
|
OrigSpaceFace *osf = (OrigSpaceFace*)data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
osf[i] = default_osf;
|
|
|
|
}
|
|
|
|
/* --------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
static void layerInterp_mcol(void **sources, float *weights,
|
|
|
|
float *sub_weights, int count, void *dest)
|
|
|
|
{
|
|
|
|
MCol *mc = dest;
|
|
|
|
int i, j, k;
|
|
|
|
struct {
|
|
|
|
float a;
|
|
|
|
float r;
|
|
|
|
float g;
|
|
|
|
float b;
|
|
|
|
} col[4];
|
2006-11-11 16:38:37 +00:00
|
|
|
float *sub_weight;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
if(count <= 0) return;
|
|
|
|
|
|
|
|
memset(col, 0, sizeof(col));
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
sub_weight = sub_weights;
|
2006-08-28 01:12:36 +00:00
|
|
|
for(i = 0; i < count; ++i) {
|
|
|
|
float weight = weights ? weights[i] : 1;
|
|
|
|
|
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
if(sub_weights) {
|
|
|
|
MCol *src = sources[i];
|
|
|
|
for(k = 0; k < 4; ++k, ++sub_weight, ++src) {
|
|
|
|
col[j].a += src->a * (*sub_weight) * weight;
|
|
|
|
col[j].r += src->r * (*sub_weight) * weight;
|
|
|
|
col[j].g += src->g * (*sub_weight) * weight;
|
|
|
|
col[j].b += src->b * (*sub_weight) * weight;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(j = 0; j < 4; ++j) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 layerSwap_mcol(void *data, int *corner_indices)
|
|
|
|
{
|
|
|
|
MCol *mcol = data;
|
|
|
|
MCol col[4];
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for(j = 0; j < 4; ++j)
|
|
|
|
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};
|
|
|
|
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;
|
|
|
|
|
|
|
|
for(i = 0; i < 4*count; i++)
|
|
|
|
mcol[i] = default_mcol;
|
|
|
|
}
|
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
|
|
|
const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
|
|
|
{sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL,
|
2006-12-12 21:29:09 +00:00
|
|
|
NULL},
|
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},
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(MEdge), "MEdge", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
|
|
|
{sizeof(MFace), "MFace", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
|
|
|
{sizeof(MTFace), "MTFace", 1, "UVTex", layerCopy_tface, NULL,
|
2006-12-12 21:29:09 +00:00
|
|
|
layerInterp_tface, layerSwap_tface, layerDefault_tface},
|
2006-11-11 16:38:37 +00:00
|
|
|
/* 4 MCol structs per face */
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(MCol)*4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol,
|
2006-12-12 21:29:09 +00:00
|
|
|
layerSwap_mcol, layerDefault_mcol},
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2006-11-11 16:38:37 +00:00
|
|
|
/* 3 floats per normal vector */
|
2006-12-21 13:47:27 +00:00
|
|
|
{sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
|
|
|
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
2007-06-04 19:18:19 +00:00
|
|
|
{sizeof(MFloatProperty), "MFloatProperty",1,"Float",NULL,NULL,NULL,NULL},
|
|
|
|
{sizeof(MIntProperty), "MIntProperty",1,"Int",NULL,NULL,NULL,NULL},
|
|
|
|
{sizeof(MStringProperty), "MStringProperty",1,"String",NULL,NULL,NULL,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
|
|
|
{sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVTex", layerCopy_origspace_face, NULL,
|
|
|
|
layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face},
|
2008-07-04 17:59:16 +00:00
|
|
|
{sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
|
|
|
{sizeof(MTexPoly), "MTexPoly", 1, "Face Texture", NULL, NULL, NULL, NULL, NULL},
|
|
|
|
{sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, NULL, NULL, NULL},
|
|
|
|
{sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, NULL, NULL, NULL}
|
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
|
|
|
const char *LAYERTYPENAMES[CD_NUMTYPES] = {
|
|
|
|
"CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", "CDMTFace",
|
2007-12-05 12:40:54 +00:00
|
|
|
"CDMCol", "CDOrigIndex", "CDNormal", "CDFlags","CDMFloatProperty",
|
2008-07-04 17:59:16 +00:00
|
|
|
"CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", "CDMTexPoly", "CDMLoopUV", "CDMloopCol"};
|
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 =
|
|
|
|
CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE;
|
|
|
|
const CustomDataMask CD_MASK_MESH =
|
|
|
|
CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
|
2007-06-04 19:18:19 +00:00
|
|
|
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL |
|
|
|
|
CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR;
|
2006-12-05 17:42:03 +00:00
|
|
|
const CustomDataMask CD_MASK_EDITMESH =
|
|
|
|
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
|
2007-06-04 19:18:19 +00:00
|
|
|
CD_MASK_MCOL|CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR;
|
2006-12-05 17:42:03 +00:00
|
|
|
const CustomDataMask CD_MASK_DERIVEDMESH =
|
|
|
|
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
|
2007-12-05 12:40:54 +00:00
|
|
|
CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
|
|
|
|
CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO;
|
2008-07-04 17:59:16 +00:00
|
|
|
const CustomDataMask CD_MASK_BMESH =
|
|
|
|
CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL;
|
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
|
|
|
static const LayerTypeInfo *layerType_getInfo(int 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
|
|
|
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
|
|
|
{
|
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(type < 0 || type >= CD_NUMTYPES) return NULL;
|
|
|
|
|
|
|
|
return LAYERTYPENAMES[type];
|
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
|
|
|
/********************* 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,
|
2006-12-21 13:47:27 +00:00
|
|
|
int type, int alloctype, void *layerdata, int totelem, const char *name);
|
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
|
|
|
void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
|
2006-12-05 17:42:03 +00:00
|
|
|
CustomDataMask mask, int alloctype, int totelem)
|
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
|
|
|
const LayerTypeInfo *typeInfo;
|
2006-12-12 21:29:09 +00:00
|
|
|
CustomDataLayer *layer, *newlayer;
|
2007-05-02 00:01:23 +00:00
|
|
|
int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 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
|
|
|
for(i = 0; i < source->totlayer; ++i) {
|
|
|
|
layer = &source->layers[i];
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
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;
|
2006-12-12 21:29:09 +00:00
|
|
|
lasttype = 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
|
|
|
else
|
|
|
|
number++;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(layer->flag & CD_FLAG_NOCOPY) continue;
|
|
|
|
else if(!(mask & (1 << 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
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if((alloctype == CD_ASSIGN) && (layer->flag & CD_FLAG_NOFREE))
|
|
|
|
newlayer = customData_add_layer__internal(dest, type, CD_REFERENCE,
|
2006-12-21 13:47:27 +00:00
|
|
|
layer->data, totelem, layer->name);
|
2006-12-12 21:29:09 +00:00
|
|
|
else
|
|
|
|
newlayer = customData_add_layer__internal(dest, type, alloctype,
|
2006-12-21 13:47:27 +00:00
|
|
|
layer->data, totelem, layer->name);
|
2006-12-12 21:29:09 +00:00
|
|
|
|
2007-05-02 00:01:23 +00:00
|
|
|
if(newlayer) {
|
2006-12-12 21:29:09 +00:00
|
|
|
newlayer->active = lastactive;
|
2007-05-02 00:01:23 +00:00
|
|
|
newlayer->active_rnd = lastrender;
|
|
|
|
}
|
2006-12-12 21:29:09 +00:00
|
|
|
}
|
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,
|
2006-12-05 17:42:03 +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
|
|
|
{
|
|
|
|
memset(dest, 0, sizeof(*dest));
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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(!(layer->flag & CD_FLAG_NOFREE) && layer->data) {
|
|
|
|
typeInfo = layerType_getInfo(layer->type);
|
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
|
|
|
if(typeInfo->free)
|
|
|
|
typeInfo->free(layer->data, totelem, typeInfo->size);
|
|
|
|
|
|
|
|
if(layer->data)
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
|
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(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
|
|
|
|
|
|
|
memset(data, 0, sizeof(*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;
|
|
|
|
|
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-12-21 13:47:27 +00:00
|
|
|
int CustomData_get_layer_index(const CustomData *data, int type)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
int i;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
return i;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-12-23 23:33:03 +00:00
|
|
|
int CustomData_get_named_layer_index(const CustomData *data, int type, char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type && strcmp(data->layers[i].name, name)==0)
|
|
|
|
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
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
return i + data->layers[i].active;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-05-02 00:01:23 +00:00
|
|
|
int CustomData_get_render_layer_index(const CustomData *data, int type)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
return i + data->layers[i].active_rnd;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-09-18 19:39:25 +00:00
|
|
|
int CustomData_get_active_layer(const CustomData *data, int type)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
return data->layers[i].active;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CustomData_get_render_layer(const CustomData *data, int type)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
return data->layers[i].active_rnd;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
void CustomData_set_layer_active(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
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;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
data->layers[i].active_rnd = 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;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
data->layers[i].active = n-i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_set_layer_render_index(CustomData *data, int type, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
data->layers[i].active_rnd = n-i;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
for(i=0; i < data->totlayer; ++i)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
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
|
|
|
{
|
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 *tmp = MEM_callocN(sizeof(*tmp)*(data->maxlayer + amount),
|
2006-11-11 16:38:37 +00:00
|
|
|
"CustomData->layers");
|
2006-08-28 01:12:36 +00:00
|
|
|
if(!tmp) return 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
|
|
|
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,
|
2006-12-21 13:47:27 +00:00
|
|
|
int type, int alloctype, void *layerdata, int totelem, const char *name)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo= layerType_getInfo(type);
|
|
|
|
int size = typeInfo->size * totelem, flag = 0, index = data->totlayer;
|
|
|
|
void *newlayerdata;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2007-01-06 20:16:06 +00:00
|
|
|
if (!typeInfo->defaultname && CustomData_has_layer(data, type))
|
|
|
|
return &data->layers[CustomData_get_layer_index(data, type)];
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) {
|
|
|
|
newlayerdata = layerdata;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newlayerdata = MEM_callocN(size, layerType_getName(type));
|
|
|
|
if(!newlayerdata)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alloctype == CD_DUPLICATE) {
|
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(layerdata, newlayerdata, totelem);
|
|
|
|
else
|
|
|
|
memcpy(newlayerdata, layerdata, size);
|
|
|
|
}
|
|
|
|
else if (alloctype == CD_DEFAULT) {
|
|
|
|
if(typeInfo->set_default)
|
|
|
|
typeInfo->set_default((char*)newlayerdata, totelem);
|
|
|
|
}
|
|
|
|
else if (alloctype == CD_REFERENCE)
|
|
|
|
flag |= CD_FLAG_NOFREE;
|
|
|
|
|
|
|
|
if(index >= data->maxlayer) {
|
|
|
|
if(!customData_resize(data, CUSTOMDATA_GROW)) {
|
|
|
|
if(newlayerdata != layerdata)
|
|
|
|
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 */
|
|
|
|
for( ; index > 0 && data->layers[index - 1].type > type; --index)
|
|
|
|
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;
|
|
|
|
|
2006-12-21 13:47:27 +00:00
|
|
|
if(name) {
|
|
|
|
strcpy(data->layers[index].name, name);
|
|
|
|
CustomData_set_layer_unique_name(data, index);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
data->layers[index].name[0] = '\0';
|
|
|
|
|
2007-05-02 00:01:23 +00:00
|
|
|
if(index > 0 && data->layers[index-1].type == type) {
|
2006-12-12 21:29:09 +00:00
|
|
|
data->layers[index].active = data->layers[index-1].active;
|
2007-05-02 00:01:23 +00:00
|
|
|
data->layers[index].active_rnd = data->layers[index-1].active_rnd;
|
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
|
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,
|
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 *layerdata, int totelem)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
CustomDataLayer *layer;
|
2006-12-21 13:47:27 +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,
|
2006-12-21 13:47:27 +00:00
|
|
|
totelem, typeInfo->defaultname);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(layer)
|
|
|
|
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,
|
|
|
|
void *layerdata, int totelem, char *name)
|
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
|
|
|
|
layer = customData_add_layer__internal(data, type, alloctype, layerdata,
|
|
|
|
totelem, name);
|
|
|
|
|
|
|
|
if(layer)
|
|
|
|
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-12-12 21:29:09 +00:00
|
|
|
CustomDataLayer *layer;
|
2006-12-23 17:07:02 +00:00
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
if (index < 0) return 0;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
layer = &data->layers[index];
|
|
|
|
|
|
|
|
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
|
|
|
|
2006-12-12 21:29:09 +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)) {
|
|
|
|
i = CustomData_get_layer_index(data, type);
|
|
|
|
|
|
|
|
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--;
|
|
|
|
}
|
2006-12-12 21:29:09 +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;
|
|
|
|
|
|
|
|
for(i = 0; i < data->totlayer; i++)
|
|
|
|
if(data->layers[i].type == type)
|
|
|
|
number++;
|
|
|
|
|
|
|
|
return number;
|
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
|
|
|
void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type)
|
|
|
|
{
|
|
|
|
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);
|
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(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
|
|
|
|
if (layer->flag & CD_FLAG_NOFREE) {
|
|
|
|
layer->data = MEM_dupallocN(layer->data);
|
|
|
|
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,
|
|
|
|
int type, char *name)
|
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
/* get the layer index of the desired layer */
|
|
|
|
layer_index = CustomData_get_named_layer_index(data, type, name);
|
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
layer = &data->layers[layer_index];
|
|
|
|
|
|
|
|
if (layer->flag & CD_FLAG_NOFREE) {
|
|
|
|
layer->data = MEM_dupallocN(layer->data);
|
|
|
|
layer->flag &= ~CD_FLAG_NOFREE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 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
|
|
|
void CustomData_free_temporary(CustomData *data, int totelem)
|
|
|
|
{
|
|
|
|
CustomDataLayer *layer;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for(i = 0, j = 0; i < data->totlayer; ++i) {
|
|
|
|
layer = &data->layers[i];
|
|
|
|
|
|
|
|
if (i != j)
|
|
|
|
data->layers[j] = data->layers[i];
|
|
|
|
|
|
|
|
if ((layer->flag & CD_FLAG_TEMPORARY) == CD_FLAG_TEMPORARY)
|
2006-12-12 21:29:09 +00:00
|
|
|
customData_free_layer__internal(layer, 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
|
|
|
else
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->totlayer = j;
|
|
|
|
|
|
|
|
if(data->totlayer <= data->maxlayer-CUSTOMDATA_GROW)
|
|
|
|
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,
|
|
|
|
CustomDataMask mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < data->totlayer; ++i)
|
|
|
|
if(!(mask & (1 << data->layers[i].type)))
|
|
|
|
data->layers[i].flag |= CD_FLAG_NOCOPY;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
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;
|
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
|
|
|
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)
|
|
|
|
*/
|
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
|
|
|
while(dest_i < dest->totlayer
|
2006-08-28 01:12:36 +00:00
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_i;
|
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
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(dest_i >= dest->totlayer) return;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type) {
|
|
|
|
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;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(src_data + src_offset,
|
2006-08-28 01:12:36 +00:00
|
|
|
dest_data + dest_offset,
|
2006-12-12 21:29:09 +00:00
|
|
|
count);
|
2006-08-28 01:12:36 +00:00
|
|
|
else
|
|
|
|
memcpy(dest_data + dest_offset,
|
|
|
|
src_data + src_offset,
|
2006-12-12 21:29:09 +00:00
|
|
|
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
|
|
|
|
*/
|
|
|
|
++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
|
|
|
void CustomData_free_elem(CustomData *data, int index, int count)
|
2006-08-28 01:12:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
|
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
|
|
|
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);
|
|
|
|
|
|
|
|
if(typeInfo->free) {
|
|
|
|
int offset = typeInfo->size * index;
|
|
|
|
|
|
|
|
typeInfo->free((char *)data->layers[i].data + offset,
|
|
|
|
count, typeInfo->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#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,
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
if(count > SOURCE_BUF_SIZE)
|
|
|
|
sources = MEM_callocN(sizeof(*sources) * count,
|
|
|
|
"CustomData_interp sources");
|
|
|
|
|
|
|
|
/* interpolates a layer at a time */
|
2006-12-12 21:29:09 +00:00
|
|
|
dest_i = 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
|
|
|
for(src_i = 0; src_i < source->totlayer; ++src_i) {
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo= layerType_getInfo(source->layers[src_i].type);
|
|
|
|
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)
|
|
|
|
*/
|
|
|
|
while(dest_i < dest->totlayer
|
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_i;
|
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
|
|
|
if(dest_i >= dest->totlayer) return;
|
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 */
|
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type) {
|
|
|
|
void *src_data = source->layers[src_i].data;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
for(j = 0; j < count; ++j)
|
|
|
|
sources[j] = (char *)src_data
|
2006-12-12 21:29:09 +00:00
|
|
|
+ typeInfo->size * src_indices[j];
|
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,
|
|
|
|
(char *)dest->layers[dest_i].data + dest_offset);
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
++dest_i;
|
2006-08-28 01:12:36 +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
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_swap(struct CustomData *data, int index, int *corner_indices)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
|
|
|
|
|
|
|
if(typeInfo->swap) {
|
|
|
|
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);
|
2006-08-28 01:12:36 +00:00
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
/* get the offset of the desired element */
|
|
|
|
offset = layerType_getInfo(type)->size * index;
|
|
|
|
|
|
|
|
return (char *)data->layers[layer_index].data + offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2006-08-28 01:12:36 +00:00
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
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 */
|
|
|
|
int layer_index = CustomData_get_layer_index(data, type);
|
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
return data->layers[layer_index+n].data;
|
|
|
|
}
|
|
|
|
|
2007-01-29 15:10:55 +00:00
|
|
|
void *CustomData_get_layer_named(const struct CustomData *data, int type,
|
|
|
|
char *name)
|
|
|
|
{
|
|
|
|
int layer_index = CustomData_get_named_layer_index(data, type, name);
|
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
return data->layers[layer_index].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
|
|
|
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
|
|
|
|
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
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 */
|
|
|
|
int layer_index = CustomData_get_layer_index(data, type);
|
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
data->layers[layer_index+n].data = ptr;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if(!dest) return;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->copy)
|
|
|
|
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
|
|
|
|
|
|
|
/* EditMesh functions */
|
|
|
|
|
2006-11-11 23:23:15 +00:00
|
|
|
void CustomData_em_free_block(CustomData *data, void **block)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(!*block) return;
|
|
|
|
|
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
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
|
|
|
if(!(data->layers[i].flag & CD_FLAG_NOFREE)) {
|
2006-11-11 23:23:15 +00:00
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
|
|
|
|
|
|
|
if(typeInfo->free) {
|
|
|
|
int offset = data->layers[i].offset;
|
|
|
|
typeInfo->free((char*)*block + offset, 1, typeInfo->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(*block);
|
|
|
|
*block = NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
static void CustomData_em_alloc_block(CustomData *data, void **block)
|
|
|
|
{
|
|
|
|
/* TODO: optimize free/alloc */
|
|
|
|
|
|
|
|
if (*block)
|
2006-11-11 23:23:15 +00:00
|
|
|
CustomData_em_free_block(data, block);
|
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 (data->totsize > 0)
|
|
|
|
*block = MEM_callocN(data->totsize, "CustomData EM block");
|
2006-11-11 16:38:37 +00:00
|
|
|
else
|
|
|
|
*block = 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
|
|
|
void CustomData_em_copy_data(const CustomData *source, CustomData *dest,
|
2006-11-11 23:23:15 +00:00
|
|
|
void *src_block, void **dest_block)
|
2006-11-11 16:38:37 +00:00
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo;
|
2006-11-11 23:23:15 +00:00
|
|
|
int dest_i, src_i;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
if (!*dest_block)
|
2006-11-11 23:23:15 +00:00
|
|
|
CustomData_em_alloc_block(dest, dest_block);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
/* copies a layer at a time */
|
2006-11-11 23:23:15 +00:00
|
|
|
dest_i = 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
|
|
|
for(src_i = 0; src_i < source->totlayer; ++src_i) {
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-11-11 23:23:15 +00:00
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by 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
|
|
|
while(dest_i < dest->totlayer
|
2006-11-11 23:23:15 +00:00
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_i;
|
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
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(dest_i >= dest->totlayer) return;
|
2006-11-11 23:23:15 +00:00
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
2008-05-15 19:40:09 +00:00
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type &&
|
|
|
|
strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
|
2006-11-11 23:23:15 +00:00
|
|
|
char *src_data = (char*)src_block + source->layers[src_i].offset;
|
|
|
|
char *dest_data = (char*)*dest_block + dest->layers[dest_i].offset;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo = layerType_getInfo(source->layers[src_i].type);
|
2006-11-11 23:23:15 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(src_data, dest_data, 1);
|
2006-11-11 23:23:15 +00:00
|
|
|
else
|
2006-12-12 21:29:09 +00:00
|
|
|
memcpy(dest_data, src_data, typeInfo->size);
|
2006-11-11 23:23:15 +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
|
|
|
|
*/
|
|
|
|
++dest_i;
|
|
|
|
}
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void *CustomData_em_get(const CustomData *data, void *block, int type)
|
|
|
|
{
|
|
|
|
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);
|
2006-11-11 16:38:37 +00:00
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
return (char *)block + data->layers[layer_index].offset;
|
|
|
|
}
|
|
|
|
|
2007-01-10 06:09:10 +00:00
|
|
|
void *CustomData_em_get_n(const CustomData *data, void *block, int type, int n)
|
|
|
|
{
|
|
|
|
int layer_index;
|
|
|
|
|
|
|
|
/* get the layer index of the first layer of type */
|
2008-06-07 18:16:23 +00:00
|
|
|
layer_index = CustomData_get_layer_index(data, type);
|
2007-01-10 06:09:10 +00:00
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
return (char *)block + data->layers[layer_index+n].offset;
|
|
|
|
}
|
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
void CustomData_em_set(CustomData *data, void *block, int type, void *source)
|
|
|
|
{
|
2006-11-11 17:18:42 +00:00
|
|
|
void *dest = CustomData_em_get(data, block, type);
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
if(!dest) return;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(source, dest, 1);
|
2006-11-11 16:38:37 +00:00
|
|
|
else
|
2006-12-12 21:29:09 +00:00
|
|
|
memcpy(dest, source, typeInfo->size);
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
|
2007-01-10 06:09:10 +00:00
|
|
|
void CustomData_em_set_n(CustomData *data, void *block, int type, int n, void *source)
|
|
|
|
{
|
|
|
|
void *dest = CustomData_em_get_n(data, block, type, n);
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
|
|
|
|
|
|
|
if(!dest) return;
|
|
|
|
|
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(source, dest, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest, source, 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
|
|
|
void CustomData_em_interp(CustomData *data, void **src_blocks, float *weights,
|
|
|
|
float *sub_weights, int count, void *dest_block)
|
2006-11-11 16:38:37 +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
|
|
|
|
*/
|
|
|
|
if(count > SOURCE_BUF_SIZE)
|
|
|
|
sources = MEM_callocN(sizeof(*sources) * count,
|
|
|
|
"CustomData_interp sources");
|
|
|
|
|
|
|
|
/* interpolates 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
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
2006-11-11 16:38:37 +00:00
|
|
|
CustomDataLayer *layer = &data->layers[i];
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->interp) {
|
2006-11-11 16:38:37 +00:00
|
|
|
for(j = 0; j < count; ++j)
|
|
|
|
sources[j] = (char *)src_blocks[j] + layer->offset;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo->interp(sources, weights, sub_weights, count,
|
2006-11-11 16:38:37 +00:00
|
|
|
(char *)dest_block + layer->offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(count > SOURCE_BUF_SIZE) MEM_freeN(sources);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_em_set_default(CustomData *data, void **block)
|
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo;
|
2006-11-11 16:38:37 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!*block)
|
|
|
|
CustomData_em_alloc_block(data, block);
|
|
|
|
|
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
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
2006-11-11 16:38:37 +00:00
|
|
|
int offset = data->layers[i].offset;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->set_default)
|
|
|
|
typeInfo->set_default((char*)*block + offset, 1);
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_to_em_block(const CustomData *source, CustomData *dest,
|
|
|
|
int src_index, void **dest_block)
|
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo;
|
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 dest_i, src_i, src_offset;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
|
|
|
if (!*dest_block)
|
|
|
|
CustomData_em_alloc_block(dest, dest_block);
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
for(src_i = 0; src_i < source->totlayer; ++src_i) {
|
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
|
|
|
while(dest_i < dest->totlayer
|
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_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
|
|
|
/* if there are no more dest layers, we're done */
|
|
|
|
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 */
|
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type) {
|
|
|
|
int offset = dest->layers[dest_i].offset;
|
|
|
|
char *src_data = source->layers[src_i].data;
|
|
|
|
char *dest_data = (char*)*dest_block + offset;
|
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
|
|
|
|
src_offset = src_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
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(src_data + src_offset, dest_data, 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, src_data + src_offset, 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
|
|
|
|
*/
|
|
|
|
++dest_i;
|
|
|
|
}
|
2006-11-11 16:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_from_em_block(const CustomData *source, CustomData *dest,
|
|
|
|
void *src_block, int dest_index)
|
|
|
|
{
|
2006-12-12 21:29:09 +00:00
|
|
|
const LayerTypeInfo *typeInfo;
|
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 dest_i, src_i, dest_offset;
|
2006-11-11 16:38:37 +00:00
|
|
|
|
2008-07-04 17:59:16 +00:00
|
|
|
/* copies a layer at a time */
|
|
|
|
dest_i = 0;
|
|
|
|
for(src_i = 0; src_i < source->totlayer; ++src_i) {
|
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
|
|
|
while(dest_i < dest->totlayer
|
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_i;
|
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
|
|
|
if(dest_i >= dest->totlayer) return;
|
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type) {
|
|
|
|
int offset = source->layers[src_i].offset;
|
|
|
|
char *src_data = (char*)src_block + offset;
|
|
|
|
char *dest_data = dest->layers[dest_i].data;
|
|
|
|
|
|
|
|
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
|
|
|
|
dest_offset = dest_index * typeInfo->size;
|
|
|
|
|
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(src_data, dest_data + dest_offset, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest_data + dest_offset, 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
|
|
|
|
*/
|
|
|
|
++dest_i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Bmesh functions*/
|
|
|
|
void CustomData_bmesh_free_block(CustomData *data, void **block)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(!*block) return;
|
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
|
|
|
if(!(data->layers[i].flag & CD_FLAG_NOFREE)) {
|
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
|
|
|
|
|
|
|
if(typeInfo->free) {
|
|
|
|
int offset = data->layers[i].offset;
|
|
|
|
typeInfo->free((char*)*block + offset, 1, typeInfo->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_mempool_free(data->pool, *block);
|
|
|
|
*block = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (*block)
|
|
|
|
CustomData_bmesh_free_block(data, block);
|
|
|
|
|
|
|
|
if (data->totsize > 0)
|
|
|
|
*block = BLI_mempool_alloc(data->pool);
|
|
|
|
else
|
|
|
|
*block = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
|
|
|
|
void *src_block, void **dest_block)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int dest_i, src_i;
|
|
|
|
|
|
|
|
if (!*dest_block)
|
|
|
|
CustomData_bmesh_alloc_block(dest, dest_block);
|
|
|
|
|
|
|
|
/* copies a layer at a time */
|
|
|
|
dest_i = 0;
|
|
|
|
for(src_i = 0; src_i < source->totlayer; ++src_i) {
|
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
|
|
|
while(dest_i < dest->totlayer
|
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_i;
|
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
|
|
|
if(dest_i >= dest->totlayer) return;
|
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type &&
|
|
|
|
strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
|
|
|
|
char *src_data = (char*)src_block + source->layers[src_i].offset;
|
|
|
|
char *dest_data = (char*)*dest_block + dest->layers[dest_i].offset;
|
|
|
|
|
|
|
|
typeInfo = layerType_getInfo(source->layers[src_i].type);
|
|
|
|
|
|
|
|
if(typeInfo->copy)
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
++dest_i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*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);
|
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
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);
|
|
|
|
if(layer_index < 0) return NULL;
|
|
|
|
|
|
|
|
return (char *)block + data->layers[layer_index+n].offset;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if(!dest) return;
|
|
|
|
|
|
|
|
if(typeInfo->copy)
|
|
|
|
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);
|
|
|
|
|
|
|
|
if(!dest) return;
|
|
|
|
|
|
|
|
if(typeInfo->copy)
|
|
|
|
typeInfo->copy(source, dest, 1);
|
|
|
|
else
|
|
|
|
memcpy(dest, source, typeInfo->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights,
|
|
|
|
float *sub_weights, int count, void *dest_block)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
if(count > SOURCE_BUF_SIZE)
|
|
|
|
sources = MEM_callocN(sizeof(*sources) * count,
|
|
|
|
"CustomData_interp sources");
|
|
|
|
|
|
|
|
/* interpolates a layer at a time */
|
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
|
|
|
CustomDataLayer *layer = &data->layers[i];
|
|
|
|
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
|
|
|
|
|
|
|
|
if(typeInfo->interp) {
|
|
|
|
for(j = 0; j < count; ++j)
|
|
|
|
sources[j] = (char *)src_blocks[j] + layer->offset;
|
|
|
|
|
|
|
|
typeInfo->interp(sources, weights, sub_weights, count,
|
|
|
|
(char *)dest_block + layer->offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(count > SOURCE_BUF_SIZE) MEM_freeN(sources);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_bmesh_set_default(CustomData *data, void **block)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!*block)
|
|
|
|
CustomData_bmesh_alloc_block(data, block);
|
|
|
|
|
|
|
|
for(i = 0; i < data->totlayer; ++i) {
|
|
|
|
int offset = data->layers[i].offset;
|
|
|
|
|
|
|
|
typeInfo = layerType_getInfo(data->layers[i].type);
|
|
|
|
|
|
|
|
if(typeInfo->set_default)
|
|
|
|
typeInfo->set_default((char*)*block + offset, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
|
|
|
|
int src_index, void **dest_block)
|
|
|
|
{
|
|
|
|
const LayerTypeInfo *typeInfo;
|
|
|
|
int dest_i, src_i, src_offset;
|
|
|
|
|
|
|
|
if (!*dest_block)
|
|
|
|
CustomData_bmesh_alloc_block(dest, dest_block);
|
|
|
|
|
|
|
|
/* copies a layer at a time */
|
|
|
|
dest_i = 0;
|
|
|
|
for(src_i = 0; src_i < source->totlayer; ++src_i) {
|
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
|
|
|
while(dest_i < dest->totlayer
|
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_i;
|
|
|
|
|
|
|
|
/* if there are no more dest layers, we're done */
|
|
|
|
if(dest_i >= dest->totlayer) return;
|
|
|
|
|
|
|
|
/* if we found a matching layer, copy the data */
|
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type) {
|
|
|
|
int offset = dest->layers[dest_i].offset;
|
|
|
|
char *src_data = source->layers[src_i].data;
|
|
|
|
char *dest_data = (char*)*dest_block + offset;
|
|
|
|
|
|
|
|
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
|
|
|
|
src_offset = src_index * typeInfo->size;
|
|
|
|
|
|
|
|
if(typeInfo->copy)
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
++dest_i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
|
|
|
|
void *src_block, int dest_index)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
for(src_i = 0; src_i < source->totlayer; ++src_i) {
|
|
|
|
|
|
|
|
/* find the first dest layer with type >= the source type
|
|
|
|
* (this should work because layers are ordered by type)
|
|
|
|
*/
|
|
|
|
while(dest_i < dest->totlayer
|
|
|
|
&& dest->layers[dest_i].type < source->layers[src_i].type)
|
|
|
|
++dest_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
|
|
|
/* if there are no more dest layers, we're done */
|
|
|
|
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 */
|
|
|
|
if(dest->layers[dest_i].type == source->layers[src_i].type) {
|
|
|
|
int offset = source->layers[src_i].offset;
|
|
|
|
char *src_data = (char*)src_block + offset;
|
|
|
|
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
|
|
|
|
2006-12-12 21:29:09 +00:00
|
|
|
if(typeInfo->copy)
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
++dest_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
|
|
|
|
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
|
|
|
void CustomData_file_write_info(int type, char **structname, int *structnum)
|
|
|
|
{
|
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
|
|
|
|
2007-06-04 19:18:19 +00:00
|
|
|
static int CustomData_is_property_layer(int type)
|
|
|
|
{
|
|
|
|
if((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-21 13:47:27 +00:00
|
|
|
void CustomData_set_layer_unique_name(CustomData *data, int index)
|
|
|
|
{
|
|
|
|
char tempname[64];
|
|
|
|
int number, i, type;
|
|
|
|
char *dot, *name;
|
|
|
|
CustomDataLayer *layer, *nlayer= &data->layers[index];
|
|
|
|
const LayerTypeInfo *typeInfo= layerType_getInfo(nlayer->type);
|
|
|
|
|
|
|
|
if (!typeInfo->defaultname)
|
|
|
|
return;
|
|
|
|
|
|
|
|
type = nlayer->type;
|
|
|
|
name = nlayer->name;
|
|
|
|
|
|
|
|
if (name[0] == '\0')
|
|
|
|
BLI_strncpy(nlayer->name, typeInfo->defaultname, sizeof(nlayer->name));
|
|
|
|
|
|
|
|
/* see if there is a duplicate */
|
|
|
|
for(i=0; i<data->totlayer; i++) {
|
|
|
|
layer = &data->layers[i];
|
2007-06-04 19:18:19 +00:00
|
|
|
|
|
|
|
if(CustomData_is_property_layer(type)){
|
|
|
|
if(i!=index && CustomData_is_property_layer(layer->type) &&
|
|
|
|
strcmp(layer->name, name)==0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(i!=index && layer->type==type && strcmp(layer->name, name)==0)
|
|
|
|
break;
|
|
|
|
}
|
2006-12-21 13:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(i == data->totlayer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* strip off the suffix */
|
|
|
|
dot = strchr(nlayer->name, '.');
|
|
|
|
if(dot) *dot=0;
|
|
|
|
|
|
|
|
for(number=1; number <=999; number++) {
|
|
|
|
sprintf(tempname, "%s.%03d", nlayer->name, number);
|
|
|
|
|
|
|
|
for(i=0; i<data->totlayer; i++) {
|
|
|
|
layer = &data->layers[i];
|
|
|
|
|
2007-06-04 19:18:19 +00:00
|
|
|
if(CustomData_is_property_layer(type)){
|
|
|
|
if(i!=index && CustomData_is_property_layer(layer->type) &&
|
|
|
|
strcmp(layer->name, tempname)==0)
|
|
|
|
|
2006-12-21 13:47:27 +00:00
|
|
|
break;
|
2007-06-04 19:18:19 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(i!=index && layer->type==type && strcmp(layer->name, tempname)==0)
|
|
|
|
break;
|
|
|
|
}
|
2006-12-21 13:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(i == data->totlayer) {
|
|
|
|
BLI_strncpy(nlayer->name, tempname, sizeof(nlayer->name));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) &&
|
|
|
|
data->layers[index-1].type == layer->type)
|
|
|
|
keeplayer = 0; /* multiple layers of which we only support one */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!keeplayer) {
|
|
|
|
for (i=index+1; i < data->totlayer; ++i)
|
|
|
|
data->layers[i-1] = data->layers[i];
|
|
|
|
data->totlayer--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return keeplayer;
|
|
|
|
}
|
|
|
|
|