Blender V2.61 - r43446
Classes | Defines | Functions

cdderivedmesh.c File Reference

#include "GL/glew.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_editVert.h"
#include "BLI_math.h"
#include "BLI_pbvh.h"
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_paint.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_curve_types.h"
#include "MEM_guardedalloc.h"
#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_material.h"
#include <string.h>
#include <limits.h>
#include <math.h>

Go to the source code of this file.

Classes

struct  CDDerivedMesh

Defines

#define PASSVERT(index)

Functions

static int cdDM_getNumVerts (DerivedMesh *dm)
static int cdDM_getNumEdges (DerivedMesh *dm)
static int cdDM_getNumFaces (DerivedMesh *dm)
static void cdDM_getVert (DerivedMesh *dm, int index, MVert *vert_r)
static void cdDM_getEdge (DerivedMesh *dm, int index, MEdge *edge_r)
static void cdDM_getFace (DerivedMesh *dm, int index, MFace *face_r)
static void cdDM_copyVertArray (DerivedMesh *dm, MVert *vert_r)
static void cdDM_copyEdgeArray (DerivedMesh *dm, MEdge *edge_r)
static void cdDM_copyFaceArray (DerivedMesh *dm, MFace *face_r)
static void cdDM_getMinMax (DerivedMesh *dm, float min_r[3], float max_r[3])
static void cdDM_getVertCo (DerivedMesh *dm, int index, float co_r[3])
static void cdDM_getVertCos (DerivedMesh *dm, float(*cos_r)[3])
static void cdDM_getVertNo (DerivedMesh *dm, int index, float no_r[3])
static ListBasecdDM_getFaceMap (Object *ob, DerivedMesh *dm)
static int can_pbvh_draw (Object *ob, DerivedMesh *dm)
static struct PBVHcdDM_getPBVH (Object *ob, DerivedMesh *dm)
static void cdDM_update_normals_from_pbvh (DerivedMesh *dm)
static void cdDM_drawVerts (DerivedMesh *dm)
static void cdDM_drawUVEdges (DerivedMesh *dm)
static void cdDM_drawEdges (DerivedMesh *dm, int drawLooseEdges, int drawAllEdges)
static void cdDM_drawLooseEdges (DerivedMesh *dm)
static void cdDM_drawFacesSolid (DerivedMesh *dm, float(*partial_redraw_planes)[4], int UNUSED(fast), int(*setMaterial)(int, void *attribs))
static void cdDM_drawFacesColored (DerivedMesh *dm, int useTwoSided, unsigned char *col1, unsigned char *col2)
static void cdDM_drawFacesTex_common (DerivedMesh *dm, int(*drawParams)(MTFace *tface, int has_mcol, int matnr), int(*drawParamsMapped)(void *userData, int index), int(*compareDrawOptions)(void *userData, int cur_index, int next_index), void *userData)
static void cdDM_drawFacesTex (DerivedMesh *dm, int(*setDrawOptions)(MTFace *tface, int has_mcol, int matnr), int(*compareDrawOptions)(void *userData, int cur_index, int next_index), void *userData)
static void cdDM_drawMappedFaces (DerivedMesh *dm, int(*setDrawOptions)(void *userData, int index, int *drawSmooth_r), int(*setMaterial)(int, void *attribs), int(*compareDrawOptions)(void *userData, int cur_index, int next_index), void *userData, int useColors)
static void cdDM_drawMappedFacesTex (DerivedMesh *dm, int(*setDrawOptions)(void *userData, int index), int(*compareDrawOptions)(void *userData, int cur_index, int next_index), void *userData)
static void cddm_draw_attrib_vertex (DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal)
static void cdDM_drawMappedFacesGLSL (DerivedMesh *dm, int(*setMaterial)(int, void *attribs), int(*setDrawOptions)(void *userData, int index), void *userData)
static void cdDM_drawFacesGLSL (DerivedMesh *dm, int(*setMaterial)(int, void *attribs))
static void cdDM_drawMappedFacesMat (DerivedMesh *dm, void(*setMaterial)(void *userData, int, void *attribs), int(*setFace)(void *userData, int index), void *userData)
static void cdDM_drawMappedEdges (DerivedMesh *dm, int(*setDrawOptions)(void *userData, int index), void *userData)
static void cdDM_foreachMappedVert (DerivedMesh *dm, void(*func)(void *userData, int index, float *co, float *no_f, short *no_s), void *userData)
static void cdDM_foreachMappedEdge (DerivedMesh *dm, void(*func)(void *userData, int index, float *v0co, float *v1co), void *userData)
static void cdDM_foreachMappedFaceCenter (DerivedMesh *dm, void(*func)(void *userData, int index, float *cent, float *no), void *userData)
static void cdDM_free_internal (CDDerivedMesh *cddm)
static void cdDM_release (DerivedMesh *dm)
static CDDerivedMeshcdDM_create (const char *desc)
DerivedMeshCDDM_new (int numVerts, int numEdges, int numFaces)
DerivedMeshCDDM_from_mesh (Mesh *mesh, Object *UNUSED(ob))
DerivedMeshCDDM_from_editmesh (EditMesh *em, Mesh *UNUSED(me))
DerivedMeshCDDM_from_curve (Object *ob)
DerivedMeshCDDM_from_curve_customDB (Object *ob, ListBase *dispbase)
DerivedMeshCDDM_copy (DerivedMesh *source)
DerivedMeshCDDM_from_template (DerivedMesh *source, int numVerts, int numEdges, int numFaces)
void CDDM_apply_vert_coords (DerivedMesh *dm, float(*vertCoords)[3])
void CDDM_apply_vert_normals (DerivedMesh *dm, short(*vertNormals)[3])
void CDDM_calc_normals (DerivedMesh *dm)
void CDDM_calc_edges (DerivedMesh *dm)
void CDDM_lower_num_verts (DerivedMesh *dm, int numVerts)
void CDDM_lower_num_edges (DerivedMesh *dm, int numEdges)
void CDDM_lower_num_faces (DerivedMesh *dm, int numFaces)
MVertCDDM_get_vert (DerivedMesh *dm, int index)
MEdgeCDDM_get_edge (DerivedMesh *dm, int index)
MFaceCDDM_get_face (DerivedMesh *dm, int index)
MVertCDDM_get_verts (DerivedMesh *dm)
MEdgeCDDM_get_edges (DerivedMesh *dm)
MFaceCDDM_get_faces (DerivedMesh *dm)

