Blender V2.61 - r43446

BKE_DerivedMesh.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00028 #ifndef BKE_DERIVEDMESH_H
00029 #define BKE_DERIVEDMESH_H
00030 
00045 #include "DNA_customdata_types.h"
00046 #include "BKE_customdata.h"
00047 #include "BKE_bvhutils.h"
00048 
00049 struct MVert;
00050 struct MEdge;
00051 struct MFace;
00052 struct MTFace;
00053 struct Object;
00054 struct Scene;
00055 struct Mesh;
00056 struct EditMesh;
00057 struct KeyBlock;
00058 struct ModifierData;
00059 struct MCol;
00060 struct ColorBand;
00061 struct GPUVertexAttribs;
00062 struct GPUDrawObject;
00063 struct ListBase;
00064 struct PBVH;
00065 
00066 /* number of sub-elements each mesh element has (for interpolation) */
00067 #define SUB_ELEMS_VERT 0
00068 #define SUB_ELEMS_EDGE 2
00069 #define SUB_ELEMS_FACE 4
00070 
00071 typedef struct DMGridData {
00072     float co[3];
00073     float no[3];
00074 } DMGridData;
00075 
00076 typedef struct DMGridAdjacency {
00077     int index[4];
00078     int rotation[4];
00079 } DMGridAdjacency;
00080 
00081 typedef enum DerivedMeshType {
00082     DM_TYPE_CDDM,
00083     DM_TYPE_EDITMESH,
00084     DM_TYPE_CCGDM
00085 } DerivedMeshType;
00086 
00087 typedef struct DerivedMesh DerivedMesh;
00088 struct DerivedMesh {
00089     /* Private DerivedMesh data, only for internal DerivedMesh use */
00090     CustomData vertData, edgeData, faceData;
00091     int numVertData, numEdgeData, numFaceData;
00092     int needsFree; /* checked on ->release, is set to 0 for cached results */
00093     int deformedOnly; /* set by modifier stack if only deformed from original */
00094     BVHCache bvhCache;
00095     struct GPUDrawObject *drawObject;
00096     DerivedMeshType type;
00097     float auto_bump_scale;
00098 
00099     /* Misc. Queries */
00100 
00101     /* Also called in Editmode */
00102     int (*getNumVerts)(DerivedMesh *dm);
00103     /* Also called in Editmode */
00104     int (*getNumFaces)(DerivedMesh *dm);
00105 
00106     int (*getNumEdges)(DerivedMesh *dm);
00107 
00108     /* copy a single vert/edge/face from the derived mesh into
00109      * *{vert/edge/face}_r. note that the current implementation
00110      * of this function can be quite slow, iterating over all
00111      * elements (editmesh)
00112      */
00113     void (*getVert)(DerivedMesh *dm, int index, struct MVert *vert_r);
00114     void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *edge_r);
00115     void (*getFace)(DerivedMesh *dm, int index, struct MFace *face_r);
00116 
00117     /* return a pointer to the entire array of verts/edges/face from the
00118      * derived mesh. if such an array does not exist yet, it will be created,
00119      * and freed on the next ->release(). consider using getVert/Edge/Face if
00120      * you are only interested in a few verts/edges/faces.
00121      */
00122     struct MVert *(*getVertArray)(DerivedMesh *dm);
00123     struct MEdge *(*getEdgeArray)(DerivedMesh *dm);
00124     struct MFace *(*getFaceArray)(DerivedMesh *dm);
00125 
00126     /* copy all verts/edges/faces from the derived mesh into
00127      * *{vert/edge/face}_r (must point to a buffer large enough)
00128      */
00129     void (*copyVertArray)(DerivedMesh *dm, struct MVert *vert_r);
00130     void (*copyEdgeArray)(DerivedMesh *dm, struct MEdge *edge_r);
00131     void (*copyFaceArray)(DerivedMesh *dm, struct MFace *face_r);
00132 
00133     /* return a copy of all verts/edges/faces from the derived mesh
00134      * it is the caller's responsibility to free the returned pointer
00135      */
00136     struct MVert *(*dupVertArray)(DerivedMesh *dm);
00137     struct MEdge *(*dupEdgeArray)(DerivedMesh *dm);
00138     struct MFace *(*dupFaceArray)(DerivedMesh *dm);
00139 
00140     /* return a pointer to a single element of vert/edge/face custom data
00141      * from the derived mesh (this gives a pointer to the actual data, not
00142      * a copy)
00143      */
00144     void *(*getVertData)(DerivedMesh *dm, int index, int type);
00145     void *(*getEdgeData)(DerivedMesh *dm, int index, int type);
00146     void *(*getFaceData)(DerivedMesh *dm, int index, int type);
00147 
00148     /* return a pointer to the entire array of vert/edge/face custom data
00149      * from the derived mesh (this gives a pointer to the actual data, not
00150      * a copy)
00151      */
00152     void *(*getVertDataArray)(DerivedMesh *dm, int type);
00153     void *(*getEdgeDataArray)(DerivedMesh *dm, int type);
00154     void *(*getFaceDataArray)(DerivedMesh *dm, int type);
00155 
00156     /* optional grid access for subsurf */
00157     int (*getNumGrids)(DerivedMesh *dm);
00158     int (*getGridSize)(DerivedMesh *dm);
00159     DMGridData **(*getGridData)(DerivedMesh *dm);
00160     DMGridAdjacency *(*getGridAdjacency)(DerivedMesh *dm);
00161     int *(*getGridOffset)(DerivedMesh *dm);
00162 
00163     /* Iterate over each mapped vertex in the derived mesh, calling the
00164      * given function with the original vert and the mapped vert's new
00165      * coordinate and normal. For historical reasons the normal can be
00166      * passed as a float or short array, only one should be non-NULL.
00167      */
00168     void (*foreachMappedVert)(
00169                           DerivedMesh *dm,
00170                           void (*func)(void *userData, int index, float *co,
00171                                        float *no_f, short *no_s),
00172                           void *userData);
00173 
00174     /* Iterate over each mapped edge in the derived mesh, calling the
00175      * given function with the original edge and the mapped edge's new
00176      * coordinates.
00177      */
00178     void (*foreachMappedEdge)(DerivedMesh *dm,
00179                               void (*func)(void *userData, int index,
00180                                            float *v0co, float *v1co),
00181                               void *userData);
00182 
00183     /* Iterate over each mapped face in the derived mesh, calling the
00184      * given function with the original face and the mapped face's (or
00185      * faces') center and normal.
00186      */
00187     void (*foreachMappedFaceCenter)(DerivedMesh *dm,
00188                                     void (*func)(void *userData, int index,
00189                                                  float *cent, float *no),
00190                                     void *userData);
00191 
00192     /* Iterate over all vertex points, calling DO_MINMAX with given args.
00193      *
00194      * Also called in Editmode
00195      */
00196     void (*getMinMax)(DerivedMesh *dm, float min_r[3], float max_r[3]);
00197 
00198     /* Direct Access Operations */
00199     /*  o Can be undefined */
00200     /*  o Must be defined for modifiers that only deform however */
00201 
00202     /* Get vertex location, undefined if index is not valid */
00203     void (*getVertCo)(DerivedMesh *dm, int index, float co_r[3]);
00204 
00205     /* Fill the array (of length .getNumVerts()) with all vertex locations */
00206     void (*getVertCos)(DerivedMesh *dm, float (*cos_r)[3]);
00207 
00208     /* Get smooth vertex normal, undefined if index is not valid */
00209     void (*getVertNo)(DerivedMesh *dm, int index, float no_r[3]);
00210 
00211     /* Get a map of vertices to faces
00212      */
00213     struct ListBase *(*getFaceMap)(struct Object *ob, DerivedMesh *dm);
00214 
00215     /* Get the BVH used for paint modes
00216      */
00217     struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm);
00218 
00219     /* Drawing Operations */
00220 
00221     /* Draw all vertices as bgl points (no options) */
00222     void (*drawVerts)(DerivedMesh *dm);
00223 
00224     /* Draw edges in the UV mesh (if exists) */
00225     void (*drawUVEdges)(DerivedMesh *dm);
00226 
00227     /* Draw all edges as lines (no options) 
00228      *
00229      * Also called for *final* editmode DerivedMeshes
00230      */
00231     void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges);
00232     
00233     /* Draw all loose edges (edges w/ no adjoining faces) */
00234     void (*drawLooseEdges)(DerivedMesh *dm);
00235 
00236     /* Draw all faces
00237      *  o Set face normal or vertex normal based on inherited face flag
00238      *  o Use inherited face material index to call setMaterial
00239      *  o Only if setMaterial returns true
00240      *
00241      * Also called for *final* editmode DerivedMeshes
00242      */
00243     void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
00244                            int fast, int (*setMaterial)(int, void *attribs));
00245 
00246     /* Draw all faces
00247      *  o If useTwoSided, draw front and back using col arrays
00248      *  o col1,col2 are arrays of length numFace*4 of 4 component colors
00249      *    in ABGR format, and should be passed as per-face vertex color.
00250      */
00251     void (*drawFacesColored)(DerivedMesh *dm, int useTwoSided,
00252                              unsigned char *col1, unsigned char *col2);
00253 
00254     /* Draw all faces using MTFace 
00255      *  o Drawing options too complicated to enumerate, look at code.
00256      */
00257     void (*drawFacesTex)(DerivedMesh *dm,
00258                          int (*setDrawOptions)(struct MTFace *tface,
00259                              int has_mcol, int matnr),
00260                         int (*compareDrawOptions)(void *userData,
00261                              int cur_index,
00262                              int next_index),
00263                         void *userData);
00264 
00265     /* Draw all faces with GLSL materials
00266      *  o setMaterial is called for every different material nr
00267      *  o Only if setMaterial returns true
00268      */
00269     void (*drawFacesGLSL)(DerivedMesh *dm,
00270         int (*setMaterial)(int, void *attribs));
00271 
00272     /* Draw mapped faces (no color, or texture)
00273      *  o Only if !setDrawOptions or
00274      *    setDrawOptions(userData, mapped-face-index, drawSmooth_r)
00275      *    returns true
00276      *
00277      * If drawSmooth is set to true then vertex normals should be set and
00278      * glShadeModel called with GL_SMOOTH. Otherwise the face normal should
00279      * be set and glShadeModel called with GL_FLAT.
00280      *
00281      * The setDrawOptions is allowed to not set drawSmooth (for example, when
00282      * lighting is disabled), in which case the implementation should draw as
00283      * smooth shaded.
00284      */
00285     void (*drawMappedFaces)(DerivedMesh *dm,
00286                             int (*setDrawOptions)(void *userData, int index,
00287                                                   int *drawSmooth_r),
00288                             int (*setMaterial)(int, void *attribs),
00289                             int (*compareDrawOptions)(void *userData,
00290                                                       int cur_index,
00291                                                       int next_index),
00292                             void *userData, int useColors);
00293 
00294     /* Draw mapped faces using MTFace 
00295      *  o Drawing options too complicated to enumerate, look at code.
00296      */
00297     void (*drawMappedFacesTex)(DerivedMesh *dm,
00298                                int (*setDrawOptions)(void *userData,
00299                                                      int index),
00300                                int (*compareDrawOptions)(void *userData,
00301                                                          int cur_index,
00302                                                          int next_index),
00303                                void *userData);
00304 
00305     /* Draw mapped faces with GLSL materials
00306      *  o setMaterial is called for every different material nr
00307      *  o setDrawOptions is called for every face
00308      *  o Only if setMaterial and setDrawOptions return true
00309      */
00310     void (*drawMappedFacesGLSL)(DerivedMesh *dm,
00311         int (*setMaterial)(int, void *attribs),
00312         int (*setDrawOptions)(void *userData, int index),
00313         void *userData);
00314 
00315     /* Draw mapped edges as lines
00316      *  o Only if !setDrawOptions or setDrawOptions(userData, mapped-edge)
00317      *    returns true
00318      */
00319     void (*drawMappedEdges)(DerivedMesh *dm,
00320                             int (*setDrawOptions)(void *userData, int index),
00321                             void *userData);
00322 
00323     /* Draw mapped edges as lines with interpolation values
00324      *  o Only if !setDrawOptions or
00325      *    setDrawOptions(userData, mapped-edge, mapped-v0, mapped-v1, t)
00326      *    returns true
00327      *
00328      * NOTE: This routine is optional!
00329      */
00330     void (*drawMappedEdgesInterp)(DerivedMesh *dm, 
00331                                   int (*setDrawOptions)(void *userData,
00332                                                         int index), 
00333                                   void (*setDrawInterpOptions)(void *userData,
00334                                                                int index,
00335                                                                float t),
00336                                   void *userData);
00337 
00338     /* Draw all faces with materials
00339      *  o setMaterial is called for every different material nr
00340      *  o setFace is called to verify if a face must be hidden
00341      */
00342     void (*drawMappedFacesMat)(DerivedMesh *dm,
00343         void (*setMaterial)(void *userData, int, void *attribs),
00344         int (*setFace)(void *userData, int index), void *userData);
00345 
00346     /* Release reference to the DerivedMesh. This function decides internally
00347      * if the DerivedMesh will be freed, or cached for later use. */
00348     void (*release)(DerivedMesh *dm);
00349 };
00350 
00351 /* utility function to initialise a DerivedMesh's function pointers to
00352  * the default implementation (for those functions which have a default)
00353  */
00354 void DM_init_funcs(DerivedMesh *dm);
00355 
00356 /* utility function to initialise a DerivedMesh for the desired number
00357  * of vertices, edges and faces (doesn't allocate memory for them, just
00358  * sets up the custom data layers)
00359  */
00360 void DM_init(DerivedMesh *dm, DerivedMeshType type,
00361              int numVerts, int numEdges, int numFaces);
00362 
00363 /* utility function to initialise a DerivedMesh for the desired number
00364  * of vertices, edges and faces, with a layer setup copied from source
00365  */
00366 void DM_from_template(DerivedMesh *dm, DerivedMesh *source,
00367                       DerivedMeshType type,
00368                       int numVerts, int numEdges, int numFaces);
00369 
00370 /* utility function to release a DerivedMesh's layers
00371  * returns 1 if DerivedMesh has to be released by the backend, 0 otherwise
00372  */
00373 int DM_release(DerivedMesh *dm);
00374 
00375 /* utility function to convert a DerivedMesh to a Mesh
00376  */
00377 void DM_to_mesh(DerivedMesh *dm, struct Mesh *me);
00378 
00379 /* utility function to convert a DerivedMesh to a shape key block 
00380  */
00381 void DM_to_meshkey(DerivedMesh *dm, struct Mesh *me, struct KeyBlock *kb);
00382 
00383 /* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
00384  * zero for the layer type, so only layer types specified by the mask
00385  * will be copied
00386  */
00387 void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask);
00388 
00389 /* adds a vertex/edge/face custom data layer to a DerivedMesh, optionally
00390  * backed by an external data array
00391  * alloctype defines how the layer is allocated or copied, and how it is
00392  * freed, see BKE_customdata.h for the different options
00393  */
00394 void DM_add_vert_layer(struct DerivedMesh *dm, int type, int alloctype,
00395                        void *layer);
00396 void DM_add_edge_layer(struct DerivedMesh *dm, int type, int alloctype,
00397                        void *layer);
00398 void DM_add_face_layer(struct DerivedMesh *dm, int type, int alloctype,
00399                        void *layer);
00400 
00401 /* custom data access functions
00402  * return pointer to data from first layer which matches type
00403  * if they return NULL for valid indices, data doesn't exist
00404  * note these return pointers - any change modifies the internals of the mesh
00405  */
00406 void *DM_get_vert_data(struct DerivedMesh *dm, int index, int type);
00407 void *DM_get_edge_data(struct DerivedMesh *dm, int index, int type);
00408 void *DM_get_face_data(struct DerivedMesh *dm, int index, int type);
00409 
00410 /* custom data layer access functions
00411  * return pointer to first data layer which matches type (a flat array)
00412  * if they return NULL, data doesn't exist
00413  * note these return pointers - any change modifies the internals of the mesh
00414  */
00415 void *DM_get_vert_data_layer(struct DerivedMesh *dm, int type);
00416 void *DM_get_edge_data_layer(struct DerivedMesh *dm, int type);
00417 void *DM_get_face_data_layer(struct DerivedMesh *dm, int type);
00418 
00419 /* custom data setting functions
00420  * copy supplied data into first layer of type using layer's copy function
00421  * (deep copy if appropriate)
00422  */
00423 void DM_set_vert_data(struct DerivedMesh *dm, int index, int type, void *data);
00424 void DM_set_edge_data(struct DerivedMesh *dm, int index, int type, void *data);
00425 void DM_set_face_data(struct DerivedMesh *dm, int index, int type, void *data);
00426 
00427 /* custom data copy functions
00428  * copy count elements from source_index in source to dest_index in dest
00429  * these copy all layers for which the CD_FLAG_NOCOPY flag is not set
00430  */
00431 void DM_copy_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest,
00432                        int source_index, int dest_index, int count);
00433 void DM_copy_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest,
00434                        int source_index, int dest_index, int count);
00435 void DM_copy_face_data(struct DerivedMesh *source, struct DerivedMesh *dest,
00436                        int source_index, int dest_index, int count);
00437 
00438 /* custom data free functions
00439  * free count elements, starting at index
00440  * they free all layers for which the CD_FLAG_NOCOPY flag is not set
00441  */
00442 void DM_free_vert_data(struct DerivedMesh *dm, int index, int count);
00443 void DM_free_edge_data(struct DerivedMesh *dm, int index, int count);
00444 void DM_free_face_data(struct DerivedMesh *dm, int index, int count);
00445 
00446 /* interpolates vertex data from the vertices indexed by src_indices in the
00447  * source mesh using the given weights and stores the result in the vertex
00448  * indexed by dest_index in the dest mesh
00449  */
00450 void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest,
00451                          int *src_indices, float *weights,
00452                          int count, int dest_index);
00453 
00454 /* interpolates edge data from the edges indexed by src_indices in the
00455  * source mesh using the given weights and stores the result in the edge indexed
00456  * by dest_index in the dest mesh.
00457  * if weights is NULL, all weights default to 1.
00458  * if vert_weights is non-NULL, any per-vertex edge data is interpolated using
00459  * vert_weights[i] multiplied by weights[i].
00460  */
00461 typedef float EdgeVertWeight[SUB_ELEMS_EDGE][SUB_ELEMS_EDGE];
00462 void DM_interp_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest,
00463                          int *src_indices,
00464                          float *weights, EdgeVertWeight *vert_weights,
00465                          int count, int dest_index);
00466 
00467 /* interpolates face data from the faces indexed by src_indices in the
00468  * source mesh using the given weights and stores the result in the face indexed
00469  * by dest_index in the dest mesh.
00470  * if weights is NULL, all weights default to 1.
00471  * if vert_weights is non-NULL, any per-vertex face data is interpolated using
00472  * vert_weights[i] multiplied by weights[i].
00473  */
00474 typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE];
00475 void DM_interp_face_data(struct DerivedMesh *source, struct DerivedMesh *dest,
00476                          int *src_indices,
00477                          float *weights, FaceVertWeight *vert_weights,
00478                          int count, int dest_index);
00479 
00480 void DM_swap_face_data(struct DerivedMesh *dm, int index, const int *corner_indices);
00481 
00482 /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
00483 void vDM_ColorBand_store(struct ColorBand *coba);
00484 
00485 /* Simple function to get me->totvert amount of vertices/normals,
00486    correctly deformed and subsurfered. Needed especially when vertexgroups are involved.
00487    In use now by vertex/weigt paint and particles */
00488 float *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
00489 
00490     /* */
00491 DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob,
00492                                     CustomDataMask dataMask);
00493 DerivedMesh *mesh_get_derived_deform(struct Scene *scene, struct Object *ob,
00494                                      CustomDataMask dataMask);
00495 
00496 DerivedMesh *mesh_create_derived_for_modifier(struct Scene *scene, struct Object *ob, struct ModifierData *md);
00497 
00498 DerivedMesh *mesh_create_derived_render(struct Scene *scene, struct Object *ob,
00499                                         CustomDataMask dataMask);
00500 
00501 DerivedMesh *mesh_create_derived_index_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index);
00502 
00503         /* same as above but wont use render settings */
00504 DerivedMesh *mesh_create_derived(struct Mesh *me, struct Object *ob, float (*vertCos)[3]);
00505 DerivedMesh *mesh_create_derived_view(struct Scene *scene, struct Object *ob,
00506                                       CustomDataMask dataMask);
00507 DerivedMesh *mesh_create_derived_no_deform(struct Scene *scene, struct Object *ob,
00508                                            float (*vertCos)[3],
00509                                            CustomDataMask dataMask);
00510 DerivedMesh *mesh_create_derived_no_deform_render(struct Scene *scene, struct Object *ob,
00511                                                   float (*vertCos)[3],
00512                                                   CustomDataMask dataMask);
00513 /* for gameengine */
00514 DerivedMesh *mesh_create_derived_no_virtual(struct Scene *scene, struct Object *ob, float (*vertCos)[3],
00515                                             CustomDataMask dataMask);
00516 DerivedMesh *mesh_create_derived_physics(struct Scene *scene, struct Object *ob, float (*vertCos)[3],
00517                                             CustomDataMask dataMask);
00518 
00519 DerivedMesh *editmesh_get_derived(struct EditMesh *em, float (*vertexCos)[3]);
00520 DerivedMesh *editmesh_get_derived_base(struct Object *, struct EditMesh *em);
00521 DerivedMesh *editmesh_get_derived_cage(struct Scene *scene, struct Object *, 
00522                                        struct EditMesh *em, CustomDataMask dataMask);
00523 DerivedMesh *editmesh_get_derived_cage_and_final(struct Scene *scene, struct Object *, 
00524                                                  struct EditMesh *em, DerivedMesh **final_r,
00525                                                  CustomDataMask dataMask);
00526 float (*editmesh_get_vertex_cos(struct EditMesh *em, int *numVerts_r))[3];
00527 int editmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
00528 void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct EditMesh *em, CustomDataMask dataMask);
00529 
00530 /* returns an array of deform matrices for crazyspace correction, and the
00531    number of modifiers left */
00532 int editmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct EditMesh *em,
00533                                        float (**deformmats)[3][3], float (**deformcos)[3]);
00534 
00535 /* returns an array of deform matrices for crazyspace correction when sculpting,
00536    and the number of modifiers left */
00537 int sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob,
00538                                 float (**deformmats)[3][3], float (**deformcos)[3]);
00539 
00540 void weight_to_rgb(float r_rgb[3], const float weight);
00541 
00542 /* convert layers requested by a GLSL material to actually available layers in
00543  * the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
00544 typedef struct DMVertexAttribs {
00545     struct {
00546         struct MTFace *array;
00547         int emOffset, glIndex, glTexco;
00548     } tface[MAX_MTFACE];
00549 
00550     struct {
00551         struct MCol *array;
00552         int emOffset, glIndex;
00553     } mcol[MAX_MCOL];
00554 
00555     struct {
00556         float (*array)[4];
00557         int emOffset, glIndex;
00558     } tang;
00559 
00560     struct {
00561         float (*array)[3];
00562         int emOffset, glIndex, glTexco;
00563     } orco;
00564 
00565     int tottface, totmcol, tottang, totorco;
00566 } DMVertexAttribs;
00567 
00568 /* should be local, bmesh replaces this */
00569 typedef struct {
00570     DerivedMesh dm;
00571 
00572     struct EditMesh *em;
00573     float (*vertexCos)[3];
00574     float (*vertexNos)[3];
00575     float (*faceNos)[3];
00576 } EditMeshDerivedMesh;
00577 
00578 void DM_vertex_attributes_from_gpu(DerivedMesh *dm,
00579     struct GPUVertexAttribs *gattribs, DMVertexAttribs *attribs);
00580 
00581 void DM_add_tangent_layer(DerivedMesh *dm);
00582 void DM_calc_auto_bump_scale(DerivedMesh *dm);
00583 
00584 /* Set object's bounding box based on DerivedMesh min/max data */
00585 void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm);
00586 
00587 #endif
00588