diff options
Diffstat (limited to 'source/blender/blenkernel')
24 files changed, 445 insertions, 136 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index c7ddab47952..64512dcaac8 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -28,12 +28,14 @@ #ifndef __BKE_DERIVEDMESH_H__ #define __BKE_DERIVEDMESH_H__ -/* +/** * Basic design of the DerivedMesh system: * * DerivedMesh is a common set of interfaces for mesh systems. * - * There are three main mesh data structures in Blender: Mesh, CDDM, and BMesh. + * There are three main mesh data structures in Blender: + * #Mesh, #CDDerivedMesh and #BMesh. + * * These, and a few others, all implement DerivedMesh interfaces, * which contains unified drawing interfaces, a few utility interfaces, * and a bunch of read-only interfaces intended mostly for conversion from @@ -67,7 +69,6 @@ * as it is and stick with using BMesh and CDDM. */ - #include "DNA_customdata_types.h" #include "DNA_meshdata_types.h" @@ -151,7 +152,7 @@ typedef enum DMDirtyFlag { typedef struct DerivedMesh DerivedMesh; struct DerivedMesh { - /* Private DerivedMesh data, only for internal DerivedMesh use */ + /** Private DerivedMesh data, only for internal DerivedMesh use */ CustomData vertData, edgeData, faceData, loopData, polyData; int numVertData, numEdgeData, numTessFaceData, numLoopData, numPolyData; int needsFree; /* checked on ->release, is set to 0 for cached results */ @@ -162,10 +163,10 @@ struct DerivedMesh { float auto_bump_scale; DMDirtyFlag dirty; - /* calculate vert and face normals */ + /** Calculate vert and face normals */ void (*calcNormals)(DerivedMesh *dm); - /* recalculates mesh tessellation */ + /** Recalculates mesh tessellation */ void (*recalcTessellation)(DerivedMesh *dm); /* Misc. Queries */ @@ -177,7 +178,7 @@ struct DerivedMesh { int (*getNumLoops)(DerivedMesh *dm); int (*getNumPolys)(DerivedMesh *dm); - /* copy a single vert/edge/tessellated face from the derived mesh into + /** Copy a single vert/edge/tessellated face from the derived mesh into * *{vert/edge/face}_r. note that the current implementation * of this function can be quite slow, iterating over all * elements (editmesh) @@ -186,7 +187,7 @@ struct DerivedMesh { void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *edge_r); void (*getTessFace)(DerivedMesh *dm, int index, struct MFace *face_r); - /* return a pointer to the entire array of verts/edges/face from the + /** Return a pointer to the entire array of verts/edges/face from the * derived mesh. if such an array does not exist yet, it will be created, * and freed on the next ->release(). consider using getVert/Edge/Face if * you are only interested in a few verts/edges/faces. @@ -197,7 +198,7 @@ struct DerivedMesh { struct MLoop *(*getLoopArray)(DerivedMesh * dm); struct MPoly *(*getPolyArray)(DerivedMesh * dm); - /* copy all verts/edges/faces from the derived mesh into + /** Copy all verts/edges/faces from the derived mesh into * *{vert/edge/face}_r (must point to a buffer large enough) */ void (*copyVertArray)(DerivedMesh *dm, struct MVert *vert_r); @@ -206,7 +207,7 @@ struct DerivedMesh { void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *loop_r); void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *poly_r); - /* return a copy of all verts/edges/faces from the derived mesh + /** Return a copy of all verts/edges/faces from the derived mesh * it is the caller's responsibility to free the returned pointer */ struct MVert *(*dupVertArray)(DerivedMesh * dm); @@ -215,7 +216,7 @@ struct DerivedMesh { struct MLoop *(*dupLoopArray)(DerivedMesh * dm); struct MPoly *(*dupPolyArray)(DerivedMesh * dm); - /* return a pointer to a single element of vert/edge/face custom data + /** Return a pointer to a single element of vert/edge/face custom data * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ @@ -223,7 +224,7 @@ struct DerivedMesh { void *(*getEdgeData)(DerivedMesh * dm, int index, int type); void *(*getTessFaceData)(DerivedMesh * dm, int index, int type); - /* return a pointer to the entire array of vert/edge/face custom data + /** Return a pointer to the entire array of vert/edge/face custom data * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ @@ -231,7 +232,7 @@ struct DerivedMesh { void *(*getEdgeDataArray)(DerivedMesh * dm, int type); void *(*getTessFaceDataArray)(DerivedMesh * dm, int type); - /* retrieves the base CustomData structures for + /** Retrieves the base CustomData structures for * verts/edges/tessfaces/loops/facdes*/ CustomData *(*getVertDataLayout)(DerivedMesh * dm); CustomData *(*getEdgeDataLayout)(DerivedMesh * dm); @@ -239,12 +240,12 @@ struct DerivedMesh { CustomData *(*getLoopDataLayout)(DerivedMesh * dm); CustomData *(*getPolyDataLayout)(DerivedMesh * dm); - /*copies all customdata for an element source into dst at index dest*/ + /** Copies all customdata for an element source into dst at index dest */ void (*copyFromVertCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); void (*copyFromEdgeCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); void (*copyFromFaceCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); - /* optional grid access for subsurf */ + /** Optional grid access for subsurf */ int (*getNumGrids)(DerivedMesh *dm); int (*getGridSize)(DerivedMesh *dm); struct CCGElem **(*getGridData)(DerivedMesh * dm); @@ -255,7 +256,7 @@ struct DerivedMesh { unsigned int **(*getGridHidden)(DerivedMesh * dm); - /* Iterate over each mapped vertex in the derived mesh, calling the + /** Iterate over each mapped vertex in the derived mesh, calling the * given function with the original vert and the mapped vert's new * coordinate and normal. For historical reasons the normal can be * passed as a float or short array, only one should be non-NULL. @@ -265,7 +266,7 @@ struct DerivedMesh { const float no_f[3], const short no_s[3]), void *userData); - /* Iterate over each mapped edge in the derived mesh, calling the + /** Iterate over each mapped edge in the derived mesh, calling the * given function with the original edge and the mapped edge's new * coordinates. */ @@ -274,7 +275,7 @@ struct DerivedMesh { const float v0co[3], const float v1co[3]), void *userData); - /* Iterate over each mapped face in the derived mesh, calling the + /** Iterate over each mapped face in the derived mesh, calling the * given function with the original face and the mapped face's (or * faces') center and normal. */ @@ -283,51 +284,51 @@ struct DerivedMesh { const float cent[3], const float no[3]), void *userData); - /* Iterate over all vertex points, calling DO_MINMAX with given args. + /** Iterate over all vertex points, calling DO_MINMAX with given args. * * Also called in Editmode */ void (*getMinMax)(DerivedMesh *dm, float min_r[3], float max_r[3]); - /* Direct Access Operations */ - /* o Can be undefined */ - /* o Must be defined for modifiers that only deform however */ + /** Direct Access Operations + * - Can be undefined + * - Must be defined for modifiers that only deform however */ - /* Get vertex location, undefined if index is not valid */ + /** Get vertex location, undefined if index is not valid */ void (*getVertCo)(DerivedMesh *dm, int index, float co_r[3]); - /* Fill the array (of length .getNumVerts()) with all vertex locations */ + /** Fill the array (of length .getNumVerts()) with all vertex locations */ void (*getVertCos)(DerivedMesh *dm, float (*cos_r)[3]); - /* Get smooth vertex normal, undefined if index is not valid */ + /** Get smooth vertex normal, undefined if index is not valid */ void (*getVertNo)(DerivedMesh *dm, int index, float no_r[3]); - /* Get a map of vertices to faces + /** Get a map of vertices to faces */ const struct MeshElemMap *(*getPolyMap)(struct Object *ob, DerivedMesh *dm); - /* Get the BVH used for paint modes + /** Get the BVH used for paint modes */ struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm); /* Drawing Operations */ - /* Draw all vertices as bgl points (no options) */ + /** Draw all vertices as bgl points (no options) */ void (*drawVerts)(DerivedMesh *dm); - /* Draw edges in the UV mesh (if exists) */ + /** Draw edges in the UV mesh (if exists) */ void (*drawUVEdges)(DerivedMesh *dm); - /* Draw all edges as lines (no options) + /** Draw all edges as lines (no options) * * Also called for *final* editmode DerivedMeshes */ void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges); - /* Draw all loose edges (edges w/ no adjoining faces) */ + /** Draw all loose edges (edges w/ no adjoining faces) */ void (*drawLooseEdges)(DerivedMesh *dm); - /* Draw all faces + /** Draw all faces * o Set face normal or vertex normal based on inherited face flag * o Use inherited face material index to call setMaterial * o Only if setMaterial returns true @@ -337,24 +338,24 @@ struct DerivedMesh { void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, DMSetMaterial setMaterial); - /* Draw all faces using MTFace - * o Drawing options too complicated to enumerate, look at code. + /** Draw all faces using MTFace + * - Drawing options too complicated to enumerate, look at code. */ void (*drawFacesTex)(DerivedMesh *dm, DMSetDrawOptionsTex setDrawOptions, DMCompareDrawOptions compareDrawOptions, void *userData); - /* Draw all faces with GLSL materials + /** Draw all faces with GLSL materials * o setMaterial is called for every different material nr * o Only if setMaterial returns true */ void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial); - /* Draw mapped faces (no color, or texture) - * o Only if !setDrawOptions or - * setDrawOptions(userData, mapped-face-index, drawSmooth_r) - * returns true + /** Draw mapped faces (no color, or texture) + * - Only if !setDrawOptions or + * setDrawOptions(userData, mapped-face-index, drawSmooth_r) + * returns true * * If drawSmooth is set to true then vertex normals should be set and * glShadeModel called with GL_SMOOTH. Otherwise the face normal should @@ -371,36 +372,36 @@ struct DerivedMesh { void *userData, DMDrawFlag flag); - /* Draw mapped faces using MTFace - * o Drawing options too complicated to enumerate, look at code. + /** Draw mapped faces using MTFace + * - Drawing options too complicated to enumerate, look at code. */ void (*drawMappedFacesTex)(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, DMCompareDrawOptions compareDrawOptions, void *userData); - /* Draw mapped faces with GLSL materials - * o setMaterial is called for every different material nr - * o setDrawOptions is called for every face - * o Only if setMaterial and setDrawOptions return true + /** Draw mapped faces with GLSL materials + * - setMaterial is called for every different material nr + * - setDrawOptions is called for every face + * - Only if setMaterial and setDrawOptions return true */ void (*drawMappedFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial, DMSetDrawOptions setDrawOptions, void *userData); - /* Draw mapped edges as lines - * o Only if !setDrawOptions or setDrawOptions(userData, mapped-edge) - * returns true + /** Draw mapped edges as lines + * - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge) + * returns true */ void (*drawMappedEdges)(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData); - /* Draw mapped edges as lines with interpolation values - * o Only if !setDrawOptions or - * setDrawOptions(userData, mapped-edge, mapped-v0, mapped-v1, t) - * returns true + /** Draw mapped edges as lines with interpolation values + * - Only if !setDrawOptions or + * setDrawOptions(userData, mapped-edge, mapped-v0, mapped-v1, t) + * returns true * * NOTE: This routine is optional! */ @@ -409,32 +410,32 @@ struct DerivedMesh { DMSetDrawInterpOptions setDrawInterpOptions, void *userData); - /* Draw all faces with materials - * o setMaterial is called for every different material nr - * o setFace is called to verify if a face must be hidden + /** Draw all faces with materials + * - setMaterial is called for every different material nr + * - setFace is called to verify if a face must be hidden */ void (*drawMappedFacesMat)(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData); - /* Release reference to the DerivedMesh. This function decides internally + /** Release reference to the DerivedMesh. This function decides internally * if the DerivedMesh will be freed, or cached for later use. */ void (*release)(DerivedMesh *dm); }; -/* utility function to initialize a DerivedMesh's function pointers to +/** utility function to initialize a DerivedMesh's function pointers to * the default implementation (for those functions which have a default) */ void DM_init_funcs(DerivedMesh *dm); -/* utility function to initialize a DerivedMesh for the desired number +/** utility function to initialize a DerivedMesh for the desired number * of vertices, edges and faces (doesn't allocate memory for them, just * sets up the custom data layers) */ void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges, int numFaces, int numLoops, int numPolys); -/* utility function to initialize a DerivedMesh for the desired number +/** utility function to initialize a DerivedMesh for the desired number * of vertices, edges and faces, with a layer setup copied from source */ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, @@ -442,12 +443,12 @@ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, int numVerts, int numEdges, int numFaces, int numLoops, int numPolys); -/* utility function to release a DerivedMesh's layers +/** utility function to release a DerivedMesh's layers * returns 1 if DerivedMesh has to be released by the backend, 0 otherwise */ int DM_release(DerivedMesh *dm); -/* utility function to convert a DerivedMesh to a Mesh +/** utility function to convert a DerivedMesh to a Mesh */ void DM_to_mesh(DerivedMesh *dm, struct Mesh *me, struct Object *ob); @@ -459,11 +460,10 @@ void DM_to_bmesh_ex(struct DerivedMesh *dm, struct BMesh *bm); struct BMesh *DM_to_bmesh(struct DerivedMesh *dm); -/* utility function to convert a DerivedMesh to a shape key block - */ +/** Utility function to convert a DerivedMesh to a shape key block */ void DM_to_meshkey(DerivedMesh *dm, struct Mesh *me, struct KeyBlock *kb); -/* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is +/** set the CD_FLAG_NOCOPY flag in custom data layers where the mask is * zero for the layer type, so only layer types specified by the mask * will be copied */ @@ -545,7 +545,7 @@ void DM_ensure_tessface(DerivedMesh *dm); void DM_update_tessface_data(DerivedMesh *dm); -/* interpolates vertex data from the vertices indexed by src_indices in the +/** interpolates vertex data from the vertices indexed by src_indices in the * source mesh using the given weights and stores the result in the vertex * indexed by dest_index in the dest mesh */ @@ -553,7 +553,7 @@ void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest, int *src_indices, float *weights, int count, int dest_index); -/* interpolates edge data from the edges indexed by src_indices in the +/** interpolates edge data from the edges indexed by src_indices in the * source mesh using the given weights and stores the result in the edge indexed * by dest_index in the dest mesh. * if weights is NULL, all weights default to 1. @@ -566,7 +566,7 @@ void DM_interp_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest, float *weights, EdgeVertWeight *vert_weights, int count, int dest_index); -/* interpolates face data from the faces indexed by src_indices in the +/** interpolates face data from the faces indexed by src_indices in the * source mesh using the given weights and stores the result in the face indexed * by dest_index in the dest mesh. * if weights is NULL, all weights default to 1. @@ -592,7 +592,7 @@ void DM_interp_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest, /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */ void vDM_ColorBand_store(struct ColorBand *coba); -/* Simple function to get me->totvert amount of vertices/normals, +/** Simple function to get me->totvert amount of vertices/normals, * correctly deformed and subsurfered. Needed especially when vertexgroups are involved. * In use now by vertex/weight paint and particles */ float *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob); @@ -641,13 +641,13 @@ int editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh *em, CustomDataMask dataMask, int build_shapekey_layers); -/* returns an array of deform matrices for crazyspace correction, and the +/** returns an array of deform matrices for crazyspace correction, and the * number of modifiers left */ int editbmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct BMEditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]); void weight_to_rgb(float r_rgb[3], const float weight); -/* Update the weight MCOL preview layer. +/** Update the weight MCOL preview layer. * If weights are NULL, use object's active vgroup(s). * Else, weights must be an array of weight float values. * If indices is NULL, it must be of numVerts length. @@ -657,7 +657,7 @@ void weight_to_rgb(float r_rgb[3], const float weight); void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const draw_flag, float *weights, int num, const int *indices); -/* convert layers requested by a GLSL material to actually available layers in +/** convert layers requested by a GLSL material to actually available layers in * the DerivedMesh, with both a pointer for arrays and an offset for editmesh */ typedef struct DMVertexAttribs { struct { @@ -689,7 +689,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, void DM_add_tangent_layer(DerivedMesh *dm); void DM_calc_auto_bump_scale(DerivedMesh *dm); -/* Set object's bounding box based on DerivedMesh min/max data */ +/** Set object's bounding box based on DerivedMesh min/max data */ void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm); void DM_init_origspace(DerivedMesh *dm); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 5fe28d2b254..171b62461a0 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -51,7 +51,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE alpha +#define BLENDER_VERSION_CYCLE beta extern char versionstr[]; /* from blender.c */ diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 593b4afb85c..2d30844af80 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -119,7 +119,8 @@ enum { G_DEBUG_FFMPEG = (1 << 1), G_DEBUG_PYTHON = (1 << 2), /* extra python info */ G_DEBUG_EVENTS = (1 << 3), /* input/window/screen events */ - G_DEBUG_WM = (1 << 4) /* operator, undo */ + G_DEBUG_WM = (1 << 4), /* operator, undo */ + G_DEBUG_JOBS = (1 << 5) /* jobs time profiling */ }; #define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM) diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index e2263a5edb7..699eb0a9f02 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -191,7 +191,7 @@ struct Image *BKE_image_copy(struct Image *ima); void BKE_image_merge(struct Image *dest, struct Image *source); /* scale the image */ -void BKE_image_scale(struct Image *image, int width, int height); +int BKE_image_scale(struct Image *image, int width, int height); /* check if texture has alpha (depth=32) */ int BKE_image_has_alpha(struct Image *image); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 887340622ad..abd0c4d96db 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -296,6 +296,7 @@ int BKE_mesh_validate_arrays( struct Mesh *me, struct MVert *mverts, unsigned int totvert, struct MEdge *medges, unsigned int totedge, + struct MFace *mfaces, unsigned int totface, struct MLoop *mloops, unsigned int totloop, struct MPoly *mpolys, unsigned int totpoly, struct MDeformVert *dverts, /* assume totvert length */ diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 1ff53291044..82a791348dd 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -47,6 +47,9 @@ struct Scene; /* Delete mesh mdisps and grid paint masks */ void multires_customdata_delete(struct Mesh *me); +void multires_set_tot_level(struct Object *ob, + struct MultiresModifierData *mmd, int lvl); + void multires_mark_as_modified(struct Object *ob, enum MultiresModifiedFlags flags); void multires_force_update(struct Object *ob); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 170638f0e8d..a0cfc4295ef 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1490,7 +1490,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } /* only counts visible particles */ - ++index; + index++; } /* restore objects since they were changed in BKE_object_where_is_calc_time */ diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 1bd650ef568..d99c36b6c91 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -325,8 +325,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM result = 1; } - else - { + else { // Apply repulse impulse if distance too short // I_r = -min(dt*kd, max(0, 1d/dt - v_n)) // DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index eb5e4e4f8b5..a6467af2773 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_group_types.h" /*GroupObject*/ @@ -46,6 +47,7 @@ #include "DNA_texture_types.h" #include "BKE_animsys.h" +#include "BKE_armature.h" #include "BKE_bvhutils.h" /* bvh tree */ #include "BKE_blender.h" #include "BKE_cdderivedmesh.h" @@ -528,11 +530,6 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram } } } - /* for curve following objects, parented curve has to be updated too */ - if (ob->type == OB_CURVE) { - Curve *cu = ob->data; - BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); - } /* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; @@ -547,6 +544,18 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram else BKE_object_where_is_calc_time(scene, ob, frame); + /* for curve following objects, parented curve has to be updated too */ + if (ob->type == OB_CURVE) { + Curve *cu = ob->data; + BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); + } + /* and armatures... */ + if (ob->type == OB_ARMATURE) { + bArmature *arm = ob->data; + BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM); + BKE_pose_where_is(scene, ob); + } + return 0; } @@ -734,7 +743,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) /* deactivate zero axises */ for (i = 0; i < 3; i++) { - if (td[i] < min_dim) {td[i] = 1.0f; axis -= 1; } + if (td[i] < min_dim) { td[i] = 1.0f; axis -= 1; } } if (axis == 0 || MAX3(td[0], td[1], td[2]) < 0.0001f) { @@ -2016,11 +2025,11 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh /* Dist to second edge */ t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[1]], tface[cPoint->face_index].uv[uindex[2]]); - if (t_dist < dist) {e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; } + if (t_dist < dist) { e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; } /* Dist to third edge */ t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[2]], tface[cPoint->face_index].uv[uindex[0]]); - if (t_dist < dist) {e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; } + if (t_dist < dist) { e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; } /* @@ -2284,7 +2293,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; - if ((u > 0) && (v > 0) && (u + v < 1)) {isInside = 1; } /* is inside a triangle */ + if ((u > 0) && (v > 0) && (u + v < 1)) { isInside = 1; } /* is inside a triangle */ /* If collision wasn't found but the face is a quad * do another check for the second half */ @@ -2304,7 +2313,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; - if ((u > 0) && (v > 0) && (u + v < 1)) {isInside = 2; } /* is inside the second half of the quad */ + if ((u > 0) && (v > 0) && (u + v < 1)) { isInside = 2; } /* is inside the second half of the quad */ } @@ -2583,7 +2592,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_IMF_IMTYPE_OPENEXR : R_IMF_IMTYPE_PNG; char output_file[FILE_MAX]; - if (!sData || !sData->type_data) {setError(surface->canvas, "Image save failed: Invalid surface."); return; } + if (!sData || !sData->type_data) { setError(surface->canvas, "Image save failed: Invalid surface."); return; } /* if selected format is openexr, but current build doesnt support one */ #ifndef WITH_OPENEXR if (format == R_IMF_IMTYPE_OPENEXR) format = R_IMF_IMTYPE_PNG; @@ -2597,7 +2606,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam /* Init image buffer */ ibuf = IMB_allocImBuf(surface->image_resolution, surface->image_resolution, 32, IB_rectfloat); - if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory."); return; } + if (ibuf == NULL) { setError(surface->canvas, "Image save failed: Not enough free memory."); return; } #pragma omp parallel for schedule(static) for (index = 0; index < sData->total_points; index++) { @@ -3287,7 +3296,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, int v1 = mface[hit.index].v1, v2 = mface[hit.index].v2, v3 = mface[hit.index].v3, quad = (hit.no[0] == 1.0f); float dot; - if (quad) {v2 = mface[hit.index].v3; v3 = mface[hit.index].v4; } + if (quad) { v2 = mface[hit.index].v3; v3 = mface[hit.index].v4; } normal_tri_v3(hit.no, mvert[v1].co, mvert[v2].co, mvert[v3].co); dot = ray_dir[0] * hit.no[0] + ray_dir[1] * hit.no[1] + ray_dir[2] * hit.no[2]; @@ -3580,7 +3589,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, /* for debug purposes check if any NAN particle proceeds * For some reason they get past activity check, this should rule most of them out */ - if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) {invalidParticles++; continue; } + if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) { invalidParticles++; continue; } /* make sure particle is close enough to canvas */ if (!boundIntersectPoint(&grid->grid_bounds, pa->state.co, range)) continue; @@ -3953,7 +3962,7 @@ void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, floa int n_index = sData->adj_data->n_index[index] + i; float dir_dot = dot_v3v3(bNeighs[n_index].dir, force); - if (dir_dot > closest_d[0] && dir_dot > 0.0f) {closest_d[0] = dir_dot; closest_id[0] = n_index; } + if (dir_dot > closest_d[0] && dir_dot > 0.0f) { closest_d[0] = dir_dot; closest_id[0] = n_index; } } if (closest_d[0] < 0.0f) return; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index b5254b97844..b32ac24084f 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -789,6 +789,12 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3); if (mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */ + /* generate intensity if texture only has rgb value */ + if (hasrgb & TEX_RGB) { + int i; + for (i=0; i<4; i++) + result[i].tin = (1.0f / 3.0f) * (result[i].tr + result[i].tg + result[i].tb); + } force[0] = (result[0].tin - result[1].tin) * strength; force[1] = (result[0].tin - result[2].tin) * strength; force[2] = (result[0].tin - result[3].tin) * strength; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index e20a74e713c..d072ffb72ec 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -811,7 +811,7 @@ void calchandles_fcurve(FCurve *fcu) if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0] = bezt->vec[1][0]; /* calculate auto-handles */ - BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ + BKE_nurb_handle_calc(bezt, prev, next, 1); /* (1 == special) autohandle */ /* for automatic ease in and out */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ea396b6d88c..beaf8f719e3 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -514,17 +514,21 @@ void BKE_image_merge(Image *dest, Image *source) } /* note, we could be clever and scale all imbuf's but since some are mipmaps its not so simple */ -void BKE_image_scale(Image *image, int width, int height) +int BKE_image_scale(Image *image, int width, int height) { ImBuf *ibuf; void *lock; ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); - IMB_scaleImBuf(ibuf, width, height); - ibuf->userflags |= IB_BITMAPDIRTY; + if (ibuf) { + IMB_scaleImBuf(ibuf, width, height); + ibuf->userflags |= IB_BITMAPDIRTY; + } BKE_image_release_ibuf(image, lock); + + return (ibuf != NULL); } Image *BKE_image_load(const char *filepath) @@ -2851,7 +2855,7 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath) if (ima->source == IMA_SRC_SEQUENCE) { char head[FILE_MAX], tail[FILE_MAX]; unsigned short numlen; - int frame = iuser->framenr; + int frame = iuser ? iuser->framenr : ima->lastframe; BLI_stringdec(filepath, head, tail, &numlen); BLI_stringenc(filepath, head, tail, numlen, frame); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index deb294a6738..bed70bbd780 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -771,7 +771,7 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k ofsp = ofs; - while (cp[0]) { /* cp[0]==amount */ + while (cp[0]) { /* (cp[0] == amount) */ switch (cp[1]) { case IPO_FLOAT: @@ -936,7 +936,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key ofsp = ofs; - while (cp[0]) { /* cp[0]==amount */ + while (cp[0]) { /* (cp[0] == amount) */ switch (cp[1]) { case IPO_FLOAT: diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 2fe6999c6e8..1cd2d159431 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1336,7 +1336,7 @@ void clear_id_newpoins(void) } } -#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 +#define LIBTAG(a) if (a && a->id.lib) { a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 static void lib_indirect_test_id(ID *id, Library *lib) { diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index d85722931a7..2767a67086b 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -64,7 +64,7 @@ static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoi if (spline->flag & MASK_SPLINE_CYCLIC) { return &points_array[0]; } - else { + else { return NULL; } } @@ -79,7 +79,7 @@ static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline, MaskSplinePoi if (spline->flag & MASK_SPLINE_CYCLIC) { return &points_array[spline->tot_point - 1]; } - else { + else { return NULL; } } @@ -94,7 +94,7 @@ static BezTriple *mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoin if (spline->flag & MASK_SPLINE_CYCLIC) { return &(points_array[0].bezt); } - else { + else { return NULL; } } diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 669ae4f198a..4528b748412 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -50,6 +50,16 @@ #define SELECT 1 +typedef union { + uint32_t verts[2]; + int64_t edval; +} EdgeUUID; + +typedef struct SortFace { + EdgeUUID es[4]; + unsigned int index; +} SortFace; + /* Used to detect polys (faces) using exactly the same vertices. */ /* Used to detect loops used by no (disjoint) or more than one (intersect) polys. */ typedef struct SortPoly { @@ -60,6 +70,84 @@ typedef struct SortPoly { int invalid; /* Poly index. */ } SortPoly; +static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint32_t v2) +{ + if (v1 < v2) { + verts[0] = v1; + verts[1] = v2; + } + else { + verts[0] = v2; + verts[1] = v1; + } +} + +static void edge_store_from_mface_quad(EdgeUUID es[4], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v4); + edge_store_assign(es[3].verts, mf->v4, mf->v1); +} + +static void edge_store_from_mface_tri(EdgeUUID es[4], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v1); + es[3].verts[0] = es[3].verts[1] = UINT_MAX; +} + +static int int64_cmp(const void *v1, const void *v2) +{ + const int64_t x1 = *(const int64_t *)v1; + const int64_t x2 = *(const int64_t *)v2; + + if (x1 > x2) { + return 1; + } + else if (x1 < x2) { + return -1; + } + + return 0; +} + +static int search_face_cmp(const void *v1, const void *v2) +{ + const SortFace *sfa = v1, *sfb = v2; + + if (sfa->es[0].edval > sfb->es[0].edval) { + return 1; + } + else if (sfa->es[0].edval < sfb->es[0].edval) { + return -1; + } + + else if (sfa->es[1].edval > sfb->es[1].edval) { + return 1; + } + else if (sfa->es[1].edval < sfb->es[1].edval) { + return -1; + } + + else if (sfa->es[2].edval > sfb->es[2].edval) { + return 1; + } + else if (sfa->es[2].edval < sfb->es[2].edval) { + return -1; + } + + else if (sfa->es[3].edval > sfb->es[3].edval) { + return 1; + } + else if (sfa->es[3].edval < sfb->es[3].edval) { + return -1; + } + + return 0; +} + /* TODO check there is not some standard define of this somewhere! */ static int int_cmp(const void *v1, const void *v2) { @@ -98,6 +186,7 @@ static int search_polyloop_cmp(const void *v1, const void *v2) int BKE_mesh_validate_arrays(Mesh *mesh, MVert *mverts, unsigned int totvert, MEdge *medges, unsigned int totedge, + MFace *mfaces, unsigned int totface, MLoop *mloops, unsigned int totloop, MPoly *mpolys, unsigned int totpoly, MDeformVert *dverts, /* assume totvert length */ @@ -117,10 +206,12 @@ int BKE_mesh_validate_arrays(Mesh *mesh, int *v; short do_edge_free = FALSE; + short do_face_free = FALSE; short do_polyloop_free = FALSE; /* This regroups loops and polys! */ short verts_fixed = FALSE; short vert_weights_fixed = FALSE; + int msel_fixed = FALSE; int do_edge_recalc = FALSE; @@ -193,6 +284,143 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } + if (mfaces && !mpolys) { +# define REMOVE_FACE_TAG(_mf) { _mf->v3 = 0; do_face_free = TRUE; } (void)0 +# define CHECK_FACE_VERT_INDEX(a, b) \ + if (mf->a == mf->b) { \ + PRINT(" face %u: verts invalid, " STRINGIFY(a) "/" STRINGIFY(b) " both %u\n", i, mf->a); \ + remove = do_fixes; \ + } (void)0 +# define CHECK_FACE_EDGE(a, b) \ + if (!BLI_edgehash_haskey(edge_hash, mf->a, mf->b)) { \ + PRINT(" face %u: edge " STRINGIFY(a) "/" STRINGIFY(b) \ + " (%u,%u) is missing egde data\n", i, mf->a, mf->b); \ + do_edge_recalc = TRUE; \ + } + + MFace *mf; + MFace *mf_prev; + + SortFace *sort_faces = MEM_callocN(sizeof(SortFace) * totface, "search faces"); + SortFace *sf; + SortFace *sf_prev; + unsigned int totsortface = 0; + + for (i = 0, mf = mfaces, sf = sort_faces; i < totface; i++, mf++) { + int remove = FALSE; + int fidx; + unsigned int fv[4]; + + fidx = mf->v4 ? 3 : 2; + do { + fv[fidx] = *(&(mf->v1) + fidx); + if (fv[fidx] >= totvert) { + PRINT(" face %u: 'v%d' index out of range, %u\n", i, fidx + 1, fv[fidx]); + remove = do_fixes; + } + } while (fidx--); + + if (remove == FALSE) { + if (mf->v4) { + CHECK_FACE_VERT_INDEX(v1, v2); + CHECK_FACE_VERT_INDEX(v1, v3); + CHECK_FACE_VERT_INDEX(v1, v4); + + CHECK_FACE_VERT_INDEX(v2, v3); + CHECK_FACE_VERT_INDEX(v2, v4); + + CHECK_FACE_VERT_INDEX(v3, v4); + } + else { + CHECK_FACE_VERT_INDEX(v1, v2); + CHECK_FACE_VERT_INDEX(v1, v3); + + CHECK_FACE_VERT_INDEX(v2, v3); + } + + if (remove == FALSE) { + if (totedge) { + if (mf->v4) { + CHECK_FACE_EDGE(v1, v2); + CHECK_FACE_EDGE(v2, v3); + CHECK_FACE_EDGE(v3, v4); + CHECK_FACE_EDGE(v4, v1); + } + else { + CHECK_FACE_EDGE(v1, v2); + CHECK_FACE_EDGE(v2, v3); + CHECK_FACE_EDGE(v3, v1); + } + } + + sf->index = i; + + if (mf->v4) { + edge_store_from_mface_quad(sf->es, mf); + + qsort(sf->es, 4, sizeof(int64_t), int64_cmp); + } + else { + edge_store_from_mface_tri(sf->es, mf); + qsort(sf->es, 3, sizeof(int64_t), int64_cmp); + } + + totsortface++; + sf++; + } + } + + if (remove) { + REMOVE_FACE_TAG(mf); + } + } + + qsort(sort_faces, totsortface, sizeof(SortFace), search_face_cmp); + + sf = sort_faces; + sf_prev = sf; + sf++; + + for (i = 1; i < totsortface; i++, sf++) { + int remove = FALSE; + + /* on a valid mesh, code below will never run */ + if (memcmp(sf->es, sf_prev->es, sizeof(sf_prev->es)) == 0) { + mf = mfaces + sf->index; + + if (do_verbose) { + mf_prev = mfaces + sf_prev->index; + + if (mf->v4) { + PRINT(" face %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)\n", + sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4, + mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); + } + else { + PRINT(" face %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)\n", + sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, + mf_prev->v1, mf_prev->v2, mf_prev->v3); + } + } + + remove = do_fixes; + } + else { + sf_prev = sf; + } + + if (remove) { + REMOVE_FACE_TAG(mf); + } + } + + MEM_freeN(sort_faces); + +# undef REMOVE_FACE_TAG +# undef CHECK_FACE_VERT_INDEX +# undef CHECK_FACE_EDGE + } + /* Checking loops and polys is a bit tricky, as they are quite intricated... * * Polys must have: @@ -527,14 +755,16 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - PRINT("BKE_mesh_validate: finished\n\n"); - # undef REMOVE_EDGE_TAG # undef IS_REMOVED_EDGE # undef REMOVE_LOOP_TAG # undef REMOVE_POLY_TAG if (mesh) { + if (do_face_free) { + BKE_mesh_strip_loose_faces(mesh); + } + if (do_polyloop_free) { BKE_mesh_strip_loose_polysloops(mesh); } @@ -548,7 +778,51 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc); + if (mesh && mesh->mselect) { + MSelect *msel; + int free_msel = FALSE; + + for (i = 0, msel = mesh->mselect; i < mesh->totselect; i++, msel++) { + int tot_elem; + + if (msel->index < 0) { + PRINT("Mesh select element %d type %d index is negative, " + "resetting selection stack.\n", i, msel->type); + free_msel = TRUE; + break; + } + + switch (msel->type) { + case ME_VSEL: + tot_elem = mesh->totvert; + break; + case ME_ESEL: + tot_elem = mesh->totedge; + break; + case ME_FSEL: + tot_elem = mesh->totface; + break; + } + + if (msel->index > tot_elem) { + PRINT("Mesh select element %d type %d index %d is larger than data array size %d, " + "resetting selection stack.\n", i, msel->type, msel->index, tot_elem); + + free_msel = TRUE; + break; + } + } + + if (free_msel) { + MEM_freeN(mesh->mselect); + mesh->mselect = NULL; + mesh->totselect = 0; + } + } + + PRINT("BKE_mesh_validate: finished\n\n"); + + return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc || msel_fixed); } static int mesh_validate_customdata(CustomData *data, short do_verbose, const short do_fixes) @@ -605,6 +879,7 @@ int BKE_mesh_validate(Mesh *me, int do_verbose) arrays_fixed = BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, + me->mface, me->totface, me->mloop, me->totloop, me->mpoly, me->totpoly, me->dvert, @@ -622,6 +897,7 @@ int BKE_mesh_validate_dm(DerivedMesh *dm) return BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), + dm->getTessFaceArray(dm), dm->getNumTessFaces(dm), dm->getLoopArray(dm), dm->getNumLoops(dm), dm->getPolyArray(dm), dm->getNumPolys(dm), dm->getVertDataArray(dm, CD_MDEFORMVERT), diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 99bb3468320..72c3cda9272 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -72,8 +72,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm) BM_data_layer_add(bm, &bm->edata, CD_BWEIGHT); BM_data_layer_add(bm, &bm->vdata, CD_BWEIGHT); - vtable = MEM_callocN(sizeof(void**) * totvert, "vert table in BMDM_Copy"); - etable = MEM_callocN(sizeof(void**) * totedge, "edge table in BMDM_Copy"); + vtable = MEM_callocN(sizeof(void **) * totvert, "vert table in BMDM_Copy"); + etable = MEM_callocN(sizeof(void **) * totedge, "edge table in BMDM_Copy"); /*do verts*/ mv = mvert = dm->dupVertArray(dm); diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 44169cd3d6a..54e93f58307 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1067,6 +1067,9 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); + scopes->marker = marker; + scopes->track = track; + if (marker->flag & MARKER_DISABLED) { scopes->track_disabled = TRUE; } @@ -1074,8 +1077,6 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user); scopes->track_disabled = FALSE; - scopes->marker = marker; - scopes->track = track; if (ibuf && (ibuf->rect || ibuf->rect_float)) { ImBuf *search_ibuf; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index cb6f6823f48..2bc5c37b41b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -347,7 +347,7 @@ static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl) : mmd->lvl; } -static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) +void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) { mmd->totlvl = lvl; @@ -2105,6 +2105,8 @@ void multires_load_old(Object *ob, Mesh *me) me->mr = NULL; } +/* If 'ob' and 'to_ob' both have multires modifiers, syncronize them + * such that 'ob' has the same total number of levels as 'to_ob'. */ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) { MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1); @@ -2119,10 +2121,12 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) multires_customdata_delete(ob->data); } - if (!mmd || !to_mmd) return; - - if (mmd->totlvl > to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); - else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); + if (mmd && to_mmd) { + if (mmd->totlvl > to_mmd->totlvl) + multires_del_higher(mmd, ob, to_mmd->totlvl); + else + multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); + } } static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9537a31838c..a1fe1f7b8a9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3752,7 +3752,7 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co } #define SET_PARTICLE_TEXTURE(type, pvalue, texfac) \ - if ((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } (void)0 + if ((event & mtex->mapto) & type) { pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } (void)0 #define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) \ if (event & type) { if (pvalue < 0.0f) pvalue = 1.0f + pvalue; CLAMP(pvalue, 0.0f, 1.0f); } (void)0 diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 8cb47118e7d..78ccdc425e5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1220,7 +1220,11 @@ static void seq_open_anim_file(Sequence *seq) } if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) { - IMB_anim_set_index_dir(seq->anim, seq->strip->proxy->dir); + char dir[FILE_MAX]; + BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); + BLI_path_abs(dir, G.main->name); + + IMB_anim_set_index_dir(seq->anim, dir); } } @@ -2089,7 +2093,7 @@ static ImBuf *seq_render_mask_strip( fp_src = maskbuf; fp_dst = ibuf->rect_float; i = context.rectx * context.recty; - while(--i) { + while (--i) { fp_dst[0] = fp_dst[1] = fp_dst[2] = *fp_src; fp_dst[3] = 1.0f; @@ -2115,7 +2119,7 @@ static ImBuf *seq_render_mask_strip( fp_src = maskbuf; ub_dst = (unsigned char *)ibuf->rect; i = context.rectx * context.recty; - while(--i) { + while (--i) { ub_dst[0] = ub_dst[1] = ub_dst[2] = (unsigned char)(*fp_src * 255.0f); /* already clamped */ ub_dst[3] = 255; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index a5c04387b68..3dea8a85915 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2551,7 +2551,8 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in if ((marker->flag & MARKER_DISABLED) == 0) { libmv_tracksInsert(tracks, marker->framenr, tracknr, - marker->pos[0] * width, marker->pos[1] * height); + (marker->pos[0] + track->offset[0]) * width, + (marker->pos[1] + track->offset[1]) * height); } } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index aa9cc40f71f..1180d2c72d5 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -125,7 +125,7 @@ static struct bUnitDef buMetricLenDef[] = { #endif {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialLenDef[] = { {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -137,7 +137,7 @@ static struct bUnitDef buImperialLenDef[] = { {"thou", "thou", "thou", "mil", "Thou", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef) / sizeof(bUnitDef)}; /* Areas */ static struct bUnitDef buMetricAreaDef[] = { @@ -151,7 +151,7 @@ static struct bUnitDef buMetricAreaDef[] = { {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAreaDef[] = { {"square mile", "square miles", "sq mi", "sq m","Square Miles", UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -163,7 +163,7 @@ static struct bUnitDef buImperialAreaDef[] = { {"square thou", "square thous", "sq mil",NULL, "Square Thous", UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef) / sizeof(bUnitDef)}; /* Volumes */ static struct bUnitDef buMetricVolDef[] = { @@ -177,7 +177,7 @@ static struct bUnitDef buMetricVolDef[] = { {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM*UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVolDef[] = { {"cubic mile", "cubic miles", "cu mi", "cu m","Cubic Miles", UN_SC_MI*UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -189,7 +189,7 @@ static struct bUnitDef buImperialVolDef[] = { {"cubic thou", "cubic thous", "cu mil",NULL, "Cubic Thous", UN_SC_MIL*UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef) / sizeof(bUnitDef)}; /* Mass */ static struct bUnitDef buMetricMassDef[] = { @@ -201,7 +201,7 @@ static struct bUnitDef buMetricMassDef[] = { {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialMassDef[] = { {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, @@ -211,7 +211,7 @@ static struct bUnitDef buImperialMassDef[] = { {"ounce", "ounces", "oz", NULL, "Ounces", UN_SC_OZ, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef) / sizeof(bUnitDef)}; /* Even if user scales the system to a point where km^3 is used, velocity and * acceleration aren't scaled: that's why we have so few units for them */ @@ -222,27 +222,27 @@ static struct bUnitDef buMetricVelDef[] = { {"kilometer per hour", "kilometers per hour", "km/h", NULL, "Kilometers per hour", UN_SC_KM/3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVelDef[] = { {"foot per second", "feet per second", "ft/s", "fps", "Feet per second", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"mile per hour", "miles per hour", "mph", NULL, "Miles per hour", UN_SC_MI/3600.0f, 0.0,B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef) / sizeof(bUnitDef)}; /* Acceleration */ static struct bUnitDef buMetricAclDef[] = { {"meter per second squared", "meters per second squared", "m/s²", "m/s2", "Meters per second squared", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAclDef[] = { {"foot per second squared", "feet per second squared", "ft/s²", "ft/s2", "Feet per second squared", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef) / sizeof(bUnitDef)}; /* Time */ static struct bUnitDef buNaturalTimeDef[] = { @@ -255,7 +255,7 @@ static struct bUnitDef buNaturalTimeDef[] = { {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)}; static struct bUnitDef buNaturalRotDef[] = { @@ -264,7 +264,7 @@ static struct bUnitDef buNaturalRotDef[] = { // {"turn", "turns", "t", NULL, "Turns", 1.0/(M_PI*2.0), 0.0,B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef) / sizeof(bUnitDef)}; #define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1) static struct bUnitCollection *bUnitSystems[][9] = { diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index b3101638a4e..f72942df8b3 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -924,7 +924,7 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd) fe++; } - if (!*fe) { + if (*fe == NULL) { strcat(string, autosplit); BLI_path_frame_range(string, rd->sfra, rd->efra, 4); |