Detailed Description

Definition in file cdderivedmesh.c.


Define Documentation

#define PASSVERT (   index)
Value:
{                       \
    if(shademodel == GL_SMOOTH) {               \
        short *no = mvert[index].no;            \
        glNormal3sv(no);                        \
    }                                           \
    glVertex3fv(mvert[index].co);   \
}

Referenced by cdDM_drawFacesSolid().


Function Documentation

static int can_pbvh_draw ( Object ob,
DerivedMesh dm 
) [static]
void CDDM_apply_vert_coords ( DerivedMesh dm,
float(*)  vertCoords[3] 
)
void CDDM_apply_vert_normals ( DerivedMesh dm,
short(*)  vertNormals[3] 
)
void CDDM_calc_edges ( DerivedMesh dm)
void CDDM_calc_normals ( DerivedMesh dm)
DerivedMesh* CDDM_copy ( DerivedMesh source) [read]
static void cdDM_copyEdgeArray ( DerivedMesh dm,
MEdge edge_r 
) [static]

Definition at line 125 of file cdderivedmesh.c.

References CDDerivedMesh::medge, and DerivedMesh::numEdgeData.

Referenced by cdDM_create().

static void cdDM_copyFaceArray ( DerivedMesh dm,
MFace face_r 
) [static]

Definition at line 131 of file cdderivedmesh.c.

References CDDerivedMesh::mface, and DerivedMesh::numFaceData.

Referenced by cdDM_create().

static void cdDM_copyVertArray ( DerivedMesh dm,
MVert vert_r 
) [static]

Definition at line 119 of file cdderivedmesh.c.

