2009-06-18 19:48:55 +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) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#include "BKE_customdata.h"
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2009-06-18 19:48:55 +00:00
|
|
|
#include "BKE_DerivedMesh.h"
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
#include "BKE_main.h"
|
2009-06-28 13:29:03 +00:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
2009-07-01 13:37:52 +00:00
|
|
|
#include "BLI_arithb.h"
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
#include "BLI_edgehash.h"
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
static void rna_Mesh_calc_edges(Mesh *mesh)
|
2009-06-18 19:48:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
CustomData edata;
|
|
|
|
EdgeHashIterator *ehi;
|
|
|
|
MFace *mf = mesh->mface;
|
|
|
|
MEdge *med;
|
|
|
|
EdgeHash *eh = BLI_edgehash_new();
|
|
|
|
int i, *index, totedge, totface = mesh->totface;
|
|
|
|
|
|
|
|
for (i = 0; i < totface; i++, mf++) {
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2))
|
|
|
|
BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL);
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3))
|
|
|
|
BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL);
|
|
|
|
|
|
|
|
if (mf->v4) {
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4))
|
|
|
|
BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
|
|
|
|
BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
|
|
|
|
} else {
|
|
|
|
if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
|
|
|
|
BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
totedge = BLI_edgehash_size(eh);
|
|
|
|
|
|
|
|
/* write new edges into a temporary CustomData */
|
|
|
|
memset(&edata, 0, sizeof(edata));
|
|
|
|
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
|
|
|
|
|
|
|
|
ehi = BLI_edgehashIterator_new(eh);
|
|
|
|
med = CustomData_get_layer(&edata, CD_MEDGE);
|
|
|
|
for(i = 0; !BLI_edgehashIterator_isDone(ehi);
|
|
|
|
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
|
|
|
|
BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
|
|
|
|
|
|
|
|
med->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
|
|
|
}
|
|
|
|
BLI_edgehashIterator_free(ehi);
|
|
|
|
|
|
|
|
/* free old CustomData and assign new one */
|
|
|
|
CustomData_free(&mesh->edata, mesh->totedge);
|
|
|
|
mesh->edata = edata;
|
|
|
|
mesh->totedge = totedge;
|
|
|
|
|
|
|
|
mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE);
|
|
|
|
|
|
|
|
BLI_edgehash_free(eh, NULL);
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
static void rna_Mesh_update(Mesh *mesh, bContext *C)
|
2009-06-18 19:48:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
Object *ob;
|
|
|
|
|
|
|
|
if(mesh->totface && mesh->totedge == 0)
|
|
|
|
rna_Mesh_calc_edges(mesh);
|
|
|
|
|
|
|
|
mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL);
|
|
|
|
|
|
|
|
for(ob=bmain->object.first; ob; ob=ob->id.next) {
|
|
|
|
if(ob->data == mesh) {
|
|
|
|
ob->recalc |= OB_RECALC_DATA;
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
|
|
|
|
}
|
|
|
|
}
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 13:37:52 +00:00
|
|
|
static void rna_Mesh_transform(Mesh *me, float *mat)
|
2009-06-18 19:48:55 +00:00
|
|
|
{
|
2009-07-01 13:37:52 +00:00
|
|
|
|
2009-06-23 17:52:58 +00:00
|
|
|
/* TODO: old API transform had recalc_normals option */
|
|
|
|
int i;
|
|
|
|
MVert *mvert= me->mvert;
|
|
|
|
|
2009-06-24 19:23:34 +00:00
|
|
|
for(i= 0; i < me->totvert; i++, mvert++) {
|
2009-06-23 17:52:58 +00:00
|
|
|
Mat4MulVecfl(mat, mvert->co);
|
|
|
|
}
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
static void rna_Mesh_add_verts(Mesh *mesh, int len)
|
2009-06-18 19:48:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
CustomData vdata;
|
|
|
|
MVert *mvert;
|
|
|
|
int i, totvert;
|
|
|
|
|
|
|
|
if(len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
totvert= mesh->totvert + len;
|
|
|
|
CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert);
|
|
|
|
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
|
|
|
|
|
|
|
|
if(!CustomData_has_layer(&vdata, CD_MVERT))
|
|
|
|
CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->vdata, mesh->totvert);
|
|
|
|
mesh->vdata= vdata;
|
|
|
|
mesh_update_customdata_pointers(mesh);
|
|
|
|
|
|
|
|
/* scan the input list and insert the new vertices */
|
|
|
|
|
|
|
|
mvert= &mesh->mvert[mesh->totvert];
|
|
|
|
for(i=0; i<len; i++, mvert++)
|
|
|
|
mvert->flag |= SELECT;
|
|
|
|
|
|
|
|
/* set final vertex list size */
|
|
|
|
mesh->totvert= totvert;
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 13:29:03 +00:00
|
|
|
Mesh *rna_Mesh_create_copy(Mesh *me)
|
|
|
|
{
|
|
|
|
Mesh *ret= copy_mesh(me);
|
|
|
|
ret->id.us--;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
static void rna_Mesh_add_edges(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
CustomData edata;
|
|
|
|
MEdge *medge;
|
|
|
|
int i, totedge;
|
|
|
|
|
|
|
|
if(len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
totedge= mesh->totedge+len;
|
|
|
|
|
|
|
|
/* update customdata */
|
|
|
|
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
|
|
|
|
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
if(!CustomData_has_layer(&edata, CD_MEDGE))
|
|
|
|
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->edata, mesh->totedge);
|
|
|
|
mesh->edata= edata;
|
|
|
|
mesh_update_customdata_pointers(mesh);
|
|
|
|
|
|
|
|
/* set default flags */
|
|
|
|
medge= &mesh->medge[mesh->totedge];
|
|
|
|
for(i=0; i<len; i++, medge++)
|
|
|
|
medge->flag= ME_EDGEDRAW|ME_EDGERENDER|SELECT;
|
|
|
|
|
|
|
|
mesh->totedge= totedge;
|
|
|
|
}
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
static void rna_Mesh_add_faces(Mesh *mesh, int len)
|
2009-06-18 19:48:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
CustomData fdata;
|
|
|
|
MFace *mface;
|
|
|
|
int i, totface;
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
if(len == 0)
|
2009-06-18 19:48:55 +00:00
|
|
|
return;
|
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
totface= mesh->totface + len; /* new face count */
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
/* update customdata */
|
|
|
|
CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface);
|
|
|
|
CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
if(!CustomData_has_layer(&fdata, CD_MFACE))
|
|
|
|
CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->fdata, mesh->totface);
|
|
|
|
mesh->fdata= fdata;
|
|
|
|
mesh_update_customdata_pointers(mesh);
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
/* set default flags */
|
|
|
|
mface= &mesh->mface[mesh->totface];
|
|
|
|
for(i=0; i<len; i++, mface++)
|
|
|
|
mface->flag= SELECT;
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
mesh->totface= totface;
|
|
|
|
}
|
|
|
|
|
2009-07-01 18:23:11 +00:00
|
|
|
/*
|
|
|
|
static void rna_Mesh_add_faces(Mesh *mesh)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
static void rna_Mesh_add_geometry(Mesh *mesh, int verts, int edges, int faces)
|
|
|
|
{
|
|
|
|
if(verts)
|
|
|
|
rna_Mesh_add_verts(mesh, verts);
|
|
|
|
if(edges)
|
|
|
|
rna_Mesh_add_edges(mesh, edges);
|
|
|
|
if(faces)
|
|
|
|
rna_Mesh_add_faces(mesh, faces);
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 18:23:11 +00:00
|
|
|
static void rna_Mesh_add_uv_layer(Mesh *me)
|
|
|
|
{
|
|
|
|
me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface);
|
|
|
|
}
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
void RNA_api_mesh(StructRNA *srna)
|
|
|
|
{
|
2009-06-23 17:52:58 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
PropertyRNA *parm;
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2009-06-23 17:52:58 +00:00
|
|
|
func= RNA_def_function(srna, "transform", "rna_Mesh_transform");
|
|
|
|
RNA_def_function_ui_description(func, "Transform mesh vertices by a matrix.");
|
|
|
|
parm= RNA_def_float_matrix(func, "matrix", 16, NULL, 0.0f, 0.0f, "", "Matrix.", 0.0f, 0.0f);
|
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
2009-06-18 19:48:55 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
func= RNA_def_function(srna, "add_geometry", "rna_Mesh_add_geometry");
|
|
|
|
parm= RNA_def_int(func, "verts", 0, 0, INT_MAX, "Number", "Number of vertices to add.", 0, INT_MAX);
|
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
|
|
parm= RNA_def_int(func, "edges", 0, 0, INT_MAX, "Number", "Number of edges to add.", 0, INT_MAX);
|
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
|
|
parm= RNA_def_int(func, "faces", 0, 0, INT_MAX, "Number", "Number of faces to add.", 0, INT_MAX);
|
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
|
|
|
2009-06-28 13:29:03 +00:00
|
|
|
func= RNA_def_function(srna, "create_copy", "rna_Mesh_create_copy");
|
|
|
|
RNA_def_function_ui_description(func, "Create a copy of this Mesh datablock.");
|
|
|
|
parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh, remove it if it is only used for export.");
|
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
2009-07-01 18:23:11 +00:00
|
|
|
func= RNA_def_function(srna, "add_uv_layer", "rna_Mesh_add_uv_layer");
|
|
|
|
RNA_def_function_ui_description(func, "Add new UV layer to Mesh.");
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
/*
|
|
|
|
func= RNA_def_function(srna, "add_geom", "rna_Mesh_add_geom");
|
|
|
|
RNA_def_function_ui_description(func, "Add geometry data to mesh.");
|
|
|
|
prop= RNA_def_collection(func, "verts", "?", "", "Vertices.");
|
|
|
|
RNA_def_property_flag(prop, PROP_REQUIRED);
|
|
|
|
prop= RNA_def_collection(func, "faces", "?", "", "Faces.");
|
|
|
|
RNA_def_property_flag(prop, PROP_REQUIRED);
|
|
|
|
*/
|
2009-07-01 13:37:52 +00:00
|
|
|
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
func= RNA_def_function(srna, "update", "rna_Mesh_update");
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|