References CDDerivedMesh::mvert, and DerivedMesh::numVertData.

Referenced by cdDM_create().

static CDDerivedMesh* cdDM_create ( const char *  desc) [static]

Definition at line 1556 of file cdderivedmesh.c.

References cdDM_copyEdgeArray(), cdDM_copyFaceArray(), cdDM_copyVertArray(), cdDM_drawEdges(), cdDM_drawFacesColored(), cdDM_drawFacesGLSL(), cdDM_drawFacesSolid(), cdDM_drawFacesTex(), cdDM_drawLooseEdges(), cdDM_drawMappedEdges(), cdDM_drawMappedFaces(), cdDM_drawMappedFacesGLSL(), cdDM_drawMappedFacesMat(), cdDM_drawMappedFacesTex(), cdDM_drawUVEdges(), cdDM_drawVerts(), cdDM_foreachMappedEdge(), cdDM_foreachMappedFaceCenter(), cdDM_foreachMappedVert(), cdDM_getEdge(), cdDM_getFace(), cdDM_getFaceMap(), cdDM_getMinMax(), cdDM_getNumEdges(), cdDM_getNumFaces(), cdDM_getNumVerts(), cdDM_getPBVH(), cdDM_getVert(), cdDM_getVertCo(), cdDM_getVertCos(), cdDM_getVertNo(), cdDM_release(), DerivedMesh::copyEdgeArray, DerivedMesh::copyFaceArray, DerivedMesh::copyVertArray, CDDerivedMesh::dm, DM_get_edge_data(), DM_get_edge_data_layer(), DM_get_face_data(), DM_get_face_data_layer(), DM_get_vert_data(), DM_get_vert_data_layer(), DerivedMesh::drawEdges, DerivedMesh::drawFacesColored, DerivedMesh::drawFacesGLSL, DerivedMesh::drawFacesSolid, DerivedMesh::drawFacesTex, DerivedMesh::drawLooseEdges, DerivedMesh::drawMappedEdges, DerivedMesh::drawMappedFaces, DerivedMesh::drawMappedFacesGLSL, DerivedMesh::drawMappedFacesMat, DerivedMesh::drawMappedFacesTex, DerivedMesh::drawUVEdges, DerivedMesh::drawVerts, DerivedMesh::foreachMappedEdge, DerivedMesh::foreachMappedFaceCenter, DerivedMesh::foreachMappedVert, DerivedMesh::getEdge, DerivedMesh::getEdgeData, DerivedMesh::getEdgeDataArray, DerivedMesh::getFace, DerivedMesh::getFaceData, DerivedMesh::getFaceDataArray, DerivedMesh::getFaceMap, DerivedMesh::getMinMax, DerivedMesh::getNumEdges, DerivedMesh::getNumFaces, DerivedMesh::getNumVerts, DerivedMesh::getPBVH, DerivedMesh::getVert, DerivedMesh::getVertCo, DerivedMesh::getVertCos, DerivedMesh::getVertData, DerivedMesh::getVertDataArray, DerivedMesh::getVertNo, MEM_callocN(), and DerivedMesh::release.

Referenced by CDDM_copy(), CDDM_from_mesh(), CDDM_from_template(), and CDDM_new().

static void cddm_draw_attrib_vertex ( DMVertexAttribs attribs,
MVert mvert,
int  a,
int  index,
int  vert,
int  smoothnormal 
) [static]
static void cdDM_drawEdges ( DerivedMesh dm,
int  drawLooseEdges,
int  drawAllEdges 
) [static]
static void cdDM_drawFacesColored ( DerivedMesh dm,
int  useTwoSided,
unsigned char *  col1,
unsigned char *  col2 
) [static]
static void cdDM_drawFacesGLSL ( DerivedMesh dm,
int(*)(int, void *attribs)  setMaterial 
) [static]

Definition at line 1350 of file cdderivedmesh.c.

References DerivedMesh::drawMappedFacesGLSL, and NULL.

Referenced by cdDM_create().

static void cdDM_drawFacesSolid ( DerivedMesh dm,
float(*)  partial_redraw_planes[4],
int   UNUSEDfast,
int(*)(int, void *attribs)  setMaterial 
) [static]
static void cdDM_drawFacesTex ( DerivedMesh dm,
int(*)(MTFace *tface, int has_mcol, int matnr)  setDrawOptions,
int(*)(void *userData, int cur_index, int next_index)  compareDrawOptions,
void *  userData 
) [static]

Definition at line 835 of file cdderivedmesh.c.

References cdDM_drawFacesTex_common(), compareDrawOptions(), and NULL.

Referenced by cdDM_create().

static void cdDM_drawFacesTex_common ( DerivedMesh dm,
int(*)(MTFace *tface, int has_mcol, int matnr)  drawParams,
int(*)(void *userData, int index)  drawParamsMapped,
int(*)(void *userData, int cur_index, int next_index)  compareDrawOptions,
void *  userData 
) [static]
static void cdDM_drawLooseEdges ( DerivedMesh dm) [static]
static void cdDM_drawMappedEdges ( DerivedMesh dm,
int(*)(void *userData, int index)  setDrawOptions,
void *  userData 
) [static]
static void cdDM_drawMappedFaces ( DerivedMesh dm,
int(*)(void *userData, int index, int *drawSmooth_r)  setDrawOptions,
int(*)(int, void *attribs)  setMaterial,
int(*)(void *userData, int cur_index, int next_index)  compareDrawOptions,
void *  userData,
int  useColors 
) [static]
static void cdDM_drawMappedFacesGLSL ( DerivedMesh dm,
int(*)(int, void *attribs)  setMaterial,
int(*)(void *userData, int index)  setDrawOptions,
void *  userData 
) [static]
static void cdDM_drawMappedFacesMat ( DerivedMesh dm,
void(*)(void *userData, int, void *attribs)  setMaterial,
int(*)(void *userData, int index)  setFace,
void *  userData 
) [static]
static void cdDM_drawMappedFacesTex ( DerivedMesh dm,
int(*)(void *userData, int index)  setDrawOptions,
int(*)(void *userData, int cur_index, int next_index)  compareDrawOptions,
void *  userData 
) [static]

Definition at line 1008 of file cdderivedmesh.c.

References cdDM_drawFacesTex_common(), compareDrawOptions(), and NULL.

Referenced by cdDM_create().

static void cdDM_drawUVEdges ( DerivedMesh dm) [static]
static void cdDM_drawVerts ( DerivedMesh dm) [static]
static void cdDM_foreachMappedEdge ( DerivedMesh dm,
void(*)(void *userData, int index, float *v0co, float *v1co)  func,
void *  userData 
) [static]
static void cdDM_foreachMappedFaceCenter ( DerivedMesh dm,
void(*)(void *userData, int index, float *cent, float *no)  func,
void *  userData 
) [static]
static void cdDM_foreachMappedVert ( DerivedMesh dm,
void(*)(void *userData, int index, float *co, float *no_f, short *no_s)  func,
void *  userData 
) [static]
static void cdDM_free_internal ( CDDerivedMesh cddm) [static]

Definition at line 1539 of file cdderivedmesh.c.

References CDDerivedMesh::fmap, CDDerivedMesh::fmap_mem, and MEM_freeN().

Referenced by cdDM_release().

DerivedMesh* CDDM_from_curve ( Object ob) [read]

Definition at line 1762 of file cdderivedmesh.c.

References CDDM_from_curve_customDB(), and Object::disp.

Referenced by applyModifier(), and get_dm().

DerivedMesh* CDDM_from_curve_customDB ( Object ob,
ListBase dispbase 
)
DerivedMesh* CDDM_from_editmesh ( EditMesh em,
Mesh UNUSEDme 
)
DerivedMesh* CDDM_from_mesh ( Mesh mesh,
Object UNUSEDob 
)
DerivedMesh* CDDM_from_template ( DerivedMesh source,
int  numVerts,
int  numEdges,
int  numFaces 
) [read]
MEdge* CDDM_get_edge ( DerivedMesh dm,
int  index 
) [read]

Definition at line 1999 of file cdderivedmesh.c.

Referenced by applyModifier(), and doMirrorOnAxis().

MEdge* CDDM_get_edges ( DerivedMesh dm) [read]
MFace* CDDM_get_face ( DerivedMesh dm,
int  index 
) [read]
MFace* CDDM_get_faces ( DerivedMesh dm) [read]
MVert* CDDM_get_vert ( DerivedMesh dm,
int  index 
) [read]
MVert* CDDM_get_verts ( DerivedMesh dm) [read]
static void cdDM_getEdge ( DerivedMesh dm,
int  index,
MEdge edge_r 
) [static]

Definition at line 107 of file cdderivedmesh.c.

References IndexNode::index, and CDDerivedMesh::medge.

Referenced by cdDM_create().

static void cdDM_getFace ( DerivedMesh dm,
int  index,
MFace face_r 
) [static]

Definition at line 113 of file cdderivedmesh.c.

References IndexNode::index, and CDDerivedMesh::mface.

Referenced by cdDM_create().

static ListBase* cdDM_getFaceMap ( Object ob,
DerivedMesh dm 
) [static]
static void cdDM_getMinMax ( DerivedMesh dm,
float  min_r[3],
float  max_r[3] 
) [static]

Definition at line 137 of file cdderivedmesh.c.

References MVert::co, DO_MINMAX, i, CDDerivedMesh::mvert, and DerivedMesh::numVertData.

Referenced by cdDM_create().

static int cdDM_getNumEdges ( DerivedMesh dm) [static]

Definition at line 91 of file cdderivedmesh.c.

References DerivedMesh::numEdgeData.

Referenced by cdDM_create().

static int cdDM_getNumFaces ( DerivedMesh dm) [static]

Definition at line 96 of file cdderivedmesh.c.

References DerivedMesh::numFaceData.

Referenced by cdDM_create().

static int cdDM_getNumVerts ( DerivedMesh dm) [static]

Definition at line 86 of file cdderivedmesh.c.

References DerivedMesh::numVertData.

Referenced by cdDM_create().

static struct PBVH* cdDM_getPBVH ( Object ob,
DerivedMesh dm 
) [static, read]
static void cdDM_getVert ( DerivedMesh dm,
int  index,
MVert vert_r 
) [static]

Definition at line 101 of file cdderivedmesh.c.

References IndexNode::index, and CDDerivedMesh::mvert.

Referenced by cdDM_create().

static void cdDM_getVertCo ( DerivedMesh dm,
int  index,
float  co_r[3] 
) [static]

Definition at line 151 of file cdderivedmesh.c.

References MVert::co, copy_v3_v3(), and CDDerivedMesh::mvert.

Referenced by cdDM_create().

static void cdDM_getVertCos ( DerivedMesh dm,
float(*)  cos_r[3] 
) [static]

Definition at line 158 of file cdderivedmesh.c.

References CDDM_get_verts(), MVert::co, copy_v3_v3(), i, and DerivedMesh::numVertData.

Referenced by cdDM_create().

static void cdDM_getVertNo ( DerivedMesh dm,
int  index,
float  no_r[3] 
) [static]

Definition at line 167 of file cdderivedmesh.c.

References CDDerivedMesh::mvert, MVert::no, and normal_short_to_float_v3().

Referenced by cdDM_create().

void CDDM_lower_num_edges ( DerivedMesh dm,
int  numEdges 
)
void CDDM_lower_num_faces ( DerivedMesh dm,
int  numFaces 
)
void CDDM_lower_num_verts ( DerivedMesh dm,
int  numVerts 
)
DerivedMesh* CDDM_new ( int  numVerts,
int  numEdges,
int  numFaces 
) [read]
static void cdDM_release ( DerivedMesh dm) [static]

Definition at line 1545 of file cdderivedmesh.c.

References cdDM_free_internal(), DM_release(), and MEM_freeN().

Referenced by cdDM_create().

static void cdDM_update_normals_from_pbvh ( DerivedMesh dm) [static]