diff options
Diffstat (limited to 'source')
418 files changed, 5399 insertions, 2906 deletions
diff --git a/source/SConscript b/source/SConscript index cfb204cd52a..fdd126b28c6 100644 --- a/source/SConscript +++ b/source/SConscript @@ -1,7 +1,7 @@ #!/usr/bin/python Import ('env') -SConscript(['blender/SConscript', 'creator/SConscript']) +SConscript(['blender/SConscript']) if env['WITH_BF_GAMEENGINE']: SConscript (['gameengine/SConscript']) diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index a0d840b5de6..3c756668578 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -95,12 +95,10 @@ add_subdirectory(blenkernel) add_subdirectory(blenlib) add_subdirectory(bmesh) add_subdirectory(render) -add_subdirectory(compositor) add_subdirectory(blenfont) add_subdirectory(blenloader) add_subdirectory(ikplugin) add_subdirectory(gpu) -add_subdirectory(opencl) add_subdirectory(imbuf) add_subdirectory(avi) add_subdirectory(nodes) @@ -108,6 +106,11 @@ add_subdirectory(modifiers) add_subdirectory(makesdna) add_subdirectory(makesrna) +if(WITH_COMPOSITOR) + add_subdirectory(opencl) # later on this may be used more generally + add_subdirectory(compositor) +endif() + if(WITH_IMAGE_OPENEXR) add_subdirectory(imbuf/intern/openexr) endif() diff --git a/source/blender/SConscript b/source/blender/SConscript index c2ca6eb5ae5..e1f81f9aaba 100644 --- a/source/blender/SConscript +++ b/source/blender/SConscript @@ -8,11 +8,9 @@ SConscript(['avi/SConscript', 'blenlib/SConscript', 'blenloader/SConscript', 'gpu/SConscript', - 'opencl/SConscript', 'editors/SConscript', 'imbuf/SConscript', 'makesdna/SConscript', - 'compositor/SConscript', 'render/SConscript', 'nodes/SConscript', 'modifiers/SConscript', @@ -39,3 +37,7 @@ if env['WITH_BF_QUICKTIME']: if env['WITH_BF_COLLADA']: SConscript (['collada/SConscript']) + +if env['WITH_BF_COMPOSITOR']: + SConscript (['compositor/SConscript', + 'opencl/SConscript']) 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_action.h b/source/blender/blenkernel/BKE_action.h index 527d85c7cf3..7df491c0fef 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -113,7 +113,7 @@ struct bActionGroup *get_active_actiongroup(struct bAction *act); void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select); /* Sync colors used for action/bone group with theme settings */ -void action_group_colors_sync(struct bActionGroup *grp); +void action_group_colors_sync(struct bActionGroup *grp, const struct bActionGroup *ref_grp); /* Add a new action group with the given name to the action */ struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]); diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index d605776ed50..acb9234b2d4 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -43,7 +43,7 @@ struct bPoseChannel; struct ReportList; /* ---------------------------------------------------- */ -/* Animation Visualisation */ +/* Animation Visualization */ void animviz_settings_init(struct bAnimVizSettings *avs); 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..909ed471081 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -157,7 +157,7 @@ void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf); /* called on frame change or before render */ void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); -int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr); +int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range); void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, char *path); /* sets index offset for multilayer files */ @@ -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_mask.h b/source/blender/blenkernel/BKE_mask.h index 0682b16536c..ee7c13ba7cb 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -27,6 +27,7 @@ #ifndef __BKE_MASK_H__ #define __BKE_MASK_H__ +struct ListBase; struct Main; struct Mask; struct MaskParent; @@ -50,12 +51,16 @@ void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay); void BKE_mask_layer_free_shapes(struct MaskLayer *masklay); void BKE_mask_layer_free(struct MaskLayer *masklay); +void BKE_mask_layer_free_list(struct ListBase *masklayers); void BKE_mask_spline_free(struct MaskSpline *spline); struct MaskSpline *BKE_mask_spline_copy(struct MaskSpline *spline); void BKE_mask_point_free(struct MaskSplinePoint *point); void BKE_mask_layer_unique_name(struct Mask *mask, struct MaskLayer *masklay); +struct MaskLayer *BKE_mask_layer_copy(struct MaskLayer *layer); +void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, struct ListBase *masklayers); + /* splines */ struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay); @@ -170,6 +175,11 @@ void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, i /* rasterization */ int BKE_mask_get_duration(struct Mask *mask); + +void BKE_mask_rasterize_layers(struct ListBase *masklayers, int width, int height, float *buffer, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather); + void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, const short do_aspect_correct, const short do_mask_aa, const short do_feather); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 8aa25a235a8..2407330a237 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -42,6 +42,7 @@ struct ID; struct Object; struct Mesh; struct MTFace; +struct Scene; /* materials */ @@ -92,6 +93,9 @@ int material_in_material(struct Material *parmat, struct Material *mat); void ramp_blend(int type, float r_col[3], const float fac, const float col[3]); +/* driver update hacks */ +void material_drivers_update(struct Scene *scene, struct Material *mat, float ctime); + /* copy/paste */ void clear_matcopybuf(void); void free_matcopybuf(void); 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_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 551a31509a3..3b675f3b620 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -345,6 +345,7 @@ void modifiers_clearErrors(struct Object *ob); int modifiers_getCageIndex(struct Scene *scene, struct Object *ob, int *lastPossibleCageIndex_r, int virtual_); +int modifiers_isModifierEnabled(struct Object *ob, int modifierType); int modifiers_isSoftbodyEnabled(struct Object *ob); int modifiers_isClothEnabled(struct Object *ob); int modifiers_isParticleEnabled(struct Object *ob); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index b3d2e3371f4..8d1707725b5 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -253,7 +253,7 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) } /* Sync colors used for action/bone group with theme settings */ -void action_group_colors_sync(bActionGroup *grp) +void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp) { /* only do color copying if using a custom color (i.e. not default color) */ if (grp->customCol) { @@ -265,9 +265,15 @@ void action_group_colors_sync(bActionGroup *grp) memcpy(&grp->cs, col_set, sizeof(ThemeWireColor)); } else { - /* init custom colors with a generic multi-color rgb set, if not initialized already - * (for custom color set) */ - if (grp->cs.solid[0] == 0) { + /* if a reference group is provided, use the custom color from there... */ + if (ref_grp) { + /* assumption: reference group has a color set */ + memcpy(&grp->cs, &ref_grp->cs, sizeof(ThemeWireColor)); + } + /* otherwise, init custom color with a generic/placeholder color set if + * no previous theme color was used that we can just keep using + */ + else if (grp->cs.solid[0] == 0) { /* define for setting colors in theme below */ rgba_char_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255); rgba_char_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 170638f0e8d..52399801691 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -78,9 +78,9 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int par_index, int level, int animated); /* ******************************************************************** */ -/* Animation Visualisation */ +/* Animation Visualization */ -/* Initialize the default settings for animation visualisation */ +/* Initialize the default settings for animation visualization */ void animviz_settings_init(bAnimVizSettings *avs) { /* sanity check */ @@ -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/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index a0da23a8f8f..943bad35cf2 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1857,7 +1857,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li /* prepare template for 'evaluation strip' * - based on the transition strip's evaluation strip data * - strip_mode is NES_TIME_TRANSITION_* based on which endpoint - * - strip_time is the 'normalised' (i.e. in-strip) time for evaluation, + * - strip_time is the 'normalized' (i.e. in-strip) time for evaluation, * which doubles up as an additional weighting factor for the strip influences * which allows us to appear to be 'interpolating' between the two extremes */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 96959398bc2..5822b296a8a 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2207,7 +2207,7 @@ void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) axis_angle_to_mat3(rmat, pchan->rotAxis, pchan->rotAngle); } else { - /* quats are normalised before use to eliminate scaling issues */ + /* quats are normalized before use to eliminate scaling issues */ float quat[4]; /* NOTE: we now don't normalize the stored values anymore, since this was kindof evil in some cases 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/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index a1e67ebd414..2faa882e3ea 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -66,6 +66,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" +#include "BKE_material.h" #include "BKE_mball.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -311,7 +312,7 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - int isdata_fcu = isdata || (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")); + int isdata_fcu = (isdata) || (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")); /* loop over variables to get the target relationships */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { @@ -347,6 +348,48 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node } } +/* XXX: forward def for material driver handling... */ +static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma); + +/* recursive handling for material nodetree drivers */ +static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree) +{ + bNode *n; + + /* nodetree itself */ + if (ntree->adt) { + dag_add_driver_relation(ntree->adt, dag, node, 1); + } + + /* nodetree's nodes... */ + for (n = ntree->nodes.first; n; n = n->next) { + if (n->id && GS(n->id->name) == ID_MA) { + dag_add_material_driver_relations(dag, node, (Material *)n->id); + } + else if (n->type == NODE_GROUP && n->id) { + dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id); + } + } +} + +/* recursive handling for material drivers */ +static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma) +{ + /* material itself */ + if (ma->adt) { + dag_add_driver_relation(ma->adt, dag, node, 1); + } + + /* textures */ + // TODO... + //dag_add_texture_driver_relations(DagForest *dag, DagNode *node, ID *id); + + /* material's nodetree */ + if (ma->nodetree) { + dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree); + } +} + static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node) { Base *base; @@ -516,7 +559,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O /* softbody collision */ if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) { - if (modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first) + if (modifiers_isModifierEnabled(ob, eModifierType_Softbody) + || modifiers_isModifierEnabled(ob, eModifierType_Cloth) + || modifiers_isModifierEnabled(ob, eModifierType_Smoke) + || modifiers_isModifierEnabled(ob, eModifierType_DynamicPaint) + || ob->particlesystem.first) dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ } @@ -572,6 +619,20 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O break; } + /* material drivers */ + if (ob->totcol) { + int a; + + for (a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); + + if (ma) { + /* recursively figure out if there are drivers, and hook these up to this object */ + dag_add_material_driver_relations(dag, node, ma); + } + } + } + /* particles */ psys = ob->particlesystem.first; if (psys) { @@ -605,15 +666,15 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O /* note that this relation actually runs in the wrong direction, the problem * is that dupli system all have this (due to parenting), and the render * engine instancing assumes particular ordering of objects in list */ - dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualisation"); + dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualization"); if (part->dup_ob->type == OB_MBALL) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualization"); } if (part->ren_as == PART_DRAW_GR && part->dup_group) { for (go = part->dup_group->gobject.first; go; go = go->next) { node2 = dag_get_node(dag, go->ob); - dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualization"); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 6589b1e1082..dd5751c5d1f 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; } @@ -1677,7 +1686,7 @@ struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, c[1] = material->g; c[2] = material->b; } - else { /* default grey */ + else { /* default gray */ c[0] = 0.65f; c[1] = 0.65f; c[2] = 0.65f; 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/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index b7ede15d00b..f981ecaf810 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -285,7 +285,7 @@ static FModifierTypeInfo FMI_GENERATOR = { * x is the evaluation 'time', and 'y' is the resultant value * * Functions available are - * sin, cos, tan, sinc (normalised sin), natural log, square root + * sin, cos, tan, sinc (normalized sin), natural log, square root */ static void fcm_fn_generator_new_data(void *mdata) @@ -297,7 +297,7 @@ static void fcm_fn_generator_new_data(void *mdata) data->phase_multiplier = 1.0f; } -/* Unary 'normalised sine' function +/* Unary 'normalized sine' function * y = sin(PI + x) / (PI * x), * except for x = 0 when y = 1. */ @@ -326,7 +326,7 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float case FCM_GENERATOR_FN_COS: /* cosine wave */ fn = cos; break; - case FCM_GENERATOR_FN_SINC: /* normalised sine wave */ + case FCM_GENERATOR_FN_SINC: /* normalized sine wave */ fn = sinc; break; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ea396b6d88c..d2a2412843a 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) @@ -2780,10 +2784,14 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) return BKE_image_acquire_ibuf(ima, iuser, NULL); } -int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) +int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range) { const int len = (iuser->fie_ima * iuser->frames) / 2; + if (r_is_in_range) { + *r_is_in_range = FALSE; + } + if (len == 0) { return 0; } @@ -2796,10 +2804,23 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) cfra = ((cfra) % len); if (cfra < 0) cfra += len; if (cfra == 0) cfra = len; + + if (r_is_in_range) { + *r_is_in_range = TRUE; + } } - if (cfra < 0) cfra = 0; - else if (cfra > len) cfra = len; + if (cfra < 0) { + cfra = 0; + } + else if (cfra > len) { + cfra = len; + } + else { + if (r_is_in_range) { + *r_is_in_range = TRUE; + } + } /* convert current frame to current field */ cfra = 2 * (cfra); @@ -2808,7 +2829,6 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) /* transform to images space */ framenr = (cfra + iuser->fie_ima - 2) / iuser->fie_ima; if (framenr > iuser->frames) framenr = iuser->frames; - framenr += iuser->offset; if (iuser->cycl) { framenr = ((framenr) % len); @@ -2816,6 +2836,9 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) if (framenr == 0) framenr = len; } + /* important to apply after else we cant loop on frames 100 - 110 for eg. */ + framenr += iuser->offset; + return framenr; } } @@ -2823,7 +2846,15 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr) { if (iuser) { - const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr); + short is_in_range; + const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr, &is_in_range); + + if (is_in_range) { + iuser->flag |= IMA_USER_FRAME_IN_RANGE; + } + else { + iuser->flag &= ~IMA_USER_FRAME_IN_RANGE; + } /* allows image users to handle redraws */ if (iuser->flag & IMA_ANIM_ALWAYS) @@ -2851,7 +2882,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/mask.c b/source/blender/blenkernel/intern/mask.c index d85722931a7..b400332db81 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; } } @@ -188,6 +188,41 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay) BLI_uniquename(&mask->masklayers, masklay, "MaskLayer", '.', offsetof(MaskLayer, name), sizeof(masklay->name)); } +MaskLayer *BKE_mask_layer_copy(MaskLayer *layer) +{ + MaskLayer *layer_new; + MaskSpline *spline; + + layer_new = MEM_callocN(sizeof(MaskLayer), "new mask layer"); + + BLI_strncpy(layer_new->name, layer->name, sizeof(layer_new->name)); + + layer_new->alpha = layer->alpha; + layer_new->blend = layer->blend; + layer_new->blend_flag = layer->blend_flag; + layer_new->flag = layer->flag; + layer_new->restrictflag = layer->restrictflag; + + for (spline = layer->splines.first; spline; spline = spline->next) { + MaskSpline *spline_new = BKE_mask_spline_copy(spline); + + BLI_addtail(&layer_new->splines, spline_new); + } + + return layer_new; +} + +void BKE_mask_layer_copy_list(ListBase *masklayers_new, ListBase *masklayers) +{ + MaskLayer *layer; + + for (layer = masklayers->first; layer; layer = layer->next) { + MaskLayer *layer_new = BKE_mask_layer_copy(layer); + + BLI_addtail(masklayers_new, layer_new); + } +} + /* splines */ MaskSpline *BKE_mask_spline_add(MaskLayer *masklay) @@ -988,21 +1023,34 @@ void BKE_mask_spline_free(MaskSpline *spline) MEM_freeN(spline); } +static MaskSplinePoint *mask_spline_points_copy(MaskSplinePoint *points, int tot_point) +{ + MaskSplinePoint *npoints; + int i; + + npoints = MEM_dupallocN(points); + + for (i = 0; i < tot_point; i++) { + MaskSplinePoint *point = &npoints[i]; + + if (point->uw) + point->uw = MEM_dupallocN(point->uw); + } + + return npoints; +} + MaskSpline *BKE_mask_spline_copy(MaskSpline *spline) { MaskSpline *nspline = MEM_callocN(sizeof(MaskSpline), "new spline"); - int i; *nspline = *spline; nspline->points_deform = NULL; - nspline->points = MEM_dupallocN(nspline->points); - - for (i = 0; i < nspline->tot_point; i++) { - MaskSplinePoint *point = &nspline->points[i]; + nspline->points = mask_spline_points_copy(spline->points, spline->tot_point); - if (point->uw) - point->uw = MEM_dupallocN(point->uw); + if (spline->points_deform) { + nspline->points_deform = mask_spline_points_copy(spline->points_deform, spline->tot_point); } return nspline; @@ -1068,20 +1116,25 @@ void BKE_mask_layer_free(MaskLayer *masklay) MEM_freeN(masklay); } -void BKE_mask_free(Mask *mask) +void BKE_mask_layer_free_list(ListBase *masklayers) { - MaskLayer *masklay = mask->masklayers.first; + MaskLayer *masklay = masklayers->first; while (masklay) { - MaskLayer *next_masklay = masklay->next; + MaskLayer *masklay_next = masklay->next; - BLI_remlink(&mask->masklayers, masklay); + BLI_remlink(masklayers, masklay); BKE_mask_layer_free(masklay); - masklay = next_masklay; + masklay = masklay_next; } } +void BKE_mask_free(Mask *mask) +{ + BKE_mask_layer_free_list(&mask->masklayers); +} + void BKE_mask_unlink(Main *bmain, Mask *mask) { bScreen *scr; @@ -2093,9 +2146,9 @@ int BKE_mask_get_duration(Mask *mask) } /* rasterization */ -void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, const short do_mask_aa, - const short do_feather) +void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, float *buffer, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather) { MaskLayer *masklay; @@ -2103,7 +2156,7 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, const int buffer_size = width * height; float *buffer_tmp = MEM_mallocN(sizeof(float) * buffer_size, __func__); - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + for (masklay = masklayers->first; masklay; masklay = masklay->next) { MaskSpline *spline; float alpha; @@ -2226,3 +2279,10 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, MEM_freeN(buffer_tmp); } + +void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather) +{ + BKE_mask_rasterize_layers(&mask->masklayers, width, height, buffer, do_aspect_correct, do_mask_aa, do_feather); +} diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 48d629a2944..23f197155a1 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_curve_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" @@ -1050,6 +1051,52 @@ int material_in_material(Material *parmat, Material *mat) else return 0; } + + +/* ****************** */ + +/* Update drivers for materials in a nodetree */ +static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime) +{ + bNode *node; + + /* nodetree itself */ + if (ntree->adt && ntree->adt->drivers.first) { + BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS); + } + + /* nodes... */ + for (node = ntree->nodes.first; node; node = node->next) { + if (node->id && GS(node->id->name) == ID_MA) { + /* TODO: prevent infinite recursion here... */ + material_drivers_update(scene, (Material *)node->id, ctime); + } + else if (node->type == NODE_GROUP && node->id) { + material_node_drivers_update(scene, (bNodeTree *)node->id, ctime); + } + } +} + +/* Calculate all drivers for materials + * FIXME: this is really a terrible method which may result in some things being calculated + * multiple times. However, without proper despgraph support for these things, we are forced + * into this sort of thing... + */ +void material_drivers_update(Scene *scene, Material *ma, float ctime) +{ + //if (G.f & G_DEBUG) + // printf("material_drivers_update(%s, %s)\n", scene->id.name, ma->id.name); + + /* material itself */ + if (ma->adt && ma->adt->drivers.first) { + BKE_animsys_evaluate_animdata(scene, &ma->id, ma->adt, ctime, ADT_RECALC_DRIVERS); + } + + /* nodes */ + if (ma->nodetree) { + material_node_drivers_update(scene, ma->nodetree, ctime); + } +} /* ****************** */ #if 0 /* UNUSED */ @@ -1060,19 +1107,19 @@ static char colname_array[125][20]= { "LightGreen", "Chartreuse", "YellowGreen", "Yellow", "Gold", "Green", "LawnGreen", "GreenYellow", "LightOlive", "Yellow", "DarkBlue", "DarkPurple", "HotPink", "VioletPink", "RedPink", -"SlateGray", "DarkGrey", "PalePurple", "IndianRed", "Tomato", +"SlateGray", "DarkGray", "PalePurple", "IndianRed", "Tomato", "SeaGreen", "PaleGreen", "GreenKhaki", "LightBrown", "LightSalmon", "SpringGreen", "PaleGreen", "MediumOlive", "YellowBrown", "LightGold", "LightGreen", "LightGreen", "LightGreen", "GreenYellow", "PaleYellow", "HalfBlue", "DarkSky", "HalfMagenta", "VioletRed", "DeepPink", "SteelBlue", "SkyBlue", "Orchid", "LightHotPink", "HotPink", -"SeaGreen", "SlateGray", "MediumGrey", "Burlywood", "LightPink", +"SeaGreen", "SlateGray", "MediumGray", "Burlywood", "LightPink", "SpringGreen", "Aquamarine", "PaleGreen", "Khaki", "PaleOrange", "SpringGreen", "SeaGreen", "PaleGreen", "PaleWhite", "YellowWhite", "LightBlue", "Purple", "MediumOrchid", "Magenta", "Magenta", "RoyalBlue", "SlateBlue", "MediumOrchid", "Orchid", "Magenta", "DeepSkyBlue", "LightSteelBlue", "LightSkyBlue", "Violet", "LightPink", -"Cyan", "DarkTurquoise", "SkyBlue", "Grey", "Snow", +"Cyan", "DarkTurquoise", "SkyBlue", "Gray", "Snow", "Mint", "Mint", "Aquamarine", "MintCream", "Ivory", "Blue", "Blue", "DarkMagenta", "DarkOrchid", "Magenta", "SkyBlue", "RoyalBlue", "LightSlateBlue", "MediumOrchid", "Magenta", diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index e3b13ca0f17..8d81e7b595d 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2153,7 +2153,7 @@ void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id, CustomData *fdata, CustomData } } - /* note, we don't convert FGons at all, these are not even real ngons, + /* note, we don't convert NGons at all, these are not even real ngons, * they have their own UV's, colors etc - its more an editing feature. */ BLI_edgehash_free(eh, NULL); @@ -3146,19 +3146,17 @@ void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys) } } - void BKE_mesh_ensure_navmesh(Mesh *me) { if (!CustomData_has_layer(&me->pdata, CD_RECAST)) { int i; int numFaces = me->totpoly; int *recastData; - CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_CALLOC, NULL, numFaces, "recastData"); - recastData = (int *)CustomData_get_layer(&me->pdata, CD_RECAST); + recastData = (int *)MEM_mallocN(numFaces * sizeof(int), __func__); for (i = 0; i < numFaces; i++) { recastData[i] = i + 1; } - CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_REFERENCE, recastData, numFaces, "recastData"); + CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_ASSIGN, recastData, numFaces, "recastData"); } } 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/modifier.c b/source/blender/blenkernel/intern/modifier.c index b4c30203000..65538e5bea2 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -331,6 +331,13 @@ int modifiers_isClothEnabled(Object *ob) return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)); } +int modifiers_isModifierEnabled(Object *ob, int modifierType) +{ + ModifierData *md = modifiers_findByType(ob, modifierType); + + return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)); +} + int modifiers_isParticleEnabled(Object *ob) { ModifierData *md = modifiers_findByType(ob, eModifierType_ParticleSystem); 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/nla.c b/source/blender/blenkernel/intern/nla.c index 2b4fe72e8bb..fb15aa82fa2 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1391,7 +1391,7 @@ static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls) /* set overlaps for this strip * - don't use the values obtained though if the end in question - * is directly followed/preceeded by another strip, forming an + * is directly followed/preceded by another strip, forming an * 'island' of continuous strips */ if ((ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0)) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 8fb8d863a8c..f0d47791374 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -843,7 +843,7 @@ Object *BKE_object_add_only_object(int type, const char *name) ob->pc_ids.first = ob->pc_ids.last = NULL; - /* Animation Visualisation defaults */ + /* Animation Visualization defaults */ animviz_settings_init(&ob->avs); return ob; @@ -1460,7 +1460,7 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[][3]) axis_angle_to_mat3(dmat, ob->drotAxis, ob->drotAngle); } else { - /* quats are normalised before use to eliminate scaling issues */ + /* quats are normalized before use to eliminate scaling issues */ float tquat[4]; normalize_qt_qt(tquat, ob->quat); @@ -2538,7 +2538,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) printf("recalcdata %s\n", ob->id.name + 2); if (adt) { - /* evaluate drivers */ + /* evaluate drivers - datalevel */ // XXX: for mesh types, should we push this to derivedmesh instead? BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS); } @@ -2595,8 +2595,26 @@ void BKE_object_handle_update(Scene *scene, Object *ob) BKE_lattice_modifiers_calc(scene, ob); break; } - - + + /* related materials */ + /* XXX: without depsgraph tagging, this will always need to be run, which will be slow! + * However, not doing anything (or trying to hack around this lack) is not an option + * anymore, especially due to Cycles [#31834] + */ + if (ob->totcol) { + int a; + + for (a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); + + if (ma) { + /* recursively update drivers for this material */ + material_drivers_update(scene, ma, ctime); + } + } + } + + /* particles */ if (ob->particlesystem.first) { ParticleSystem *tpsys, *psys; DerivedMesh *dm; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 569e69f2d51..65f22ebc88f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3320,7 +3320,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR } } - /* stickness was possibly added before, so cancel that before calculating new normal velocity */ + /* stickiness was possibly added before, so cancel that before calculating new normal velocity */ /* otherwise particles go flying out of the surface because of high reversed sticky velocity */ if (v0_dot < 0.0f) { v0_dot += pd->pdef_stickness; @@ -3379,7 +3379,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR madd_v3_v3fl(pa->state.vel, nor, -dot); } - /* add stickness to surface */ + /* add stickiness to surface */ madd_v3_v3fl(pa->state.vel, pce->nor, -pd->pdef_stickness); /* set coordinates for next iteration */ 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 3dea8a85915..6167536fb9b 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -3028,9 +3028,9 @@ static unsigned char *detect_get_frame_ucharbuf(ImBuf *ibuf) if (ibuf->rect_float) { const float *rrgbf = ibuf->rect_float + pixel * 4; - const float grey_f = 0.2126f * rrgbf[0] + 0.7152f * rrgbf[1] + 0.0722f * rrgbf[2]; + const float gray_f = 0.2126f * rrgbf[0] + 0.7152f * rrgbf[1] + 0.0722f * rrgbf[2]; - *cp = FTOCHAR(grey_f); + *cp = FTOCHAR(gray_f); } else { const unsigned char *rrgb = (unsigned char *)ibuf->rect + pixel * 4; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index aa9cc40f71f..df4d2d8cc38 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -108,154 +108,154 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum /* Lengths */ static struct bUnitDef buMetricLenDef[] = { - {"kilometer", "kilometers", "km", NULL, "Kilometers", UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"hectometer", "hectometers", "hm", NULL, "100 Meters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"dekameter", "dekameters", "dam",NULL, "10 Meters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"meter", "meters", "m", NULL, "Meters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, - {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, - {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too? + {"kilometer", "kilometers", "km", NULL, "Kilometers", UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"hectometer", "hectometers", "hm", NULL, "100 Meters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dam", NULL, "10 Meters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"meter", "meters", "m", NULL, "Meters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too? /* These get displayed because of float precision problems in the transform header, * could work around, but for now probably people wont use these */ #if 0 - {"nanometer", "Nanometers", "nm", NULL, 0.000000001, 0.0, B_UNIT_DEF_NONE}, - {"picometer", "Picometers", "pm", NULL, 0.000000000001, 0.0,B_UNIT_DEF_NONE}, + {"nanometer", "Nanometers", "nm", NULL, 0.000000001, 0.0, B_UNIT_DEF_NONE}, + {"picometer", "Picometers", "pm", NULL, 0.000000000001, 0.0, B_UNIT_DEF_NONE}, #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}, - {"furlong", "furlongs", "fur", NULL, "Furlongs",UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, - {"chain", "chains", "ch", NULL, "Chains", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, - {"yard", "yards", "yd", NULL, "Yards", UN_SC_YD, 0.0, B_UNIT_DEF_SUPPRESS}, - {"foot", "feet", "'", "ft", "Feet", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"inch", "inches", "\"", "in", "Inches", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, - {"thou", "thou", "thou", "mil", "Thou", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ + {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"furlong", "furlongs", "fur", NULL, "Furlongs", UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"chain", "chains", "ch", NULL, "Chains", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"yard", "yards", "yd", NULL, "Yards", UN_SC_YD, 0.0, B_UNIT_DEF_SUPPRESS}, + {"foot", "feet", "'", "ft", "Feet", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"inch", "inches", "\"", "in", "Inches", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"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[] = { - {"square kilometer", "square kilometers", "km²", "km2", "Square Kilometers", UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"square hectometer","square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, /* hectare */ - {"square dekameter", "square dekameters", "dam²","dam2", "Square Dekameters", UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, /* are */ - {"square meter", "square meters", "m²", "m2", "Square Meters", UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"square decimetre", "square decimetres", "dm²", "dm2", "Square Decimetres", UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, - {"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, - {"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} + {"square kilometer", "square kilometers", "km²", "km2", "Square Kilometers", UN_SC_KM * UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"square hectometer", "square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, /* hectare */ + {"square dekameter", "square dekameters", "dam²", "dam2", "Square Dekameters", UN_SC_DAM * UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, /* are */ + {"square meter", "square meters", "m²", "m2", "Square Meters", UN_SC_M * UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square decimeter", "square decimetees", "dm²", "dm2", "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"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}, - {"square furlong", "square furlongs", "sq fur",NULL, "Square Furlongs", UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, - {"square chain", "square chains", "sq ch", NULL, "Square Chains", UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, - {"square yard", "square yards", "sq yd", NULL, "Square Yards", UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, - {"square foot", "square feet", "sq ft", NULL, "Square Feet", UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"square inch", "square inches", "sq in", NULL, "Square Inches", UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, - {"square thou", "square thous", "sq mil",NULL, "Square Thous", UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, + {"square mile", "square miles", "sq mi", "sq m", "Square Miles", UN_SC_MI * UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"square furlong", "square furlongs", "sq fur", NULL, "Square Furlongs", UN_SC_FUR * UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square chain", "square chains", "sq ch", NULL, "Square Chains", UN_SC_CH * UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square yard", "square yards", "sq yd", NULL, "Square Yards", UN_SC_YD * UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"square foot", "square feet", "sq ft", NULL, "Square Feet", UN_SC_FT * UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square inch", "square inches", "sq in", NULL, "Square Inches", UN_SC_IN * UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"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[] = { - {"cubic kilometer", "cubic kilometers", "km³", "km3", "Cubic Kilometers", UN_SC_KM*UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"cubic hectometer","cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM*UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, - {"cubic dekameter", "cubic dekameters", "dam³","dam3", "Cubic Dekameters", UN_SC_DAM*UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"cubic meter", "cubic meters", "m³", "m3", "Cubic Meters", UN_SC_M*UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"cubic decimetre", "cubic decimetres", "dm³", "dm3", "Cubic Decimetres", UN_SC_DM*UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM*UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, - {"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM*UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, - {"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} + {"cubic kilometer", "cubic kilometers", "km³", "km3", "Cubic Kilometers", UN_SC_KM * UN_SC_KM * UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"cubic hectometer", "cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM * UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, + {"cubic dekameter", "cubic dekameters", "dam³", "dam3", "Cubic Dekameters", UN_SC_DAM * UN_SC_DAM * UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic meter", "cubic meters", "m³", "m3", "Cubic Meters", UN_SC_M * UN_SC_M * UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic decimeter", "cubic decimeters", "dm³", "dm3", "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM * UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM * UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"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}, - {"cubic furlong", "cubic furlongs", "cu fur",NULL, "Cubic Furlongs", UN_SC_FUR*UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, - {"cubic chain", "cubic chains", "cu ch", NULL, "Cubic Chains", UN_SC_CH*UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, - {"cubic yard", "cubic yards", "cu yd", NULL, "Cubic Yards", UN_SC_YD*UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, - {"cubic foot", "cubic feet", "cu ft", NULL, "Cubic Feet", UN_SC_FT*UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"cubic inch", "cubic inches", "cu in", NULL, "Cubic Inches", UN_SC_IN*UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, - {"cubic thou", "cubic thous", "cu mil",NULL, "Cubic Thous", UN_SC_MIL*UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, + {"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}, + {"cubic furlong", "cubic furlongs", "cu fur", NULL, "Cubic Furlongs", UN_SC_FUR * UN_SC_FUR * UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic chain", "cubic chains", "cu ch", NULL, "Cubic Chains", UN_SC_CH * UN_SC_CH * UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic yard", "cubic yards", "cu yd", NULL, "Cubic Yards", UN_SC_YD * UN_SC_YD * UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"cubic foot", "cubic feet", "cu ft", NULL, "Cubic Feet", UN_SC_FT * UN_SC_FT * UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic inch", "cubic inches", "cu in", NULL , "Cubic Inches", UN_SC_IN * UN_SC_IN * UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"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[] = { - {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, - {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, - {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_NONE}, - {"dekagram", "dekagrams", "dag",NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, - {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, - {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} + {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, + {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, + {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_NONE}, + {"dekagram", "dekagrams", "dag", NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, + {"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}, + {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, {"centum weight", "centum weights", "cwt", NULL, "Centum weights", UN_SC_CWT, 0.0, B_UNIT_DEF_NONE}, - {"stone", "stones", "st", NULL, "Stones", UN_SC_ST, 0.0, B_UNIT_DEF_NONE}, - {"pound", "pounds", "lb", NULL, "Pounds", UN_SC_LB, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"ounce", "ounces", "oz", NULL, "Ounces", UN_SC_OZ, 0.0, B_UNIT_DEF_NONE}, + {"stone", "stones", "st", NULL, "Stones", UN_SC_ST, 0.0, B_UNIT_DEF_NONE}, + {"pound", "pounds", "lb", NULL, "Pounds", UN_SC_LB, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"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 */ /* Velocity */ static struct bUnitDef buMetricVelDef[] = { - {"meter per second", "meters per second", "m/s", NULL, "Meters per second", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"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} + {"meter per second", "meters per second", "m/s", NULL, "Meters per second", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"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}, + {"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} + {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[] = { /* weeks? - probably not needed for blender */ - {"day", "days", "d", NULL, "Days", 90000.0, 0.0, B_UNIT_DEF_NONE}, - {"hour", "hours", "hr", "h", "Hours", 3600.0, 0.0, B_UNIT_DEF_NONE}, - {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, - {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE}, - {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, + {"day", "days", "d", NULL, "Days", 90000.0, 0.0, B_UNIT_DEF_NONE}, + {"hour", "hours", "hr", "h", "Hours", 3600.0, 0.0, B_UNIT_DEF_NONE}, + {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, + {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE}, + {"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); diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index ca810ee5b93..ac0ec6a52a7 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -65,7 +65,7 @@ int BLI_is_dir(const char *path); int BLI_is_file(const char *path); void BLI_dir_create_recursive(const char *dir); double BLI_dir_free_space(const char *dir); -char *BLI_current_working_dir(char *dir, const int maxlen); +char *BLI_current_working_dir(char *dir, const size_t maxlen); unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist); diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index ec7b59702bd..5f564f71646 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -401,7 +401,7 @@ static void join_dirfile_alloc(char **dst, size_t *alloc_len, const char *dir, c { size_t len = strlen(dir) + strlen(file) + 1; - if (!*dst) + if (*dst == NULL) *dst = MEM_callocN(len + 1, "join_dirfile_alloc path"); else if (*alloc_len < len) *dst = MEM_reallocN(*dst, len + 1); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index a0e72af8131..eb2070bce76 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -545,90 +545,90 @@ typedef struct FT_Outline_ #endif -/***//* -from: http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-1 - -Vectorial representation of Freetype glyphs - -The source format of outlines is a collection of closed paths called "contours". Each contour is -made of a series of line segments and bezier arcs. Depending on the file format, these can be -second-order or third-order polynomials. The former are also called quadratic or conic arcs, and -they come from the TrueType format. The latter are called cubic arcs and mostly come from the -Type1 format. - -Each arc is described through a series of start, end and control points. Each point of the outline -has a specific tag which indicates wether it is used to describe a line segment or an arc. - - -The following rules are applied to decompose the contour's points into segments and arcs : - -# two successive "on" points indicate a line segment joining them. - -# one conic "off" point amidst two "on" points indicates a conic bezier arc, the "off" point being - the control point, and the "on" ones the start and end points. - -# Two successive cubic "off" points amidst two "on" points indicate a cubic bezier arc. There must - be exactly two cubic control points and two on points for each cubic arc (using a single cubic - "off" point between two "on" points is forbidden, for example). - -# finally, two successive conic "off" points forces the rasterizer to create (during the scan-line - conversion process exclusively) a virtual "on" point amidst them, at their exact middle. This - greatly facilitates the definition of successive conic bezier arcs. Moreover, it's the way - outlines are described in the TrueType specification. - -Note that it is possible to mix conic and cubic arcs in a single contour, even though no current -font driver produces such outlines. - - * # on - * off - __---__ - #-__ _-- -_ - --__ _- - - --__ # \ - --__ # - -# - Two "on" points - Two "on" points and one "conic" point - between them - - - - * - # __ Two "on" points with two "conic" - \ - - points between them. The point - \ / \ marked '0' is the middle of the - - 0 \ "off" points, and is a 'virtual' - -_ _- # "on" point where the curve passes. - -- It does not appear in the point - list. - * - - - - - * # on - * * off - __---__ - _-- -_ - _- - - # \ - # - - Two "on" points - and two "cubic" point - between them - - -Each glyph's original outline points are located on a grid of indivisible units. The points are stored -in the font file as 16-bit integer grid coordinates, with the grid origin's being at (0, 0); they thus -range from -16384 to 16383. - -Convert conic to bezier arcs: -Conic P0 P1 P2 -Bezier B0 B1 B2 B3 -B0=P0 -B1=(P0+2*P1)/3 -B2=(P2+2*P1)/3 -B3=P2 - -*//****/ +/* + * from: http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-1 + * + * Vectorial representation of Freetype glyphs + * + * The source format of outlines is a collection of closed paths called "contours". Each contour is + * made of a series of line segments and bezier arcs. Depending on the file format, these can be + * second-order or third-order polynomials. The former are also called quadratic or conic arcs, and + * they come from the TrueType format. The latter are called cubic arcs and mostly come from the + * Type1 format. + * + * Each arc is described through a series of start, end and control points. Each point of the outline + * has a specific tag which indicates wether it is used to describe a line segment or an arc. + * + * + * The following rules are applied to decompose the contour's points into segments and arcs : + * + * # two successive "on" points indicate a line segment joining them. + * + * # one conic "off" point amidst two "on" points indicates a conic bezier arc, the "off" point being + * the control point, and the "on" ones the start and end points. + * + * # Two successive cubic "off" points amidst two "on" points indicate a cubic bezier arc. There must + * be exactly two cubic control points and two on points for each cubic arc (using a single cubic + * "off" point between two "on" points is forbidden, for example). + * + * # finally, two successive conic "off" points forces the rasterizer to create (during the scan-line + * conversion process exclusively) a virtual "on" point amidst them, at their exact middle. This + * greatly facilitates the definition of successive conic bezier arcs. Moreover, it's the way + * outlines are described in the TrueType specification. + * + * Note that it is possible to mix conic and cubic arcs in a single contour, even though no current + * font driver produces such outlines. + * + * * # on + * * off + * __---__ + * #-__ _-- -_ + * --__ _- - + * --__ # \ + * --__ # + * -# + * Two "on" points + * Two "on" points and one "conic" point + * between them + * + * + * + * * + * # __ Two "on" points with two "conic" + * \ - - points between them. The point + * \ / \ marked '0' is the middle of the + * - 0 \ "off" points, and is a 'virtual' + * -_ _- # "on" point where the curve passes. + * -- It does not appear in the point + * list. + * * + * + * + * + * + * * # on + * * * off + * __---__ + * _-- -_ + * _- - + * # \ + * # + * + * Two "on" points + * and two "cubic" point + * between them + * + * + * Each glyph's original outline points are located on a grid of indivisible units. The points are stored + * in the font file as 16-bit integer grid coordinates, with the grid origin's being at (0, 0); they thus + * range from -16384 to 16383. + * + * Convert conic to bezier arcs: + * Conic P0 P1 P2 + * Bezier B0 B1 B2 B3 + * B0=P0 + * B1=(P0+2*P1)/3 + * B2=(P2+2*P1)/3 + * B3=P2 + * + */ diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 58ee898ea28..a3835b5bb4a 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -225,7 +225,7 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack) /* TODO: * * regarding #rgb_to_bw vs #rgb_to_grayscale, - * it seems nobody knows why we have both functions which convert color to greys + * it seems nobody knows why we have both functions which convert color to grays * but with different influences, this is quite stupid, and should be resolved * by someone who knows this stuff: see this thread * http://lists.blender.org/pipermail/bf-committers/2012-June/037180.html diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d35624e84d2..e51d0d2645f 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -901,8 +901,8 @@ static int getLowestRoot(const float a, const float b, const float c, const floa // If determinant is negative it means no solutions. if (determinant >= 0.0f) { - // calculate the two roots: (if determinant == 0 then - // x1==x2 but lets disregard that slight optimization) + /* calculate the two roots: (if determinant == 0 then + * x1==x2 but lets disregard that slight optimization) */ float sqrtD = (float)sqrt(determinant); float r1 = (-b - sqrtD) / (2.0f * a); float r2 = (-b + sqrtD) / (2.0f * a); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 46a0ac630c1..c85efc1fd9a 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -806,7 +806,7 @@ void BLI_getlastdir(const char *dir, char *last, const size_t maxlen) const char *BLI_getDefaultDocumentFolder(void) { #ifndef WIN32 - const char *xdg_documents_dir= getenv("XDG_DOCUMENTS_DIR"); + const char *xdg_documents_dir = getenv("XDG_DOCUMENTS_DIR"); if (xdg_documents_dir) return xdg_documents_dir; @@ -1643,7 +1643,7 @@ int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const strncat(rel, base, rel_len); } - /* return 2 if src=dest */ + /* return 2 if (src == dest) */ if (BLI_path_cmp(path, dest_path) == 0) { // if (G.debug & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path); return BLI_REBASE_IDENTITY; diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 94752965f3a..1f0bd445831 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -288,7 +288,7 @@ static void mergepolysSimp(ScanFillContext *sf_ctx, PolyFill *pf1, PolyFill *pf2 } static short testedgeside(const float v1[2], const float v2[2], const float v3[2]) -/* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ +/* is v3 to the right of v1-v2 ? With exception: v3 == v1 || v3 == v2 */ { float inp; diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index d4f251d4f5e..965e8b5eec3 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -102,7 +102,7 @@ static struct ListBase dirbase_ = {NULL, NULL}; static struct ListBase *dirbase = &dirbase_; /* can return NULL when the size is not big enough */ -char *BLI_current_working_dir(char *dir, const int maxncpy) +char *BLI_current_working_dir(char *dir, const size_t maxncpy) { const char *pwd = getenv("PWD"); if (pwd) { diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index d591f98ddc0..348fa29eae7 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -96,7 +96,7 @@ static void *thread_tls_data; * } * // conditions to exit loop * if (if escape loop event) { - * if (BLI_available_threadslots(&lb)==maxthreads) + * if (BLI_available_threadslots(&lb) == maxthreads) * break; * } * } diff --git a/source/blender/blenlib/intern/time.c b/source/blender/blenlib/intern/time.c index 64f007513ed..bf9720fee09 100644 --- a/source/blender/blenlib/intern/time.c +++ b/source/blender/blenlib/intern/time.c @@ -37,7 +37,7 @@ double PIL_check_seconds_timer(void) { - static int hasperfcounter = -1; /* -1==unknown */ + static int hasperfcounter = -1; /* (-1 == unknown) */ static double perffreq; if (hasperfcounter == -1) { diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index accfbfc8c3c..eeb0187b74c 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -28,7 +28,7 @@ * http://blog.ivank.net/fortunes-algorithm-and-implementation.html */ -/** \file blender/blenkernel/intern/tracking.c +/** \file blender/blenkernel/intern/voronoi.c * \ingroup bli */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 47580ff3859..e87cfe07fdd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -159,52 +159,52 @@ #include <errno.h> /* - Remark: still a weak point is the newaddress() function, that doesnt solve reading from - multiple files at the same time - - (added remark: oh, i thought that was solved? will look at that... (ton) - -READ -- Existing Library (Main) push or free -- allocate new Main -- load file -- read SDNA -- for each LibBlock - - read LibBlock - - if a Library - - make a new Main - - attach ID's to it - - else - - read associated 'direct data' - - link direct data (internal and to LibBlock) -- read FileGlobal -- read USER data, only when indicated (file is ~/X.XX/startup.blend) -- free file -- per Library (per Main) - - read file - - read SDNA - - find LibBlocks and attach IDs to Main - - if external LibBlock - - search all Main's - - or it's already read, - - or not read yet - - or make new Main - - per LibBlock - - read recursive - - read associated direct data - - link direct data (internal and to LibBlock) - - free file -- per Library with unread LibBlocks - - read file - - read SDNA - - per LibBlock - - read recursive - - read associated direct data - - link direct data (internal and to LibBlock) - - free file -- join all Mains -- link all LibBlocks and indirect pointers to libblocks -- initialize FileGlobal and copy pointers to Global + * Remark: still a weak point is the newaddress() function, that doesnt solve reading from + * multiple files at the same time + * + * (added remark: oh, i thought that was solved? will look at that... (ton) + * + * READ + * - Existing Library (Main) push or free + * - allocate new Main + * - load file + * - read SDNA + * - for each LibBlock + * - read LibBlock + * - if a Library + * - make a new Main + * - attach ID's to it + * - else + * - read associated 'direct data' + * - link direct data (internal and to LibBlock) + * - read FileGlobal + * - read USER data, only when indicated (file is ~/X.XX/startup.blend) + * - free file + * - per Library (per Main) + * - read file + * - read SDNA + * - find LibBlocks and attach IDs to Main + * - if external LibBlock + * - search all Main's + * - or it's already read, + * - or not read yet + * - or make new Main + * - per LibBlock + * - read recursive + * - read associated direct data + * - link direct data (internal and to LibBlock) + * - free file + * - per Library with unread LibBlocks + * - read file + * - read SDNA + * - per LibBlock + * - read recursive + * - read associated direct data + * - link direct data (internal and to LibBlock) + * - free file + * - join all Mains + * - link all LibBlocks and indirect pointers to libblocks + * - initialize FileGlobal and copy pointers to Global */ /* also occurs in library.c */ @@ -4430,7 +4430,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_Collision) { CollisionModifierData *collmd = (CollisionModifierData *)md; - /* +#if 0 // TODO: CollisionModifier should use pointcache // + have proper reset events before enabling this collmd->x = newdataadr(fd, collmd->x); @@ -4440,7 +4440,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) collmd->current_x = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_x"); collmd->current_xnew = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_xnew"); collmd->current_v = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_v"); - */ +#endif collmd->x = NULL; collmd->xnew = NULL; @@ -5500,7 +5500,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) v3d->localvd->camera = sc->scene->camera; /* localview can become invalid during undo/redo steps, so we exit it when no could be found */ - /* XXX regionlocalview ? +#if 0 /* XXX regionlocalview ? */ for (base= sc->scene->base.first; base; base= base->next) { if (base->lay & v3d->lay) break; } @@ -5510,7 +5510,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) MEM_freeN(v3d->localvd); v3d->localvd= NULL; } - */ +#endif } else if (v3d->scenelock) v3d->lay = sc->scene->lay; @@ -5537,6 +5537,11 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) if (ads->filter_grp) ads->filter_grp = restore_pointer_by_name(newmain, (ID *)ads->filter_grp, 0); } + + /* force recalc of list of channels (i.e. includes calculating F-Curve colors) + * thus preventing the "black curves" problem post-undo + */ + sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; } else if (sl->spacetype == SPACE_BUTS) { SpaceButs *sbuts = (SpaceButs *)sl; @@ -5551,10 +5556,10 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) SpaceAction *saction = (SpaceAction *)sl; saction->action = restore_pointer_by_name(newmain, (ID *)saction->action, 1); - saction->ads.source= restore_pointer_by_name(newmain, (ID *)saction->ads.source, 1); + saction->ads.source = restore_pointer_by_name(newmain, (ID *)saction->ads.source, 1); if (saction->ads.filter_grp) - saction->ads.filter_grp= restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0); + saction->ads.filter_grp = restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0); /* force recalc of list of channels, potentially updating the active action @@ -5913,11 +5918,20 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } } else if (sl->spacetype == SPACE_SEQ) { + /* grease pencil data is not a direct data and can't be linked from direct_link* + * functions, it should be linked from lib_link* funcrions instead + * + * otherwise it'll lead to lost grease data on open because it'll likely be + * read from file after all other users of grease pencil and newdataadr would + * simple return NULL here (sergey) + */ +#if 0 SpaceSeq *sseq = (SpaceSeq *)sl; if (sseq->gpd) { sseq->gpd = newdataadr(fd, sseq->gpd); direct_link_gpencil(fd, sseq->gpd); } +#endif } else if (sl->spacetype == SPACE_BUTS) { SpaceButs *sbuts = (SpaceButs *)sl; @@ -7425,7 +7439,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (main->versionfile < 263) { /* set fluidsim rate. the version patch for this in 2.62 was wrong, so - try to correct it, if rate is 0.0 that's likely not intentional */ + * try to correct it, if rate is 0.0 that's likely not intentional */ Object *ob; for (ob = main->object.first; ob; ob = ob->id.next) { diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index bfaa526b995..ca071e0cc25 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -2580,8 +2580,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) act->type = act->otype = ACT_ACTION; /* Fix for converting 2.4x files: if we don't have an action, but we have an - object IPO, then leave the actuator as an IPO actuator for now and let the - IPO conversion code handle it */ + * object IPO, then leave the actuator as an IPO actuator for now and let the + * IPO conversion code handle it */ if (ob->ipo && !aa->act) act->type = ACT_IPO; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f257994bc1c..02b4537e9c8 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1380,14 +1380,14 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) } else if (md->type==eModifierType_Collision) { - /* +#if 0 CollisionModifierData *collmd = (CollisionModifierData*) md; // TODO: CollisionModifier should use pointcache // + have proper reset events before enabling this writestruct(wd, DATA, "MVert", collmd->numverts, collmd->x); writestruct(wd, DATA, "MVert", collmd->numverts, collmd->xnew); writestruct(wd, DATA, "MFace", collmd->numfaces, collmd->mfaces); - */ +#endif } else if (md->type==eModifierType_MeshDeform) { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 730b741fa38..4bce7a6ff51 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -32,6 +32,10 @@ set(INC ../../../intern/guardedalloc ) +set(INC_SYS + +) + set(SRC operators/bmo_bevel.c operators/bmo_connect.c diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 8d9f2ed7336..385572cceff 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -318,10 +318,10 @@ static void bm_rationalize_normals(BMesh *bm, int undo) return; } - BMO_op_initf(bm, &bmop, "righthandfaces faces=%af do_flip=%b", FALSE); + BMO_op_initf(bm, &bmop, "recalc_face_normals faces=%af do_flip=%b", FALSE); BMO_push(bm, &bmop); - bmo_righthandfaces_exec(bm, &bmop); + bmo_recalc_face_normals_exec(bm, &bmop); BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { BM_elem_flag_set(f, BM_ELEM_TAG, BMO_elem_flag_test(bm, f, FACE_FLIP)); diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 2c7007d1961..b29970dc886 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -354,12 +354,12 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - BM_loop_interp_from_face(bm, l_iter, of, FALSE, TRUE); + BM_loop_interp_multires(bm, l_iter, of); } while ((l_iter = l_iter->next) != l_first); l_iter = l_first = BM_FACE_FIRST_LOOP(nf); do { - BM_loop_interp_from_face(bm, l_iter, of, FALSE, TRUE); + BM_loop_interp_multires(bm, l_iter, of); } while ((l_iter = l_iter->next) != l_first); BM_face_kill(bm, of); diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 4186f5d47eb..b6d9fbc85a2 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -97,8 +97,8 @@ * * Smooths vertices by using a basic vertex averaging scheme. */ -static BMOpDefine bmo_vertexsmooth_def = { - "vertexsmooth", +static BMOpDefine bmo_smooth_vert_def = { + "smooth_vert", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, //set vertices close to the x axis before the operation to 0 {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, //set vertices close to the y axis before the operation to 0 @@ -106,7 +106,7 @@ static BMOpDefine bmo_vertexsmooth_def = { {BMO_OP_SLOT_FLT, "clipdist"}, //clipping threshod for the above three slots {0} /* null-terminating sentinel */, }, - bmo_vertexsmooth_exec, + bmo_smooth_vert_exec, 0 }; @@ -116,13 +116,13 @@ static BMOpDefine bmo_vertexsmooth_def = { * Computes an "outside" normal for the specified input faces. */ -static BMOpDefine bmo_righthandfaces_def = { - "righthandfaces", +static BMOpDefine bmo_recalc_face_normals_def = { + "recalc_face_normals", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, {BMO_OP_SLOT_BOOL, "do_flip"}, //internal flag, used by bmesh_rationalize_normals {0} /* null-terminating sentinel */, }, - bmo_righthandfaces_exec, + bmo_recalc_face_normals_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -136,15 +136,15 @@ static BMOpDefine bmo_righthandfaces_def = { * if usefaces is 0 then geomout spits out verts and edges, * otherwise it spits out faces. */ -static BMOpDefine bmo_regionextend_def = { - "regionextend", +static BMOpDefine bmo_region_extend_def = { + "region_extend", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output slot, computed boundary geometry. {BMO_OP_SLOT_BOOL, "constrict"}, //find boundary inside the regions, not outside. {BMO_OP_SLOT_BOOL, "use_faces"}, //extend from faces instead of edges {0} /* null-terminating sentinel */, }, - bmo_regionextend_exec, + bmo_region_extend_exec, 0 }; @@ -154,14 +154,14 @@ static BMOpDefine bmo_regionextend_def = { * Rotates edges topologically. Also known as "spin edge" to some people. * Simple example: [/] becomes [|] then [\]. */ -static BMOpDefine bmo_edgerotate_def = { - "edgerotate", +static BMOpDefine bmo_rotate_edges_def = { + "rotate_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges {BMO_OP_SLOT_BOOL, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise {0} /* null-terminating sentinel */, }, - bmo_edgerotate_exec, + bmo_rotate_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -171,12 +171,12 @@ static BMOpDefine bmo_edgerotate_def = { * Reverses the winding (vertex order) of faces. This has the effect of * flipping the normal. */ -static BMOpDefine bmo_reversefaces_def = { - "reversefaces", +static BMOpDefine bmo_reverse_faces_def = { + "reverse_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces {0} /* null-terminating sentinel */, }, - bmo_reversefaces_exec, + bmo_reverse_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -186,14 +186,14 @@ static BMOpDefine bmo_reversefaces_def = { * Splits input edges (but doesn't do anything else). * This creates a 2-valence vert. */ -static BMOpDefine bmo_edgebisect_def = { - "edgebisect", +static BMOpDefine bmo_bisect_edges_def = { + "bisect_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges {BMO_OP_SLOT_INT, "numcuts"}, //number of cuts {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, //newly created vertices and edges {0} /* null-terminating sentinel */, }, - bmo_edgebisect_exec, + bmo_bisect_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -225,17 +225,17 @@ static BMOpDefine bmo_mirror_def = { * Takes input verts and find vertices they should weld to. Outputs a * mapping slot suitable for use with the weld verts bmop. * - * If keepverts is used, vertices outside that set can only be merged + * If keep_verts is used, vertices outside that set can only be merged * with vertices in that set. */ -static BMOpDefine bmo_finddoubles_def = { - "finddoubles", +static BMOpDefine bmo_find_doubles_def = { + "find_doubles", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_ELEMENT_BUF, "keepverts"}, //list of verts to keep + {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, //list of verts to keep {BMO_OP_SLOT_FLT, "dist"}, //minimum distance {BMO_OP_SLOT_MAPPING, "targetmapout"}, {0, /* null-terminating sentinel */}}, - bmo_finddoubles_exec, + bmo_find_doubles_exec, 0, }; @@ -245,12 +245,12 @@ static BMOpDefine bmo_finddoubles_def = { * Finds groups of vertices closer then dist and merges them together, * using the weld verts bmop. */ -static BMOpDefine bmo_removedoubles_def = { - "removedoubles", +static BMOpDefine bmo_remove_doubles_def = { + "remove_doubles", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts {BMO_OP_SLOT_FLT, "dist"}, //minimum distance {0, /* null-terminating sentinel */}}, - bmo_removedoubles_exec, + bmo_remove_doubles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -305,11 +305,11 @@ static BMOpDefine bmo_pointmerge_facedata_def = { * the bounding box center. (I know, it's not averaging but * the vert_snap_to_bb_center is just too long). */ -static BMOpDefine bmo_vert_average_facedata_def = { - "vert_average_facedata", +static BMOpDefine bmo_average_vert_facedata_def = { + "average_vert_facedata", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ {0, /* null-terminating sentinel */}}, - bmo_vert_average_facedata_exec, + bmo_average_vert_facedata_exec, 0, }; @@ -321,7 +321,7 @@ static BMOpDefine bmo_vert_average_facedata_def = { static BMOpDefine bmo_pointmerge_def = { "pointmerge", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ - {BMO_OP_SLOT_VEC, "mergeco"}, + {BMO_OP_SLOT_VEC, "merge_co"}, {0, /* null-terminating sentinel */}}, bmo_pointmerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, @@ -347,11 +347,11 @@ static BMOpDefine bmo_collapse_uvs_def = { * use or will use this bmop). You pass in mappings from vertices to the vertices * they weld with. */ -static BMOpDefine bmo_weldverts_def = { - "weldverts", +static BMOpDefine bmo_weld_verts_def = { + "weld_verts", {{BMO_OP_SLOT_MAPPING, "targetmap"}, /* maps welded vertices to verts they should weld to */ {0, /* null-terminating sentinel */}}, - bmo_weldverts_exec, + bmo_weld_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -361,12 +361,12 @@ static BMOpDefine bmo_weldverts_def = { * Creates a single vertex; this bmop was necessary * for click-create-vertex. */ -static BMOpDefine bmo_makevert_def = { - "makevert", +static BMOpDefine bmo_create_vert_def = { + "create_vert", {{BMO_OP_SLOT_VEC, "co"}, //the coordinate of the new vert {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, //the new vert {0, /* null-terminating sentinel */}}, - bmo_makevert_exec, + bmo_create_vert_exec, 0, }; @@ -528,8 +528,8 @@ static BMOpDefine bmo_transform_def = { */ static BMOpDefine bmo_object_load_bmesh_def = { "object_load_bmesh", - {{BMO_OP_SLOT_PNT, "scene"}, - {BMO_OP_SLOT_PNT, "object"}, + {{BMO_OP_SLOT_PTR, "scene"}, + {BMO_OP_SLOT_PTR, "object"}, {0, /* null-terminating sentinel */}}, bmo_object_load_bmesh_exec, 0, @@ -543,8 +543,8 @@ static BMOpDefine bmo_object_load_bmesh_def = { */ static BMOpDefine bmo_bmesh_to_mesh_def = { "bmesh_to_mesh", - {{BMO_OP_SLOT_PNT, "mesh"}, //pointer to a mesh structure to fill in - {BMO_OP_SLOT_PNT, "object"}, //pointer to an object structure + {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a mesh structure to fill in + {BMO_OP_SLOT_PTR, "object"}, //pointer to an object structure {BMO_OP_SLOT_BOOL, "notessellation"}, //don't calculate mfaces {0, /* null-terminating sentinel */}}, bmo_bmesh_to_mesh_exec, @@ -559,8 +559,8 @@ static BMOpDefine bmo_bmesh_to_mesh_def = { */ static BMOpDefine bmo_mesh_to_bmesh_def = { "mesh_to_bmesh", - {{BMO_OP_SLOT_PNT, "mesh"}, //pointer to a Mesh structure - {BMO_OP_SLOT_PNT, "object"}, //pointer to an Object structure + {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a Mesh structure + {BMO_OP_SLOT_PTR, "object"}, //pointer to an Object structure {BMO_OP_SLOT_BOOL, "set_shapekey"}, //load active shapekey coordinates into verts {0, /* null-terminating sentinel */}}, bmo_mesh_to_bmesh_exec, @@ -572,13 +572,13 @@ static BMOpDefine bmo_mesh_to_bmesh_def = { * * Extrudes faces individually. */ -static BMOpDefine bmo_extrude_indivface_def = { - "extrude_face_indiv", +static BMOpDefine bmo_extrude_discrete_faces_def = { + "extrude_discrete_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //output faces {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, //output skirt geometry, faces and edges {0} /* null-terminating sentinel */}, - bmo_extrude_face_indiv_exec, + bmo_extrude_discrete_faces_exec, 0 }; @@ -612,12 +612,12 @@ static BMOpDefine bmo_extrude_vert_indiv_def = { 0 }; -static BMOpDefine bmo_connectverts_def = { - "connectverts", +static BMOpDefine bmo_connect_verts_def = { + "connect_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, {0} /* null-terminating sentinel */}, - bmo_connectverts_exec, + bmo_connect_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -691,8 +691,8 @@ static BMOpDefine bmo_triangulate_def = { BMO_OP_FLAG_UNTAN_MULTIRES }; -static BMOpDefine bmo_esubd_def = { - "esubd", +static BMOpDefine bmo_subdivide_edges_def = { + "subdivide_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, {BMO_OP_SLOT_FLT, "smooth"}, {BMO_OP_SLOT_FLT, "fractal"}, @@ -714,21 +714,21 @@ static BMOpDefine bmo_esubd_def = { {0} /* null-terminating sentinel */, }, - bmo_esubd_exec, + bmo_subdivide_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; -static BMOpDefine bmo_del_def = { - "del", +static BMOpDefine bmo_delete_def = { + "delete", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_INT, "context"}, {0} /* null-terminating sentinel */}, - bmo_del_exec, + bmo_delete_exec, 0 }; -static BMOpDefine bmo_dupe_def = { - "dupe", +static BMOpDefine bmo_duplicate_def = { + "duplicate", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_ELEMENT_BUF, "origout"}, {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, @@ -737,9 +737,9 @@ static BMOpDefine bmo_dupe_def = { {BMO_OP_SLOT_MAPPING, "facemap"}, {BMO_OP_SLOT_MAPPING, "boundarymap"}, {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ {0} /* null-terminating sentinel */}, - bmo_dupe_exec, + bmo_duplicate_exec, 0 }; @@ -749,7 +749,7 @@ static BMOpDefine bmo_split_def = { {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, {BMO_OP_SLOT_MAPPING, "boundarymap"}, {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ {BMO_OP_SLOT_BOOL, "use_only_faces"}, /* when enabled. don't duplicate loose verts/edges */ {0} /* null-terminating sentinel */}, bmo_split_exec, @@ -783,14 +783,14 @@ static BMOpDefine bmo_spin_def = { * * Find similar faces (area/material/perimeter, ...). */ -static BMOpDefine bmo_similarfaces_def = { - "similarfaces", +static BMOpDefine bmo_similar_faces_def = { + "similar_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similarfaces_exec, + bmo_similar_faces_exec, 0 }; @@ -799,14 +799,14 @@ static BMOpDefine bmo_similarfaces_def = { * * Find similar edges (length, direction, edge, seam, ...). */ -static BMOpDefine bmo_similaredges_def = { - "similaredges", +static BMOpDefine bmo_similar_edges_def = { + "similar_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similaredges_exec, + bmo_similar_edges_exec, 0 }; @@ -815,14 +815,14 @@ static BMOpDefine bmo_similaredges_def = { * * Find similar vertices (normal, face, vertex group, ...). */ -static BMOpDefine bmo_similarverts_def = { - "similarverts", +static BMOpDefine bmo_similar_verts_def = { + "similar_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similarverts_exec, + bmo_similar_verts_exec, 0 }; @@ -830,12 +830,12 @@ static BMOpDefine bmo_similarverts_def = { * uv rotation * cycle the uvs */ -static BMOpDefine bmo_face_rotateuvs_def = { - "face_rotateuvs", +static BMOpDefine bmo_rotate_uvs_def = { + "rotate_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_INT, "dir"}, /* direction */ {0} /* null-terminating sentinel */}, - bmo_face_rotateuvs_exec, + bmo_rotate_uvs_exec, 0 }; @@ -843,11 +843,11 @@ static BMOpDefine bmo_face_rotateuvs_def = { * uv reverse * reverse the uvs */ -static BMOpDefine bmo_face_reverseuvs_def = { - "face_reverseuvs", +static BMOpDefine bmo_reverse_uvs_def = { + "reverse_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */}, - bmo_face_reverseuvs_exec, + bmo_reverse_uvs_exec, 0 }; @@ -855,12 +855,12 @@ static BMOpDefine bmo_face_reverseuvs_def = { * color rotation * cycle the colors */ -static BMOpDefine bmo_face_rotatecolors_def = { - "face_rotatecolors", +static BMOpDefine bmo_rotate_colors_def = { + "rotate_colors", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_INT, "dir"}, /* direction */ {0} /* null-terminating sentinel */}, - bmo_rotatecolors_exec, + bmo_rotate_colors_exec, 0 }; @@ -868,11 +868,11 @@ static BMOpDefine bmo_face_rotatecolors_def = { * color reverse * reverse the colors */ -static BMOpDefine bmo_face_reversecolors_def = { - "face_reversecolors", +static BMOpDefine bmo_reverse_colors_def = { + "reverse_colors", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */}, - bmo_face_reversecolors_exec, + bmo_reverse_colors_exec, 0 }; @@ -881,14 +881,14 @@ static BMOpDefine bmo_face_reversecolors_def = { * * Find similar vertices (normal, face, vertex group, ...). */ -static BMOpDefine bmo_vertexshortestpath_def = { - "vertexshortestpath", +static BMOpDefine bmo_shortest_path_def = { + "shortest_path", {{BMO_OP_SLOT_ELEMENT_BUF, "startv"}, /* start vertex */ {BMO_OP_SLOT_ELEMENT_BUF, "endv"}, /* end vertex */ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {0} /* null-terminating sentinel */}, - bmo_vertexshortestpath_exec, + bmo_shortest_path_exec, 0 }; @@ -897,15 +897,15 @@ static BMOpDefine bmo_vertexshortestpath_def = { * * Disconnects faces along input edges. */ -static BMOpDefine bmo_edgesplit_def = { - "edgesplit", +static BMOpDefine bmo_split_edges_def = { + "split_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* old output disconnected edges */ /* needed for vertex rip so we can rip only half an edge at a boundary wich would otherwise split off */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* optional tag verts, use to have greater control of splits */ {BMO_OP_SLOT_BOOL, "use_verts"}, /* use 'verts' for splitting, else just find verts to split from edges */ {0} /* null-terminating sentinel */}, - bmo_edgesplit_exec, + bmo_split_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1034,12 +1034,12 @@ static BMOpDefine bmo_bevel_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "face_spans"}, /* new geometry */ {BMO_OP_SLOT_ELEMENT_BUF, "face_holes"}, /* new geometry */ - {BMO_OP_SLOT_BOOL, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata laye */ + {BMO_OP_SLOT_BOOL, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata layer */ {BMO_OP_SLOT_BOOL, "use_even"}, /* corner vert placement: use shell/angle calculations */ {BMO_OP_SLOT_BOOL, "use_dist"}, /* corner vert placement: evaluate percent as a distance, * modifier uses this. We could do this as another float setting */ {BMO_OP_SLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */ - {BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand bevelled edge */ + {BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand beveled edge */ {0} /* null-terminating sentinel */}, bmo_bevel_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -1134,14 +1134,14 @@ static BMOpDefine bmo_wireframe_def = { * * Translates vertes along an edge */ -static BMOpDefine bmo_vertex_slide_def = { - "vertex_slide", +static BMOpDefine bmo_slide_vert_def = { + "slide_vert", {{BMO_OP_SLOT_ELEMENT_BUF, "vert"}, {BMO_OP_SLOT_ELEMENT_BUF, "edge"}, {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, {BMO_OP_SLOT_FLT, "distance_t"}, {0} /* null-terminating sentinel */}, - bmo_vertex_slide_exec, + bmo_slide_vert_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1176,75 +1176,76 @@ static BMOpDefine bmo_convex_hull_def = { }; BMOpDefine *opdefines[] = { - &bmo_split_def, - &bmo_spin_def, - &bmo_dupe_def, - &bmo_del_def, - &bmo_esubd_def, - &bmo_triangulate_def, - &bmo_dissolve_faces_def, - &bmo_dissolve_edges_def, + &bmo_automerge_def, + &bmo_average_vert_facedata_def, + &bmo_beautify_fill_def, + &bmo_bevel_def, + &bmo_bisect_edges_def, + &bmo_bmesh_to_mesh_def, + &bmo_bridge_loops_def, + &bmo_collapse_def, + &bmo_collapse_uvs_def, + &bmo_connect_verts_def, + &bmo_contextual_create_def, + &bmo_convex_hull_def, + &bmo_create_circle_def, + &bmo_create_cone_def, + &bmo_create_cube_def, + &bmo_create_grid_def, + &bmo_create_icosphere_def, + &bmo_create_monkey_def, + &bmo_create_uvsphere_def, + &bmo_create_vert_def, + &bmo_delete_def, &bmo_dissolve_edge_loop_def, - &bmo_dissolve_verts_def, + &bmo_dissolve_edges_def, + &bmo_dissolve_faces_def, &bmo_dissolve_limit_def, + &bmo_dissolve_verts_def, + &bmo_duplicate_def, + &bmo_edgenet_fill_def, + &bmo_edgenet_prepare_def, + &bmo_extrude_discrete_faces_def, + &bmo_extrude_edge_only_def, &bmo_extrude_face_region_def, - &bmo_connectverts_def, &bmo_extrude_vert_indiv_def, + &bmo_find_doubles_def, + &bmo_inset_def, + &bmo_join_triangles_def, &bmo_mesh_to_bmesh_def, - &bmo_object_load_bmesh_def, - &bmo_transform_def, - &bmo_translate_def, - &bmo_rotate_def, - &bmo_edgenet_fill_def, - &bmo_contextual_create_def, - &bmo_makevert_def, - &bmo_weldverts_def, - &bmo_removedoubles_def, - &bmo_finddoubles_def, &bmo_mirror_def, - &bmo_edgebisect_def, - &bmo_reversefaces_def, - &bmo_edgerotate_def, - &bmo_regionextend_def, - &bmo_righthandfaces_def, - &bmo_vertexsmooth_def, - &bmo_extrude_edge_only_def, - &bmo_extrude_indivface_def, - &bmo_collapse_uvs_def, + &bmo_object_load_bmesh_def, &bmo_pointmerge_def, - &bmo_collapse_def, - &bmo_similarfaces_def, - &bmo_similaredges_def, - &bmo_similarverts_def, &bmo_pointmerge_facedata_def, - &bmo_vert_average_facedata_def, - &bmo_face_rotateuvs_def, - &bmo_bmesh_to_mesh_def, - &bmo_face_reverseuvs_def, - &bmo_edgenet_prepare_def, - &bmo_face_rotatecolors_def, - &bmo_face_reversecolors_def, - &bmo_vertexshortestpath_def, + &bmo_recalc_face_normals_def, + &bmo_region_extend_def, + &bmo_remove_doubles_def, + &bmo_reverse_colors_def, + &bmo_reverse_faces_def, + &bmo_reverse_uvs_def, + &bmo_rotate_colors_def, + &bmo_rotate_def, + &bmo_rotate_edges_def, + &bmo_rotate_uvs_def, &bmo_scale_def, - &bmo_edgesplit_def, - &bmo_automerge_def, - &bmo_create_uvsphere_def, - &bmo_create_grid_def, - &bmo_create_icosphere_def, - &bmo_create_monkey_def, - &bmo_create_cube_def, - &bmo_create_circle_def, - &bmo_create_cone_def, - &bmo_join_triangles_def, - &bmo_bevel_def, - &bmo_beautify_fill_def, - &bmo_triangle_fill_def, - &bmo_bridge_loops_def, + &bmo_shortest_path_def, + &bmo_similar_edges_def, + &bmo_similar_faces_def, + &bmo_similar_verts_def, + &bmo_slide_vert_def, + &bmo_smooth_vert_def, &bmo_solidify_def, - &bmo_inset_def, + &bmo_spin_def, + &bmo_split_def, + &bmo_split_edges_def, + &bmo_subdivide_edges_def, + &bmo_transform_def, + &bmo_translate_def, + &bmo_triangle_fill_def, + &bmo_triangulate_def, + &bmo_weld_verts_def, &bmo_wireframe_def, - &bmo_vertex_slide_def, - &bmo_convex_hull_def, + }; int bmesh_total_ops = (sizeof(opdefines) / sizeof(void *)); diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index b5e6534de3e..74087c00940 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -99,7 +99,7 @@ enum { /* normally store pointers to object, scene, * _never_ store arrays corresponding to mesh elements with this */ - BMO_OP_SLOT_PNT = 4, + BMO_OP_SLOT_PTR = 4, BMO_OP_SLOT_MAT = 5, BMO_OP_SLOT_VEC = 8, @@ -116,7 +116,7 @@ enum { * for when your defining an operator with BMOpDefine.*/ typedef struct BMOpSlot { - int slottype; + int slot_type; int len; int flag; int index; /* index within slot array */ @@ -132,16 +132,13 @@ typedef struct BMOpSlot { #define BMO_OP_MAX_SLOTS 16 /* way more than probably needed */ -#ifdef slots -#undef slots -#endif - typedef struct BMOperator { int type; - int slottype; + int slot_type; int needflag; int flag; - struct BMOpSlot slots[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, struct BMOperator *op); + struct BMOpSlot slot_args[BMO_OP_MAX_SLOTS]; + void (*exec)(BMesh *bm, struct BMOperator *op); struct MemArena *arena; } BMOperator; @@ -154,7 +151,7 @@ typedef struct BMOSlotType { typedef struct BMOpDefine { const char *name; - BMOSlotType slottypes[BMO_OP_MAX_SLOTS]; + BMOSlotType slot_types[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, BMOperator *op); int flag; } BMOpDefine; @@ -197,11 +194,11 @@ int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag) * this system is used to execute or initialize an operator, * using a formatted-string system. * - * for example, BMO_op_callf(bm, "del geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES); + * for example, BMO_op_callf(bm, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES); * . . .will execute the delete operator, feeding in selected faces, deleting them. * * the basic format for the format string is: - * [operatorname] [slotname]=%[code] [slotname]=%[code] + * [operatorname] [slot_name]=%[code] [slot_name]=%[code] * * as in printf, you pass in one additional argument to the function * for every code. @@ -246,10 +243,10 @@ int BMO_op_initf(BMesh *bm, BMOperator *op, const char *fmt, ...); int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *fmt, va_list vlist); /* test whether a named slot exists */ -int BMO_slot_exists(BMOperator *op, const char *slotname); +int BMO_slot_exists(BMOperator *op, const char *slot_name); /* get a pointer to a slot. this may be removed layer on from the public API. */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slotname); +BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name); /* copies the data of a slot from one operator to another. src and dst are the * source/destination slot codes, respectively. */ @@ -270,30 +267,30 @@ enum { void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag); void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag); -void BMO_slot_float_set(BMOperator *op, const char *slotname, const float f); -float BMO_slot_float_get(BMOperator *op, const char *slotname); -void BMO_slot_int_set(BMOperator *op, const char *slotname, const int i); -int BMO_slot_int_get(BMOperator *op, const char *slotname); -void BMO_slot_bool_set(BMOperator *op, const char *slotname, const int i); -int BMO_slot_bool_get(BMOperator *op, const char *slotname); +void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f); +float BMO_slot_float_get(BMOperator *op, const char *slot_name); +void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i); +int BMO_slot_int_get(BMOperator *op, const char *slot_name); +void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i); +int BMO_slot_bool_get(BMOperator *op, const char *slot_name); /* don't pass in arrays that are supposed to map to elements this way. * * so, e.g. passing in list of floats per element in another slot is bad. * passing in, e.g. pointer to an editmesh for the conversion operator is fine * though. */ -void BMO_slot_ptr_set(BMOperator *op, const char *slotname, void *p); -void *BMO_slot_ptr_get(BMOperator *op, const char *slotname); -void BMO_slot_vec_set(BMOperator *op, const char *slotname, const float vec[3]); -void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]); +void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p); +void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name); +void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]); +void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]); /* only supports square mats */ /* size must be 3 or 4; this api is meant only for transformation matrices. * note that internally the matrix is stored in 4x4 form, and it's safe to * call whichever BMO_Get_Mat* function you want. */ -void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, int size); -void BMO_slot_mat4_get(BMOperator *op, const char *slotname, float r_mat[4][4]); -void BMO_slot_mat3_set(BMOperator *op, const char *slotname, float r_mat[3][3]); +void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size); +void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]); +void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]); void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, const short oflag); @@ -303,47 +300,47 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot, /* puts every element of type 'type' (which is a bitmask) with tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* puts every element of type 'type' (which is a bitmask) without tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush); /* puts every element of type 'type' (which is a bitmask) with header * flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, + const char *slot_name, const char htype, const char hflag); /* puts every element of type 'type' (which is a bitmask) without * header flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, + const char *slot_name, const char htype, const char hflag); /* counts number of elements inside a slot array. */ -int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slotname); -int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slotname); +int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slot_name); +int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slot_name); -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element, void *data, int len); /* Counts the number of edges with tool flag toolflag around @@ -352,9 +349,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag); /* flags all elements in a mapping. note that the mapping must only have * bmesh elements in it.*/ -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char hflag, const short oflag); +void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len); + +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, + const char htype); + /* this part of the API is used to iterate over element buffer or * mapping slots. * @@ -363,7 +365,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * BMOIter oiter; * BMFace *f; * - * f = BMO_iter_new(&oiter, bm, some_operator, "slotname", BM_FACE); + * f = BMO_iter_new(&oiter, bm, some_operator, "slot_name", BM_FACE); * for (; f; f = BMO_iter_step(&oiter)) { * /do something with the face * } @@ -373,7 +375,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * void *key; * void *val; * - * key = BMO_iter_new(&oiter, bm, some_operator, "slotname", 0); + * key = BMO_iter_new(&oiter, bm, some_operator, "slot_name", 0); * for (; key; key = BMO_iter_step(&oiter)) { * val = BMO_iter_map_value(&oiter); * //do something with the key/val pair @@ -396,10 +398,10 @@ typedef struct BMOIter { char restrictmask; /* bitwise '&' with BMHeader.htype */ } BMOIter; -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname); +void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name); void *BMO_iter_new(BMOIter *iter, BMesh *bm, BMOperator *op, - const char *slotname, const char restrictmask); + const char *slot_name, const char restrictmask); void *BMO_iter_step(BMOIter *iter); /* returns a pointer to the key value when iterating over mappings. @@ -412,8 +414,8 @@ void *BMO_iter_map_value_p(BMOIter *iter); /* use this for float mappings */ float BMO_iter_map_value_f(BMOIter *iter); -#define BMO_ITER(ele, iter, bm, op, slotname, restrict) \ - for (ele = BMO_iter_new(iter, bm, op, slotname, restrict); ele; ele = BMO_iter_step(iter)) +#define BMO_ITER(ele, iter, bm, op, slot_name, restrict) \ + for (ele = BMO_iter_new(iter, bm, op, slot_name, restrict); ele; ele = BMO_iter_step(iter)) /******************* Inlined Functions********************/ typedef void (*opexec)(BMesh *bm, BMOperator *op); diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index e04079f42c9..16c2b8b0505 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -69,16 +69,16 @@ BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const shor oflags[bm->stackdepth - 1].f ^= oflag; } -BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, int val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(int)); } -BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, float val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(float)); } @@ -87,16 +87,16 @@ BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char * do NOT use these for non-operator-api-allocated memory! instead * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */ -BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, void *val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void *)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(void *)); } -BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element) +BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return 0; @@ -104,12 +104,12 @@ BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const ch return BLI_ghash_haskey(slot->data.ghash, element); } -BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return NULL; @@ -121,28 +121,28 @@ BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const return mapping + 1; } -BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - float *val = (float *) BMO_slot_map_data_get(bm, op, slotname, element); + float *val = (float *) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return 0.0f; } -BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - int *val = (int *) BMO_slot_map_data_get(bm, op, slotname, element); + int *val = (int *) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return 0; } -BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - void **val = (void **) BMO_slot_map_data_get(bm, op, slotname, element); + void **val = (void **) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return NULL; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 65288522b3b..5447e6b5a55 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -145,9 +145,9 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const char *opname) op->flag = opdefines[opcode]->flag; /* initialize the operator slot types */ - for (i = 0; opdefines[opcode]->slottypes[i].type; i++) { - op->slots[i].slottype = opdefines[opcode]->slottypes[i].type; - op->slots[i].index = i; + for (i = 0; opdefines[opcode]->slot_types[i].type; i++) { + op->slot_args[i].slot_type = opdefines[opcode]->slot_types[i].type; + op->slot_args[i].index = i; } /* callback */ @@ -192,9 +192,9 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) BMOpSlot *slot; int i; - for (i = 0; opdefines[op->type]->slottypes[i].type; i++) { - slot = &op->slots[i]; - if (slot->slottype == BMO_OP_SLOT_MAPPING) { + for (i = 0; opdefines[op->type]->slot_types[i].type; i++) { + slot = &op->slot_args[i]; + if (slot->slot_type == BMO_OP_SLOT_MAPPING) { if (slot->data.ghash) BLI_ghash_free(slot->data.ghash, NULL, NULL); } @@ -214,26 +214,26 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) * * \return Success if the slot if found. */ -int BMO_slot_exists(BMOperator *op, const char *slotname) +int BMO_slot_exists(BMOperator *op, const char *slot_name) { - int slotcode = bmo_name_to_slotcode(opdefines[op->type], slotname); - return (slotcode >= 0); + int slot_code = bmo_name_to_slotcode(opdefines[op->type], slot_name); + return (slot_code >= 0); } /** * \brief BMESH OPSTACK GET SLOT * - * Returns a pointer to the slot of type 'slotcode' + * Returns a pointer to the slot of type 'slot_code' */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slotname) +BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name) { - int slotcode = bmo_name_to_slotcode_check(opdefines[op->type], slotname); + int slot_code = bmo_name_to_slotcode_check(opdefines[op->type], slot_name); - if (slotcode < 0) { + if (slot_code < 0) { return &BMOpEmptySlot; } - return &(op->slots[slotcode]); + return &(op->slot_args[slot_code]); } /** @@ -249,22 +249,22 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, if (source_slot == dest_slot) return; - if (source_slot->slottype != dest_slot->slottype) { + if (source_slot->slot_type != dest_slot->slot_type) { /* possibly assert here? */ return; } - if (dest_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF) { + if (dest_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { /* do buffer copy */ dest_slot->data.buf = NULL; dest_slot->len = source_slot->len; if (dest_slot->len) { - const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len; + const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slot_type] * dest_slot->len; dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, slot_alloc_size); memcpy(dest_slot->data.buf, source_slot->data.buf, slot_alloc_size); } } - else if (dest_slot->slottype == BMO_OP_SLOT_MAPPING) { + else if (dest_slot->slot_type == BMO_OP_SLOT_MAPPING) { GHashIterator it; BMOElemMapping *srcmap, *dstmap; @@ -301,42 +301,42 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, * Sets the value of a slot depending on it's type */ -void BMO_slot_float_set(BMOperator *op, const char *slotname, const float f) +void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_FLT); - if (!(slot->slottype == BMO_OP_SLOT_FLT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return; slot->data.f = f; } -void BMO_slot_int_set(BMOperator *op, const char *slotname, const int i) +void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_INT); - if (!(slot->slottype == BMO_OP_SLOT_INT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); + if (!(slot->slot_type == BMO_OP_SLOT_INT)) return; slot->data.i = i; } -void BMO_slot_bool_set(BMOperator *op, const char *slotname, const int i) +void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_BOOL); - if (!(slot->slottype == BMO_OP_SLOT_BOOL)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return; slot->data.i = i; } /* only supports square mats */ -void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, int size) +void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; slot->len = 4; @@ -355,93 +355,93 @@ void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, in } } -void BMO_slot_mat4_get(BMOperator *op, const char *slotname, float r_mat[4][4]) +void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; copy_m4_m4(r_mat, (float (*)[4])slot->data.p); } -void BMO_slot_mat3_set(BMOperator *op, const char *slotname, float r_mat[3][3]) +void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; copy_m3_m4(r_mat, slot->data.p); } -void BMO_slot_ptr_set(BMOperator *op, const char *slotname, void *p) +void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_PNT); - if (!(slot->slottype == BMO_OP_SLOT_PNT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return; slot->data.p = p; } -void BMO_slot_vec_set(BMOperator *op, const char *slotname, const float vec[3]) +void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_VEC); - if (!(slot->slottype == BMO_OP_SLOT_VEC)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; copy_v3_v3(slot->data.vec, vec); } -float BMO_slot_float_get(BMOperator *op, const char *slotname) +float BMO_slot_float_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_FLT); - if (!(slot->slottype == BMO_OP_SLOT_FLT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return 0.0f; return slot->data.f; } -int BMO_slot_int_get(BMOperator *op, const char *slotname) +int BMO_slot_int_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_INT); - if (!(slot->slottype == BMO_OP_SLOT_INT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); + if (!(slot->slot_type == BMO_OP_SLOT_INT)) return 0; return slot->data.i; } -int BMO_slot_bool_get(BMOperator *op, const char *slotname) +int BMO_slot_bool_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_BOOL); - if (!(slot->slottype == BMO_OP_SLOT_BOOL)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return 0; return slot->data.i; } -void *BMO_slot_ptr_get(BMOperator *op, const char *slotname) +void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_PNT); - if (!(slot->slottype == BMO_OP_SLOT_PNT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return NULL; return slot->data.p; } -void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]) +void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_VEC); - if (!(slot->slottype == BMO_OP_SLOT_VEC)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; copy_v3_v3(r_vec, slot->data.vec); @@ -515,25 +515,25 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty } } -int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) +int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return 0; return slot->len; } -int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) +int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* check if its actually a buffer */ - if (!(slot->slottype == BMO_OP_SLOT_MAPPING)) + if (!(slot->slot_type == BMO_OP_SLOT_MAPPING)) return 0; return slot->data.ghash ? BLI_ghash_size(slot->data.ghash) : 0; @@ -542,12 +542,12 @@ int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) /* inserts a key/value mapping into a mapping slot. note that it copies the * value, it doesn't store a reference to it. */ -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element, void *data, int len) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); @@ -563,9 +563,9 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname } #if 0 -void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) +void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd) { - BMOpSlot *slot = &op->slots[slotcode]; + BMOpSlot *slot = &op->slots[slot_code]; void *tmp; ssize_t allocsize; @@ -579,7 +579,7 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) if (slot->len >= slot->size) { slot->size = (slot->size + 1 + totadd) * 2; - allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->size; + allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slot_types[slot_code].type] * slot->size; tmp = slot->data.buf; slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array"); @@ -594,7 +594,7 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) slot->len += totadd; slot->size = slot->len + 2; - allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->len; + allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slot_types[slot_code].type] * slot->len; tmp = slot->data.buf; slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array"); @@ -605,14 +605,14 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) } #endif -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { GHashIterator it; - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElemF *ele_f; - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return; @@ -625,18 +625,18 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, } } -static void *bmo_slot_buffer_alloc(BMOperator *op, const char *slotname, int len) +void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; slot->len = len; if (len) - slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slottype] * len); + slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len); return slot->data.buf; } @@ -645,9 +645,9 @@ static void *bmo_slot_buffer_alloc(BMOperator *op, const char *slotname, int len * * Copies all elements of a certain type into an operator slot. */ -static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slotname, const char htype) +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, const char htype) { - BMOpSlot *output = BMO_slot_get(op, slotname); + BMOpSlot *output = BMO_slot_get(op, slot_name); int totelement = 0, i = 0; if (htype & BM_VERT) totelement += bm->totvert; @@ -658,7 +658,7 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot BMIter iter; BMHeader *ele; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -691,11 +691,11 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot * Copies elements of a certain type, which have a certain header flag * enabled/disabled into a slot for an operator. */ -static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slotname, +static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const short test_for_enabled) { - BMOpSlot *output = BMO_slot_get(op, slotname); + BMOpSlot *output = BMO_slot_get(op, slot_name); int totelement = 0, i = 0; BLI_assert(ELEM(test_for_enabled, TRUE, FALSE)); @@ -709,7 +709,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl BMIter iter; BMElem *ele; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -751,16 +751,16 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl } } -void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slotname, htype, hflag, TRUE); + bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, TRUE); } -void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slotname, htype, hflag, FALSE); + bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, FALSE); } /** @@ -772,15 +772,15 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, BMOpSlot *output_slot = BMO_slot_get(output_op, output_slot_name); BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name); - BLI_assert(output_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF && - other_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(output_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF && + other_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); if (output_slot->len == 0) { /* output slot is empty, copy rather than append */ BMO_slot_copy(other_op, output_op, other_slot_name, output_slot_name); } else if (other_slot->len != 0) { - int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slottype]; + int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slot_type]; int alloc_size = elem_size * (output_slot->len + other_slot->len); /* allocate new buffer */ void *buf = BLI_memarena_alloc(output_op->arena, alloc_size); @@ -800,11 +800,11 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, * Copies elements of a certain type, which have a certain flag set * into an output slot for an operator. */ -static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slotname, +static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag, const short test_for_enabled) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); int totelement, i = 0; BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); @@ -814,14 +814,14 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo else totelement = BMO_mesh_disabled_flag_count(bm, htype, oflag); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); if (totelement) { BMIter iter; BMHeader *ele; BMHeader **ele_array; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); ele_array = (BMHeader **)slot->data.p; @@ -859,16 +859,16 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo } } -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, TRUE); + bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, TRUE); } -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, FALSE); + bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, FALSE); } /** @@ -877,16 +877,16 @@ void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *s * Header Flags elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++, data++) { if (!(htype & (*data)->head.htype)) @@ -910,16 +910,16 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotnam * Removes flags from elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++, data++) { if (!(htype & (*data)->head.htype)) @@ -961,14 +961,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag) * * Flags elements in a slots buffer */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMHeader **data = slot->data.p; int i; - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) @@ -983,14 +983,14 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname * * Removes flags from elements in a slots buffer */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMHeader **data = slot->data.p; int i; - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) @@ -1131,11 +1131,11 @@ static void bmo_flag_layer_clear(BMesh *bm) bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); } -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname) +void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; return slot->data.buf ? *(void **)slot->data.buf : NULL; @@ -1148,9 +1148,9 @@ void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname) * (e.g. combination of BM_VERT, BM_EDGE, BM_FACE), if iterating * over an element buffer (not a mapping). */ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, - const char *slotname, const char restrictmask) + const char *slot_name, const char restrictmask) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); memset(iter, 0, sizeof(BMOIter)); @@ -1158,7 +1158,7 @@ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, iter->cur = 0; iter->restrictmask = restrictmask; - if (iter->slot->slottype == BMO_OP_SLOT_MAPPING) { + if (iter->slot->slot_type == BMO_OP_SLOT_MAPPING) { if (iter->slot->data.ghash) { BLI_ghashIterator_init(&iter->giter, slot->data.ghash); } @@ -1172,7 +1172,7 @@ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, void *BMO_iter_step(BMOIter *iter) { - if (iter->slot->slottype == BMO_OP_SLOT_ELEMENT_BUF) { + if (iter->slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { BMHeader *h; if (iter->cur >= iter->slot->len) { @@ -1190,7 +1190,7 @@ void *BMO_iter_step(BMOIter *iter) return h; } - else if (iter->slot->slottype == BMO_OP_SLOT_MAPPING) { + else if (iter->slot->slot_type == BMO_OP_SLOT_MAPPING) { BMOElemMapping *map; void *ret = BLI_ghashIterator_getKey(&iter->giter); map = BLI_ghashIterator_getValue(&iter->giter); @@ -1286,8 +1286,8 @@ static int bmo_name_to_slotcode(BMOpDefine *def, const char *name) { int i; - for (i = 0; def->slottypes[i].type; i++) { - if (!strncmp(name, def->slottypes[i].name, MAX_SLOTNAME)) { + for (i = 0; def->slot_types[i].type; i++) { + if (!strncmp(name, def->slot_types[i].name, MAX_SLOTNAME)) { return i; } } @@ -1320,7 +1320,7 @@ static int bmo_opname_to_opcode(const char *opname) } /* Example: - * BMO_op_callf(bm, "del %i %hv", DEL_ONLYFACES, BM_ELEM_SELECT); + * BMO_op_callf(bm, "delete %i %hv", DEL_ONLYFACES, BM_ELEM_SELECT); * * i - int * b - boolean (same as int but 1/0 only) @@ -1331,14 +1331,17 @@ static int bmo_opname_to_opcode(const char *opname) * fv - flagged verts (oflag) * fe - flagged edges (oflag) * ff - flagged faces (oflag) + * + * capitals - H, F to use the flag flipped (when the flag is off) + * Hv, He, Hf, Fv, Fe, Ff, */ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) { BMOpDefine *def; char *opname, *ofmt, *fmt; - char slotname[64] = {0}; - int i /*, n = strlen(fmt) */, stop /*, slotcode = -1 */, type, state; + char slot_name[64] = {0}; + int i /*, n = strlen(fmt) */, stop /*, slot_code = -1 */, type, state; char htype; int noslot = 0; @@ -1377,7 +1380,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) def = opdefines[i]; i = 0; - state = 1; /* 0: not inside slotcode name, 1: inside slotcode name */ + state = 1; /* 0: not inside slot_code name, 1: inside slot_code name */ while (*fmt) { if (state) { @@ -1401,7 +1404,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) GOTO_ERROR("name to slot code check failed"); } - BLI_strncpy(slotname, fmt, sizeof(slotname)); + BLI_strncpy(slot_name, fmt, sizeof(slot_name)); state = 0; fmt += i; @@ -1422,18 +1425,18 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) else if (c == '4') size = 4; else GOTO_ERROR("matrix size was not 3 or 4"); - BMO_slot_mat_set(op, slotname, va_arg(vlist, void *), size); + BMO_slot_mat_set(op, slot_name, va_arg(vlist, void *), size); state = 1; break; } case 'v': { - BMO_slot_vec_set(op, slotname, va_arg(vlist, float *)); + BMO_slot_vec_set(op, slot_name, va_arg(vlist, float *)); state = 1; break; } case 'e': { BMHeader *ele = va_arg(vlist, void *); - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4); slot->len = 1; @@ -1444,22 +1447,22 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) } case 's': { BMOperator *op2 = va_arg(vlist, void *); - const char *slotname2 = va_arg(vlist, char *); + const char *slot_name2 = va_arg(vlist, char *); - BMO_slot_copy(op2, op, slotname2, slotname); + BMO_slot_copy(op2, op, slot_name2, slot_name); state = 1; break; } case 'i': - BMO_slot_int_set(op, slotname, va_arg(vlist, int)); + BMO_slot_int_set(op, slot_name, va_arg(vlist, int)); state = 1; break; case 'b': - BMO_slot_bool_set(op, slotname, va_arg(vlist, int)); + BMO_slot_bool_set(op, slot_name, va_arg(vlist, int)); state = 1; break; case 'p': - BMO_slot_ptr_set(op, slotname, va_arg(vlist, void *)); + BMO_slot_ptr_set(op, slot_name, va_arg(vlist, void *)); state = 1; break; case 'f': @@ -1470,7 +1473,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) type = *fmt; if (NEXT_CHAR(fmt) == ' ' || NEXT_CHAR(fmt) == '\0') { - BMO_slot_float_set(op, slotname, va_arg(vlist, double)); + BMO_slot_float_set(op, slot_name, va_arg(vlist, double)); } else { htype = 0; @@ -1492,19 +1495,19 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) } if (type == 'h') { - BMO_slot_buffer_from_enabled_hflag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'H') { - BMO_slot_buffer_from_disabled_hflag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'a') { - BMO_slot_buffer_from_all(bm, op, slotname, htype); + BMO_slot_buffer_from_all(bm, op, slot_name, htype); } else if (type == 'f') { - BMO_slot_buffer_from_enabled_flag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'F') { - BMO_slot_buffer_from_disabled_flag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); } } diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h index df48ec8468f..dc1bdaa4689 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -33,74 +33,74 @@ struct BMOperator; void BMO_push(BMesh *bm, BMOperator *op); void BMO_pop(BMesh *bm); -void bmo_split_exec(BMesh *bm, BMOperator *op); -void bmo_spin_exec(BMesh *bm, BMOperator *op); -void bmo_dupe_exec(BMesh *bm, BMOperator *op); -void bmo_del_exec(BMesh *bm, BMOperator *op); -void bmo_esubd_exec(BMesh *bm, BMOperator *op); -void bmo_triangulate_exec(BMesh *bm, BMOperator *op); +void bmo_automerge_exec(BMesh *bm, BMOperator *op); +void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op); +void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op); +void bmo_bevel_exec(BMesh *bm, BMOperator *op); +void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op); +void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op); +void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op); +void bmo_collapse_exec(BMesh *bm, BMOperator *op); +void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_connect_verts_exec(BMesh *bm, BMOperator *op); +void bmo_contextual_create_exec(BMesh *bm, BMOperator *op); +void bmo_convex_hull_exec(BMesh *bm, BMOperator *op); +void bmo_create_circle_exec(BMesh *bm, BMOperator *op); +void bmo_create_cone_exec(BMesh *bm, BMOperator *op); +void bmo_create_cube_exec(BMesh *bm, BMOperator *op); +void bmo_create_grid_exec(BMesh *bm, BMOperator *op); +void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op); +void bmo_create_monkey_exec(BMesh *bm, BMOperator *op); +void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op); +void bmo_create_vert_exec(BMesh *bm, BMOperator *op); +void bmo_delete_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op); void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op); void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op); +void bmo_duplicate_exec(BMesh *bm, BMOperator *op); +void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op); +void bmo_edgenet_prepare(BMesh *bm, BMOperator *op); +void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op); +void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op); void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op); -void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op); -void bmo_connectverts_exec(BMesh *bm, BMOperator *op); void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op); +void bmo_find_doubles_exec(BMesh *bm, BMOperator *op); +void bmo_inset_exec(BMesh *bm, BMOperator *op); +void bmo_join_triangles_exec(BMesh *bm, BMOperator *op); void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op); -void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op); -void bmo_translate_exec(BMesh *bm, BMOperator *op); -void bmo_transform_exec(BMesh *bm, BMOperator *op); -void bmo_contextual_create_exec(BMesh *bm, BMOperator *op); -void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op); -void bmo_rotate_exec(BMesh *bm, BMOperator *op); -void bmo_makevert_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op); -void bmo_weldverts_exec(BMesh *bm, BMOperator *op); -void bmo_removedoubles_exec(BMesh *bm, BMOperator *op); -void bmo_finddoubles_exec(BMesh *bm, BMOperator *op); void bmo_mirror_exec(BMesh *bm, BMOperator *op); -void bmo_edgebisect_exec(BMesh *bm, BMOperator *op); -void bmo_reversefaces_exec(BMesh *bm, BMOperator *op); -void bmo_edgerotate_exec(BMesh *bm, BMOperator *op); -void bmo_regionextend_exec(BMesh *bm, BMOperator *op); -void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op); -void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op); -void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op); -void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op); -void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op); void bmo_pointmerge_exec(BMesh *bm, BMOperator *op); -void bmo_collapse_exec(BMesh *bm, BMOperator *op); -void bmo_similarfaces_exec(BMesh *bm, BMOperator *op); -void bmo_similaredges_exec(BMesh *bm, BMOperator *op); -void bmo_similarverts_exec(BMesh *bm, BMOperator *op); void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op); -void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op); -void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op); -void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op); -void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op); -void bmo_edgenet_prepare(BMesh *bm, BMOperator *op); -void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op); -void bmo_face_reversecolors_exec(BMesh *bm, BMOperator *op); -void bmo_vertexshortestpath_exec(BMesh *bm, BMOperator *op); +void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op); +void bmo_region_extend_exec(BMesh *bm, BMOperator *op); +void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op); void bmo_scale_exec(BMesh *bm, BMOperator *op); -void bmo_edgesplit_exec(BMesh *bm, BMOperator *op); -void bmo_automerge_exec(BMesh *bm, BMOperator *op); -void bmo_create_cone_exec(BMesh *bm, BMOperator *op); -void bmo_create_monkey_exec(BMesh *bm, BMOperator *op); -void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op); -void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op); -void bmo_create_grid_exec(BMesh *bm, BMOperator *op); -void bmo_create_cube_exec(BMesh *bm, BMOperator *op); -void bmo_join_triangles_exec(BMesh *bm, BMOperator *op); -void bmo_bevel_exec(BMesh *bm, BMOperator *op); -void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op); -void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op); -void bmo_create_circle_exec(BMesh *bm, BMOperator *op); -void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op); +void bmo_shortest_path_exec(BMesh *bm, BMOperator *op); +void bmo_similar_edges_exec(BMesh *bm, BMOperator *op); +void bmo_similar_faces_exec(BMesh *bm, BMOperator *op); +void bmo_similar_verts_exec(BMesh *bm, BMOperator *op); +void bmo_slide_vert_exec(BMesh *bm, BMOperator *op); +void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op); void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op); -void bmo_inset_exec(BMesh *bm, BMOperator *op); +void bmo_spin_exec(BMesh *bm, BMOperator *op); +void bmo_split_edges_exec(BMesh *bm, BMOperator *op); +void bmo_split_exec(BMesh *bm, BMOperator *op); +void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op); +void bmo_transform_exec(BMesh *bm, BMOperator *op); +void bmo_translate_exec(BMesh *bm, BMOperator *op); +void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op); +void bmo_triangulate_exec(BMesh *bm, BMOperator *op); +void bmo_weld_verts_exec(BMesh *bm, BMOperator *op); void bmo_wireframe_exec(BMesh *bm, BMOperator *op); -void bmo_convex_hull_exec(BMesh *bm, BMOperator *op); #endif /* __BMESH_OPERATORS_PRIVATE_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 0b2c3040df3..094b5af9a00 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -699,14 +699,18 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int if (cos1 > cos_threshold) { if (cos1 > fabsf(cos_v3v3v3(larr[i]->v->co, larr[i4]->v->co, larr[i + 2]->v->co)) && cos1 > fabsf(cos_v3v3v3(larr[i]->v->co, larr[i + 1]->v->co, larr[i + 2]->v->co))) + { i = !i; + } } /* Last check we do not get overlapping triangles * (as much as possible, ther are some cases with no good solution!) */ i4 = (i + 3) % 4; if (!bm_face_goodline((float const (*)[3])verts, f, BM_elem_index_get(larr[i4]->v), BM_elem_index_get(larr[i]->v), BM_elem_index_get(larr[i + 1]->v), nvert)) + { i = !i; + } /* printf("%d\n", i);*/ bestear = larr[i]; diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 3ec4c51bcb1..b6a56e64dcf 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -190,6 +190,22 @@ BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v) } /** + * Get the first loop of a vert. Uses the same initialization code for the first loop of the + * iterator API + */ + +BMLoop *BM_vert_find_first_loop(BMVert *v) +{ + BMEdge *e; + + if(!v || !v->e) + return NULL; + + e = bmesh_disk_faceedge_find_first(v->e, v); + return bmesh_radial_faceloop_find_first(e->l, v); +} + +/** * Returns TRUE if the vertex is used in a given face. */ diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 2df5adcfae3..36ffc296759 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -42,6 +42,7 @@ BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v); BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v); BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v); BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v); +BMLoop *BM_vert_find_first_loop(BMVert *v); int BM_vert_edge_count_nonwire(BMVert *v); int BM_vert_edge_count(BMVert *v); diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index f02b88c5b05..0b036c6ff2b 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -865,7 +865,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } #endif - BMO_op_callf(bm, "del geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); + BMO_op_callf(bm, "delete geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); /* clean up any edges that might not get properly delete */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { @@ -873,8 +873,8 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, e, BEVEL_DEL); } - BMO_op_callf(bm, "del geom=%fe context=%i", BEVEL_DEL, DEL_EDGES); - BMO_op_callf(bm, "del geom=%ff context=%i", BEVEL_DEL, DEL_FACES); + BMO_op_callf(bm, "delete geom=%fe context=%i", BEVEL_DEL, DEL_EDGES); + BMO_op_callf(bm, "delete geom=%ff context=%i", BEVEL_DEL, DEL_FACES); BLI_smallhash_release(&hash); BLI_array_free(tags); diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 653bbaf8602..7418be3565c 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -40,7 +40,7 @@ #define EDGE_MARK 4 #define EDGE_DONE 8 -void bmo_connectverts_exec(BMesh *bm, BMOperator *op) +void bmo_connect_verts_exec(BMesh *bm, BMOperator *op) { BMIter iter, liter; BMFace *f, *nf; diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 1451625d3bb..8e69696f771 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -164,7 +164,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) } - BMO_op_callf(bm, "del geom=%ff context=%i", FACE_ORIG, DEL_FACES); + BMO_op_callf(bm, "delete geom=%ff context=%i", FACE_ORIG, DEL_FACES); if (use_verts) { diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 6e6037239b9..1421ae294bc 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -314,7 +314,7 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) * BMOP_DUPE_FNEW: Buffer containing pointers to the new mesh faces */ -void bmo_dupe_exec(BMesh *bm, BMOperator *op) +void bmo_duplicate_exec(BMesh *bm, BMOperator *op) { BMOperator *dupeop = op; BMesh *bm2 = BMO_slot_ptr_get(op, "dest"); @@ -345,7 +345,7 @@ void BMO_dupe_from_flag(BMesh *bm, int htype, const char hflag) { BMOperator dupeop; - BMO_op_init(bm, &dupeop, "dupe"); + BMO_op_init(bm, &dupeop, "duplicate"); BMO_slot_buffer_from_enabled_hflag(bm, &dupeop, "geom", htype, hflag); BMO_op_exec(bm, &dupeop); @@ -381,8 +381,8 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) const short use_only_faces = BMO_slot_bool_get(op, "use_only_faces"); /* initialize our sub-operator */ - BMO_op_init(bm, &dupeop, "dupe"); - BMO_op_init(bm, &delop, "del"); + BMO_op_init(bm, &dupeop, "duplicate"); + BMO_op_init(bm, &delop, "delete"); BMO_slot_copy(splitop, &dupeop, "geom", "geom"); BMO_op_exec(bm, &dupeop); @@ -443,7 +443,7 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) } -void bmo_del_exec(BMesh *bm, BMOperator *op) +void bmo_delete_exec(BMesh *bm, BMOperator *op) { #define DEL_INPUT 1 @@ -487,7 +487,7 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op) BMO_slot_copy(op, op, "geom", "lastout"); for (a = 0; a < steps; a++) { if (do_dupli) { - BMO_op_initf(bm, &dupop, "dupe geom=%s", op, "lastout"); + BMO_op_initf(bm, &dupop, "duplicate geom=%s", op, "lastout"); BMO_op_exec(bm, &dupop); BMO_op_callf(bm, "rotate cent=%v mat=%m3 verts=%s", cent, rmat, &dupop, "newout"); diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c index ccbcb293915..1f6689ed06c 100644 --- a/source/blender/bmesh/operators/bmo_edgesplit.c +++ b/source/blender/bmesh/operators/bmo_edgesplit.c @@ -100,7 +100,7 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op) } /* keep this operator fast, its used in a modifier */ -void bmo_edgesplit_exec(BMesh *bm, BMOperator *op) +void bmo_split_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e; diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 09b79376ff6..b8993b41caf 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -49,7 +49,7 @@ enum { #define VERT_NONMAN 2 #define EDGE_NONMAN 2 -void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) +void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter liter, liter2; @@ -118,7 +118,7 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) BLI_array_free(edges); - BMO_op_callf(bm, "del geom=%ff context=%i", EXT_DEL, DEL_ONLYFACES); + BMO_op_callf(bm, "delete geom=%ff context=%i", EXT_DEL, DEL_ONLYFACES); BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP); } @@ -172,7 +172,7 @@ static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e } /* Disable the skin root flag on the input vert, assumes that the vert - data includes an CD_MVERT_SKIN layer */ + * data includes an CD_MVERT_SKIN layer */ static void bm_extrude_disable_skin_root(BMesh *bm, BMVert *v) { MVertSkin *vs; @@ -195,7 +195,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, e->v2, EXT_INPUT); } - BMO_op_initf(bm, &dupeop, "dupe geom=%fve", EXT_INPUT); + BMO_op_initf(bm, &dupeop, "duplicate geom=%fve", EXT_INPUT); BMO_op_exec(bm, &dupeop); /* disable root flag on all new skin nodes */ @@ -273,7 +273,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) int found, fwd, delorig = FALSE; /* initialize our sub-operators */ - BMO_op_init(bm, &dupeop, "dupe"); + BMO_op_init(bm, &dupeop, "duplicate"); BMO_slot_buffer_flag_enable(bm, op, "edgefacein", BM_EDGE | BM_FACE, EXT_INPUT); @@ -341,7 +341,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) } if (delorig == TRUE) { - BMO_op_initf(bm, &delop, "del geom=%fvef context=%i", + BMO_op_initf(bm, &delop, "delete geom=%fvef context=%i", EXT_DEL, DEL_ONLYTAGGED); } @@ -647,7 +647,7 @@ void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op) thickness = BMO_slot_float_get(op, "thickness"); /* Flip original faces (so the shell is extruded inward) */ - BMO_op_init(bm, &reverseop, "reversefaces"); + BMO_op_init(bm, &reverseop, "reverse_faces"); BMO_slot_copy(op, &reverseop, "geom", "faces"); BMO_op_exec(bm, &reverseop); BMO_op_finish(bm, &reverseop); diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 160db7cba75..1bd2f41209b 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -140,11 +140,14 @@ static void hull_add_triangle(BMesh *bm, GHash *hull_triangles, BLI_mempool *poo static int hull_point_tri_side(const HullTriangle *t, const float co[3]) { - float p[3], d; + /* Added epsilon to fix bug [#31941], improves output when some + * vertices are nearly coplanar. Might need further tweaking for + * other cases though. */ + float p[3], d, epsilon = 0.0001; sub_v3_v3v3(p, co, t->v[0]->co); d = dot_v3v3(t->no, p); - if (d < 0) return -1; - else if (d > 0) return 1; + if (d < -epsilon) return -1; + else if (d > epsilon) return 1; else return 0; } diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c index 53c51dfd483..1ab439b38bb 100644 --- a/source/blender/bmesh/operators/bmo_mirror.c +++ b/source/blender/bmesh/operators/bmo_mirror.c @@ -62,7 +62,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_slot_mat4_get(op, "mat", mtx); invert_m4_m4(imtx, mtx); - BMO_op_initf(bm, &dupeop, "dupe geom=%s", op, "geom"); + BMO_op_initf(bm, &dupeop, "duplicate geom=%s", op, "geom"); BMO_op_exec(bm, &dupeop); BMO_slot_buffer_flag_enable(bm, &dupeop, "newout", BM_ALL, ELE_NEW); @@ -84,7 +84,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, "scale verts=%fv vec=%v", ELE_NEW, scale); BMO_op_callf(bm, "transform verts=%fv mat=%m4", ELE_NEW, imtx); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); for (i = 0; i < ototvert; i++) { diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 08cd3835b2d..d59a90ba3a1 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -365,7 +365,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) len2 = len_v3v3(vec, vec2); /* use shortest segment length divided by 3 as merge threshold */ - BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f); + BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f); } /* and now do imat */ @@ -427,7 +427,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) BMOperator bmop; BMO_op_initf(bm, &bmop, - "esubd edges=%fe " + "subdivide_edges edges=%fe " "smooth=%f " "numcuts=%i " "use_gridfill=%b use_sphere=%b", @@ -661,7 +661,7 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op) BM_face_create_quad_tri(bm, v1, v2, firstv2, firstv1, NULL, FALSE); - BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, 0.000001); + BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, 0.000001); BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); } diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 52c693efc84..b3c348a330c 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -96,7 +96,7 @@ int remdoubles_face_overlaps(BMesh *bm, BMVert **varr, } #endif -void bmo_weldverts_exec(BMesh *bm, BMOperator *op) +void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) { BMIter iter, liter; BMVert *v, *v2; @@ -227,7 +227,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op) } } - BMO_op_callf(bm, "del geom=%fvef context=%i", ELE_DEL, DEL_ONLYTAGGED); + BMO_op_callf(bm, "delete geom=%fvef context=%i", ELE_DEL, DEL_ONLYTAGGED); BLI_array_free(edges); BLI_array_free(loops); @@ -301,7 +301,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op) } } -void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op) +void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter iter; @@ -345,10 +345,10 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op) BMVert *v, *snapv = NULL; float vec[3]; - BMO_slot_vec_get(op, "mergeco", vec); + BMO_slot_vec_get(op, "merge_co", vec); //BMO_op_callf(bm, "collapse_uvs edges=%s", op, "edges"); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { if (!snapv) { @@ -375,7 +375,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) int i, tot; BMO_op_callf(bm, "collapse_uvs edges=%s", op, "edges"); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); @@ -487,7 +487,7 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op) } } -void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) +void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) { BMOIter oiter; BMVert *v, *v2; @@ -505,17 +505,17 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c verts[i++] = v; } - /* Test whether keepverts arg exists and is non-empty */ - if (BMO_slot_exists(op, "keepverts")) { - keepvert = BMO_iter_new(&oiter, bm, op, "keepverts", BM_VERT) != NULL; + /* Test whether keep_verts arg exists and is non-empty */ + if (BMO_slot_exists(op, "keep_verts")) { + keepvert = BMO_iter_new(&oiter, bm, op, "keep_verts", BM_VERT) != NULL; } /* sort by vertex coordinates added together */ qsort(verts, BLI_array_count(verts), sizeof(void *), vergaverco); - /* Flag keepverts */ + /* Flag keep_verts */ if (keepvert) { - BMO_slot_buffer_flag_enable(bm, op, "keepverts", BM_VERT, VERT_KEEP); + BMO_slot_buffer_flag_enable(bm, op, "keep_verts", BM_VERT, VERT_KEEP); } len = BLI_array_count(verts); @@ -557,20 +557,20 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c BLI_array_free(verts); } -void bmo_removedoubles_exec(BMesh *bm, BMOperator *op) +void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op) { BMOperator weldop; - BMO_op_init(bm, &weldop, "weldverts"); - bmesh_finddoubles_common(bm, op, &weldop, "targetmap"); + BMO_op_init(bm, &weldop, "weld_verts"); + bmesh_find_doubles_common(bm, op, &weldop, "targetmap"); BMO_op_exec(bm, &weldop); BMO_op_finish(bm, &weldop); } -void bmo_finddoubles_exec(BMesh *bm, BMOperator *op) +void bmo_find_doubles_exec(BMesh *bm, BMOperator *op) { - bmesh_finddoubles_common(bm, op, op, "targetmapout"); + bmesh_find_doubles_common(bm, op, op, "targetmapout"); } void bmo_automerge_exec(BMesh *bm, BMOperator *op) @@ -591,12 +591,12 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op) /* Search for doubles among all vertices, but only merge non-VERT_KEEP * vertices into VERT_KEEP vertices. */ - BMO_op_initf(bm, &findop, "finddoubles verts=%av keepverts=%fv", VERT_KEEP); + BMO_op_initf(bm, &findop, "find_doubles verts=%av keep_verts=%fv", VERT_KEEP); BMO_slot_copy(op, &findop, "dist", "dist"); BMO_op_exec(bm, &findop); /* weld the vertices */ - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_slot_copy(&findop, &weldop, "targetmapout", "targetmap"); BMO_op_exec(bm, &weldop); diff --git a/source/blender/bmesh/operators/bmo_slide.c b/source/blender/bmesh/operators/bmo_slide.c index 238cc5ac66f..0036f095d00 100644 --- a/source/blender/bmesh/operators/bmo_slide.c +++ b/source/blender/bmesh/operators/bmo_slide.c @@ -40,7 +40,7 @@ * Slides a vertex along a connected edge * */ -void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) +void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) { BMOIter oiter; BMIter iter; @@ -61,7 +61,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) if (!vertex) { if (G.debug & G_DEBUG) { - fprintf(stderr, "vertex_slide: No vertex selected..."); + fprintf(stderr, "slide_vert: No vertex selected..."); } BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); return; @@ -81,7 +81,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) /* Only allow sliding if an edge is selected */ if (selected_edges == 0) { if (G.debug & G_DEBUG) { - fprintf(stderr, "vertex_slide: select a single edge\n"); + fprintf(stderr, "slide_vert: select a single edge\n"); } BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); return; diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 03a691e3e9c..ee3e34c527f 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -672,7 +672,7 @@ typedef struct SubDFaceData { BMFace *face; } SubDFaceData; -void bmo_esubd_exec(BMesh *bm, BMOperator *op) +void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) { BMOpSlot *einput; SubDPattern *pat; @@ -1038,7 +1038,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, /* use_sphere isnt exposed here since its only used for new primitives */ BMO_op_initf(bm, &op, - "esubd edges=%he " + "subdivide_edges edges=%he " "smooth=%f fractal=%f along_normal=%f " "numcuts=%i " "quadcornertype=%i " @@ -1096,7 +1096,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, BMO_op_finish(bm, &op); } -void bmo_edgebisect_exec(BMesh *bm, BMOperator *op) +void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e; diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index e0cd3e2ba90..7d6e34b3a05 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -41,7 +41,7 @@ #include "intern/bmesh_operators_private.h" /* own include */ -void bmo_makevert_exec(BMesh *bm, BMOperator *op) +void bmo_create_vert_exec(BMesh *bm, BMOperator *op) { float vec[3]; @@ -108,7 +108,7 @@ void bmo_rotate_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, "translate verts=%s vec=%v", op, "verts", vec); } -void bmo_reversefaces_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMFace *f; @@ -118,7 +118,7 @@ void bmo_reversefaces_exec(BMesh *bm, BMOperator *op) } } -void bmo_edgerotate_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e, *e2; @@ -172,7 +172,7 @@ void bmo_edgerotate_exec(BMesh *bm, BMOperator *op) #define SEL_FLAG 1 #define SEL_ORIG 2 -static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) +static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces) { BMVert *v; BMEdge *e; @@ -211,7 +211,7 @@ static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) } } -static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces) +static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) { BMVert *v; BMEdge *e; @@ -253,7 +253,7 @@ static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces) } } -void bmo_regionextend_exec(BMesh *bm, BMOperator *op) +void bmo_region_extend_exec(BMesh *bm, BMOperator *op) { int use_faces = BMO_slot_bool_get(op, "use_faces"); int constrict = BMO_slot_bool_get(op, "constrict"); @@ -261,9 +261,9 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, op, "geom", BM_ALL, SEL_ORIG); if (constrict) - bmo_regionextend_constrict(bm, op, use_faces); + bmo_region_extend_constrict(bm, op, use_faces); else - bmo_regionextend_extend(bm, op, use_faces); + bmo_region_extend_extend(bm, op, use_faces); BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, SEL_FLAG); } @@ -275,7 +275,7 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) #define FACE_MARK 4 #define FACE_FLIP 8 -/* NOTE: these are the original righthandfaces comment in editmesh_mods.c, +/* NOTE: these are the original recalc_face_normals comment in editmesh_mods.c, * copied here for reference. */ /* based at a select-connected to witness loose objects */ @@ -296,7 +296,7 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) /* NOTE: BM_ELEM_TAG is used on faces to tell if they are flipped. */ -void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op) +void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op) { BMIter liter, liter2; BMOIter siter; @@ -397,13 +397,13 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op) /* check if we have faces yet to do. if so, recurse */ BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { if (!BMO_elem_flag_test(bm, f, FACE_VIS)) { - bmo_righthandfaces_exec(bm, op); + bmo_recalc_face_normals_exec(bm, op); break; } } } -void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op) +void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter iter; @@ -511,7 +511,7 @@ typedef struct SimSel_FaceExt { * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces */ -void bmo_similarfaces_exec(BMesh *bm, BMOperator *op) +void bmo_similar_faces_exec(BMesh *bm, BMOperator *op) { BMIter fm_iter; BMFace *fs, *fm; @@ -684,7 +684,7 @@ typedef struct SimSel_EdgeExt { * select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h * choices are length, direction, face, ... */ -void bmo_similaredges_exec(BMesh *bm, BMOperator *op) +void bmo_similar_edges_exec(BMesh *bm, BMOperator *op) { BMOIter es_iter; /* selected edges iterator */ BMIter e_iter; /* mesh edges iterator */ @@ -882,7 +882,7 @@ typedef struct SimSel_VertExt { * select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h * choices are normal, face, vertex group... */ -void bmo_similarverts_exec(BMesh *bm, BMOperator *op) +void bmo_similar_verts_exec(BMesh *bm, BMOperator *op) { BMOIter vs_iter; /* selected verts iterator */ BMIter v_iter; /* mesh verts iterator */ @@ -996,7 +996,7 @@ void bmo_similarverts_exec(BMesh *bm, BMOperator *op) * Cycle UVs for a face **************************************************************************** */ -void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1063,7 +1063,7 @@ void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op) * Reverse UVs for a face **************************************************************************** */ -void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1103,7 +1103,7 @@ void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op) * Cycle colors for a face **************************************************************************** */ -void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1169,7 +1169,7 @@ void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op) * Reverse colors for a face *************************************************************************** */ -void bmo_face_reversecolors_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1213,7 +1213,7 @@ typedef struct ElemNode { HeapNode *hn; /* heap node */ } ElemNode; -void bmo_vertexshortestpath_exec(BMesh *bm, BMOperator *op) +void bmo_shortest_path_exec(BMesh *bm, BMOperator *op) { BMOIter vs_iter /* , vs2_iter */; /* selected verts iterator */ BMIter v_iter; /* mesh verts iterator */ diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 59927e961bf..ded937bf8f3 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -294,8 +294,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has su } - else if (type == COLLADAFW::MeshPrimitive::LINES) - { + else if (type == COLLADAFW::MeshPrimitive::LINES) { // TODO: Add Checker for line syntax here } @@ -582,8 +581,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) COLLADAFW::MeshPrimitive *mp = prim_arr[i]; int type = mp->getPrimitiveType(); - if (type == COLLADAFW::MeshPrimitive::LINES) - { + if (type == COLLADAFW::MeshPrimitive::LINES) { unsigned int edge_count = mp->getFaceCount(); unsigned int *indices = mp->getPositionIndices().getData(); @@ -857,8 +855,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T indices += vcount; } } - else if (type == COLLADAFW::MeshPrimitive::LINES) - { + else if (type == COLLADAFW::MeshPrimitive::LINES) { continue; // read the lines later after all the rest is done } diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 65f552d5d0c..4aaff024cac 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -57,8 +57,7 @@ void SceneExporter::exportHierarchy(Scene *sce) // Now find all exportable base ojects (highest in export hierarchy) for (node = this->export_settings->export_set; node; node = node->next) { Object *ob = (Object *) node->link; - if (bc_is_base_node(this->export_settings->export_set, ob)) - { + if (bc_is_base_node(this->export_settings->export_set, ob)) { switch (ob->type) { case OB_MESH: case OB_CAMERA: @@ -86,8 +85,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) // Add associated armature first if available bool armature_exported = false; Object *ob_arm = bc_get_assigned_armature(ob); - if (ob_arm != NULL) - { + if (ob_arm != NULL) { armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm); if (armature_exported && bc_is_marked(ob_arm)) { bc_remove_mark(ob_arm); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index cb9da9918be..955d699d96c 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -187,8 +187,7 @@ Object *bc_get_assigned_armature(Object *ob) Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob) { Object *ancestor = ob; - while (ob->parent && bc_is_marked(ob->parent)) - { + while (ob->parent && bc_is_marked(ob->parent)) { ob = ob->parent; ancestor = ob; } diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index d0093c58d23..9bad1b55d95 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -46,6 +46,10 @@ set(INC ../../../intern/guardedalloc ) +set(INC_SYS + +) + set(SRC COM_compositor.h COM_defines.h @@ -415,10 +419,10 @@ set(SRC operations/COM_PreviewOperation.cpp operations/COM_SplitViewerOperation.h operations/COM_SplitViewerOperation.cpp - operations/COM_ConvertValueToColourProg.h - operations/COM_ConvertValueToColourProg.cpp - operations/COM_ConvertColourToValueProg.h - operations/COM_ConvertColourToValueProg.cpp + operations/COM_ConvertValueToColorProg.h + operations/COM_ConvertValueToColorProg.cpp + operations/COM_ConvertColorToValueProg.h + operations/COM_ConvertColorToValueProg.cpp operations/COM_ConvertColorToBWOperation.h operations/COM_ConvertColorToBWOperation.cpp operations/COM_ConvertColorToVectorOperation.h diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index 4d8c83a5b2d..86390e5650a 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -224,7 +224,7 @@ extern "C" { * For every CPUcore a working thread is created. These working threads will ask the WorkScheduler if there is work * for a specific Device. * the workscheduler will find work for the device and the device will be asked to execute the WorkPackage - + * * @subsection singlethread Single threaded * For debugging reasons the multi-threading can be disabled. This is done by changing the COM_CURRENT_THREADING_MODEL * to COM_TM_NOTHREAD. When compiling the workscheduler @@ -268,7 +268,7 @@ extern "C" { * * @section executePixel executing a pixel * Finally the last step, the node functionality :) - + * * @page newnode Creating new nodes */ diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index 56335630b80..fbdb4cd6b28 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -30,6 +30,7 @@ CompositorContext::CompositorContext() this->m_quality = COM_QUALITY_HIGH; this->m_hasActiveOpenCLDevices = false; this->m_activegNode = NULL; + this->m_fastCalculation = false; } const int CompositorContext::getFramenumber() const diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 49acda811f1..2f6abf39985 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -73,6 +73,11 @@ private: * @brief does this system have active opencl devices? */ bool m_hasActiveOpenCLDevices; + + /** + * @brief Skip slow nodes + */ + bool m_fastCalculation; public: /** @@ -148,6 +153,9 @@ public: int getChunksize() { return this->getbNodeTree()->chunksize; } const int isColorManaged() const; + + void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;} + bool isFastCalculation() {return this->m_fastCalculation;} }; diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 38c514d8e99..4ed7ae7ca8a 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -48,8 +48,8 @@ #include "COM_CompositorNode.h" #include "COM_ConvertAlphaNode.h" #include "COM_ConvertColorToVectorOperation.h" -#include "COM_ConvertColourToValueProg.h" -#include "COM_ConvertValueToColourProg.h" +#include "COM_ConvertColorToValueProg.h" +#include "COM_ConvertValueToColorProg.h" #include "COM_ConvertValueToVectorOperation.h" #include "COM_ConvertVectorToColorOperation.h" #include "COM_ConvertVectorToValueOperation.h" @@ -117,7 +117,7 @@ #include "COM_ViewerNode.h" #include "COM_ZCombineNode.h" -Node *Converter::convert(bNode *b_node) +Node *Converter::convert(bNode *b_node, bool fast) { Node *node; @@ -125,6 +125,22 @@ Node *Converter::convert(bNode *b_node) node = new MuteNode(b_node); return node; } + if (fast) { + if (b_node->type == CMP_NODE_BLUR || + b_node->type == CMP_NODE_VECBLUR || + b_node->type == CMP_NODE_BILATERALBLUR || + b_node->type == CMP_NODE_DEFOCUS || + b_node->type == CMP_NODE_BOKEHBLUR || + b_node->type == CMP_NODE_GLARE || + b_node->type == CMP_NODE_DBLUR || + b_node->type == CMP_NODE_MOVIEDISTORTION || + b_node->type == CMP_NODE_LENSDIST || + b_node->type == CMP_NODE_DOUBLEEDGEMASK || + b_node->type == CMP_NODE_DILATEERODE) + { + return new MuteNode(b_node); + } + } switch (b_node->type) { case CMP_NODE_COMPOSITE: @@ -137,7 +153,7 @@ Node *Converter::convert(bNode *b_node) node = new TextureNode(b_node); break; case CMP_NODE_RGBTOBW: - node = new ColourToBWNode(b_node); + node = new ColorToBWNode(b_node); break; case CMP_NODE_MIX_RGB: node = new MixNode(b_node); @@ -376,13 +392,13 @@ void Converter::convertDataType(SocketConnection *connection, ExecutionSystem *s DataType toDatatype = inputSocket->getDataType(); NodeOperation *converter = NULL; if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) { - converter = new ConvertValueToColourProg(); + converter = new ConvertValueToColorProg(); } else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) { converter = new ConvertValueToVectorOperation(); } else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) { - converter = new ConvertColourToValueProg(); + converter = new ConvertColorToValueProg(); } else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) { converter = new ConvertColorToVectorOperation(); diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h index 6cf22a1e2a4..15bda0839fa 100644 --- a/source/blender/compositor/intern/COM_Converter.h +++ b/source/blender/compositor/intern/COM_Converter.h @@ -42,7 +42,7 @@ public: * @see Node * @see MuteNode */ - static Node *convert(bNode *b_node); + static Node *convert(bNode *b_node, bool fast); /** * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type. @@ -60,7 +60,7 @@ public: * * @note Conversion logic is implemented in this method * @see InputSocketResizeMode for the possible conversions. - + * * @param connection the SocketConnection what needs conversion * @param system the ExecutionSystem to add the conversion to. * @see SocketConnection - a link between two sockets diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 1a0bd95b7d6..e437b069e33 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -27,6 +27,8 @@ #include "BLI_math.h" #include "PIL_time.h" +#include "WM_api.h" +#include "WM_types.h" #include "COM_ExecutionGroup.h" #include "COM_InputSocket.h" @@ -347,6 +349,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph) finished = false; startEvaluated = true; numberEvaluated++; + + WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL); } else if (state == COM_ES_SCHEDULED) { finished = false; @@ -485,14 +489,18 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area float chunkSizef = this->m_chunkSize; int indexx, indexy; - const int minxchunk = floor(area->xmin / chunkSizef); - const int maxxchunk = ceil((area->xmax - 1) / chunkSizef); - const int minychunk = floor(area->ymin / chunkSizef); - const int maxychunk = ceil((area->ymax - 1) / chunkSizef); + int minxchunk = floor(area->xmin / chunkSizef); + int maxxchunk = ceil((area->xmax - 1) / chunkSizef); + int minychunk = floor(area->ymin / chunkSizef); + int maxychunk = ceil((area->ymax - 1) / chunkSizef); + minxchunk = MAX2(minxchunk, 0); + minychunk = MAX2(minychunk, 0); + maxxchunk = MIN2(maxxchunk, this->m_numberOfXChunks); + maxychunk = MIN2(maxychunk, this->m_numberOfYChunks); bool result = true; - for (indexx = max(minxchunk, 0); indexx < maxxchunk; indexx++) { - for (indexy = max(minychunk, 0); indexy < maxychunk; indexy++) { + for (indexx = minxchunk; indexx < maxxchunk; indexx++) { + for (indexy = minychunk; indexy < maxychunk; indexy++) { if (!scheduleChunkWhenPossible(graph, indexx, indexy)) { result = false; } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 23e243187d5..ff841092848 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -44,9 +44,10 @@ #include "MEM_guardedalloc.h" #endif -ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering) +ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation) { this->m_context.setbNodeTree(editingtree); + this->m_context.setFastCalculation(fastcalculation); bNode *gnode; for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) { if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) { @@ -137,8 +138,10 @@ void ExecutionSystem::execute() WorkScheduler::start(this->m_context); executeGroups(COM_PRIORITY_HIGH); - executeGroups(COM_PRIORITY_MEDIUM); - executeGroups(COM_PRIORITY_LOW); + if (!this->getContext().isFastCalculation()) { + executeGroups(COM_PRIORITY_MEDIUM); + executeGroups(COM_PRIORITY_LOW); + } WorkScheduler::finish(); WorkScheduler::stop(); diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index e51bd7f3026..209358ec786 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -156,7 +156,7 @@ public: * @param editingtree [bNodeTree*] * @param rendering [true false] */ - ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering); + ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation); /** * Destructor diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index 0f6ba1f4ac9..0abf7efdcfa 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -49,7 +49,7 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star /* add all nodes of the tree to the node list */ bNode *node = (bNode *)tree->nodes.first; while (node != NULL) { - addNode(nodes, node, isActiveGroup); + addNode(nodes, node, isActiveGroup, system.getContext().isFastCalculation()); node = (bNode *)node->next; } @@ -77,11 +77,11 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node) nodes.push_back(node); } -Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup) +Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup, bool fast) { Converter converter; Node *node; - node = converter.convert(b_node); + node = converter.convert(b_node, fast); node->setIsInActiveGroup(inActiveGroup); if (node != NULL) { addNode(nodes, node); diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index 4b65ed15577..bd34fe8ab02 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h @@ -58,7 +58,7 @@ public: * @param bNode node to add * @return Node that represents the bNode or null when not able to convert. */ - static Node *addNode(vector<Node *>& nodes, bNode *b_node, bool isInActiveGroup); + static Node *addNode(vector<Node *>& nodes, bNode *b_node, bool isInActiveGroup, bool fast); /** * @brief Add a Node to a list diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h index f02da215b5f..130c5f5057a 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.h +++ b/source/blender/compositor/intern/COM_MemoryProxy.h @@ -50,12 +50,12 @@ private: /** * @brief datatype of this MemoryProxy */ - DataType m_datatype; + /* DataType m_datatype; */ /* UNUSED */ /** * @brief channel information of this buffer */ - ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS]; + /* ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS]; */ /* UNUSED */ /** * @brief the allocated memory diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 15b8a3933a7..320baacb669 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -39,9 +39,9 @@ //#include <stdio.h> #include "COM_defines.h" -Node::Node(bNode *editorNode, bool create_sockets) +Node::Node(bNode *editorNode, bool create_sockets): NodeBase() { - this->m_editorNode = editorNode; + setbNode(editorNode); if (create_sockets) { bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first; @@ -64,15 +64,6 @@ Node::Node(bNode *editorNode, bool create_sockets) } } } -Node::Node() -{ - this->m_editorNode = NULL; -} - -bNode *Node::getbNode() -{ - return this->m_editorNode; -} void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex) { diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 5d6d232f37a..bc4a25db605 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -48,10 +48,6 @@ typedef pair<NodeIterator, NodeIterator> NodeRange; */ class Node : public NodeBase { private: - /** - * @brief stores the reference to the SDNA bNode struct - */ - bNode *m_editorNode; /** * @brief Is this node part of the active group @@ -60,12 +56,7 @@ private: public: Node(bNode *editorNode, bool create_sockets = true); - - /** - * @brief get the reference to the SDNA bNode struct - */ - bNode *getbNode(); - + /** * @brief Is this node in the active group (the group that is being edited) * @param isInActiveGroup @@ -137,9 +128,6 @@ public: */ OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket); protected: - - Node(); - void addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket); void addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket); diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp index 8dbda5f649c..5c2ce37bdea 100644 --- a/source/blender/compositor/intern/COM_NodeBase.cpp +++ b/source/blender/compositor/intern/COM_NodeBase.cpp @@ -33,7 +33,7 @@ NodeBase::NodeBase() { - /* pass */ + this->m_editorNode = NULL; } diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h index 7095cda39e3..3c390f6bcdb 100644 --- a/source/blender/compositor/intern/COM_NodeBase.h +++ b/source/blender/compositor/intern/COM_NodeBase.h @@ -54,6 +54,11 @@ private: */ vector<OutputSocket *> m_outputsockets; + /** + * @brief stores the reference to the SDNA bNode struct + */ + bNode *m_editorNode; + protected: /** * @brief get access to the vector of input sockets @@ -74,6 +79,18 @@ public: virtual ~NodeBase(); /** + * @brief get the reference to the SDNA bNode struct + */ + bNode *getbNode() {return m_editorNode;} + + /** + * @brief set the reference to the bNode + * @note used in Node instances to receive the storage/settings and complex node for highlight during execution + * @param bNode + */ + void setbNode(bNode *bNode) {this->m_editorNode = bNode;} + + /** * @brief is this node an operation? * This is true when the instance is of the subclass NodeOperation. * @return [true:false] diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index 6ef8a5ff078..c3fa308971c 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -28,7 +28,7 @@ #include "COM_SocketConnection.h" #include "COM_defines.h" -NodeOperation::NodeOperation() +NodeOperation::NodeOperation() : NodeBase() { this->m_resolutionInputSocketIndex = 0; this->m_complex = false; diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp index 2dd44f8140f..eae1ffeb08a 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp @@ -23,7 +23,7 @@ #include "COM_OpenCLDevice.h" #include "COM_WorkScheduler.h" -typedef enum COM_VendorID {NVIDIA=0x10DE, AMD=0x1002} COM_VendorID; +typedef enum COM_VendorID {NVIDIA = 0x10DE, AMD = 0x1002} COM_VendorID; OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId) { diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 7282cf65bc3..9e48334bcca 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -57,8 +57,23 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) /* set progress bar to 0% and status to init compositing*/ editingtree->progress(editingtree->prh, 0.0); + bool twopass = (editingtree->flag&NTREE_TWO_PASS) > 0 || rendering; /* initialize execution system */ - ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering); + if (twopass) { + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass); + system->execute(); + delete system; + + if (editingtree->test_break(editingtree->tbh)) { + // during editing multiple calls to this method can be triggered. + // make sure one the last one will be doing the work. + BLI_mutex_unlock(&compositorMutex); + return; + } + } + + + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false); system->execute(); delete system; diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp index f96a92068f4..683093302c1 100644 --- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp @@ -35,6 +35,7 @@ void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorCo { NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage; BilateralBlurOperation *operation = new BilateralBlurOperation(); + operation->setbNode(this->getbNode()); operation->setQuality(context->getQuality()); operation->setData(data); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index 1b541d81c33..5447652c238 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -49,6 +49,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co if (data->filtertype == R_FILTER_FAST_GAUSS) { FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); operationfgb->setData(data); + operationfgb->setbNode(editorNode); this->getInputSocket(0)->relinkConnections(operationfgb->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph); this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0)); @@ -58,12 +59,14 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co else if (!data->bokeh) { GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); operationx->setData(data); + operationx->setbNode(editorNode); operationx->setQuality(quality); this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); graph->addOperation(operationx); GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); operationy->setData(data); + operationy->setbNode(editorNode); operationy->setQuality(quality); this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); graph->addOperation(operationy); @@ -79,6 +82,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co else { GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); operation->setData(data); + operation->setbNode(editorNode); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); operation->setQuality(quality); diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp index 59ec9525fa6..0ea4b20c793 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp @@ -61,6 +61,7 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph); operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value); operation->setQuality(context->getQuality()); + operation->setbNode(this->getbNode()); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); // } diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp index 430f317eae2..511fdf09f41 100644 --- a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp @@ -25,18 +25,18 @@ #include "COM_ConvertColorToBWOperation.h" #include "COM_ExecutionSystem.h" -ColourToBWNode::ColourToBWNode(bNode *editorNode) : Node(editorNode) +ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode) { /* pass */ } -void ColourToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) +void ColorToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - InputSocket *colourSocket = this->getInputSocket(0); + InputSocket *colorSocket = this->getInputSocket(0); OutputSocket *valueSocket = this->getOutputSocket(0); ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation(); - colourSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); + colorSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); valueSocket->relinkConnections(convertProg->getOutputSocket(0)); graph->addOperation(convertProg); } diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h index 9262634edda..f21c6ecef52 100644 --- a/source/blender/compositor/nodes/COM_ColorToBWNode.h +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h @@ -20,18 +20,18 @@ * Monique Dewanchand */ -#ifndef _COM_ColourToBWNode_h_ -#define _COM_ColourToBWNode_h_ +#ifndef _COM_ColorToBWNode_h_ +#define _COM_ColorToBWNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" /** - * @brief ColourToBWNode + * @brief ColorToBWNode * @ingroup Node */ -class ColourToBWNode : public Node { +class ColorToBWNode : public Node { public: - ColourToBWNode(bNode *editorNode); + ColorToBWNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; #endif diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index 6a6f2d1b4ff..28e466203c4 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -34,12 +34,12 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte InputSocket *imageSocket = this->getInputSocket(0); InputSocket *alphaSocket = this->getInputSocket(1); if (imageSocket->isConnected()) { - CompositorOperation *colourAlphaProg = new CompositorOperation(); - colourAlphaProg->setRenderData(context->getRenderData()); - colourAlphaProg->setbNodeTree(context->getbNodeTree()); - imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0)); - alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1)); - graph->addOperation(colourAlphaProg); - addPreviewOperation(graph, colourAlphaProg->getInputSocket(0)); + CompositorOperation *colorAlphaProg = new CompositorOperation(); + colorAlphaProg->setRenderData(context->getRenderData()); + colorAlphaProg->setbNodeTree(context->getbNodeTree()); + imageSocket->relinkConnections(colorAlphaProg->getInputSocket(0)); + alphaSocket->relinkConnections(colorAlphaProg->getInputSocket(1)); + graph->addOperation(colorAlphaProg); + addPreviewOperation(graph, colorAlphaProg->getInputSocket(0)); } } diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index 461505871c6..4c6b3ad137b 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -46,6 +46,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext NodeDefocus *data = (NodeDefocus *)node->storage; NodeOperation *radiusOperation; + OutputSocket * depthOperation; if (data->no_zbuf) { MathMultiplyOperation *multiply = new MathMultiplyOperation(); SetValueOperation *multiplier = new SetValueOperation(); @@ -63,6 +64,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext graph->addOperation(maxRadius); graph->addOperation(minimize); radiusOperation = minimize; + depthOperation = minimize->getOutputSocket(0); } else { ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); @@ -72,6 +74,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), 1, graph); graph->addOperation(converter); radiusOperation = converter; + depthOperation = converter->getInputSocket(0)->getConnection()->getFromSocket(); } BokehImageOperation *bokeh = new BokehImageOperation(); @@ -89,7 +92,15 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext bokeh->setData(bokehdata); bokeh->deleteDataOnFinish(); graph->addOperation(bokeh); - + +#ifdef COM_DEFOCUS_SEARCH + InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation(); + addLink(graph, radiusOperation->getOutputSocket(0), search->getInputSocket(0)); + addLink(graph, depthOperation, search->getInputSocket(1)); + search->setMaxBlur(data->maxblur); + search->setThreshold(data->bthresh); + graph->addOperation(search); +#endif VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); if (data->preview) { operation->setQuality(COM_QUALITY_LOW); @@ -97,10 +108,14 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext operation->setQuality(context->getQuality()); } operation->setMaxBlur(data->maxblur); + operation->setbNode(node); operation->setThreshold(data->bthresh); addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1)); addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2)); - addLink(graph, radiusOperation->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(3)); + addLink(graph, depthOperation, operation->getInputSocket(3)); +#ifdef COM_DEFOCUS_SEARCH + addLink(graph, search->getOutputSocket(), operation->getInputSocket(4)); +#endif if (data->gamco) { GammaCorrectOperation *correct = new GammaCorrectOperation(); GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); @@ -115,6 +130,5 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket()->relinkConnections(operation->getOutputSocket()); } - graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp index 3f4e3736bbe..043ae367fbb 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -40,6 +40,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont bNode *editorNode = this->getbNode(); if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) { DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation(); + operation->setbNode(editorNode); operation->setDistance(editorNode->custom2); operation->setInset(editorNode->custom3); @@ -59,6 +60,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) { if (editorNode->custom2 > 0) { DilateDistanceOperation *operation = new DilateDistanceOperation(); + operation->setbNode(editorNode); operation->setDistance(editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -66,6 +68,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } else { ErodeDistanceOperation *operation = new ErodeDistanceOperation(); + operation->setbNode(editorNode); operation->setDistance(-editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -90,12 +93,14 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setbNode(editorNode); operationx->setData(data); operationx->setQuality(quality); this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph); // this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); // no size input yet graph->addOperation(operationx); GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setbNode(editorNode); operationy->setData(data); operationy->setQuality(quality); this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); @@ -127,6 +132,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont else { if (editorNode->custom2 > 0) { DilateStepOperation *operation = new DilateStepOperation(); + operation->setbNode(editorNode); operation->setIterations(editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -134,6 +140,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } else { ErodeStepOperation *operation = new ErodeStepOperation(); + operation->setbNode(editorNode); operation->setIterations(-editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp index 57c319e7630..ab1d83385c7 100644 --- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp +++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp @@ -36,6 +36,7 @@ void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, Compositor bNode *bnode = this->getbNode(); operation = new DoubleEdgeMaskOperation(); + operation->setbNode(bnode); operation->setAdjecentOnly(bnode->custom1); operation->setKeepInside(bnode->custom2); diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp index 23f87805821..021ec6c2508 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.cpp +++ b/source/blender/compositor/nodes/COM_FilterNode.cpp @@ -73,7 +73,7 @@ void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext * operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0); break; } - + operation->setbNode(this->getbNode()); inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); outputSocket->relinkConnections(operation->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp index 7b34fa4d286..8782e6bb6d9 100644 --- a/source/blender/compositor/nodes/COM_GlareNode.cpp +++ b/source/blender/compositor/nodes/COM_GlareNode.cpp @@ -63,6 +63,8 @@ void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext * SetValueOperation *mixvalueoperation = new SetValueOperation(); MixGlareOperation *mixoperation = new MixGlareOperation(); mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT); + thresholdOperation->setbNode(node); + glareoperation->setbNode(node); this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system); addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp index df125403f98..fd961030ebf 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp @@ -22,7 +22,7 @@ #include "COM_HueSaturationValueCorrectNode.h" -#include "COM_ConvertColourToValueProg.h" +#include "COM_ConvertColorToValueProg.h" #include "COM_ExecutionSystem.h" #include "COM_ConvertRGBToHSVOperation.h" #include "COM_ConvertHSVToRGBOperation.h" @@ -41,7 +41,7 @@ HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode) void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *valueSocket = this->getInputSocket(0); - InputSocket *colourSocket = this->getInputSocket(1); + InputSocket *colorSocket = this->getInputSocket(1); OutputSocket *outputSocket = this->getOutputSocket(0); bNode *editorsnode = getbNode(); CurveMapping *storage = (CurveMapping *)editorsnode->storage; @@ -51,7 +51,7 @@ void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); MixBlendOperation *blend = new MixBlendOperation(); - colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); + colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp index ef501317e48..9b55b809212 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp @@ -22,7 +22,7 @@ #include "COM_HueSaturationValueNode.h" -#include "COM_ConvertColourToValueProg.h" +#include "COM_ConvertColorToValueProg.h" #include "COM_ExecutionSystem.h" #include "COM_ConvertRGBToHSVOperation.h" #include "COM_ConvertHSVToRGBOperation.h" @@ -40,7 +40,7 @@ HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorN void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *valueSocket = this->getInputSocket(0); - InputSocket *colourSocket = this->getInputSocket(1); + InputSocket *colorSocket = this->getInputSocket(1); OutputSocket *outputSocket = this->getOutputSocket(0); bNode *editorsnode = getbNode(); NodeHueSat *storage = (NodeHueSat *)editorsnode->storage; @@ -50,7 +50,7 @@ void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, Composi ChangeHSVOperation *changeHSV = new ChangeHSVOperation(); MixBlendOperation *blend = new MixBlendOperation(); - colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 0, graph); + colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 0, graph); addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index cc6fc6e1236..7c39765fbf1 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -74,9 +74,11 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu blurXOperation->setSize(size); blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); + blurXOperation->setbNode(this->getbNode()); blurYOperation->setSize(size); blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); + blurYOperation->setbNode(this->getbNode()); addLink(graph, separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0)); addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); @@ -104,9 +106,11 @@ OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *po blurXOperation->setSize(size); blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); + blurXOperation->setbNode(this->getbNode()); blurYOperation->setSize(size); blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); + blurYOperation->setbNode(this->getbNode()); addLink(graph, postBlurInput, blurXOperation->getInputSocket(0)); addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); @@ -129,6 +133,7 @@ OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket dilateErodeOperation = new ErodeDistanceOperation(); dilateErodeOperation->setDistance(-distance); } + dilateErodeOperation->setbNode(this->getbNode()); addLink(graph, dilateErodeInput, dilateErodeOperation->getInputSocket(0)); @@ -161,14 +166,16 @@ OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext operationx->setSize(1.0f); operationx->setSubtract(distance < 0); operationx->setFalloff(falloff); + operationx->setbNode(this->getbNode()); graph->addOperation(operationx); - + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); operationy->setData(data); operationy->setQuality(quality); operationy->setSize(1.0f); operationy->setSubtract(distance < 0); operationy->setFalloff(falloff); + operationy->setbNode(this->getbNode()); graph->addOperation(operationy); addLink(graph, featherInput, operationx->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp index 0fb8d45d066..cd1f79235ea 100644 --- a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp @@ -45,6 +45,7 @@ void KeyingScreenNode::convertToOperations(ExecutionSystem *graph, CompositorCon // always connect the output image KeyingScreenOperation *operation = new KeyingScreenOperation(); + operation->setbNode(editorNode); if (outputScreen->isConnected()) { outputScreen->relinkConnections(operation->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp index 0319e66ee22..4870e252b74 100644 --- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp @@ -37,7 +37,7 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC NodeLensDist *data = (NodeLensDist *)editorNode->storage; if (data->proj) { ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation(); - + operation->setbNode(editorNode); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -48,13 +48,22 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC } else { ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); + operation->setbNode(editorNode); + operation->setData(data); + if (!(this->getInputSocket(1)->isConnected() || this->getInputSocket(2)->isConnected())) + { + // no nodes connected to the distortion and dispersion. We can precalculate some values + float distortion = ((const bNodeSocketValueFloat *)this->getInputSocket(1)->getbNodeSocket()->default_value)->value; + float dispersion = ((const bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value; + operation->setDistortionAndDispersion(distortion, dispersion); + } this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); - operation->setData(data); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp index ba2fc804f42..ac57ffed9da 100644 --- a/source/blender/compositor/nodes/COM_MapValueNode.cpp +++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp @@ -32,12 +32,12 @@ MapValueNode::MapValueNode(bNode *editorNode) : Node(editorNode) void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - InputSocket *colourSocket = this->getInputSocket(0); + InputSocket *colorSocket = this->getInputSocket(0); OutputSocket *valueSocket = this->getOutputSocket(0); TexMapping *storage = (TexMapping *)this->getbNode()->storage; MapValueOperation *convertProg = new MapValueOperation(); convertProg->setSettings(storage); - colourSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); + colorSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); valueSocket->relinkConnections(convertProg->getOutputSocket(0)); graph->addOperation(convertProg); } diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index 13037b61a56..b6300300f6f 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -45,7 +45,7 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co // always connect the output image MaskOperation *operation = new MaskOperation(); - + operation->setbNode(editorNode); operation->setMaskWidth(data->xsch * data->size / 100.0f); operation->setMaskHeight(data->ysch * data->size / 100.0f); diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp index 95e759fde24..dfb46af841c 100644 --- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp @@ -82,7 +82,7 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - testSocketConnection(graph, 0, new RenderLayersColourProg()); + testSocketConnection(graph, 0, new RenderLayersColorProg()); testSocketConnection(graph, 1, new RenderLayersAlphaProg()); testSocketConnection(graph, 2, new RenderLayersDepthProg()); testSocketConnection(graph, 3, new RenderLayersNormalOperation()); diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp index a1f33ed464b..68e322e9dcf 100644 --- a/source/blender/compositor/nodes/COM_TonemapNode.cpp +++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp @@ -34,7 +34,7 @@ void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext { NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage; TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : new TonemapOperation(); - + operation->setbNode(this->getbNode()); operation->setData(data); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp index 5ef384a9984..07c8120b1d2 100644 --- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp @@ -34,6 +34,7 @@ void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorCont bNode *node = this->getbNode(); NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage; VectorBlurOperation *operation = new VectorBlurOperation(); + operation->setbNode(node); operation->setVectorBlurSettings(vectorBlurSettings); operation->setQuality(context->getQuality()); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h index e5b1f56f06c..113ec245ee6 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverKeyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h index 24a991da17b..3c0b955e360 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverMixedOperation : public MixBaseOperation { private: diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h index bba3b714f6b..7b7b9238794 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverPremultiplyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index d1ddecc0df6..696c0748d69 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -27,8 +27,9 @@ extern "C" { #include "RE_pipeline.h" } -BlurBaseOperation::BlurBaseOperation(DataType data_type=COM_DT_COLOR) : NodeOperation() +BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation() { + /* data_type is almost always COM_DT_COLOR except for alpha-blur */ this->addInputSocket(data_type); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(data_type); diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h index 9c343db9c3c..ee35fbe01d4 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChangeHSVOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h index 859df200020..ee17036a78d 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h @@ -25,14 +25,14 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChannelMatteOperation : public NodeOperation { private: SocketReader *m_inputImageProgram; - int m_color_space; /* node->custom1 */ + /* int m_color_space; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */ int m_matte_channel; /* node->custom2 */ int m_limit_method; /* node->algorithm */ int m_limit_channel; /* node->channel */ diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h index 472a797fa28..eaca05e66ca 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChromaMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index 479927d30d1..a9c0dff9ad4 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -25,8 +25,8 @@ #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorBalanceASCCDLOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h index ec3652da09e..ffc78fae6f1 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorBalanceLGGOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h index ae904f8f938..d996ce34667 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.h +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index 6e3156819b2..7aac612cb8c 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -25,8 +25,8 @@ #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorSpillOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h index 0b9a07a57ca..b237448d16e 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorProfileOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h index 2a57c997196..9c62ad8dd39 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorToBWOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp index c872f3e85bb..c09842b1aa9 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp @@ -20,28 +20,28 @@ * Monique Dewanchand */ -#include "COM_ConvertColourToValueProg.h" +#include "COM_ConvertColorToValueProg.h" -ConvertColourToValueProg::ConvertColourToValueProg() : NodeOperation() +ConvertColorToValueProg::ConvertColorToValueProg() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); this->m_inputOperation = NULL; } -void ConvertColourToValueProg::initExecution() +void ConvertColorToValueProg::initExecution() { this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColourToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertColorToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f; } -void ConvertColourToValueProg::deinitExecution() +void ConvertColorToValueProg::deinitExecution() { this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h index ebd4bcbd59b..c1ac7ca69ce 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h @@ -20,16 +20,16 @@ * Monique Dewanchand */ -#ifndef _COM_ConvertColourToValueProg_h -#define _COM_ConvertColourToValueProg_h +#ifndef _COM_ConvertColorToValueProg_h +#define _COM_ConvertColorToValueProg_h #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ -class ConvertColourToValueProg : public NodeOperation { +class ConvertColorToValueProg : public NodeOperation { private: /** * Cached reference to the inputProgram @@ -39,7 +39,7 @@ public: /** * Default constructor */ - ConvertColourToValueProg(); + ConvertColorToValueProg(); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h index f9170dfc7aa..51fa3a677cd 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorToVectorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h index 966a74c04ad..415befea168 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h @@ -26,8 +26,8 @@ #include "DNA_object_types.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertDepthToRadiusOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h index f8b6a4c11fa..3babbfb7c1d 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertHSVToRGBOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h index 2b5e1871972..50b39928305 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertKeyToPremulOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h index 05c6b26b171..173cbb4fc0a 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertPremulToKeyOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h index af8a7f78a61..42bd439c8c2 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToHSVOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h index 97fbdb29874..744e0657dc6 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToYCCOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h index 89998897782..b470378704e 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToYUVOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp index a29a381938f..100a4931d69 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp @@ -20,20 +20,20 @@ * Monique Dewanchand */ -#include "COM_ConvertValueToColourProg.h" +#include "COM_ConvertValueToColorProg.h" -ConvertValueToColourProg::ConvertValueToColourProg() : NodeOperation() +ConvertValueToColorProg::ConvertValueToColorProg() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->m_inputProgram = NULL; } -void ConvertValueToColourProg::initExecution() +void ConvertValueToColorProg::initExecution() { this->m_inputProgram = this->getInputSocketReader(0); } -void ConvertValueToColourProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertValueToColorProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); @@ -43,7 +43,7 @@ void ConvertValueToColourProg::executePixel(float *color, float x, float y, Pixe color[3] = 1.0f; } -void ConvertValueToColourProg::deinitExecution() +void ConvertValueToColorProg::deinitExecution() { this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h index 69ce7e9afea..d59964dd400 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h @@ -20,19 +20,19 @@ * Monique Dewanchand */ -#ifndef _COM_ConvertValueToColourProg_h -#define _COM_ConvertValueToColourProg_h +#ifndef _COM_ConvertValueToColorProg_h +#define _COM_ConvertValueToColorProg_h #include "COM_NodeOperation.h" -class ConvertValueToColourProg : public NodeOperation { +class ConvertValueToColorProg : public NodeOperation { private: /** * Cached reference to the inputProgram */ SocketReader *m_inputProgram; public: - ConvertValueToColourProg(); + ConvertValueToColorProg(); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h index 781b31f7fce..0e79c1ff3df 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertValueToVectorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h index 2f1173ba4e8..8225d03d58e 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertVectorToColorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h index 8770992c69c..a7981e8dc59 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertVectorToValueOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h index a595fc19bc7..e23dfd8a985 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertYCCToRGBOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h index e89f1500d69..3368e0a24df 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertYUVToRGBOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp index 75f909e2198..3c4bdfe8e5b 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp @@ -49,7 +49,7 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y float inColor1[4]; float inColor2[4]; - const float tolerence = this->m_settings->t1; + const float tolerance = this->m_settings->t1; const float falloff = this->m_settings->t2; float difference; float alpha; @@ -65,12 +65,12 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y difference = difference / 3.0f; /*make 100% transparent*/ - if (difference < tolerence) { + if (difference < tolerance) { outputValue[0] = 0.0f; } /*in the falloff region, make partially transparent */ - else if (difference < falloff + tolerence) { - difference = difference - tolerence; + else if (difference < falloff + tolerance) { + difference = difference - tolerance; alpha = difference / falloff; /*only change if more transparent than before */ if (alpha < inColor1[3]) { diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h index 48eb2626f02..c35550560e1 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class DifferenceMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp index 19cca3d25bb..5bdc616fed7 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp @@ -49,7 +49,7 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, float inKey[4]; float inImage[4]; - const float tolerence = this->m_settings->t1; + const float tolerance = this->m_settings->t1; const float falloff = this->m_settings->t2; float distance; @@ -67,12 +67,12 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, */ /*make 100% transparent */ - if (distance < tolerence) { + if (distance < tolerance) { outputValue[0] = 0.f; } /*in the falloff region, make partially transparent */ - else if (distance < falloff + tolerence) { - distance = distance - tolerence; + else if (distance < falloff + tolerance) { + distance = distance - tolerance; alpha = distance / falloff; /*only change if more transparent than before */ if (alpha < inImage[3]) { diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceMatteOperation.h index 51e139d179e..267aa1fca7a 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class DistanceMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index c3c115b7c3b..e5a145bab2e 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -781,10 +781,10 @@ static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *l if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* - Next we test all 4 directions around the current pixel: next/prev/up/down - The test ensures that the outer mask is empty and that the inner mask - is also empty. If both conditions are true for any one of the 4 adjacent pixels - then the current pixel is counted as being a true outer edge pixel. + * Next we test all 4 directions around the current pixel: next/prev/up/down + * The test ensures that the outer mask is empty and that the inner mask + * is also empty. If both conditions are true for any one of the 4 adjacent pixels + * then the current pixel is counted as being a true outer edge pixel. */ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || @@ -843,10 +843,10 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned i if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* - Next we test all 4 directions around the current pixel: next/prev/up/down - The test ensures that the outer mask is empty and that the inner mask - is also empty. If both conditions are true for any one of the 4 adjacent pixels - then the current pixel is counted as being a true outer edge pixel. + * Next we test all 4 directions around the current pixel: next/prev/up/down + * The test ensures that the outer mask is empty and that the inner mask + * is also empty. If both conditions are true for any one of the 4 adjacent pixels + * then the current pixel is counted as being a true outer edge pixel. */ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || @@ -902,65 +902,65 @@ static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, unsigne unsigned int outerAccum = 0; // for looping outer edge pixel indexes, represents current position from offset unsigned int gradientAccum = 0; // for looping gradient pixel indexes, represents current position from offset /* - Here we compute the size of buffer needed to hold (row,col) coordinates - for each pixel previously determined to be either gradient, inner edge, - or outer edge. - - Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even - though gbuf[] is declared as unsigned short* (2 bytes) because we don't - store the pixel indexes, we only store x,y location of pixel in buffer. - - This does make the assumption that x and y can fit in 16 unsigned bits - so if Blender starts doing renders greater than 65536 in either direction - this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes - per flagged pixel. - - In general, the buffer on-screen: - - Example: 9 by 9 pixel block - - . = pixel non-white in both outer and inner mask - o = pixel white in outer, but not inner mask, adjacent to "." pixel - g = pixel white in outer, but not inner mask, not adjacent to "." pixel - i = pixel white in inner mask, adjacent to "g" or "." pixel - F = pixel white in inner mask, only adjacent to other pixels white in the inner mask - - - ......... <----- pixel #80 - ..oooo... - .oggggo.. - .oggiggo. - .ogiFigo. - .oggiggo. - .oggggo.. - ..oooo... - pixel #00 -----> ......... - - gsz = 18 (18 "g" pixels above) - isz = 4 (4 "i" pixels above) - osz = 18 (18 "o" pixels above) - - - The memory in gbuf[] after filling will look like this: - - gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels) - / / / - / / / - |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y) - +--------------------------------> <----------------> <------------------------> <----------------+ - |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes - +--------------------------------> <----------------> <------------------------> <----------------+ - |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel - / / / - / / / - / / / - +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+ - - - Ultimately we do need the pixel's memory buffer index to set the output - pixel color, but it's faster to reconstruct the memory buffer location - each iteration of the final gradient calculation than it is to deconstruct - a memory location into x,y pairs each round. + * Here we compute the size of buffer needed to hold (row,col) coordinates + * for each pixel previously determined to be either gradient, inner edge, + * or outer edge. + * + * Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even + * though gbuf[] is declared as unsigned short* (2 bytes) because we don't + * store the pixel indexes, we only store x,y location of pixel in buffer. + * + * This does make the assumption that x and y can fit in 16 unsigned bits + * so if Blender starts doing renders greater than 65536 in either direction + * this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes + * per flagged pixel. + * + * In general, the buffer on-screen: + * + * Example: 9 by 9 pixel block + * + * . = pixel non-white in both outer and inner mask + * o = pixel white in outer, but not inner mask, adjacent to "." pixel + * g = pixel white in outer, but not inner mask, not adjacent to "." pixel + * i = pixel white in inner mask, adjacent to "g" or "." pixel + * F = pixel white in inner mask, only adjacent to other pixels white in the inner mask + * + * + * ......... <----- pixel #80 + * ..oooo... + * .oggggo.. + * .oggiggo. + * .ogiFigo. + * .oggiggo. + * .oggggo.. + * ..oooo... + * pixel #00 -----> ......... + * + * gsz = 18 (18 "g" pixels above) + * isz = 4 (4 "i" pixels above) + * osz = 18 (18 "o" pixels above) + * + * + * The memory in gbuf[] after filling will look like this: + * + * gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels) + * / / / + * / / / + * |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y) + * +--------------------------------> <----------------> <------------------------> <----------------+ + * |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes + * +--------------------------------> <----------------> <------------------------> <----------------+ + * |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel + * / / / + * / / / + * / / / + * +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+ + * + * + * Ultimately we do need the pixel's memory buffer index to set the output + * pixel color, but it's faster to reconstruct the memory buffer location + * each iteration of the final gradient calculation than it is to deconstruct + * a memory location into x,y pairs each round. */ diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index 694aa26bcde..cb4c27a4c80 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -120,8 +120,8 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse) } //------------------------------------------------------------------------------ /* 2D Fast Hartley Transform, Mx/My -> log2 of width/height, - nzp -> the row where zero pad data starts, - inverse -> see above */ + * nzp -> the row where zero pad data starts, + * inverse -> see above */ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, unsigned int nzp, unsigned int inverse) { diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h index bffcdb96877..1a8e71a306b 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.h +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h @@ -27,8 +27,8 @@ #include "COM_NodeOperation.h" /** - * Class with implementation of black/white clipping for keying node - */ + * Class with implementation of black/white clipping for keying node + */ class KeyingClipOperation : public NodeOperation { protected: float m_clipBlack; diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h index 879ee0acaca..4fea9b578a1 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h @@ -27,8 +27,8 @@ #include "COM_NodeOperation.h" /** - * Class with implementation of keying despill node - */ + * Class with implementation of keying despill node + */ class KeyingDespillOperation : public NodeOperation { protected: SocketReader *m_pixelReader; diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h index 61036bead80..736db54850a 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.h +++ b/source/blender/compositor/operations/COM_KeyingOperation.h @@ -32,8 +32,8 @@ #include "BLI_listbase.h" /** - * Class with implementation of keying node - */ + * Class with implementation of keying node + */ class KeyingOperation : public NodeOperation { protected: SocketReader *m_pixelReader; diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h index 7da56465cd8..041fd0d7ee9 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class LuminanceMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h index 53157c39938..fb50d0fbe4d 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.h +++ b/source/blender/compositor/operations/COM_MapValueOperation.h @@ -26,8 +26,8 @@ #include "DNA_texture_types.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MapValueOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index aa16ecf5d09..2b45cd53fd5 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -49,11 +49,19 @@ MaskOperation::MaskOperation() : NodeOperation() void MaskOperation::initExecution() { initMutex(); + this->m_rasterizedMask = NULL; + this->m_maskLayers.first = this->m_maskLayers.last = NULL; + + if (this->m_mask) { + BKE_mask_layer_copy_list(&this->m_maskLayers, &this->m_mask->masklayers); + } } void MaskOperation::deinitExecution() { + BKE_mask_layer_free_list(&this->m_maskLayers); + if (this->m_rasterizedMask) { MEM_freeN(this->m_rasterizedMask); this->m_rasterizedMask = NULL; @@ -75,7 +83,10 @@ void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers float *buffer; buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask"); - BKE_mask_rasterize(this->m_mask, width, height, buffer, TRUE, this->m_do_smooth, this->m_do_feather); + + BKE_mask_rasterize_layers(&this->m_maskLayers, width, height, buffer, TRUE, + this->m_do_smooth, this->m_do_feather); + if (this->m_do_smooth) { PLX_antialias_buffer(buffer, width, height); } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index d50f5c619bb..df1cad3c0f6 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -43,6 +43,7 @@ protected: bool m_do_smooth; bool m_do_feather; float *m_rasterizedMask; + ListBase m_maskLayers; /** * Determine the output resolution. The resolution is retrieved from the Renderer diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index bf77223e26f..be06537cbf0 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MathBaseOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_MixAddOperation.h b/source/blender/compositor/operations/COM_MixAddOperation.h index 7b03802cf7e..c5eaf0a4d77 100644 --- a/source/blender/compositor/operations/COM_MixAddOperation.h +++ b/source/blender/compositor/operations/COM_MixAddOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixAddOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h index 8e9bb283533..268d4832243 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.h +++ b/source/blender/compositor/operations/COM_MixBaseOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBaseOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.h b/source/blender/compositor/operations/COM_MixBlendOperation.h index b906134f5cb..16ad635bebd 100644 --- a/source/blender/compositor/operations/COM_MixBlendOperation.h +++ b/source/blender/compositor/operations/COM_MixBlendOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBlendOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.h b/source/blender/compositor/operations/COM_MixBurnOperation.h index af09772edde..7412f651ab3 100644 --- a/source/blender/compositor/operations/COM_MixBurnOperation.h +++ b/source/blender/compositor/operations/COM_MixBurnOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBurnOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixColorOperation.h b/source/blender/compositor/operations/COM_MixColorOperation.h index 9b0d93f934d..028ff517132 100644 --- a/source/blender/compositor/operations/COM_MixColorOperation.h +++ b/source/blender/compositor/operations/COM_MixColorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixColorOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.h b/source/blender/compositor/operations/COM_MixDarkenOperation.h index 69fb4450458..337fa1a7024 100644 --- a/source/blender/compositor/operations/COM_MixDarkenOperation.h +++ b/source/blender/compositor/operations/COM_MixDarkenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDarkenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.h b/source/blender/compositor/operations/COM_MixDifferenceOperation.h index c71b22214cc..503fbb691d3 100644 --- a/source/blender/compositor/operations/COM_MixDifferenceOperation.h +++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDifferenceOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.h b/source/blender/compositor/operations/COM_MixDivideOperation.h index 375e7129e8b..db60a39f93f 100644 --- a/source/blender/compositor/operations/COM_MixDivideOperation.h +++ b/source/blender/compositor/operations/COM_MixDivideOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDivideOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.h b/source/blender/compositor/operations/COM_MixDodgeOperation.h index a4adf6fde47..32aa8593657 100644 --- a/source/blender/compositor/operations/COM_MixDodgeOperation.h +++ b/source/blender/compositor/operations/COM_MixDodgeOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDodgeOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.h b/source/blender/compositor/operations/COM_MixGlareOperation.h index 1a025eb3edd..1c715d7414b 100644 --- a/source/blender/compositor/operations/COM_MixGlareOperation.h +++ b/source/blender/compositor/operations/COM_MixGlareOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixGlareOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixHueOperation.h b/source/blender/compositor/operations/COM_MixHueOperation.h index 56310e253c0..ff1ef369440 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.h +++ b/source/blender/compositor/operations/COM_MixHueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixHueOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.h b/source/blender/compositor/operations/COM_MixLightenOperation.h index bb251a44653..dd51215b26a 100644 --- a/source/blender/compositor/operations/COM_MixLightenOperation.h +++ b/source/blender/compositor/operations/COM_MixLightenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixLightenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.h b/source/blender/compositor/operations/COM_MixLinearLightOperation.h index 39d5b6495d1..e96e2b7eaf7 100644 --- a/source/blender/compositor/operations/COM_MixLinearLightOperation.h +++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixLinearLightOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.h b/source/blender/compositor/operations/COM_MixMultiplyOperation.h index 2c12854bfa6..4c89a8f2957 100644 --- a/source/blender/compositor/operations/COM_MixMultiplyOperation.h +++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixMultiplyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.h b/source/blender/compositor/operations/COM_MixOverlayOperation.h index 48d1d10a697..7de955b9f4f 100644 --- a/source/blender/compositor/operations/COM_MixOverlayOperation.h +++ b/source/blender/compositor/operations/COM_MixOverlayOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixOverlayOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.h b/source/blender/compositor/operations/COM_MixSaturationOperation.h index ccb95e2f00f..241009e2645 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.h +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSaturationOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.h b/source/blender/compositor/operations/COM_MixScreenOperation.h index 6b9fa302325..4d0c1fded3d 100644 --- a/source/blender/compositor/operations/COM_MixScreenOperation.h +++ b/source/blender/compositor/operations/COM_MixScreenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixScreenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.h b/source/blender/compositor/operations/COM_MixSoftLightOperation.h index 4189066de2c..bcb718027b2 100644 --- a/source/blender/compositor/operations/COM_MixSoftLightOperation.h +++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSoftLightOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.h b/source/blender/compositor/operations/COM_MixSubtractOperation.h index b820fb1e5e1..3c8112b0e36 100644 --- a/source/blender/compositor/operations/COM_MixSubtractOperation.h +++ b/source/blender/compositor/operations/COM_MixSubtractOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSubtractOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixValueOperation.h b/source/blender/compositor/operations/COM_MixValueOperation.h index d12a2d2b3d6..c0f3ce10f29 100644 --- a/source/blender/compositor/operations/COM_MixValueOperation.h +++ b/source/blender/compositor/operations/COM_MixValueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixValueOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h index ba104d07572..c6422fbbfc2 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h @@ -32,8 +32,8 @@ typedef enum MovieClipAttribute { MCA_ANGLE } MovieClipAttribute; /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MovieClipAttributeOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index 50bac63d6f2..74145c52a5d 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -36,6 +36,7 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOpera } void ProjectorLensDistortionOperation::initExecution() { + this->initMutex(); this->m_inputProgram = this->getInputSocketReader(0); } @@ -65,6 +66,7 @@ void ProjectorLensDistortionOperation::executePixel(float *color, int x, int y, void ProjectorLensDistortionOperation::deinitExecution() { + this->deinitMutex(); this->m_inputProgram = NULL; } @@ -77,16 +79,18 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *in newInput.xmin = input->xmin - this->m_kr2 - 2; newInput.xmax = input->xmax + this->m_kr2 + 2; } else { - newInput.xmin = 0; + newInput.xmin = input->xmin-7; //(0.25f*20*1)+2 == worse case dispersion newInput.ymin = input->ymin; newInput.ymax = input->ymax; - newInput.xmax = this->m_inputProgram->getWidth(); + newInput.xmax = input->xmax+7; //(0.25f*20*1)+2 == worse case dispersion } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers) { + if (this->m_dispersionAvailable) return; + this->lockMutex(); if (!this->m_dispersionAvailable) { float result[4]; this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); @@ -95,4 +99,5 @@ void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuff this->m_kr2 = this->m_kr * 20; this->m_dispersionAvailable = true; } + this->unlockMutex(); } diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h index f992b22f300..c658d66429a 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h @@ -61,7 +61,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void updateDispersion(MemoryBuffer** inputBuffers); + void updateDispersion(MemoryBuffer **inputBuffers); }; #endif diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp index 14c3d652c42..f21585844ff 100644 --- a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp @@ -22,7 +22,7 @@ #include "COM_RenderLayersImageProg.h" -RenderLayersColourProg::RenderLayersColourProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4) +RenderLayersColorProg::RenderLayersColorProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4) { this->addOutputSocket(COM_DT_COLOR); } diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.h b/source/blender/compositor/operations/COM_RenderLayersImageProg.h index b6ddac425cb..2d63bad235b 100644 --- a/source/blender/compositor/operations/COM_RenderLayersImageProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.h @@ -20,15 +20,15 @@ * Monique Dewanchand */ -#ifndef _COM_RenderLayersColourProg_h -#define _COM_RenderLayersColourProg_h +#ifndef _COM_RenderLayersColorProg_h +#define _COM_RenderLayersColorProg_h #include "COM_RenderLayersBaseProg.h" /// @TODO rename to image operation -class RenderLayersColourProg : public RenderLayersBaseProg { +class RenderLayersColorProg : public RenderLayersBaseProg { public: - RenderLayersColourProg(); + RenderLayersColorProg(); }; #endif diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index e3abf2aa70b..ea8483734d3 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -42,6 +42,10 @@ ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation() void ScreenLensDistortionOperation::initExecution() { this->m_inputProgram = this->getInputSocketReader(0); + this->initMutex(); + this->m_cx = 0.5f * (float)getWidth(); + this->m_cy = 0.5f * (float)getHeight(); + } void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -139,52 +143,192 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int void ScreenLensDistortionOperation::deinitExecution() { + this->deinitMutex(); this->m_inputProgram = NULL; } -void ScreenLensDistortionOperation::determineUV(float result[2], float x, float y) const +void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y, float distortion, float dispersion) +{ + if (!this->m_valuesAvailable) { + updateVariables(distortion, dispersion); + } + determineUV(result, x, y); +} + +void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y) const { + const float height = this->getHeight(); + const float width = this->getWidth(); + + float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; const float v = this->m_sc * ((y + 0.5f) - this->m_cy) / this->m_cy; const float u = this->m_sc * ((x + 0.5f) - this->m_cx) / this->m_cx; - const float t = ABS(MIN3(this->m_kr, this->m_kg, this->m_kb) * 4); - float d = 1.f / (1.f + sqrtf(t)); - result[0] = (u * d + 0.5f) * getWidth() - 0.5f; - result[1] = (v * d + 0.5f) * getHeight() - 0.5f; + const float uv_dot = u * u + v * v; + + if ((t = 1.f - this->m_kr4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f; + } + if ((t = 1.f - this->m_kg4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f; + } + if ((t = 1.f - this->m_kb4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f; + } + + float jit = this->m_data->jit; + float z; + { + // RG + const int dx = ln[2] - ln[0], dy = ln[3] - ln[1]; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; + const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); + const float sd = 1.f / (float)ds; + + z = ds; + const float tz = ((float)z + (1.0f)) * sd; + t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot; + d = 1.0f / (1.f + sqrtf(t)); + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; + result[0] = nx; + result[1] = ny; + } + { + // GB + const int dx = ln[4] - ln[2], dy = ln[5] - ln[3]; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; + const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); + const float sd = 1.f / (float)ds; + + z = ds; + const float tz = ((float)z + (1.0f)) * sd; + t = 1.f - (this->m_kg4 + tz * this->m_dgb) * uv_dot; + d = 1.f / (1.f + sqrtf(t)); + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; + result[2] = nx; + result[3] = ny; + } } bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { + rcti newInputValue; + newInputValue.xmin = 0; + newInputValue.ymin = 0; + newInputValue.xmax = 2; + newInputValue.ymax = 2; + + NodeOperation *operation = getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) { + return true; + } + + operation = getInputOperation(2); + if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) { + return true; + } + +#define MARGIN 64 + +#define UPDATE_INPUT \ + newInput.xmin = MIN3(newInput.xmin, coords[0], coords[2]); \ + newInput.ymin = MIN3(newInput.ymin, coords[1], coords[3]); \ + newInput.xmax = MAX3(newInput.xmax, coords[0], coords[2]); \ + newInput.ymax = MAX3(newInput.ymax, coords[1], coords[3]); + rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.ymax = this->m_inputProgram->getHeight(); - newInput.xmax = this->m_inputProgram->getWidth(); - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + float margin; + float coords[4]; + if (m_valuesAvailable) { + determineUV(coords, input->xmin, input->ymin); + newInput.xmin = coords[0]; + newInput.ymin = coords[1]; + newInput.xmax = coords[0]; + newInput.ymax = coords[1]; + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymax); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymax); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymin); + UPDATE_INPUT; + margin = (ABS(this->m_distortion)+this->m_dispersion)*MARGIN; + } + else + { + determineUV(coords, input->xmin, input->ymin, 1.0f, 1.0f); + newInput.xmin = coords[0]; + newInput.ymin = coords[1]; + newInput.xmax = coords[0]; + newInput.ymax = coords[1]; + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymin, -1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmin, input->ymax, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymax, 1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmax, input->ymax, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymax, 1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmax, input->ymin, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymin, 1.0f, 1.0f); + UPDATE_INPUT; + margin=MARGIN; + } + +#undef UPDATE_INPUT + newInput.xmin -= margin; + newInput.ymin -= margin; + newInput.xmax += margin; + newInput.ymax += margin; + + operation = getInputOperation(0); + if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { + return true; + } + return false; +} + +void ScreenLensDistortionOperation::updateVariables(float distortion, float dispersion) +{ + this->m_kg = MAX2(MIN2(distortion, 1.f), -0.999f); + // smaller dispersion range for somewhat more control + const float d = 0.25f * MAX2(MIN2(dispersion, 1.f), 0.f); + this->m_kr = MAX2(MIN2((this->m_kg + d), 1.0f), -0.999f); + this->m_kb = MAX2(MIN2((this->m_kg - d), 1.0f), -0.999f); + this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb); + this->m_sc = (this->m_data->fit && (this->m_maxk > 0.f)) ? (1.f / (1.f + 2.f * this->m_maxk)) : (1.f / (1.f + this->m_maxk)); + this->m_drg = 4.f * (this->m_kg - this->m_kr); + this->m_dgb = 4.f * (this->m_kb - this->m_kg); + + this->m_kr4 = this->m_kr * 4.0f; + this->m_kg4 = this->m_kg * 4.0f; + this->m_kb4 = this->m_kb * 4.0f; } void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers) { + if (this->m_valuesAvailable) return; + + this->lockMutex(); if (!this->m_valuesAvailable) { float result[4]; this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); this->m_distortion = result[0]; this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); this->m_dispersion = result[0]; - this->m_kg = MAX2(MIN2(this->m_distortion, 1.f), -0.999f); - // smaller dispersion range for somewhat more control - const float d = 0.25f * MAX2(MIN2(this->m_dispersion, 1.f), 0.f); - this->m_kr = MAX2(MIN2((this->m_kg + d), 1.0f), -0.999f); - this->m_kb = MAX2(MIN2((this->m_kg - d), 1.0f), -0.999f); - this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb); - this->m_sc = (this->m_data->fit && (this->m_maxk > 0.f)) ? (1.f / (1.f + 2.f * this->m_maxk)) : (1.f / (1.f + this->m_maxk)); - this->m_drg = 4.f * (this->m_kg - this->m_kr); - this->m_dgb = 4.f * (this->m_kb - this->m_kg); - - this->m_kr4 = this->m_kr * 4.0f; - this->m_kg4 = this->m_kg * 4.0f; - this->m_kb4 = this->m_kb * 4.0f; - this->m_cx = 0.5f * (float)getWidth(); - this->m_cy = 0.5f * (float)getHeight(); + updateVariables(this->m_distortion, this->m_dispersion); this->m_valuesAvailable = true; } + this->unlockMutex(); } diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h index d990651dd7d..f80b938818c 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h @@ -66,9 +66,23 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + /** + * @brief Set the distortion and dispersion and precalc some values + * @param distortion + * @param dispersion + */ + void setDistortionAndDispersion(float distortion, float dispersion) { + this->m_distortion = distortion; + this->m_dispersion = dispersion; + updateVariables(distortion, dispersion); + this->m_valuesAvailable = true; + } + private: - void determineUV(float *result, float x, float y) const; - void updateDispersionAndDistortion(MemoryBuffer** inputBuffers); + void determineUV(float result[4], float x, float y) const; + void determineUV(float result[4], float x, float y, float distortion, float dispersion); + void updateDispersionAndDistortion(MemoryBuffer **inputBuffers); + void updateVariables(float distortion, float dispersion); }; #endif diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h index 857bd08bfbf..21968c930e7 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetAlphaOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h index abfa2b9538a..a51311837ee 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.h +++ b/source/blender/compositor/operations/COM_SetColorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetColorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h index 24e0c5e2ef5..273eac159bc 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.h +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output Sampler. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output Sampler. + * it assumes we are in sRGB color space. */ class SetSamplerOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h index dce0c3299ac..642940e03cd 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.h +++ b/source/blender/compositor/operations/COM_SetValueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetValueOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h index dc2a05ceff4..d1b9fe25085 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.h +++ b/source/blender/compositor/operations/COM_SetVectorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetVectorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 9eb004b3686..46101f6355d 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -33,6 +33,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image. this->addInputSocket(COM_DT_VALUE); // radius this->addInputSocket(COM_DT_VALUE); // depth +#ifdef COM_DEFOCUS_SEARCH + this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure. +#endif this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); @@ -42,6 +45,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->m_inputDepthProgram = NULL; this->m_maxBlur = 32.0f; this->m_threshold = 1.0f; +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = NULL; +#endif } @@ -51,6 +57,9 @@ void VariableSizeBokehBlurOperation::initExecution() this->m_inputBokehProgram = getInputSocketReader(1); this->m_inputSizeProgram = getInputSocketReader(2); this->m_inputDepthProgram = getInputSocketReader(3); +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = getInputSocketReader(4); +#endif QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -63,10 +72,19 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - int miny = y - this->m_maxBlur; - int maxy = y + this->m_maxBlur; - int minx = x - this->m_maxBlur; - int maxx = x + this->m_maxBlur; +#ifdef COM_DEFOCUS_SEARCH + float search[4]; + this->inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y/InverseSearchRadiusOperation::DIVIDER, inputBuffers, NULL); + int minx = search[0]; + int miny = search[1]; + int maxx = search[2]; + int maxy = search[3]; +#else + int minx = MAX2(x - this->m_maxBlur, 0.0f); + int miny = MAX2(y - this->m_maxBlur, 0.0f); + int maxx = MIN2(x + this->m_maxBlur, m_width); + int maxy = MIN2(y + this->m_maxBlur, m_height); +#endif { this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); @@ -80,9 +98,9 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { this->m_inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); - this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); - float size = tempSize[0]; if (tempDepth[0] < centerDepth) { + this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); + float size = tempSize[0]; if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_threshold) { float dx = nx - x; float dy = ny - y; @@ -115,6 +133,10 @@ void VariableSizeBokehBlurOperation::deinitExecution() this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputSizeProgram = NULL; + this->m_inputDepthProgram = NULL; +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = NULL; +#endif } bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -130,6 +152,7 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu bokehInput.xmin = 0; bokehInput.ymax = 512; bokehInput.ymin = 0; + NodeOperation *operation = getInputOperation(2); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { @@ -143,9 +166,118 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; } +#ifdef COM_DEFOCUS_SEARCH + rcti searchInput; + searchInput.xmax = (input->xmax/InverseSearchRadiusOperation::DIVIDER)+1; + searchInput.xmin = (input->xmin/InverseSearchRadiusOperation::DIVIDER)-1; + searchInput.ymax = (input->ymax/InverseSearchRadiusOperation::DIVIDER)+1; + searchInput.ymin = (input->ymin/InverseSearchRadiusOperation::DIVIDER)-1; + operation = getInputOperation(4); + if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output) ) { + return true; + } +#endif operation = getInputOperation(0); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; } return false; } + +#ifdef COM_DEFOCUS_SEARCH +// InverseSearchRadiusOperation +InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius + this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // depth + this->addOutputSocket(COM_DT_COLOR); + this->setComplex(true); + this->inputRadius = NULL; + this->inputDepth = NULL; +} + +void InverseSearchRadiusOperation::initExecution() +{ + this->inputRadius = this->getInputSocketReader(0); + this->inputDepth = this->getInputSocketReader(1); +} + +void* InverseSearchRadiusOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + MemoryBuffer * data = new MemoryBuffer(NULL, rect); + int x, y; + float width = this->inputRadius->getWidth(); + float height = this->inputRadius->getHeight(); + + for (x = rect->xmin; x < rect->xmax ; x++) { + for (y = rect->ymin; y < rect->ymax ; y++) { + float[4] temp; + int rx = x * DIVIDER; + int ry = y * DIVIDER; + this->inputRadius->read(temp, rx, ry, memoryBuffers, NULL); + float centerRadius = temp[0]; + this->inputDepth->read(temp, rx, ry, memoryBuffers, NULL); + float centerDepth = temp[0]; + t[0] = MAX2(rx - this->maxBlur, 0.0f); + t[1] = MAX2(ry - this->maxBlur, 0.0f); + t[2] = MIN2(rx + this->maxBlur, width); + t[3] = MIN2(ry + this->maxBlur, height); + int minx = t[0]; + int miny = t[1]; + int maxx = t[2]; + int maxy = t[3]; + int sminx = rx; + int smaxx = rx; + int sminy = ry; + int smaxy = ry; + for (int nx = minx ; nx < maxx ; nx ++) { + for (int ny = miny ; ny < maxy ; ny ++) { + this->inputRadius->read(temp, nx, ny, memoryBuffers, NULL); + if (nx < rx && temp[0]) + + } + } + float t[4]; + data->writePixel(x, y, t); + } + } + return data; +} + +void InverseSearchRadiusOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + MemoryBuffer *buffer = (MemoryBuffer*)data; + buffer->read(color, x, y); +} + +void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +{ + if (data) { + MemoryBuffer* mb = (MemoryBuffer*)data; + delete mb; + } +} + +void InverseSearchRadiusOperation::deinitExecution() +{ + this->inputRadius = NULL; + this->inputDepth = NULL; +} + +void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) +{ + NodeOperation::determineResolution(resolution, preferredResolution); + resolution[0] = resolution[0] / DIVIDER; + resolution[1] = resolution[1] / DIVIDER; +} + +bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newRect; + newRect.ymin = input->ymin*DIVIDER; + newRect.ymax = input->ymax*DIVIDER; + newRect.xmin = input->xmin*DIVIDER; + newRect.xmax = input->xmax*DIVIDER; + return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output); +} +#endif diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index 8e59a43fcb1..4bf597ff831 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -25,6 +25,7 @@ #include "COM_NodeOperation.h" #include "COM_QualityStepHelper.h" + class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper { private: int m_maxBlur; @@ -33,6 +34,9 @@ private: SocketReader *m_inputBokehProgram; SocketReader *m_inputSizeProgram; SocketReader *m_inputDepthProgram; +#ifdef COM_DEFOCUS_SEARCH + SocketReader *inputSearchProgram; +#endif public: VariableSizeBokehBlurOperation(); @@ -60,4 +64,42 @@ public: }; + +#ifdef COM_DEFOCUS_SEARCH +class InverseSearchRadiusOperation : public NodeOperation { +private: + int maxBlur; + float threshold; + SocketReader *inputDepth; + SocketReader *inputRadius; +public: + static const int DIVIDER = 4; + + InverseSearchRadiusOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + + /** + * Initialize the execution + */ + void initExecution(); + void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + + /** + * Deinitialize the execution + */ + void deinitExecution(); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); + + void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; } + + void setThreshold(float threshold) { this->threshold = threshold; } +}; +#endif #endif diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 7259db34134..b8c7478b2f7 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -63,6 +63,9 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer(); float *buffer = memoryBuffer->getBuffer(); if (this->m_input->isComplex()) { + bNode* bnode = this->m_input->getbNode(); + if (bnode&& bnode->original) bnode->original->highlight++; + void *data = this->m_input->initializeTileData(rect, memoryBuffers); int x1 = rect->xmin; int y1 = rect->ymin; @@ -87,6 +90,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me this->m_input->deinitializeTileData(rect, memoryBuffers, data); data = NULL; } + if (bnode&& bnode->original) bnode->original->highlight++; } else { int x1 = rect->xmin; @@ -139,6 +143,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, list<cl_mem> *clMemToCleanUp = new list<cl_mem>(); clMemToCleanUp->push_back(clOutputBuffer); list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); + bNode* bnode = this->m_input->getbNode(); + if (bnode&& bnode->original) bnode->original->highlight++; this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); @@ -156,7 +162,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); - + + if (bnode&& bnode->original) bnode->original->highlight++; // STEP 4 diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h index 2ade3f599ad..422a946b98f 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.h +++ b/source/blender/compositor/operations/COM_ZCombineOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ZCombineOperation : public NodeOperation { protected: diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 4a5966948ae..672e11ac613 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -416,6 +416,7 @@ static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *pro char *basepath = RNA_path_from_ID_to_property(ptr, prop); char *path = basepath; /* in case no remapping is needed */ + /* Remapping will only be performed in the Properties Editor, as only this * restricts the subspace of options to the 'active' data (a manageable state) */ @@ -426,23 +427,6 @@ static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *pro if (ob && id) { /* only id-types which can be remapped to go through objects should be considered */ switch (GS(id->name)) { - case ID_MA: /* materials */ - { - Material *ma = give_current_material(ob, ob->actcol); - - /* assumes: material will only be shown if it is active objects's active material it's ok */ - if ((ID *)ma == id) { - /* create new path */ - // TODO: use RNA path functions to construct instead? - path = BLI_sprintfN("material_slots[\"%s\"].material.%s", - ma->id.name + 2, basepath); - - /* free old one */ - MEM_freeN(basepath); - } - } - break; - case ID_TE: /* textures */ { Material *ma = give_current_material(ob, ob->actcol); @@ -452,6 +436,7 @@ static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *pro if ((ID *)tex == id) { /* create new path */ // TODO: use RNA path functions to construct step by step instead? + // FIXME: maybe this isn't even needed anymore... path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s", ma->id.name + 2, tex->id.name + 2, basepath); diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 6250424d655..0c9a6ff6bf1 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -201,7 +201,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); if (grp) { agrp->customCol = grp->customCol; - action_group_colors_sync(agrp); + action_group_colors_sync(agrp, grp); } } } @@ -1581,7 +1581,7 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "all", 1, "All", "Delete keyfames from all elements of the array"); + RNA_def_boolean(ot->srna, "all", 1, "All", "Delete keyframes from all elements of the array"); } /* ******************************************* */ diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 0760b384ecd..ddf66a6169b 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -183,7 +183,7 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con void POSELIB_OT_new(struct wmOperatorType *ot); void POSELIB_OT_unlink(struct wmOperatorType *ot); -void POSELIB_OT_action_sanitise(struct wmOperatorType *ot); +void POSELIB_OT_action_sanitize(struct wmOperatorType *ot); void POSELIB_OT_pose_add(struct wmOperatorType *ot); void POSELIB_OT_pose_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index f3461f71391..59ee90c553b 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -159,7 +159,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSELIB_OT_new); WM_operatortype_append(POSELIB_OT_unlink); - WM_operatortype_append(POSELIB_OT_action_sanitise); + WM_operatortype_append(POSELIB_OT_action_sanitize); /* POSE SLIDING */ WM_operatortype_append(POSE_OT_push); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index ea3c8685525..6cef843d828 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -4563,7 +4563,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } } - /* if there are some dependencies for visualising armature state + /* if there are some dependencies for visualizing armature state * (e.g. Mask Modifier in 'Armature' mode), force update */ else if (arm->flag & ARM_HAS_VIZ_DEPS) { @@ -4828,6 +4828,9 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, if (numbones == 0) return; + if (ED_vgroup_data_create(ob->data) == FALSE) + return; + /* create an array of pointer to bones that are skinnable * and fill it with all of the skinnable bones */ bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist"); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index ab96656406e..6b6d2a1505f 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -667,25 +667,27 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, *err_str = NULL; /* count triangles and create mask */ - if ( (use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || - (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) + if ((use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || + (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); - } - for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { /* (added selectedVerts content for vertex mask, they used to just equal 1) */ if (use_vert_sel) { - for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { - if (use_vert_sel) { - mask[ml->v] = (mvert[ml->v].flag & SELECT) != 0; + for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { + for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { + if (use_vert_sel) { + mask[ml->v] = (mvert[ml->v].flag & SELECT) != 0; + } } } } else if (use_face_sel) { - if (mp->flag & ME_FACE_SEL) { - for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { - mask[ml->v] = 1; + for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { + if (mp->flag & ME_FACE_SEL) { + for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { + mask[ml->v] = 1; + } } } } diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 824a39374fd..51700793791 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -220,7 +220,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) else { /* - these weights are derived from the relative distance of these * poses from the current frame - * - they then get normalised so that they only sum up to 1 + * - they then get normalized so that they only sum up to 1 */ float wtot; diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 18e3d967835..ee54fc2c6fe 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -288,7 +288,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot) /* This tool automagically generates/validates poselib data so that it corresponds to the data * in the action. This is for use in making existing actions usable as poselibs. */ -static int poselib_sanitise_exec(bContext *C, wmOperator *op) +static int poselib_sanitize_exec(bContext *C, wmOperator *op) { Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; @@ -353,15 +353,15 @@ static int poselib_sanitise_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void POSELIB_OT_action_sanitise(wmOperatorType *ot) +void POSELIB_OT_action_sanitize(wmOperatorType *ot) { /* identifiers */ - ot->name = "Sanitise Pose Library Action"; - ot->idname = "POSELIB_OT_action_sanitise"; + ot->name = "Sanitize Pose Library Action"; + ot->idname = "POSELIB_OT_action_sanitize"; ot->description = "Make action suitable for use as a Pose Library"; /* callbacks */ - ot->exec = poselib_sanitise_exec; + ot->exec = poselib_sanitize_exec; ot->poll = has_poselib_pose_data_poll; /* flags */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 032b999c60f..e8a71a35576 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2368,7 +2368,7 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot) { /* identifiers */ ot->name = "Smooth Curve Radius"; - ot->description = "Flatten radiuses of selected points"; + ot->description = "Flatten radii of selected points"; ot->idname = "CURVE_OT_smooth_radius"; /* api clastbacks */ @@ -3932,7 +3932,8 @@ static int make_segment_exec(bContext *C, wmOperator *op) ListBase *nubase = object_editcurve_get(obedit); Nurb *nu, *nu1 = NULL, *nu2 = NULL; BPoint *bp; - int a, ok = 0; + int ok = 0; + /* int a; */ /* UNUSED */ /* first decide if this is a surface merge! */ if (obedit->type == OB_SURF) nu = nubase->first; @@ -4040,7 +4041,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) MEM_freeN(nu1->bp); nu1->bp = bp; - a = nu1->pntsu + nu1->orderu; + /* a = nu1->pntsu + nu1->orderu; */ /* UNUSED */ nu1->pntsu += nu2->pntsu; BLI_remlink(nubase, nu2); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index fa555b0ddb8..6d113cbb924 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -281,7 +281,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, } /* tessellation code - draw stroke as series of connected quads with connection - * edges rotated to minimise shrinking artifacts, and rounded endcaps + * edges rotated to minimize shrinking artifacts, and rounded endcaps */ else { bGPDspoint *pt1, *pt2; diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index a7beaa74eb7..b69db0040b5 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -399,7 +399,7 @@ void paste_gpdata(Scene *scene) /* this should be the right frame... as it may be a pre-existing frame, * must make sure that only compatible stroke types get copied over * - we cannot just add a duplicate frame, as that would cause errors - * - need to check for compatible types to minimise memory usage (copying 'junk' over) + * - need to check for compatible types to minimize memory usage (copying 'junk' over) */ for (gps = gpfs->strokes.first; gps; gps = gps->next) { short stroke_ok; diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 0979e3ec92b..6f86d01fb98 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -41,10 +41,20 @@ struct bNodeTree; struct bNode; struct bNodeTree; struct ScrArea; +struct View2D; + +typedef enum { + NODE_TOP = 1, + NODE_BOTTOM = 2, + NODE_LEFT = 4, + NODE_RIGHT = 8 +} NodeBorder; /* drawnode.c */ void ED_init_node_butfuncs(void); +void drawnodesnap(struct View2D *v2d, const float cent[2], float size, NodeBorder border); + /* node_draw.c */ void ED_node_tree_update(struct SpaceNode *snode, struct Scene *scene); void ED_node_changed_update(struct ID *id, struct bNode *node); diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index c53dca47da9..6b9d8385ac3 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -76,10 +76,10 @@ typedef struct ScreenFrameRateInfo { /* Enum for Action Zone Edges. Which edge of area is action zone. */ typedef enum { - AE_RIGHT_TO_TOPLEFT, /* Region located on the left, _right_ edge is action zone. Region minimised to the top left */ - AE_LEFT_TO_TOPRIGHT, /* Region located on the right, _left_ edge is action zone. Region minimised to the top right */ - AE_TOP_TO_BOTTOMRIGHT, /* Region located at the bottom, _top_ edge is action zone. Region minimised to the bottom right */ - AE_BOTTOM_TO_TOPLEFT /* Region located at the top, _bottom_edge is action zone. Region minimised to the top left */ + AE_RIGHT_TO_TOPLEFT, /* Region located on the left, _right_ edge is action zone. Region minimized to the top left */ + AE_LEFT_TO_TOPRIGHT, /* Region located on the right, _left_ edge is action zone. Region minimized to the top right */ + AE_TOP_TO_BOTTOMRIGHT, /* Region located at the bottom, _top_ edge is action zone. Region minimized to the bottom right */ + AE_BOTTOM_TO_TOPLEFT /* Region located at the top, _bottom_edge is action zone. Region minimized to the top left */ } AZEdge; /* for editing areas/regions */ diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 608df8dd9b3..d7e9fc323a6 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -180,6 +180,8 @@ int peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, cons int peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2], SnapMode mode); int snapObjectsTransform(struct TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode); int snapObjectsContext(struct bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode); +int snapNodesTransform(struct TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode); +int snapNodesContext(struct bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode); #endif diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 469388219d6..5039a30b61a 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -166,6 +166,7 @@ void UI_view2d_view_restore(const struct bContext *C); View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy); void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag); void UI_view2d_constant_grid_draw(struct View2D *v2d); +void UI_view2d_multi_grid_draw(struct View2D *v2d, float step, int level_size, int totlevels); void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy); void UI_view2d_grid_free(View2DGrid *grid); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index d26c8cefdf0..49d56d427ba 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -498,7 +498,7 @@ static int ui_but_float_precision(uiBut *but, double value) return prec; } -static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines) +static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines) { rcti rect; @@ -511,7 +511,7 @@ static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines) if (line->flag & UI_SELECT) glColor3ub(100, 100, 100); - else if (hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) + else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) UI_ThemeColor(TH_TEXT_HI); else glColor3ub(0, 0, 0); @@ -919,7 +919,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) if (ui_but_update_from_old_block(C, block, &but)) ui_check_but(but); - /* temp? Proper check for greying out */ + /* temp? Proper check for graying out */ if (but->optype) { wmOperatorType *ot = but->optype; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b82e7c3a1e2..30c5f2fbe40 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3362,7 +3362,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND ui_get_but_vectorf(but, rgb); rgb_to_hsv_compat_v(rgb, hsv); - /* Convert current colour on hue/sat disc to circular coordinates phi, r */ + /* Convert current color on hue/sat disc to circular coordinates phi, r */ phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI; r = hsv[1]; /* sqr= r>0.f?sqrtf(r):1; */ /* UNUSED */ @@ -5009,7 +5009,7 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) ui_window_to_block(ar, block, &mx, &my); for (but = block->buttons.first; but; but = but->next) { - /* note, LABEL is included for hilights, this allows drags */ + /* note, LABEL is included for highlights, this allows drags */ if (but->type == LABEL && but->dragpoin == NULL) continue; if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX)) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d87ca0f7bb6..e6a4c260d0f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -782,7 +782,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (modifier_couldBeCage(scene, md) && (index <= lastCageIndex)) { /* -- convert to rna ? */ but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, - TIP_("Apply modifier to editing cage during Editmode")); + TIP_("Apply modifier to editing cage during Edit mode")); if (index < cageIndex) uiButSetFlag(but, UI_BUT_DISABLED); uiButSetFunc(but, modifiers_setOnCage, ob, md); @@ -1051,7 +1051,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) * as that poses problems when restoring them, so disable the "up" button where * it may cause this situation. * - * Up/Down buttons should only be shown (or not greyed - todo) if they serve some purpose. + * Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose. */ if (proxylocked_constraints_owner(ob, pchan)) { if (con->prev) { @@ -2679,7 +2679,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) but->col[3] = 255; but = uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); - but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->greyscale); + but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->grayscale); but->col[3] = 255; uiBlockEndAlign(block); @@ -2699,7 +2699,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) uiBlockSetEmboss(block, UI_EMBOSSN); if (reports->list.first != reports->list.last) - uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, TIP_("Click to see rest of reports in textblock: 'Recent Reports'")); + uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, + UI_UNIT_X, UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'")); else uiDefIconBut(block, LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 07b1217b1bd..5ee89bb418f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1434,7 +1434,7 @@ static struct uiWidgetColors wcol_menu_back = { 25, -20 }; -/* tooltip colour */ +/* tooltip color */ static struct uiWidgetColors wcol_tooltip = { {0, 0, 0, 255}, {25, 25, 25, 230}, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index fe46a5dc9c5..407b2308af8 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1888,8 +1888,8 @@ void init_userdef_do_versions(void) rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102); /* NLA Colors */ - rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as dopesheet above */ - rgba_char_args_set(btheme->tnla.anim_non_active,153, 135, 97, 77); + rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as dopesheet above */ + rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77); rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77); rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 51e1b30f0bf..392aae1632d 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -431,7 +431,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) /* curRatio = height / width; */ /* UNUSED */ winRatio = winy / winx; - /* both sizes change (area/region maximised) */ + /* both sizes change (area/region maximized) */ if (do_x == do_y) { if (do_x && do_y) { /* here is 1,1 case, so all others must be 0,0 */ @@ -1328,6 +1328,54 @@ void UI_view2d_constant_grid_draw(View2D *v2d) glEnd(); } +/* Draw a multi-level grid in given 2d-region */ +void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totlevels) +{ + int offset = -10; + float lstep = step; + int level; + + for (level = 0; level < totlevels; ++level) { + int i; + float start; + + UI_ThemeColorShade(TH_BACK, offset); + + i = (v2d->cur.xmin >= 0.0f ? -(int)(-v2d->cur.xmin / lstep) : (int)(v2d->cur.xmin / lstep)); + start = i * lstep; + + glBegin(GL_LINES); + for (; start < v2d->cur.xmax; start += lstep, ++i) { + if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) + continue; + glVertex2f(start, v2d->cur.ymin); + glVertex2f(start, v2d->cur.ymax); + } + + i = (v2d->cur.ymin >= 0.0f ? -(int)(-v2d->cur.ymin / lstep) : (int)(v2d->cur.ymin / lstep)); + start = i * lstep; + + for (; start < v2d->cur.ymax; start += lstep, ++i) { + if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) + continue; + glVertex2f(v2d->cur.xmin, start); + glVertex2f(v2d->cur.xmax, start); + } + + /* X and Y axis */ + UI_ThemeColorShade(TH_BACK, offset - 8); + glVertex2f(0.0f, v2d->cur.ymin); + glVertex2f(0.0f, v2d->cur.ymax); + glVertex2f(v2d->cur.xmin, 0.0f); + glVertex2f(v2d->cur.xmax, 0.0f); + + glEnd(); + + lstep *= level_size; + offset -= 6; + } +} + /* the price we pay for not exposting structs :( */ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy) { diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt index 0c417c5dfb9..7db23041c88 100644 --- a/source/blender/editors/io/CMakeLists.txt +++ b/source/blender/editors/io/CMakeLists.txt @@ -31,6 +31,10 @@ set(INC ../../collada ) +set(INC_SYS + +) + set(SRC io_collada.c io_ops.c diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index dca38e53934..77808d0a00d 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/io/collada.c +/** \file blender/editors/io/io_collada.c * \ingroup collada */ #ifdef WITH_COLLADA @@ -157,59 +157,59 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) row = uiLayoutRow(box, 0); split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT); - col = uiLayoutColumn(split,0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split,0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE); uiLayoutSetEnabled(col, RNA_boolean_get(imfptr, "apply_modifiers")); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); // Texture options box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "active_uv_only", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); // Armature options box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); /* Collada options: */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); } @@ -276,7 +276,7 @@ void WM_OT_collada_export(wmOperatorType *ot) RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures", "Export textures assigned to the object Materials"); - RNA_def_boolean(ot->srna, "use_texture_copies", 1, "copy", + RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy", "Copy textures to same folder where the .dae file is exported"); diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h index 1e2c4443e43..4c04b349655 100644 --- a/source/blender/editors/io/io_ops.h +++ b/source/blender/editors/io/io_ops.h @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editor/io/io_collada.h +/** \file blender/editor/io/io_ops.h * \ingroup editor/io */ diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 83337a18223..f080b9f96e7 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -192,9 +192,9 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline, /* this could be split into its own loop */ if (draw_type == MASK_DT_OUTLINE) { - const unsigned char rgb_grey[4] = {0x60, 0x60, 0x60, 0xff}; + const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff}; glLineWidth(3); - glColor4ubv(rgb_grey); + glColor4ubv(rgb_gray); glBegin(GL_LINES); glVertex3fv(vert); glVertex3fv(handle); diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 6e0da5fd756..cce7e26115e 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -310,7 +310,8 @@ void ED_keymap_mask(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MASK_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); // WM_keymap_add_item(keymap, "MASK_OT_feather_weight_clear", SKEY, KM_PRESS, KM_ALT, 0); /* ... matches curve editmode */ - RNA_enum_set(WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", TFM_MASK_SHRINKFATTEN); + RNA_enum_set(WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0)->ptr, + "mode", TFM_MASK_SHRINKFATTEN); /* relationships */ WM_keymap_add_item(keymap, "MASK_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); @@ -329,13 +330,15 @@ void ED_operatormacros_mask(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("MASK_OT_add_vertex_slide", "Add Vertex and Slide", "Add new vertex and slide it", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("MASK_OT_add_vertex_slide", "Add Vertex and Slide", + "Add new vertex and slide it", OPTYPE_UNDO | OPTYPE_REGISTER); ot->description = "Add new vertex and slide it"; WM_operatortype_macro_define(ot, "MASK_OT_add_vertex"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(otmacro->ptr, "release_confirm", TRUE); - ot = WM_operatortype_append_macro("MASK_OT_add_feather_vertex_slide", "Add Feather Vertex and Slide", "Add new vertex to feater and slide it", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("MASK_OT_add_feather_vertex_slide", "Add Feather Vertex and Slide", + "Add new vertex to feather and slide it", OPTYPE_UNDO | OPTYPE_REGISTER); ot->description = "Add new feather vertex and slide it"; WM_operatortype_macro_define(ot, "MASK_OT_add_feather_vertex"); otmacro = WM_operatortype_macro_define(ot, "MASK_OT_slide_point"); diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index a619ac7e3cd..c5b9fc33a9b 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -229,7 +229,7 @@ void MASK_OT_shape_key_feather_reset(wmOperatorType *ot) { /* identifiers */ ot->name = "Feather Reset Animation"; - ot->description = "Resets fearther weights on all selected points animation values"; + ot->description = "Reset feather weights on all selected points animation values"; ot->idname = "MASK_OT_shape_key_feather_reset"; /* api callbacks */ @@ -394,7 +394,7 @@ void MASK_OT_shape_key_rekey(wmOperatorType *ot) { /* identifiers */ ot->name = "Re-Key Points of Selected Shapes"; - ot->description = "Recalculates animation data on selected points for frames selected in the dopesheet"; + ot->description = "Recalculate animation data on selected points for frames selected in the dopesheet"; ot->idname = "MASK_OT_shape_key_rekey"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 898399f723d..2ceb8aeef26 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2007,9 +2007,9 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) remerge_faces(kcd); /* delete left over faces */ - BMO_op_callf(bm, "del geom=%ff context=%i", DEL, DEL_ONLYFACES); - BMO_op_callf(bm, "del geom=%fe context=%i", DEL, DEL_EDGES); - BMO_op_callf(bm, "del geom=%fv context=%i", DEL, DEL_VERTS); + BMO_op_callf(bm, "delete geom=%ff context=%i", DEL, DEL_ONLYFACES); + BMO_op_callf(bm, "delete geom=%fe context=%i", DEL, DEL_EDGES); + BMO_op_callf(bm, "delete geom=%fv context=%i", DEL, DEL_VERTS); if (face_nets) MEM_freeN(face_nets); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 15e3033b7eb..eb2aabd88b8 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -313,10 +313,13 @@ static void ringsel_finish(bContext *C, wmOperator *op) edgering_sel(lcd, cuts, 1); if (lcd->do_cut) { + /* Enable gridfill, so that intersecting loopcut works as one would expect. + * Note though that it will break edgeslide in this specific case. + * See [#31939]. */ BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, 0.0f, 0.0f, 0.0f, cuts, - SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, FALSE, 0); + SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, TRUE, 0); /* force edge slide to edge select mode in in face select mode */ if (em->selectmode & SCE_SELECT_FACE) { @@ -336,7 +339,8 @@ static void ringsel_finish(bContext *C, wmOperator *op) DAG_id_tag_update(lcd->ob->data, 0); } else { - + /* XXX Is this piece of code ever used now? Simple loop select is now + * in editmesh_select.c (around line 1000)... */ /* sets as active, useful for other tools */ if (em->selectmode & SCE_SELECT_VERTEX) BM_select_history_store(em->bm, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */ diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 1bcd5cee111..f71ec56ca5f 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -347,7 +347,7 @@ static int edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op) { BMOperator bmop; - if (!EDBM_op_init(em, &bmop, op, "edgesplit edges=%he verts=%hv use_verts=%b", + if (!EDBM_op_init(em, &bmop, op, "split_edges edges=%he verts=%hv use_verts=%b", BM_ELEM_TAG, BM_ELEM_SELECT, TRUE)) { return FALSE; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 0ef62e536fa..5404eb3bea6 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -710,7 +710,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) float thresh = RNA_float_get(op->ptr, "threshold"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similarfaces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, "similar_faces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -748,7 +748,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) float thresh = RNA_float_get(op->ptr, "threshold"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similaredges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, "similar_edges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -789,7 +789,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) float thresh = RNA_float_get(op->ptr, "threshold"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similarverts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, "similar_verts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); /* execute the operator */ BMO_op_exec(em->bm, &bmop); diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index a86a274eb70..f08c229d38a 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -211,7 +211,7 @@ static void vtx_slide_confirm(bContext *C, wmOperator *op) if (other_d < vso->snap_threshold) { BM_vert_select_set(bm, other, TRUE); BM_vert_select_set(bm, vso->start_vtx, TRUE); - EDBM_op_callf(em, op, "pointmerge verts=%hv mergeco=%v", BM_ELEM_SELECT, other->co); + EDBM_op_callf(em, op, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, other->co); EDBM_flag_disable_all(em, BM_ELEM_SELECT); } else { @@ -687,7 +687,7 @@ static int edbm_vertex_slide_exec(bContext *C, wmOperator *op) /* Prepare operator */ if (!EDBM_op_init(em, &bmop, op, - "vertex_slide vert=%e edge=%hev distance_t=%f", + "slide_vert vert=%e edge=%hev distance_t=%f", start_vert, BM_ELEM_SELECT, distance_t)) { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0f7d4c5c547..0f13df4c777 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -172,7 +172,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes /* individual face extrude */ /* will use vertex normals for extrusion directions, so *nor is unaffected */ -static short edbm_extrude_face_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor)) +static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor)) { BMOIter siter; BMIter liter; @@ -180,7 +180,7 @@ static short edbm_extrude_face_indiv(BMEditMesh *em, wmOperator *op, const char BMLoop *l; BMOperator bmop; - EDBM_op_init(em, &bmop, op, "extrude_face_indiv faces=%hf", hflag); + EDBM_op_init(em, &bmop, op, "extrude_discrete_faces faces=%hf", hflag); /* deselect original verts */ EDBM_flag_disable_all(em, BM_ELEM_SELECT); @@ -473,7 +473,7 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe else if (nr == 1) transmode = edbm_extrude_edge(obedit, em, BM_ELEM_SELECT, nor); else if (nr == 4) transmode = edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor); else if (nr == 3) transmode = edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor); - else transmode = edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor); + else transmode = edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor); if (transmode == 0) { BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude"); @@ -614,7 +614,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); float nor[3]; - edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor); + edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor); EDBM_update_generic(C, em, TRUE); @@ -853,7 +853,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); mul_m4_v3(vc.obedit->imat, min); // back in object space - EDBM_op_init(vc.em, &bmop, op, "makevert co=%v", min); + EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", min); BMO_op_exec(vc.em->bm, &bmop); BMO_ITER (v1, &oiter, vc.em->bm, &bmop, "newvertout", BM_VERT) { @@ -912,24 +912,24 @@ static int edbm_delete_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); if (type == 0) { - if (!EDBM_op_callf(em, op, "del geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */ + if (!EDBM_op_callf(em, op, "delete geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */ return OPERATOR_CANCELLED; } else if (type == 1) { - if (!EDBM_op_callf(em, op, "del geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)) /* Erase Edges */ + if (!EDBM_op_callf(em, op, "delete geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)) /* Erase Edges */ return OPERATOR_CANCELLED; } else if (type == 2) { - if (!EDBM_op_callf(em, op, "del geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES)) /* Erase Faces */ + if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES)) /* Erase Faces */ return OPERATOR_CANCELLED; } else if (type == 3) { - if (!EDBM_op_callf(em, op, "del geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES)) /* Edges and Faces */ + if (!EDBM_op_callf(em, op, "delete geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES)) /* Edges and Faces */ return OPERATOR_CANCELLED; } else if (type == 4) { //"Erase Only Faces"; - if (!EDBM_op_callf(em, op, "del geom=%hf context=%i", + if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_ONLYFACES)) { return OPERATOR_CANCELLED; @@ -1197,7 +1197,7 @@ static int edbm_vert_connect(bContext *C, wmOperator *op) BMOperator bmop; int len = 0; - if (!EDBM_op_init(em, &bmop, op, "connectverts verts=%hv", BM_ELEM_SELECT)) { + if (!EDBM_op_init(em, &bmop, op, "connect_verts verts=%hv", BM_ELEM_SELECT)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &bmop); @@ -1234,7 +1234,7 @@ static int edbm_edge_split_exec(bContext *C, wmOperator *op) BMOperator bmop; int len = 0; - if (!EDBM_op_init(em, &bmop, op, "edgesplit edges=%he", BM_ELEM_SELECT)) { + if (!EDBM_op_init(em, &bmop, op, "split_edges edges=%he", BM_ELEM_SELECT)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &bmop); @@ -1271,7 +1271,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(ob); BMOperator bmop; - EDBM_op_init(em, &bmop, op, "dupe geom=%hvef", BM_ELEM_SELECT); + EDBM_op_init(em, &bmop, op, "duplicate geom=%hvef", BM_ELEM_SELECT); BMO_op_exec(em->bm, &bmop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); @@ -1318,7 +1318,7 @@ static int edbm_flip_normals_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - if (!EDBM_op_callf(em, op, "reversefaces faces=%hf", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, op, "reverse_faces faces=%hf", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; EDBM_update_generic(C, em, TRUE); @@ -1386,7 +1386,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_op_init(em, &bmop, op, "edgerotate edges=%he ccw=%b", BM_ELEM_TAG, do_ccw); + EDBM_op_init(em, &bmop, op, "rotate_edges edges=%he ccw=%b", BM_ELEM_TAG, do_ccw); /* avoids leaving old verts selected which can be a problem running multiple times, * since this means the edges become selected around the face which then attempt to rotate */ @@ -1490,11 +1490,11 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op) /* doflip has to do with bmesh_rationalize_normals, it's an internal * thing */ - if (!EDBM_op_callf(em, op, "righthandfaces faces=%hf do_flip=%b", BM_ELEM_SELECT, TRUE)) + if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf do_flip=%b", BM_ELEM_SELECT, TRUE)) return OPERATOR_CANCELLED; if (RNA_boolean_get(op->ptr, "inside")) - EDBM_op_callf(em, op, "reversefaces faces=%hf", BM_ELEM_SELECT); + EDBM_op_callf(em, op, "reverse_faces faces=%hf", BM_ELEM_SELECT); EDBM_update_generic(C, em, TRUE); @@ -1560,7 +1560,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) for (i = 0; i < repeat; i++) { if (!EDBM_op_callf(em, op, - "vertexsmooth verts=%hv mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b clipdist=%f", + "smooth_vert verts=%hv mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b clipdist=%f", BM_ELEM_SELECT, mirrx, mirry, mirrz, clipdist)) { return OPERATOR_CANCELLED; @@ -1678,7 +1678,7 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op) int dir = RNA_enum_get(op->ptr, "direction"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_rotateuvs faces=%hf dir=%i", BM_ELEM_SELECT, dir); + EDBM_op_init(em, &bmop, op, "rotate_uvs faces=%hf dir=%i", BM_ELEM_SELECT, dir); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1701,7 +1701,7 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op) BMOperator bmop; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_reverseuvs faces=%hf", BM_ELEM_SELECT); + EDBM_op_init(em, &bmop, op, "reverse_uvs faces=%hf", BM_ELEM_SELECT); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1727,7 +1727,7 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op) int dir = RNA_enum_get(op->ptr, "direction"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_rotatecolors faces=%hf dir=%i", BM_ELEM_SELECT, dir); + EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf dir=%i", BM_ELEM_SELECT, dir); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1752,7 +1752,7 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op) BMOperator bmop; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_reversecolors faces=%hf", BM_ELEM_SELECT); + EDBM_op_init(em, &bmop, op, "reverse_colors faces=%hf", BM_ELEM_SELECT); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1865,7 +1865,7 @@ static int merge_firstlast(BMEditMesh *em, int first, int uvmerge, wmOperator *w return OPERATOR_CANCELLED; } - if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv mergeco=%v", BM_ELEM_SELECT, mergevert->co)) + if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -1906,11 +1906,11 @@ static int merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, return OPERATOR_CANCELLED; if (uvmerge) { - if (!EDBM_op_callf(em, wmop, "vert_average_facedata verts=%hv", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; } - if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv mergeco=%v", BM_ELEM_SELECT, co)) + if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -2032,12 +2032,12 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) BMOperator bmop; int count; - EDBM_op_init(em, &bmop, op, "finddoubles verts=%hv dist=%f", BM_ELEM_SELECT, RNA_float_get(op->ptr, "mergedist")); + EDBM_op_init(em, &bmop, op, "find_doubles verts=%hv dist=%f", BM_ELEM_SELECT, RNA_float_get(op->ptr, "mergedist")); BMO_op_exec(em->bm, &bmop); count = BMO_slot_map_count(em->bm, &bmop, "targetmapout"); - if (!EDBM_op_callf(em, op, "weldverts targetmap=%s", &bmop, "targetmapout")) { + if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { BMO_op_finish(em->bm, &bmop); return OPERATOR_CANCELLED; } @@ -2109,7 +2109,7 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "vertexshortestpath startv=%e endv=%e type=%i", sv->ele, ev->ele, type); + EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", sv->ele, ev->ele, type); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -2714,7 +2714,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) BLI_ghash_insert(gh, bv, scr); } - if (!EDBM_op_init(em, &bmop, op, "esubd")) { + if (!EDBM_op_init(em, &bmop, op, "subdivide_edges")) { return OPERATOR_CANCELLED; } @@ -2819,8 +2819,8 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO ED_base_object_select(basenew, BA_DESELECT); - EDBM_op_callf(em, wmop, "dupe geom=%hvef dest=%p", BM_ELEM_SELECT, bm_new); - EDBM_op_callf(em, wmop, "del geom=%hvef context=%i", BM_ELEM_SELECT, DEL_FACES); + EDBM_op_callf(em, wmop, "duplicate geom=%hvef dest=%p", BM_ELEM_SELECT, bm_new); + EDBM_op_callf(em, wmop, "delete geom=%hvef context=%i", BM_ELEM_SELECT, DEL_FACES); /* clean up any loose edges */ BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { @@ -2831,7 +2831,7 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO BM_edge_select_set(em->bm, e, FALSE); } } - EDBM_op_callf(em, wmop, "del geom=%hvef context=%i", BM_ELEM_SELECT, DEL_EDGES); + EDBM_op_callf(em, wmop, "delete geom=%hvef context=%i", BM_ELEM_SELECT, DEL_EDGES); /* clean up any loose verts */ BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -2843,7 +2843,7 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO } } - EDBM_op_callf(em, wmop, "del geom=%hvef context=%i", BM_ELEM_SELECT, DEL_VERTS); + EDBM_op_callf(em, wmop, "delete geom=%hvef context=%i", BM_ELEM_SELECT, DEL_VERTS); BM_mesh_normals_update(bm_new, TRUE); @@ -2892,11 +2892,9 @@ static int mesh_separate_material(Main *bmain, Scene *scene, Base *editbase, wmO static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOperator *wmop) { int i; - BMVert *v; BMEdge *e; BMVert *v_seed; BMWalker walker; - BMIter iter; int result = FALSE; Object *obedit = editbase->object; BMEditMesh *em = BMEdit_FromObject(obedit); @@ -2913,11 +2911,7 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper * original mesh.*/ for (i = 0; i < max_iter; i++) { /* Get a seed vertex to start the walk */ - v_seed = NULL; - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - v_seed = v; - break; - } + v_seed = BM_iter_at_index(bm, BM_VERTS_OF_MESH, NULL, 0); /* No vertices available, can't do anything */ if (v_seed == NULL) { @@ -4187,11 +4181,11 @@ void MESH_OT_sort_elements(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { {SRT_VIEW_ZAXIS, "VIEW_ZAXIS", 0, "View Z Axis", - "Sort selected elements from farest to nearest one in current view"}, + "Sort selected elements from farthest to nearest one in current view"}, {SRT_VIEW_XAXIS, "VIEW_XAXIS", 0, "View X Axis", "Sort selected elements from left to right one in current view"}, {SRT_CURSOR_DISTANCE, "CURSOR_DISTANCE", 0, "Cursor Distance", - "Sort selected elements from nearest to farest from 3D cursor"}, + "Sort selected elements from nearest to farthest from 3D cursor"}, {SRT_MATERIAL, "MATERIAL", 0, "Material", "Sort selected elements from smallest to greatest material index (faces only!)"}, {SRT_SELECTED, "SELECTED", 0, "Selected", @@ -4966,7 +4960,7 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, FALSE); BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faces", BM_FACE, BM_ELEM_TAG, FALSE); - BMO_op_callf(em->bm, "del geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES); + BMO_op_callf(em->bm, "delete geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES); } BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); @@ -5032,7 +5026,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete unused vertices, edges, and faces */ if (RNA_boolean_get(op->ptr, "delete_unused")) { - if (!EDBM_op_callf(em, op, "del geom=%s context=%i", + if (!EDBM_op_callf(em, op, "delete geom=%s context=%i", &bmop, "unused_geom", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, TRUE); @@ -5042,7 +5036,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete hole edges/faces */ if (RNA_boolean_get(op->ptr, "make_holes")) { - if (!EDBM_op_callf(em, op, "del geom=%s context=%i", + if (!EDBM_op_callf(em, op, "delete geom=%s context=%i", &bmop, "holes_geom", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, TRUE); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index c3fbb2e8c16..4952dd3f09a 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -485,7 +485,7 @@ void EDBM_select_more(BMEditMesh *em) int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, - "regionextend geom=%hvef constrict=%b use_faces=%b", + "region_extend geom=%hvef constrict=%b use_faces=%b", BM_ELEM_SELECT, FALSE, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ @@ -501,7 +501,7 @@ void EDBM_select_less(BMEditMesh *em) int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, - "regionextend geom=%hvef constrict=%b use_faces=%b", + "region_extend geom=%hvef constrict=%b use_faces=%b", BM_ELEM_SELECT, TRUE, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 6d6165e2729..cdbf5751ea1 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -898,7 +898,7 @@ int mesh_mirrtopo_table(Object *ob, char mode) return 0; } -static int mesh_get_x_mirror_vert_spacial(Object *ob, int index) +static int mesh_get_x_mirror_vert_spatial(Object *ob, int index) { Mesh *me = ob->data; MVert *mvert; @@ -926,12 +926,12 @@ int mesh_get_x_mirror_vert(Object *ob, int index) return mesh_get_x_mirror_vert_topo(ob, index); } else { - return mesh_get_x_mirror_vert_spacial(ob, index); + return mesh_get_x_mirror_vert_spatial(ob, index); } return 0; } -static BMVert *editbmesh_get_x_mirror_vert_spacial(Object *ob, BMEditMesh *em, const float co[3]) +static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, const float co[3]) { float vec[3]; intptr_t poinval; @@ -989,7 +989,7 @@ BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *e return editbmesh_get_x_mirror_vert_topo(ob, em, eve, index); } else { - return editbmesh_get_x_mirror_vert_spacial(ob, em, co); + return editbmesh_get_x_mirror_vert_spatial(ob, em, co); } } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 7b7aaf5a3db..50d5569c483 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -228,7 +228,8 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of metaelems to select randomly", 0.0001f, 1.0f); + RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", + "Percentage of metaelements to select randomly", 0.0001f, 1.0f); } /***************************** Duplicate operator *****************************/ diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 810fe244984..e1c715952d1 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -616,13 +616,15 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) CLAMP(ss_lvl, 0, 6); - smd.levels = smd.renderLevels = ss_lvl; - smd.flags |= eSubsurfModifierFlag_SubsurfUv; + if (ss_lvl > 0) { + smd.levels = smd.renderLevels = ss_lvl; + smd.flags |= eSubsurfModifierFlag_SubsurfUv; - if (bkr->simple) - smd.subdivType = ME_SIMPLE_SUBSURF; + if (bkr->simple) + smd.subdivType = ME_SIMPLE_SUBSURF; - height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); + height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); + } } height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 48104c9274d..c9851c6a0db 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -237,7 +237,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *op) /* can be called with C == NULL */ static EnumPropertyItem *group_objects_remove_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { - Object *ob = ED_object_context(C); + Object *ob; EnumPropertyItem *item = NULL, item_tmp = {0}; int totitem = 0; @@ -245,6 +245,8 @@ static EnumPropertyItem *group_objects_remove_itemf(bContext *C, PointerRNA *UNU return DummyRNA_NULL_items; } + ob = ED_object_context(C); + /* check that the action exists */ if (ob) { Group *group = NULL; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index b3be18dfb9c..aab3d8afb22 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -176,7 +176,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* Return TRUE if the object has a modifier of type 'type' other than * the modifier pointed to be 'exclude', otherwise returns FALSE. */ static int object_has_modifier(const Object *ob, const ModifierData *exclude, - ModifierType type) + ModifierType type) { ModifierData *md; @@ -195,10 +195,10 @@ static int object_has_modifier(const Object *ob, const ModifierData *exclude, * * If the callback ever returns TRUE, iteration will stop and the * function value will be TRUE. Otherwise the function returns FALSE. -*/ + */ int ED_object_iter_other(Main *bmain, Object *orig_ob, int include_orig, - int (*callback)(Object *ob, void *callback_data), - void *callback_data) + int (*callback)(Object *ob, void *callback_data), + void *callback_data) { ID *ob_data_id = orig_ob->data; int users = ob_data_id->us; @@ -239,8 +239,8 @@ static int object_has_modifier_cb(Object *ob, void *data) } /* Use with ED_object_iter_other(). Sets the total number of levels - for any multires modifiers on the object to the int pointed to by - callback_data. */ + * for any multires modifiers on the object to the int pointed to by + * callback_data. */ int ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v) { ModifierData *md; @@ -257,16 +257,16 @@ int ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v) /* Return TRUE if no modifier of type 'type' other than 'exclude' */ static int object_modifier_safe_to_delete(Main *bmain, Object *ob, - ModifierData *exclude, - ModifierType type) + ModifierData *exclude, + ModifierType type) { return (!object_has_modifier(ob, exclude, type) && - !ED_object_iter_other(bmain, ob, FALSE, - object_has_modifier_cb, &type)); + !ED_object_iter_other(bmain, ob, FALSE, + object_has_modifier_cb, &type)); } static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, - int *sort_depsgraph) + int *sort_depsgraph) { ModifierData *obmd; @@ -844,19 +844,21 @@ static void edit_modifier_properties(wmOperatorType *ot) static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) { - PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier); ModifierData *md; - if (RNA_struct_property_is_set(op->ptr, "modifier")) - return 1; - - if (ptr.data) { - md = ptr.data; - RNA_string_set(op->ptr, "modifier", md->name); - return 1; + if (RNA_struct_property_is_set(op->ptr, "modifier")) { + return TRUE; } - - return 0; + else { + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier); + if (ptr.data) { + md = ptr.data; + RNA_string_set(op->ptr, "modifier", md->name); + return TRUE; + } + } + + return FALSE; } static ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) @@ -916,7 +918,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -955,7 +957,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -994,7 +996,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1042,7 +1044,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry"); edit_modifier_properties(ot); @@ -1085,7 +1087,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1124,7 +1126,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1173,7 +1175,7 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) ot->exec = multires_higher_levels_delete_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1218,7 +1220,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) ot->exec = multires_subdivide_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1282,7 +1284,7 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) ot->exec = multires_reshape_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1357,7 +1359,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->poll = multires_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; WM_operator_properties_filesel(ot, FOLDERFILE | BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); edit_modifier_properties(ot); @@ -1429,7 +1431,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) ot->exec = multires_base_apply_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1754,7 +1756,7 @@ static Object *modifier_skin_armature_create(struct Scene *scene, edges_visited = BLI_BITMAP_NEW(me->totedge, "edge_visited"); /* note: we use EditBones here, easier to set them up and use - * edit-armature functions to convert back to regular bones */ + * edit-armature functions to convert back to regular bones */ for (v = 0; v < me->totvert; v++) { if (mvert_skin[v].flag & MVERT_SKIN_ROOT) { EditBone *bone = NULL; @@ -1844,7 +1846,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot) ot->exec = skin_armature_create_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1939,7 +1941,7 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) ot->exec = meshdeform_bind_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1986,7 +1988,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) ot->exec = explode_refresh_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -2201,7 +2203,7 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot) ot->exec = ocean_bake_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); RNA_def_boolean(ot->srna, "free", FALSE, "Free", "Free the bake, rather than generating it"); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 89f018a1b76..3d3f4ef1260 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -270,7 +270,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) { if (nr == 1) { // XXX old animation system - //if (base->object->ipo==ipo) base->flag |= SELECT; + //if (base->object->ipo == ipo) base->flag |= SELECT; //changed = 1; } else if (nr == 2) { diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index b31e5c0aea3..2e58fa85a11 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -567,11 +567,14 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) if (deform) { fsmesh.channelSizeVertices = length; fsmesh.channelVertices = fobj->VertexCache; - - // remove channels + + /* remove channels */ fsmesh.channelTranslation = fsmesh.channelRotation = - fsmesh.channelScale = NULL; + fsmesh.channelScale = NULL; + + /* Override user settings, only noslip is supported here! */ + fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; } elbeemAddMesh(&fsmesh); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index de3d2d4e871..d37a16cb1bb 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -518,7 +518,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock); if (ibuf) { - /* color -> greyscale */ + /* color -> grayscale */ /* editing directly would alter the render view */ if (scene->r.im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw = IMB_dupImBuf(ibuf); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 3533a337aa1..a638aac9423 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -862,7 +862,7 @@ static void draw_join_shape(ScrArea *sa, char dir) draw_horizontal_join_shape(sa, dir); } -/* draw screen area darker with arrow (visualisation of future joining) */ +/* draw screen area darker with arrow (visualization of future joining) */ static void scrarea_draw_shape_dark(ScrArea *sa, char dir) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index cacd6d01291..6be276dea14 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -458,7 +458,7 @@ int ED_operator_editmball(bContext *C) int ED_operator_mask(bContext *C) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); return ED_space_clip_check_show_maskedit(sc); } @@ -2826,7 +2826,7 @@ static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *U uiItemS(layout); - /* file browser should be fullscreen all the time, but other regions can be maximised/restored... */ + /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */ if (sa->spacetype != SPACE_FILE) { if (sa->full) uiItemO(layout, "Tile Area", ICON_NONE, "SCREEN_OT_screen_full_area"); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a1ade77d068..6a8f7db5fc9 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4935,7 +4935,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) if (BKE_brush_size_get(scene, brush) < 2) BKE_brush_size_set(scene, brush, 2); - /* allocate and initialize spacial data structures */ + /* allocate and initialize spatial data structures */ project_paint_begin(&pop->ps); if (pop->ps.dm == NULL) @@ -5728,7 +5728,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name, image_undo_restore, image_undo_free); - /* allocate and initialize spacial data structures */ + /* allocate and initialize spatial data structures */ project_paint_begin(&ps); if (ps.dm == NULL) { diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 3c37ad8cf2a..1b62ba8a7e0 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3045,7 +3045,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) void PAINT_OT_weight_from_bones(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { - {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights froms bones"}, + {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights from bones"}, {ARM_GROUPS_ENVELOPE, "ENVELOPES", 0, "From Envelopes", "Weights from envelopes with user defined radius"}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index e6c061a06ec..bfac2922c2b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3145,40 +3145,46 @@ static const char *sculpt_tool_name(Sculpt *sd) { Brush *brush = paint_brush(&sd->paint); - switch (brush->sculpt_tool) { + switch ((BrushSculptTool)brush->sculpt_tool) { case SCULPT_TOOL_DRAW: - return "Draw Brush"; break; + return "Draw Brush"; case SCULPT_TOOL_SMOOTH: - return "Smooth Brush"; break; + return "Smooth Brush"; case SCULPT_TOOL_CREASE: - return "Crease Brush"; break; + return "Crease Brush"; case SCULPT_TOOL_BLOB: - return "Blob Brush"; break; + return "Blob Brush"; case SCULPT_TOOL_PINCH: - return "Pinch Brush"; break; + return "Pinch Brush"; case SCULPT_TOOL_INFLATE: - return "Inflate Brush"; break; + return "Inflate Brush"; case SCULPT_TOOL_GRAB: - return "Grab Brush"; break; + return "Grab Brush"; case SCULPT_TOOL_NUDGE: - return "Nudge Brush"; break; + return "Nudge Brush"; case SCULPT_TOOL_THUMB: - return "Thumb Brush"; break; + return "Thumb Brush"; case SCULPT_TOOL_LAYER: - return "Layer Brush"; break; + return "Layer Brush"; case SCULPT_TOOL_FLATTEN: - return "Flatten Brush"; break; + return "Flatten Brush"; case SCULPT_TOOL_CLAY: - return "Clay Brush"; break; + return "Clay Brush"; case SCULPT_TOOL_CLAY_STRIPS: - return "Clay Strips Brush"; break; + return "Clay Strips Brush"; case SCULPT_TOOL_FILL: - return "Fill Brush"; break; + return "Fill Brush"; case SCULPT_TOOL_SCRAPE: - return "Scrape Brush"; break; - default: - return "Sculpting"; break; + return "Scrape Brush"; + case SCULPT_TOOL_SNAKE_HOOK: + return "Snake Hook Brush"; + case SCULPT_TOOL_ROTATE: + return "Rotate Brush"; + case SCULPT_TOOL_MASK: + return "Mask Brush"; } + + return "Sculpting"; } /** @@ -3639,8 +3645,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, } /* Returns true iff any of the smoothing modes are active (currently - one of smooth brush, autosmooth, mask smooth, or shift-key - smooth) */ + * one of smooth brush, autosmooth, mask smooth, or shift-key + * smooth) */ static int sculpt_any_smooth_mode(const Brush *brush, StrokeCache *cache, int stroke_mode) diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index e76edcf0290..9d1f52568b4 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -654,7 +654,7 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", - "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); + "Cursor location in normalized (0.0-1.0) coordinates", -10.0f, 10.0f); } /********************** view zoom ratio operator *********************/ diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 3ad6614d356..a07a560328c 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -91,7 +91,7 @@ int file_directory_exec(bContext *C, struct wmOperator *unused); int file_directory_new_exec(bContext *C, struct wmOperator *unused); int file_delete_exec(bContext *C, struct wmOperator *unused); -int file_hilight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my); +int file_highlight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my); void file_sfile_to_operator(struct wmOperator *op, struct SpaceFile *sfile, char *filepath); void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 0cf3586e659..2d778b94216 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -515,7 +515,7 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000); } -int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) +int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { View2D *v2d = &ar->v2d; FileSelectParams *params; @@ -555,7 +555,7 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *e ARegion *ar = CTX_wm_region(C); SpaceFile *sfile = CTX_wm_space_file(C); - if (!file_hilight_set(sfile, ar, event->x, event->y)) + if (!file_highlight_set(sfile, ar, event->x, event->y)) return OPERATOR_CANCELLED; ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 79979603f54..95d5483b42c 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -356,7 +356,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* on first read, find active file */ if (params->active_file == -1) { wmEvent *event = CTX_wm_window(C)->eventstate; - file_hilight_set(sfile, ar, event->x, event->y); + file_highlight_set(sfile, ar, event->x, event->y); } file_draw_list(C, ar); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index ddca0030cf5..870e9bb8168 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -276,7 +276,7 @@ static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short View2D *v2d = &ar->v2d; /* only draw points if curve is visible - * - draw unselected points before selected points as separate passes to minimise color-changing overhead + * - draw unselected points before selected points as separate passes to minimize color-changing overhead * (XXX dunno if this is faster than drawing all in one pass though) * and also to make sure in the case of overlapping points that the selected is always visible * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) @@ -851,7 +851,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid setlinestyle(2); } if ( ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) || (fcu->flag & FCURVE_MUTED) ) { - /* muted curves are drawn in a greyish hue */ + /* muted curves are drawn in a grayish hue */ // XXX should we have some variations? UI_ThemeColorShade(TH_HEADER, 50); } diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 756e6997fc8..f4cb4ec3d05 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -189,6 +189,8 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... } + /* force immediate init of any invalid F-Curve colors */ + sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); } @@ -477,7 +479,13 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) if (wmn->data == ND_SPACE_GRAPH) ED_area_tag_redraw(sa); break; - + case NC_WINDOW: + if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) { + /* force redraw/refresh after undo/redo - prevents "black curve" problem */ + ED_area_tag_refresh(sa); + } + break; + // XXX: restore the case below if not enough updates occur... //default: // if (wmn->data==ND_KEYS) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index aa596b8b635..92c339d7672 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -148,7 +148,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, /* the frame number, even if we cant */ if (ima->source == IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ - const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL); ofs += sprintf(str + ofs, IFACE_(", Frame: %d"), framenr); } diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 080f12bf35b..33a2d5c18c5 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -340,7 +340,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm ReportTimerInfo *rti; float progress = 0.0, color_progress = 0.0; float neutral_col[3] = {0.35, 0.35, 0.35}; - float neutral_grey = 0.6; + float neutral_gray = 0.6; float timeout = 0.0, color_timeout = 0.0; int send_note = 0; @@ -385,7 +385,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm rti->col[1] = 0.45; rti->col[2] = 0.7; } - rti->greyscale = 0.75; + rti->grayscale = 0.75; rti->widthfac = 1.0; } @@ -398,7 +398,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm /* fade colors out sharply according to progress through fade-out duration */ interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress); - rti->greyscale = interpf(neutral_grey, rti->greyscale, color_progress); + rti->grayscale = interpf(neutral_gray, rti->grayscale, color_progress); } /* collapse report at end of timeout */ diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 7eb0f676707..92f014fd804 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -89,7 +89,7 @@ static void nla_action_get_color(AnimData *adt, bAction *act, float color[4]) UI_GetThemeColor4fv(TH_ANIM_ACTIVE, color); } else { - /* greyish-red color */ + /* grayish-red color */ UI_GetThemeColor4fv(TH_ANIM_INACTIVE, color); } } @@ -217,7 +217,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) { const float yheight = ymaxc - yminc; - /* drawing color is simply a light-grey */ + /* drawing color is simply a light-gray */ // TODO: is this color suitable? // XXX nasty hacked color for now... which looks quite bad too... glColor3f(0.7f, 0.7f, 0.7f); @@ -480,7 +480,7 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float UNUSED(yminc), float ymaxc) { const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */ - const char col[4] = {220, 220, 220, 255}; /* light grey */ + const char col[4] = {220, 220, 220, 255}; /* light gray */ char numstr[32] = ""; @@ -551,7 +551,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw each strip in the track (if visible) */ for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) { if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) { - /* draw the visualisation of the strip */ + /* draw the visualization of the strip */ nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); /* add the text for this strip to the cache */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 69f2867535a..daab0ce0f5f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1194,7 +1194,7 @@ static void node_common_set_butfunc(bNodeType *ntype) /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */ -static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imaptr, PointerRNA *iuserptr) +static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, PointerRNA *imaptr, PointerRNA *iuserptr) { uiLayout *col; int source; @@ -1213,25 +1213,24 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap Scene *scene = CTX_data_scene(C); ImageUser *iuser = iuserptr->data; char numstr[32]; - const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL); BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr); uiItemL(layout, numstr, ICON_NONE); } if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { col = uiLayoutColumn(layout, TRUE); - uiItemR(col, iuserptr, "frame_duration", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "frame_offset", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "use_cyclic", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); } col = uiLayoutColumn(layout, FALSE); if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER) - uiItemR(col, iuserptr, "layer", 0, NULL, ICON_NONE); - + uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE); } static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1311,7 +1310,10 @@ static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + /* note: image user properties used directly here, unlike compositor image node, + * which redefines them in the node struct RNA to get proper updates. + */ + node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr); } static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1323,7 +1325,7 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); uiItemR(layout, ptr, "projection", 0, "", ICON_NONE); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr); } static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1456,7 +1458,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * imaptr = RNA_pointer_get(ptr, "image"); RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr); } static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -3352,3 +3354,28 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3); // node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3); } + +void drawnodesnap(View2D *v2d, const float cent[2], float size, NodeBorder border) +{ + glBegin(GL_LINES); + + if (border & (NODE_LEFT | NODE_RIGHT)) { + glVertex2f(cent[0], v2d->cur.ymin); + glVertex2f(cent[0], v2d->cur.ymax); + } + else { + glVertex2f(cent[0], cent[1] - size); + glVertex2f(cent[0], cent[1] + size); + } + + if (border & (NODE_TOP | NODE_BOTTOM)) { + glVertex2f(v2d->cur.xmin, cent[1]); + glVertex2f(v2d->cur.xmax, cent[1]); + } + else { + glVertex2f(cent[0] - size, cent[1]); + glVertex2f(cent[0] + size, cent[1]); + } + + glEnd(); +} diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c65bbd6e15f..65646c855b7 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -65,6 +65,7 @@ #include "ED_node.h" #include "ED_gpencil.h" +#include "ED_space_api.h" #include "UI_interface.h" #include "UI_interface_icons.h" @@ -723,6 +724,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); + if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { + if (node->highlight) { + UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); + node->highlight = 0; + } + } uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); @@ -804,7 +811,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN glDisable(GL_BLEND); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -861,7 +868,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN node->block= NULL; } -static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNode *node) +static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { bNodeSocket *sock; rctf *rct= &node->totr; @@ -878,10 +885,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColor(color_id); if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); + + if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { + if (node->highlight) { + UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); + node->highlight = 0; + } + } + uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1004,7 +1019,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode) void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { if (node->flag & NODE_HIDDEN) - node_draw_hidden(C, ar, snode, node); + node_draw_hidden(C, ar, snode, ntree, node); else node_draw_basis(C, ar, snode, ntree, node); } @@ -1087,6 +1102,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) //uiFreeBlocksWin(&sa->uiblocks, sa->win); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); + /* only set once */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_MAP1_VERTEX_3); @@ -1095,7 +1112,9 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) snode->aspect= (v2d->cur.xmax - v2d->cur.xmin)/((float)ar->winx); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); - UI_view2d_constant_grid_draw(v2d); + /* grid */ + UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2); + /* backdrop */ draw_nodespace_back_pix(ar, snode, color_manage); @@ -1137,6 +1156,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + /* draw grease-pencil ('canvas' strokes) */ if (snode->nodetree) draw_gpencil_view2d(C, 1); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 48f772e8008..9a6906c43bc 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1643,7 +1643,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "Background Image Zoom"; ot->idname = "NODE_OT_backimage_zoom"; - ot->description = "Zoom in/out the brackground image"; + ot->description = "Zoom in/out the background image"; /* api callbacks */ ot->exec = backimage_zoom; diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index bf0e539efe7..f12c7941e1d 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -68,11 +68,11 @@ static void node_tag_recursive(bNode *node) bNodeSocket *input; if (!node || (node->flag & NODE_TEST)) - return; /* in case of cycles */ - + return; /* in case of cycles */ + node->flag |= NODE_TEST; - for (input=node->inputs.first; input; input=input->next) + for (input = node->inputs.first; input; input = input->next) if (input->link) node_tag_recursive(input->link->fromnode); } @@ -82,11 +82,11 @@ static void node_clear_recursive(bNode *node) bNodeSocket *input; if (!node || !(node->flag & NODE_TEST)) - return; /* in case of cycles */ - + return; /* in case of cycles */ + node->flag &= ~NODE_TEST; - for (input=node->inputs.first; input; input=input->next) + for (input = node->inputs.first; input; input = input->next) if (input->link) node_clear_recursive(input->link->fromnode); } @@ -100,20 +100,20 @@ static void node_remove_linked(bNodeTree *ntree, bNode *rem_node) return; /* tag linked nodes to be removed */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; - + node_tag_recursive(rem_node); /* clear tags on nodes that are still used by other nodes */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) if (!(node->flag & NODE_TEST)) - for (sock=node->inputs.first; sock; sock=sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->link && sock->link->fromnode != rem_node) node_clear_recursive(sock->link->fromnode); /* remove nodes */ - for (node=ntree->nodes.first; node; node=next) { + for (node = ntree->nodes.first; node; node = next) { next = node->next; if (node->flag & NODE_TEST) { @@ -166,7 +166,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t } /* find existing node that we can use */ - for (node_from=ntree->nodes.first; node_from; node_from=node_from->next) + for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) if (node_from->type == ntemp->type) break; @@ -181,7 +181,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t node_from = node_prev; } else if (!node_from) { - node_from= nodeAddNode(ntree, ntemp); + node_from = nodeAddNode(ntree, ntemp); node_from->locx = node_to->locx - (node_from->typeinfo->width + 50); node_from->locy = node_to->locy; @@ -199,11 +199,11 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t if (node_prev && node_from != node_prev) { bNodeSocket *sock_prev, *sock_from; - for (sock_prev=node_prev->inputs.first; sock_prev; sock_prev=sock_prev->next) { - for (sock_from=node_from->inputs.first; sock_from; sock_from=sock_from->next) { + for (sock_prev = node_prev->inputs.first; sock_prev; sock_prev = sock_prev->next) { + for (sock_from = node_from->inputs.first; sock_from; sock_from = sock_from->next) { if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit) continue; - + if (strcmp(sock_prev->name, sock_from->name) == 0 && sock_prev->type == sock_from->type) { bNodeLink *link = sock_prev->link; @@ -239,9 +239,9 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t /****************************** Node Link Menu *******************************/ -#define UI_NODE_LINK_ADD 0 -#define UI_NODE_LINK_DISCONNECT -1 -#define UI_NODE_LINK_REMOVE -2 +#define UI_NODE_LINK_ADD 0 +#define UI_NODE_LINK_DISCONNECT -1 +#define UI_NODE_LINK_REMOVE -2 typedef struct NodeLinkArg { Main *bmain; @@ -259,7 +259,7 @@ typedef struct NodeLinkArg { static void ui_node_link(bContext *C, void *arg_p, void *event_p) { - NodeLinkArg *arg = (NodeLinkArg*)arg_p; + NodeLinkArg *arg = (NodeLinkArg *)arg_p; Main *bmain = arg->bmain; bNode *node_to = arg->node; bNodeSocket *sock_to = arg->sock; @@ -278,7 +278,7 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p) node_socket_remove(bmain, ntree, node_to, sock_to); else node_socket_add_replace(bmain, ntree, node_to, sock_to, &ntemp, arg->output); - + ED_undo_push(C, "Node input modify"); } @@ -290,7 +290,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) if (node->type == NODE_GROUP) { if (node->id) - BLI_strncpy(node_name, node->id->name+2, UI_MAX_NAME_STR); + BLI_strncpy(node_name, node->id->name + 2, UI_MAX_NAME_STR); else BLI_strncpy(node_name, N_("Group"), UI_MAX_NAME_STR); } @@ -331,17 +331,17 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) bNodeTree *ngroup; NodeLinkArg *argN; int first = 1; - int compatibility= 0; + int compatibility = 0; if (ntree->type == NTREE_SHADER) { if (BKE_scene_use_new_shading_nodes(arg->scene)) - compatibility= NODE_NEW_SHADING; + compatibility = NODE_NEW_SHADING; else - compatibility= NODE_OLD_SHADING; + compatibility = NODE_OLD_SHADING; } if (nclass == NODE_CLASS_GROUP) { - for (ngroup=bmain->nodetree.first; ngroup; ngroup=ngroup->id.next) { + for (ngroup = bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) { bNodeSocket *gsock; char name[UI_MAX_NAME_STR]; int i, j, num = 0; @@ -349,11 +349,11 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (ngroup->type != ntree->type) continue; - for (gsock=ngroup->inputs.first; gsock; gsock=gsock->next) + for (gsock = ngroup->inputs.first; gsock; gsock = gsock->next) if (ui_compatible_sockets(gsock->type, sock->type)) num++; - for (i=0, j=0, gsock=ngroup->outputs.first; gsock; gsock=gsock->next, i++) { + for (i = 0, j = 0, gsock = ngroup->outputs.first; gsock; gsock = gsock->next, i++) { if (!ui_compatible_sockets(gsock->type, sock->type)) continue; @@ -362,27 +362,27 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; first = 0; } if (num > 1) { if (j == 0) { - uiItemL(column, ngroup->id.name+2, ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + uiItemL(column, ngroup->id.name + 2, ICON_NODE); + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } BLI_snprintf(name, UI_MAX_NAME_STR, " %s", gsock->name); j++; } else - BLI_strncpy(name, ngroup->id.name+2, UI_MAX_NAME_STR); + BLI_strncpy(name, ngroup->id.name + 2, UI_MAX_NAME_STR); - but = uiDefBut(block, BUT, 0, ngroup->id.name+2, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); + but = uiDefBut(block, BUT, 0, ngroup->id.name + 2, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); argN = MEM_dupallocN(arg); argN->type = NODE_GROUP; @@ -393,9 +393,9 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) } } else { - bNodeTreeType *ttype= ntreeGetType(ntree->type); + bNodeTreeType *ttype = ntreeGetType(ntree->type); - for (ntype=ttype->node_types.first; ntype; ntype=ntype->next) { + for (ntype = ttype->node_types.first; ntype; ntype = ntype->next) { bNodeSocketTemplate *stemp; char name[UI_MAX_NAME_STR]; int i, j, num = 0; @@ -406,11 +406,11 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (ntype->nclass != nclass) continue; - for (i=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) + for (i = 0, stemp = ntype->outputs; stemp && stemp->type != -1; stemp++, i++) if (ui_compatible_sockets(stemp->type, sock->type)) num++; - for (i=0, j=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { + for (i = 0, j = 0, stemp = ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { if (!ui_compatible_sockets(stemp->type, sock->type)) continue; @@ -419,8 +419,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; first = 0; } @@ -428,8 +428,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (num > 1) { if (j == 0) { uiItemL(column, IFACE_(ntype->name), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } BLI_snprintf(name, UI_MAX_NAME_STR, " %s", IFACE_(stemp->name)); @@ -438,8 +438,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) else BLI_strncpy(name, IFACE_(ntype->name), UI_MAX_NAME_STR); - but = uiDefBut(block, BUT, 0, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); + but = uiDefBut(block, BUT, 0, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); argN = MEM_dupallocN(arg); argN->type = ntype->type; @@ -452,7 +452,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *name) { - NodeLinkArg *arg = (NodeLinkArg*)calldata; + NodeLinkArg *arg = (NodeLinkArg *)calldata; if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT)) ui_node_menu_column(arg, nclass, name); @@ -460,22 +460,22 @@ static void node_menu_column_foreach_cb(void *calldata, int nclass, const char * static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); uiBlock *block = uiLayoutGetBlock(layout); - uiBut *but = (uiBut*)but_p; + uiBut *but = (uiBut *)but_p; uiLayout *split, *column; - NodeLinkArg *arg = (NodeLinkArg*)but->func_argN; + NodeLinkArg *arg = (NodeLinkArg *)but->func_argN; bNodeSocket *sock = arg->sock; - bNodeTreeType *ntreetype= ntreeGetType(arg->ntree->type); + bNodeTreeType *ntreetype = ntreeGetType(arg->ntree->type); uiBlockSetCurLayout(block, layout); split = uiLayoutSplit(layout, 0.0f, FALSE); - arg->bmain= bmain; - arg->scene= scene; - arg->layout= split; - + arg->bmain = bmain; + arg->scene = scene; + arg->layout = split; + if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); @@ -484,15 +484,15 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ if (sock->link) { uiItemL(column, IFACE_("Link"), ICON_NONE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; - but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); + but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_REMOVE)); - but = uiDefBut(block, BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); + but = uiDefBut(block, BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_DISCONNECT)); } @@ -517,14 +517,14 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { char name[UI_MAX_NAME_STR]; ui_node_sock_name(sock, name); - but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); + but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } else but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); - but->type= MENU; - but->flag |= UI_TEXT_LEFT|UI_BUT_NODE_LINK; - but->poin= (char*)but; + but->type = MENU; + but->flag |= UI_TEXT_LEFT | UI_BUT_NODE_LINK; + but->poin = (char *)but; but->func_argN = arg; if (sock->link && sock->link->fromnode) @@ -535,7 +535,7 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo /**************************** Node Tree Layout *******************************/ static void ui_node_draw_input(uiLayout *layout, bContext *C, - bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth); + bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth); static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, int depth) { @@ -555,8 +555,8 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b } } - for (input=node->inputs.first; input; input=input->next) - ui_node_draw_input(layout, C, ntree, node, input, depth+1); + for (input = node->inputs.first; input; input = input->next) + ui_node_draw_input(layout, C, ntree, node, input, depth + 1); } static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth) @@ -567,7 +567,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiLayout *split, *row, *col; bNode *lnode; char label[UI_MAX_NAME_STR]; - int indent = (depth > 1)? 2*(depth - 1): 0; + int indent = (depth > 1) ? 2 * (depth - 1) : 0; int dependency_loop; if (input->flag & SOCK_UNAVAIL) @@ -575,7 +575,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, /* to avoid eternal loops on cyclic dependencies */ node->flag |= NODE_TEST; - lnode = (input->link)? input->link->fromnode: NULL; + lnode = (input->link) ? input->link->fromnode : NULL; dependency_loop = (lnode && (lnode->flag & NODE_TEST)); if (dependency_loop) @@ -598,21 +598,21 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiBlockSetEmboss(block, UI_EMBOSSN); if (lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) { - int icon = (input->flag & SOCK_COLLAPSED)? ICON_DISCLOSURE_TRI_RIGHT: ICON_DISCLOSURE_TRI_DOWN; + int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); } else uiItemL(row, "", ICON_BLANK1); bt = block->buttons.last; - bt->x2 = UI_UNIT_X/2; + bt->x2 = UI_UNIT_X / 2; uiBlockSetEmboss(block, UI_EMBOSS); } uiItemL(row, label, ICON_NONE); - bt= block->buttons.last; - bt->flag= UI_TEXT_LEFT; + bt = block->buttons.last; + bt->flag = UI_TEXT_LEFT; if (dependency_loop) { row = uiLayoutRow(split, FALSE); @@ -661,7 +661,7 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode * return; /* clear for cycle check */ - for (tnode=ntree->nodes.first; tnode; tnode=tnode->next) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) tnode->flag &= ~NODE_TEST; if (input) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index e069ba2a5fc..349259ad71b 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** @@ -63,7 +63,7 @@ #include "RNA_access.h" -#include "node_intern.h" // own include +#include "node_intern.h" // own include /* ******************** manage regions ********************* */ @@ -71,23 +71,23 @@ ARegion *node_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if (ar==NULL) return NULL; - - arnew= MEM_callocN(sizeof(ARegion), "buttons for node"); - + if (ar == NULL) return NULL; + + arnew = MEM_callocN(sizeof(ARegion), "buttons for node"); + BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; - + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -97,64 +97,64 @@ static SpaceLink *node_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceNode *snode; - - snode= MEM_callocN(sizeof(SpaceNode), "initnode"); - snode->spacetype= SPACE_NODE; - + + snode = MEM_callocN(sizeof(SpaceNode), "initnode"); + snode->spacetype = SPACE_NODE; + /* backdrop */ snode->zoom = 1.0f; - + /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for node"); - + ar = MEM_callocN(sizeof(ARegion), "header for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; - + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; + /* buttons/list view */ - ar= MEM_callocN(sizeof(ARegion), "buttons for node"); - + ar = MEM_callocN(sizeof(ARegion), "buttons for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for node"); - + ar = MEM_callocN(sizeof(ARegion), "main area for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; - + ar->regiontype = RGN_TYPE_WINDOW; + ar->v2d.tot.xmin = -256.0f; ar->v2d.tot.ymin = -256.0f; ar->v2d.tot.xmax = 768.0f; ar->v2d.tot.ymax = 768.0f; - + ar->v2d.cur.xmin = -256.0f; ar->v2d.cur.ymin = -256.0f; ar->v2d.cur.xmax = 768.0f; ar->v2d.cur.ymax = 768.0f; - - ar->v2d.min[0]= 1.0f; - ar->v2d.min[1]= 1.0f; - - ar->v2d.max[0]= 32000.0f; - ar->v2d.max[1]= 32000.0f; - - ar->v2d.minzoom= 0.09f; - ar->v2d.maxzoom= 2.31f; - - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT; - ar->v2d.keeptot= 0; - + + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 1.0f; + + ar->v2d.max[0] = 32000.0f; + ar->v2d.max[1] = 32000.0f; + + ar->v2d.minzoom = 0.09f; + ar->v2d.maxzoom = 2.31f; + + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT; + ar->v2d.keeptot = 0; + return (SpaceLink *)snode; } /* not spacelink itself */ static void node_free(SpaceLink *UNUSED(sl)) -{ - +{ + } @@ -167,10 +167,10 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static void node_area_listener(ScrArea *sa, wmNotifier *wmn) { /* note, ED_area_tag_refresh will re-execute compositor */ - SpaceNode *snode= sa->spacedata.first; - int type= snode->treetype; + SpaceNode *snode = sa->spacedata.first; + int type = snode->treetype; short shader_type = snode->shaderfrom; - + /* preview renders */ switch (wmn->category) { case NC_SCENE: @@ -183,9 +183,9 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); break; case ND_TRANSFORM_DONE: - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { if (snode->flag & SNODE_AUTO_RENDER) { - snode->recalc= 1; + snode->recalc = 1; ED_area_tag_refresh(sa); } } @@ -193,43 +193,43 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_WM: - if (wmn->data==ND_FILEREAD) + if (wmn->data == ND_FILEREAD) ED_area_tag_refresh(sa); break; - + /* future: add ID checks? */ case NC_MATERIAL: - if (type==NTREE_SHADER) { - if (wmn->data==ND_SHADING) + if (type == NTREE_SHADER) { + if (wmn->data == ND_SHADING) ED_area_tag_refresh(sa); - else if (wmn->data==ND_SHADING_DRAW) + else if (wmn->data == ND_SHADING_DRAW) ED_area_tag_refresh(sa); - else if (wmn->action==NA_ADDED && snode->edittree) + else if (wmn->action == NA_ADDED && snode->edittree) nodeSetActiveID(snode->edittree, ID_MA, wmn->reference); - + } break; case NC_TEXTURE: - if (type==NTREE_SHADER || type==NTREE_TEXTURE) { - if (wmn->data==ND_NODES) + if (type == NTREE_SHADER || type == NTREE_TEXTURE) { + if (wmn->data == ND_NODES) ED_area_tag_refresh(sa); } break; case NC_WORLD: - if (type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) { - ED_area_tag_refresh(sa); + if (type == NTREE_SHADER && shader_type == SNODE_SHADER_WORLD) { + ED_area_tag_refresh(sa); } break; case NC_OBJECT: - if (type==NTREE_SHADER) { - if (wmn->data==ND_OB_SHADING) + if (type == NTREE_SHADER) { + if (wmn->data == ND_OB_SHADING) ED_area_tag_refresh(sa); } break; case NC_SPACE: - if (wmn->data==ND_SPACE_NODE) + if (wmn->data == ND_SPACE_NODE) ED_area_tag_refresh(sa); - else if (wmn->data==ND_SPACE_NODE_VIEW) + else if (wmn->data == ND_SPACE_NODE_VIEW) ED_area_tag_redraw(sa); break; case NC_NODE: @@ -247,7 +247,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_MASK: if (wmn->action == NA_EDITED) { - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { ED_area_tag_refresh(sa); } } @@ -255,7 +255,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) case NC_IMAGE: if (wmn->action == NA_EDITED) { - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { /* note that nodeUpdateID is already called by BKE_image_signal() on all * scenes so really this is just to know if the images is used in the compo else * painting on images could become very slow when the compositor is open. */ @@ -270,42 +270,42 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) { /* default now: refresh node is starting preview */ - SpaceNode *snode= sa->spacedata.first; + SpaceNode *snode = sa->spacedata.first; snode_set_context(snode, CTX_data_scene(C)); - + if (snode->nodetree) { - if (snode->treetype==NTREE_SHADER) { + if (snode->treetype == NTREE_SHADER) { if (GS(snode->id->name) == ID_MA) { - Material *ma= (Material *)snode->id; + Material *ma = (Material *)snode->id; if (ma->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } else if (GS(snode->id->name) == ID_LA) { - Lamp *la= (Lamp *)snode->id; + Lamp *la = (Lamp *)snode->id; if (la->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } else if (GS(snode->id->name) == ID_WO) { - World *wo= (World *)snode->id; + World *wo = (World *)snode->id; if (wo->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } - else if (snode->treetype==NTREE_COMPOSIT) { - Scene *scene= (Scene *)snode->id; + else if (snode->treetype == NTREE_COMPOSIT) { + Scene *scene = (Scene *)snode->id; if (scene->use_nodes) { /* recalc is set on 3d view changes for auto compo */ if (snode->recalc) { - snode->recalc= 0; - node_render_changed_exec((struct bContext*)C, NULL); + snode->recalc = 0; + node_render_changed_exec((struct bContext *)C, NULL); } - else + else snode_composite_job(C, sa); } } - else if (snode->treetype==NTREE_TEXTURE) { - Tex *tex= (Tex *)snode->id; + else if (snode->treetype == NTREE_TEXTURE) { + Tex *tex = (Tex *)snode->id; if (tex->use_nodes) { ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } @@ -315,12 +315,12 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) static SpaceLink *node_duplicate(SpaceLink *sl) { - SpaceNode *snoden= MEM_dupallocN(sl); - + SpaceNode *snoden = MEM_dupallocN(sl); + /* clear or remove stuff from old */ - snoden->nodetree= NULL; - snoden->linkdrag.first= snoden->linkdrag.last= NULL; - + snoden->nodetree = NULL; + snoden->linkdrag.first = snoden->linkdrag.last = NULL; + return (SpaceLink *)snoden; } @@ -331,7 +331,7 @@ static void node_buttons_area_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -343,12 +343,12 @@ static void node_buttons_area_draw(const bContext *C, ARegion *ar) static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) { - SpaceNode *snode= sa->spacedata.first; - + SpaceNode *snode = sa->spacedata.first; + /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->mx, &snode->my); - + node_set_cursor(win, snode); } @@ -357,26 +357,26 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; ListBase *lb; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Node Editor", SPACE_NODE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + /* add drop boxes */ lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); - + WM_event_add_dropbox_handler(&ar->handlers, lb); } static void node_main_area_draw(const bContext *C, ARegion *ar) { - View2D *v2d= &ar->v2d; - + View2D *v2d = &ar->v2d; + drawnodespace(C, ar, v2d); } @@ -385,13 +385,13 @@ static void node_main_area_draw(const bContext *C, ARegion *ar) static int node_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_ID) { - ID *id= (ID *)drag->poin; - if ( GS(id->name)==ID_IM ) + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_IM) return 1; } - else if (drag->type==WM_DRAG_PATH) { - if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ + else if (drag->type == WM_DRAG_PATH) { + if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ return 1; } return 0; @@ -399,10 +399,10 @@ static int node_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void node_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) { - ID *id= (ID *)drag->poin; - + ID *id = (ID *)drag->poin; + if (id) { - RNA_string_set(drop->ptr, "name", id->name+2); + RNA_string_set(drop->ptr, "name", id->name + 2); } if (drag->path[0]) { RNA_string_set(drop->ptr, "filepath", drag->path); @@ -412,10 +412,10 @@ static void node_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) /* this region dropbox definition */ static void node_dropboxes(void) { - ListBase *lb= WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); - + ListBase *lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); + WM_dropbox_add(lb, "NODE_OT_add_file", node_drop_poll, node_id_path_drop_copy); - + } /* ************* end drop *********** */ @@ -429,8 +429,8 @@ static void node_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar) static void node_header_area_draw(const bContext *C, ARegion *ar) { - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *scene = CTX_data_scene(C); /* find and set the context */ snode_set_context(snode, scene); @@ -444,12 +444,19 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SPACE: - if (wmn->data==ND_SPACE_NODE) + if (wmn->data == ND_SPACE_NODE) ED_region_tag_redraw(ar); break; case NC_SCREEN: - if (wmn->data == ND_GPENCIL) - ED_region_tag_redraw(ar); + switch (wmn->data) { + case ND_GPENCIL: + ED_region_tag_redraw(ar); + break; + case ND_SCREENCAST: + case ND_ANIMPLAY: + ED_region_tag_redraw(ar); + break; + } break; case NC_SCENE: case NC_MATERIAL: @@ -458,7 +465,7 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_OBJECT: - if (wmn->data==ND_OB_SHADING) + if (wmn->data == ND_OB_SHADING) ED_region_tag_redraw(ar); break; case NC_ID: @@ -472,17 +479,17 @@ const char *node_context_dir[] = {"selected_nodes", "active_node", NULL}; static int node_context(const bContext *C, const char *member, bContextDataResult *result) { - SpaceNode *snode= CTX_wm_space_node(C); - + SpaceNode *snode = CTX_wm_space_node(C); + if (CTX_data_dir(member)) { CTX_data_dir_set(result, node_context_dir); return 1; } else if (CTX_data_equals(member, "selected_nodes")) { bNode *node; - + if (snode->edittree) { - for (node=snode->edittree->nodes.last; node; node=node->prev) { + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (node->flag & NODE_SELECT) { CTX_data_list_add(result, &snode->edittree->id, &RNA_Node, node); } @@ -500,67 +507,67 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_type_set(result, CTX_DATA_TYPE_POINTER); return 1; } - + return 0; } /* only called once, from space/spacetypes.c */ void ED_spacetype_node(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype node"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype node"); ARegionType *art; - - st->spaceid= SPACE_NODE; + + st->spaceid = SPACE_NODE; strncpy(st->name, "Node", BKE_ST_MAXNAME); - - st->new= node_new; - st->free= node_free; - st->init= node_init; - st->duplicate= node_duplicate; - st->operatortypes= node_operatortypes; - st->keymap= node_keymap; - st->listener= node_area_listener; - st->refresh= node_area_refresh; - st->context= node_context; + + st->new = node_new; + st->free = node_free; + st->init = node_init; + st->duplicate = node_duplicate; + st->operatortypes = node_operatortypes; + st->keymap = node_keymap; + st->listener = node_area_listener; + st->refresh = node_area_refresh; + st->context = node_context; st->dropboxes = node_dropboxes; - + /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_WINDOW; - art->init= node_main_area_init; - art->draw= node_main_area_draw; - art->listener= node_region_listener; + art->init = node_main_area_init; + art->draw = node_main_area_draw; + art->listener = node_region_listener; art->cursor = node_cursor; art->event_cursor = TRUE; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; - art->listener= node_region_listener; - art->init= node_header_area_init; - art->draw= node_header_area_draw; - + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + art->listener = node_region_listener; + art->init = node_header_area_init; + art->draw = node_header_area_draw; + BLI_addhead(&st->regiontypes, art); node_menus_register(); - + /* regions: listview/buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_UI; - art->prefsizex= 180; // XXX - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->listener= node_region_listener; - art->init= node_buttons_area_init; - art->draw= node_buttons_area_draw; + art->prefsizex = 180; // XXX + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = node_region_listener; + art->init = node_buttons_area_init; + art->draw = node_buttons_area_draw; BLI_addhead(&st->regiontypes, art); - + node_buttons_register(art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 2f5e32c61d1..42fdd5173d4 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1541,7 +1541,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); - // grey hierarchy lines + // gray hierarchy lines UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; startx = 6; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index eb740e441b7..449914feae4 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1360,7 +1360,7 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) /* identifiers */ ot->idname = "OUTLINER_OT_keyingset_add_selected"; ot->name = "Keying Set Add Selected"; - ot->description = "Add selected items (blue-grey rows) to active Keying Set"; + ot->description = "Add selected items (blue-gray rows) to active Keying Set"; /* api callbacks */ ot->exec = outliner_keyingset_additems_exec; @@ -1397,7 +1397,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /* identifiers */ ot->idname = "OUTLINER_OT_keyingset_remove_selected"; ot->name = "Keying Set Remove Selected"; - ot->description = "Remove selected items (blue-grey rows) from active Keying Set"; + ot->description = "Remove selected items (blue-gray rows) from active Keying Set"; /* api callbacks */ ot->exec = outliner_keyingset_removeitems_exec; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 812fba50295..096713f9cd3 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -69,7 +69,7 @@ #include "outliner_intern.h" /* ****************************************************** */ -/* Outliner Selection (grey-blue highlight for rows) */ +/* Outliner Selection (gray-blue highlight for rows) */ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting) { diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index 1e452f2052d..7dbcabedccc 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -58,7 +58,7 @@ void sequencer_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil"); strcpy(pt->idname, "SEQUENCER_PT_gpencil"); strcpy(pt->label, N_("Grease Pencil")); - pt->draw= gpencil_panel_standard; + pt->draw = gpencil_panel_standard; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 9148373cb2d..38f29e8816e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1076,7 +1076,7 @@ static void draw_seq_backdrop(View2D *v2d) { int i; - /* darker grey overlay over the view backdrop */ + /* darker gray overlay over the view backdrop */ UI_ThemeColorShade(TH_BACK, -20); glRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index bc8133cded6..1c3d2b61488 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2694,8 +2694,11 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - sound_remove_scene_sound(scene, seq_act->scene_sound); - sound_remove_scene_sound(scene, seq_other->scene_sound); + if (seq_act->scene_sound) + sound_remove_scene_sound(scene, seq_act->scene_sound); + + if (seq_other->scene_sound) + sound_remove_scene_sound(scene, seq_other->scene_sound); seq_act->scene_sound = NULL; seq_other->scene_sound = NULL; @@ -2802,7 +2805,7 @@ void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot) /* identifiers */ ot->name = "Rebuild Proxy and Timecode Indices"; ot->idname = "SEQUENCER_OT_rebuild_proxy"; - ot->description = "Rebuild all selected proxies and timecode indeces using the job system"; + ot->description = "Rebuild all selected proxies and timecode indices using the job system"; /* api callbacks */ ot->exec = sequencer_rebuild_proxy_exec; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index b8bf764fabc..cabc761161e 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -454,6 +454,10 @@ static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; + case NC_SCREEN: + if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY)) + ED_region_tag_redraw(ar); + break; } } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 3ebc4eb974c..f0275fb6584 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -830,7 +830,7 @@ void TEXT_OT_paste(wmOperatorType *ot) static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op)) { - Text *text= CTX_data_edit_text(C); + Text *text = CTX_data_edit_text(C); txt_duplicate_line(text); @@ -1341,7 +1341,7 @@ static int move_lines_exec(bContext *C, wmOperator *op) txt_move_lines(text, direction); text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); /* run the script while editing, evil but useful */ if (CTX_wm_space_text(C)->live_edit) @@ -1352,7 +1352,7 @@ static int move_lines_exec(bContext *C, wmOperator *op) void TEXT_OT_move_lines(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { + static EnumPropertyItem direction_items[] = { {TXT_MOVE_LINE_UP, "UP", 0, "Up", ""}, {TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 248f73b9ab6..5376b82f24c 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -57,23 +57,23 @@ static SpaceLink *userpref_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceUserPref *spref; - - spref= MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); - spref->spacetype= SPACE_USERPREF; - + + spref = MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); + spref->spacetype = SPACE_USERPREF; + /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for userpref"); - + ar = MEM_callocN(sizeof(ARegion), "header for userpref"); + BLI_addtail(&spref->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; - + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; + /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for userpref"); - + ar = MEM_callocN(sizeof(ARegion), "main area for userpref"); + BLI_addtail(&spref->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; - + ar->regiontype = RGN_TYPE_WINDOW; + return (SpaceLink *)spref; } @@ -93,10 +93,10 @@ static void userpref_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa static SpaceLink *userpref_duplicate(SpaceLink *sl) { - SpaceUserPref *sprefn= MEM_dupallocN(sl); - + SpaceUserPref *sprefn = MEM_dupallocN(sl); + /* clear or remove stuff from old */ - + return (SpaceLink *)sprefn; } @@ -155,41 +155,41 @@ static void userpref_header_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn /* only called once, from space/spacetypes.c */ void ED_spacetype_userpref(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype userpref"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype userpref"); ARegionType *art; - - st->spaceid= SPACE_USERPREF; + + st->spaceid = SPACE_USERPREF; strncpy(st->name, "Userpref", BKE_ST_MAXNAME); - - st->new= userpref_new; - st->free= userpref_free; - st->init= userpref_init; - st->duplicate= userpref_duplicate; - st->operatortypes= userpref_operatortypes; - st->keymap= userpref_keymap; - + + st->new = userpref_new; + st->free = userpref_free; + st->init = userpref_init; + st->duplicate = userpref_duplicate; + st->operatortypes = userpref_operatortypes; + st->keymap = userpref_keymap; + /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); art->regionid = RGN_TYPE_WINDOW; - art->init= userpref_main_area_init; - art->draw= userpref_main_area_draw; - art->listener= userpref_main_area_listener; - art->keymapflag= ED_KEYMAP_UI; + art->init = userpref_main_area_init; + art->draw = userpref_main_area_draw; + art->listener = userpref_main_area_listener; + art->keymapflag = ED_KEYMAP_UI; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; - art->listener= userpref_header_listener; - art->init= userpref_header_area_init; - art->draw= userpref_header_area_draw; - + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; + art->listener = userpref_header_listener; + art->init = userpref_header_area_init; + art->draw = userpref_header_area_draw; + BLI_addhead(&st->regiontypes, art); - - + + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index e51f7a312eb..33aada7b811 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2269,7 +2269,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) } } -/* ****************************** Armature Visualisation ******************************** */ +/* ****************************** Armature Visualization ******************************** */ /* ---------- Paths --------- */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b1d06c6091b..4f6e5ecd1dc 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6442,7 +6442,7 @@ static void draw_hooks(Object *ob) } } -static void drawRBpivot(bRigidBodyJointConstraint *data, const unsigned char ob_wire_col[4]) +static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const unsigned char ob_wire_col[4]) { const char *axis_str[3] = {"px", "py", "pz"}; int axis; @@ -7072,12 +7072,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) { bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data; if (data->flag & CONSTRAINT_DRAW_PIVOT) - drawRBpivot(data, ob_wire_col); + draw_rigid_body_pivot(data, ob_wire_col); } } if (ob->gameflag & OB_BOUNDS) { if (ob->boundtype != ob->collision_boundtype || (dtx & OB_BOUNDBOX) == 0) { + setlinestyle(2); draw_bounding_volume(scene, ob, ob->collision_boundtype); setlinestyle(0); @@ -7112,8 +7113,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } if (dt <= OB_SOLID && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - if ((ob->gameflag & OB_DYNAMIC) || - ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) + if (((ob->gameflag & OB_DYNAMIC) && + !ELEM(ob->collision_boundtype, OB_BOUND_TRIANGLE_MESH, OB_BOUND_CONVEX_HULL)) || + + ((ob->gameflag & OB_BOUNDS) && + (ob->boundtype == OB_BOUND_SPHERE))) { float imat[4][4], vec[3] = {0.0f, 0.0f, 0.0f}; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index a9941dc326a..6cfa828024d 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -856,7 +856,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) uiDefBut(block, BUT, B_VGRP_PNL_NORMALIZE, IFACE_("Normalize"), 0, yco, 100, 20, NULL, 0, 0, 0, 0, TIP_("Normalize active vertex weights")); uiDefBut(block, BUT, B_VGRP_PNL_COPY, IFACE_("Copy"), 100, yco, 100, 20, - NULL, 0, 0, 0, 0, TIP_("Copy active vertex to other seleted verts")); + NULL, 0, 0, 0, 0, TIP_("Copy active vertex to other selected verts")); uiBlockEndAlign(block); } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 2d4fbb90ae1..e6ea42aa5ba 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1561,7 +1561,12 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, if (ima == NULL) continue; BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0); - ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); + if (ima->source == IMA_SRC_SEQUENCE && !(bgpic->iuser.flag & IMA_USER_FRAME_IN_RANGE)) { + ibuf = NULL; /* frame is out of range, dont show */ + } + else { + ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); + } image_aspect[0] = ima->aspx; image_aspect[1] = ima->aspx; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index cedb09e187c..164c1dd7c12 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1655,6 +1655,12 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); } + else if (t->spacetype == SPACE_NODE) { + unit_m3(t->spacemtx); + /*t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);*/ + t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); + /*t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);*/ + } else unit_m3(t->spacemtx); @@ -2170,8 +2176,8 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td) if (td->ext->rotOrder == ROT_MODE_QUAT) { /* quats */ /* objects and bones do normalization first too, otherwise - * we don't necessarily end up with a rotation matrix, and - * then conversion back to quat gives a different result */ + * we don't necessarily end up with a rotation matrix, and + * then conversion back to quat gives a different result */ float quat[4]; normalize_qt_qt(quat, td->ext->quat); quat_to_mat4(cob->matrix, quat); @@ -3542,6 +3548,11 @@ void initTranslation(TransInfo *t) t->snap[1] = 0.125f; t->snap[2] = 0.0625f; } + else if (t->spacetype == SPACE_NODE) { + t->snap[0] = 0.0f; + t->snap[1] = 125.0f; + t->snap[2] = 25.0f; + } else { t->snap[0] = 0.0f; t->snap[1] = t->snap[2] = 1.0f; @@ -5004,7 +5015,6 @@ void projectSVData(TransInfo *t, int final) for (i = 0, sv = sld->sv; i < sld->totsv; sv++, i++) { BMIter fiter; BMFace *f; - /* BMESH_TODO, this interpolates between vertex/loops which are not moved * (are only apart of a face attached to a slide vert), couldn't we iterate BM_LOOPS_OF_VERT @@ -5034,6 +5044,8 @@ void projectSVData(TransInfo *t, int final) /* project onto copied projection face */ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + /* only affected verts will get interpolated */ + char affected = FALSE; f_copy_flip = f_copy; if (BM_elem_flag_test(l->e, BM_ELEM_SELECT) || BM_elem_flag_test(l->prev->e, BM_ELEM_SELECT)) { @@ -5058,6 +5070,8 @@ void projectSVData(TransInfo *t, int final) if (!f_copy_flip) { continue; /* shouldn't happen, but protection */ } + + affected = TRUE; } else { /* the loop is attached to only one vertex and not a selected edge, @@ -5094,10 +5108,15 @@ void projectSVData(TransInfo *t, int final) f_copy_flip = BLI_smallhash_lookup(&sld->origfaces, (uintptr_t)e_sel->l->radial_next->f); } } + + affected = TRUE; } } + if(!affected) + continue; + /* only loop data, no vertex data since that contains shape keys, * and we do not want to mess up other shape keys */ BM_loop_interp_from_face(em->bm, l, f_copy_flip, FALSE, FALSE); @@ -5122,7 +5141,7 @@ void projectSVData(TransInfo *t, int final) } } } - + BLI_smallhash_release(&visit); } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index fdc09c1bed0..3ab5bf7bbfb 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -86,6 +86,7 @@ typedef struct TransSnap { float snapTarget[3]; /* to this point */ float snapNormal[3]; float snapTangent[3]; + char snapNodeBorder; ListBase points; TransSnapPoint *selectedPoint; float dist; // Distance from snapPoint to snapTarget diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index d2910c5b602..034ea3eb704 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -276,7 +276,7 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 sub_v3_v3v3(out, i1, t_con_center); /* possible some values become nan when - * viewpoint and object are both zero */ + * viewpoint and object are both zero */ if (!finite(out[0])) out[0] = 0.0f; if (!finite(out[1])) out[1] = 0.0f; if (!finite(out[2])) out[2] = 0.0f; @@ -306,7 +306,7 @@ static void planeProjection(TransInfo *t, float in[3], float out[3]) } /* - * Generic callback for constant spacial constraints applied to linear motion + * Generic callback for constant spatial constraints applied to linear motion * * The IN vector in projected into the constrained space and then further * projected along the view vector. @@ -404,9 +404,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f } /* - * Generic callback for constant spacial constraints applied to resize motion - * - * + * Generic callback for constant spatial constraints applied to resize motion */ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3]) @@ -430,9 +428,7 @@ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3 } /* - * Callback for object based spacial constraints applied to resize motion - * - * + * Callback for object based spatial constraints applied to resize motion */ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3][3]) @@ -459,7 +455,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3] } /* - * Generic callback for constant spacial constraints applied to rotations + * Generic callback for constant spatial constraints applied to rotations * * The rotation axis is copied into VEC. * @@ -501,7 +497,7 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl } /* - * Callback for object based spacial constraints applied to rotations + * Callback for object based spatial constraints applied to rotations * * The rotation axis is copied into VEC. * @@ -644,7 +640,7 @@ void drawConstraint(TransInfo *t) { TransCon *tc = &(t->con); - if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) + if (!ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) return; if (!(tc->mode & CON_APPLY)) return; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index f3a846daf29..af0b33d58ae 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5516,8 +5516,11 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) } td->loc = td2d->loc; - copy_v3_v3(td->center, td->loc); copy_v3_v3(td->iloc, td->loc); + /* use node center instead of origin (top-left corner) */ + td->center[0] = node->locx + 0.5f * (node->totr.xmax - node->totr.xmin); + td->center[1] = node->locy - 0.5f * (node->totr.ymax - node->totr.ymin); /* node height is used negative */ + td->center[2] = 0.0f; memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; @@ -5529,6 +5532,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) unit_m3(td->mtx); unit_m3(td->smtx); + + td->extra = node; } static void createTransNodeData(bContext *C, TransInfo *t) @@ -6324,7 +6329,7 @@ void createTransData(bContext *C, TransInfo *t) #endif } else if (t->spacetype == SPACE_NODE) { - t->flag |= T_2D_EDIT | T_POINTS; + t->flag |= T_POINTS | T_2D_EDIT; createTransNodeData(C, t); if (t->data && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index b3ccf004810..1507dbfddda 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -745,7 +745,7 @@ static char axisBlendAngle(float angle) } /* three colors can be set; - * grey for ghosting + * gray for ghosting * moving: in transform theme color * else the red/green/blue */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 90b67951614..c49e1715f34 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -42,6 +42,7 @@ #include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" // Temporary, for snapping to other unselected meshes +#include "DNA_node_types.h" #include "DNA_space_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" @@ -74,6 +75,7 @@ #include "ED_armature.h" #include "ED_image.h" #include "ED_mesh.h" +#include "ED_node.h" #include "ED_uvedit.h" #include "ED_view3d.h" @@ -113,6 +115,9 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]); /****************** IMPLEMENTATIONS *********************/ +static int snapNodeTest(View2D *v2d, bNode *node, SnapMode mode); +static NodeBorder snapNodeBorder(int snap_node_mode); + #if 0 int BIF_snappingSupported(Object *obedit) { @@ -140,19 +145,22 @@ int activeSnap(TransInfo *t) void drawSnapping(const struct bContext *C, TransInfo *t) { - if (validSnap(t) && activeSnap(t)) { - - unsigned char col[4], selectedCol[4], activeCol[4]; - UI_GetThemeColor3ubv(TH_TRANSFORM, col); - col[3] = 128; - - UI_GetThemeColor3ubv(TH_SELECT, selectedCol); - selectedCol[3] = 128; - - UI_GetThemeColor3ubv(TH_ACTIVE, activeCol); - activeCol[3] = 192; - - if (t->spacetype == SPACE_VIEW3D) { + unsigned char col[4], selectedCol[4], activeCol[4]; + + if (!activeSnap(t)) + return; + + UI_GetThemeColor3ubv(TH_TRANSFORM, col); + col[3] = 128; + + UI_GetThemeColor3ubv(TH_SELECT, selectedCol); + selectedCol[3] = 128; + + UI_GetThemeColor3ubv(TH_ACTIVE, activeCol); + activeCol[3] = 192; + + if (t->spacetype == SPACE_VIEW3D) { + if (validSnap(t)) { TransSnapPoint *p; View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -160,11 +168,11 @@ void drawSnapping(const struct bContext *C, TransInfo *t) float size; glDisable(GL_DEPTH_TEST); - + size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - + invert_m4_m4(imat, rv3d->viewmat); - + for (p = t->tsnap.points.first; p; p = p->next) { if (p == t->tsnap.selectedPoint) { glColor4ubv(selectedCol); @@ -172,20 +180,20 @@ void drawSnapping(const struct bContext *C, TransInfo *t) else { glColor4ubv(col); } - + drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat); } - + if (t->tsnap.status & POINT_INIT) { glColor4ubv(activeCol); - + drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat); } /* draw normal if needed */ if (usingSnappingNormal(t) && validSnappingNormal(t)) { glColor4ubv(activeCol); - + glBegin(GL_LINES); glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], @@ -197,7 +205,9 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } - else if (t->spacetype == SPACE_IMAGE) { + } + else if (t->spacetype == SPACE_IMAGE) { + if (validSnap(t)) { /* This will not draw, and Im nor sure why - campbell */ #if 0 float xuser_asp, yuser_asp; @@ -228,7 +238,36 @@ void drawSnapping(const struct bContext *C, TransInfo *t) glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f); setlinestyle(0); #endif + } + } + else if (t->spacetype == SPACE_NODE) { + if (validSnap(t)) { + ARegion *ar = CTX_wm_region(C); + TransSnapPoint *p; + float size; + + size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); + + glEnable(GL_BLEND); + for (p = t->tsnap.points.first; p; p = p->next) { + if (p == t->tsnap.selectedPoint) { + glColor4ubv(selectedCol); + } + else { + glColor4ubv(col); + } + + drawnodesnap(&ar->v2d, p->co, size, 0); + } + + if (t->tsnap.status & POINT_INIT) { + glColor4ubv(activeCol); + + drawnodesnap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder); + } + + glDisable(GL_BLEND); } } } @@ -349,6 +388,8 @@ void resetSnapping(TransInfo *t) t->tsnap.snapNormal[0] = 0; t->tsnap.snapNormal[1] = 0; t->tsnap.snapNormal[2] = 0; + + t->tsnap.snapNodeBorder = 0; } int usingSnappingNormal(TransInfo *t) @@ -373,12 +414,20 @@ static void initSnappingMode(TransInfo *t) Object *obedit = t->obedit; Scene *scene = t->scene; - /* force project off when not supported */ - if (ts->snap_mode != SCE_SNAP_MODE_FACE) { + if (t->spacetype == SPACE_NODE) { + /* force project off when not supported */ t->tsnap.project = 0; + + t->tsnap.mode = ts->snap_node_mode; + } + else { + /* force project off when not supported */ + if (ts->snap_mode != SCE_SNAP_MODE_FACE) { + t->tsnap.project = 0; + } + + t->tsnap.mode = ts->snap_mode; } - - t->tsnap.mode = ts->snap_mode; if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && /* Only 3D view or UV */ (t->flag & T_CAMERA) == 0) /* Not with camera selected in camera view */ @@ -414,6 +463,19 @@ static void initSnappingMode(TransInfo *t) t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; } } + else if (t->spacetype == SPACE_NODE) + { + setSnappingCallback(t); + + if (t->tsnap.applySnap != NULL) + { + t->tsnap.modeSelect = SNAP_NOT_SELECTED; + } + else { + /* Grid if snap is not possible */ + t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; + } + } else { /* Always grid outside of 3D view */ t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; @@ -459,7 +521,7 @@ void initSnapping(TransInfo *t, wmOperator *op) } /* use scene defaults only when transform is modal */ else if (t->flag & T_MODAL) { - if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) { + if (ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) { if (ts->snap_flag & SCE_SNAP) { t->modifiers |= MOD_SNAP; } @@ -624,7 +686,17 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3]) { float point[3]; getSnapPoint(t, point); - sub_v3_v3v3(vec, point, t->tsnap.snapTarget); + + if (t->spacetype == SPACE_NODE) { + char border = t->tsnap.snapNodeBorder; + if (border & (NODE_LEFT | NODE_RIGHT)) + vec[0] = point[0] - t->tsnap.snapTarget[0]; + if (border & (NODE_BOTTOM | NODE_TOP)) + vec[1] = point[1] - t->tsnap.snapTarget[1]; + } + else { + sub_v3_v3v3(vec, point, t->tsnap.snapTarget); + } } static void ApplySnapRotation(TransInfo *t, float *value) @@ -879,20 +951,57 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) t->tsnap.status &= ~POINT_INIT; } } + else if (t->spacetype == SPACE_NODE) { + float loc[2]; + int dist = SNAP_MIN_DISTANCE; // Use a user defined value here + char node_border; + + if (snapNodesTransform(t, t->mval, &dist, loc, &node_border, t->tsnap.modeSelect)) { + copy_v2_v2(t->tsnap.snapPoint, loc); + t->tsnap.snapNodeBorder = node_border; + + t->tsnap.status |= POINT_INIT; + } + else { + t->tsnap.status &= ~POINT_INIT; + } + } } /********************** TARGET **************************/ +static void TargetSnapOffset(TransInfo *t, TransData *td) +{ + if (t->spacetype == SPACE_NODE && td != NULL) { + bNode *node = td->extra; + char border = t->tsnap.snapNodeBorder; + float width = node->totr.xmax - node->totr.xmin; + float height = node->totr.ymax - node->totr.ymin; + + if (border & NODE_LEFT) + t->tsnap.snapTarget[0] -= 0.5f * width; + if (border & NODE_RIGHT) + t->tsnap.snapTarget[0] += 0.5f * width; + if (border & NODE_BOTTOM) + t->tsnap.snapTarget[1] -= 0.5f * height; + if (border & NODE_TOP) + t->tsnap.snapTarget[1] += 0.5f * height; + } +} + static void TargetSnapCenter(TransInfo *t) { /* Only need to calculate once */ if ((t->tsnap.status & TARGET_INIT) == 0) { copy_v3_v3(t->tsnap.snapTarget, t->center); + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } + TargetSnapOffset(t, NULL); + t->tsnap.status |= TARGET_INIT; } } @@ -914,12 +1023,14 @@ static void TargetSnapActive(TransInfo *t) if (active_td) { copy_v3_v3(t->tsnap.snapTarget, active_td->center); - + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } + TargetSnapOffset(t, active_td); + t->tsnap.status |= TARGET_INIT; } /* No active, default to median */ @@ -953,6 +1064,8 @@ static void TargetSnapMedian(TransInfo *t) mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } + TargetSnapOffset(t, NULL); + t->tsnap.status |= TARGET_INIT; } } @@ -1029,6 +1142,8 @@ static void TargetSnapClosest(TransInfo *t) } } + TargetSnapOffset(t, closest); + t->tsnap.status |= TARGET_INIT; } } @@ -1876,6 +1991,113 @@ int peelObjectsContext(bContext *C, ListBase *depth_peels, const float mval[2], return peelObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), depth_peels, mval, mode); } +/******************** NODES ***********************************/ + +static int snapNodeTest(View2D *v2d, bNode *node, SnapMode mode) +{ + /* node is use for snapping only if a) snap mode matches and b) node is inside the view */ + return ((mode == SNAP_NOT_SELECTED && !(node->flag & NODE_SELECT)) || + (mode == SNAP_ALL && !(node->flag & NODE_ACTIVE))) && + (node->totr.xmin < v2d->cur.xmax && node->totr.xmax > v2d->cur.xmin && + node->totr.ymin < v2d->cur.ymax && node->totr.ymax > v2d->cur.ymin); +} + +static NodeBorder snapNodeBorder(int snap_node_mode) +{ + switch (snap_node_mode) { + case SCE_SNAP_MODE_NODE_X: + return NODE_LEFT | NODE_RIGHT; + case SCE_SNAP_MODE_NODE_Y: + return NODE_TOP | NODE_BOTTOM; + case SCE_SNAP_MODE_NODE_XY: + return NODE_LEFT | NODE_RIGHT | NODE_TOP | NODE_BOTTOM; + } + return 0; +} + +static int snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bNode *node, const int mval[2], + float r_loc[2], int *r_dist, char *r_node_border) +{ + View2D *v2d = &ar->v2d; + NodeBorder border = snapNodeBorder(ts->snap_node_mode); + int retval = 0; + rcti totr; + int new_dist; + + UI_view2d_to_region_no_clip(v2d, node->totr.xmin, node->totr.ymin, &totr.xmin, &totr.ymin); + UI_view2d_to_region_no_clip(v2d, node->totr.xmax, node->totr.ymax, &totr.xmax, &totr.ymax); + + if (border & NODE_LEFT) { + new_dist = abs(totr.xmin - mval[0]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, totr.xmin, mval[1], &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_LEFT; + retval = 1; + } + } + + if (border & NODE_RIGHT) { + new_dist = abs(totr.xmax - mval[0]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, totr.xmax, mval[1], &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_RIGHT; + retval = 1; + } + } + + if (border & NODE_BOTTOM) { + new_dist = abs(totr.ymin - mval[1]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, mval[0], totr.ymin, &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_BOTTOM; + retval = 1; + } + } + + if (border & NODE_TOP) { + new_dist = abs(totr.ymax - mval[1]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, mval[0], totr.ymax, &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_TOP; + retval = 1; + } + } + + return retval; +} + +static int snapNodes(ToolSettings *ts, SpaceNode *snode, ARegion *ar, const int mval[2], + int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode) +{ + bNodeTree *ntree = snode->edittree; + bNode *node; + int retval = 0; + + *r_node_border = 0; + + for (node = ntree->nodes.first; node; node = node->next) { + if (snapNodeTest(&ar->v2d, node, mode)) + retval |= snapNode(ts, snode, ar, node, mval, r_loc, r_dist, r_node_border); + } + + return retval; +} + +int snapNodesTransform(TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode) +{ + return snapNodes(t->settings, t->sa->spacedata.first, t->ar, mval, r_dist, r_loc, r_node_border, mode); +} + +int snapNodesContext(bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode) +{ + Scene *scene = CTX_data_scene(C); + return snapNodes(scene->toolsettings, CTX_wm_space_node(C), CTX_wm_region(C), mval, r_dist, r_loc, r_node_border, mode); +} + /*================================================================*/ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index d52463cf406..17c57b1f6e4 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -133,7 +133,7 @@ static void draw_uvs_shadow(Object *obedit) BMIter iter, liter; MLoopUV *luv; - /* draws the grey mesh when painting */ + /* draws the gray mesh when painting */ glColor3ub(112, 112, 112); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b15df9c3e89..216ac61b628 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -3402,7 +3402,8 @@ static void UV_OT_cursor_set(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); + RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", + "Cursor location in normalized (0.0-1.0) coordinates", -10.0f, 10.0f); } /********************** set tile operator **********************/ diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 59e384cbd4b..d80e756f0b6 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -71,5 +71,10 @@ endif() add_definitions(-DGLEW_STATIC) +if(WITH_IMAGE_DDS) + add_definitions(-DWITH_DDS) +endif() + + blender_add_lib(bf_gpu "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 438cfd6b741..59140b2be80 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -122,6 +122,9 @@ void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int m void GPU_update_images_framechange(void); int GPU_update_image_time(struct Image *ima, double time); int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap); +void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int rectw, int recth, int mipmap, int use_hight_bit_depth, struct Image *ima); +void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, struct Image *ima, struct ImBuf *ibuf); +int GPU_upload_dxt_texture(struct ImBuf *ibuf); void GPU_free_image(struct Image *ima); void GPU_free_images(void); void GPU_free_images_anim(void); diff --git a/source/blender/gpu/SConscript b/source/blender/gpu/SConscript index cf1c91f25fe..7ab0c6cce46 100644 --- a/source/blender/gpu/SConscript +++ b/source/blender/gpu/SConscript @@ -17,4 +17,7 @@ incs += ' ' + env['BF_OPENGL_INC'] if env['WITH_BF_SMOKE']: defs.append('WITH_SMOKE') +if env['WITH_BF_DDS']: + defs.append('WITH_DDS') + env.BlenderLib ( 'bf_gpu', sources, Split(incs), defines = defs, libtype=['core','player'], priority=[160,110] ) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 636476a74d2..942fc503394 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -427,8 +427,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int ImBuf *ibuf = NULL; unsigned int *bind = NULL; int rectw, recth, tpx=0, tpy=0, y; - unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL; - float *ftilerect= NULL, *fscalerect = NULL, *frect = NULL; + unsigned int *tilerect= NULL, *rect= NULL; + float *ftilerect= NULL, *frect = NULL; float *srgb_frect = NULL; short texwindx, texwindy, texwinsx, texwinsy; /* flag to determine whether high resolution format is used */ @@ -537,7 +537,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, ibuf->x, ibuf->y, ibuf->x, ibuf->x); - /* clamp buffer colours to 1.0 to avoid artifacts due to glu for hdr images */ + /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */ IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y); frect= srgb_frect + texwinsy*ibuf->x + texwinsx; } @@ -562,7 +562,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, ibuf->x, ibuf->y, ibuf->x, ibuf->x); - /* clamp buffer colours to 1.0 to avoid artifacts due to glu for hdr images */ + /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */ IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y); } else @@ -611,8 +611,33 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int rect= tilerect; } } +#ifdef WITH_DDS + if (ibuf->ftype & DDS) + GPU_create_gl_tex_compressed(bind, rect, rectw, recth, mipmap, ima, ibuf); + else +#endif + GPU_create_gl_tex(bind, rect, frect, rectw, recth, mipmap, use_high_bit_depth, ima); + + /* clean up */ + if (tilerect) + MEM_freeN(tilerect); + if (ftilerect) + MEM_freeN(ftilerect); + if (srgb_frect) + MEM_freeN(srgb_frect); + + return *bind; +} - /* scale if not a power of two. this is not strictly necessary for newer +void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float * frect, int rectw, int recth, int mipmap, int use_high_bit_depth, Image *ima) +{ + unsigned int *scalerect = NULL; + float *fscalerect = NULL; + + int tpx = rectw; + int tpy = recth; + + /* scale if not a power of two. this is not strictly necessary for newer * GPUs (OpenGL version >= 2.0) since they support non-power-of-two-textures */ if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) { rectw= smaller_pow2_limit(rectw); @@ -626,9 +651,9 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int } else { scalerect= MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect"); - gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect); + gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, pix, rectw, recth, GL_UNSIGNED_BYTE, scalerect); - rect= scalerect; + pix= scalerect; } } @@ -640,7 +665,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); } @@ -649,14 +674,14 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix); glGenerateMipmapEXT(GL_TEXTURE_2D); } else { if (use_high_bit_depth) gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect); else - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect); + gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, pix); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); @@ -668,21 +693,88 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); /* set to modulate with vertex color */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - /* clean up */ - if (tilerect) - MEM_freeN(tilerect); - if (ftilerect) - MEM_freeN(ftilerect); + if (scalerect) MEM_freeN(scalerect); if (fscalerect) MEM_freeN(fscalerect); - if (srgb_frect) - MEM_freeN(srgb_frect); - return *bind; } +/** + * GPU_upload_dxt_texture() assumes that the texture is already bound and ready to go. + * This is so the viewport and the BGE can share some code. + * Returns FALSE if the provided ImBuf doesn't have a supported DXT compression format + */ +int GPU_upload_dxt_texture(ImBuf *ibuf) +{ +#if WITH_DDS + GLint format = 0; + int blocksize, height, width, i, size, offset = 0; + + height = ibuf->x; + width = ibuf->y; + + if (GLEW_EXT_texture_compression_s3tc) { + if (ibuf->dds_data.fourcc == FOURCC_DXT1) + format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + else if (ibuf->dds_data.fourcc == FOURCC_DXT3) + format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + else if (ibuf->dds_data.fourcc == FOURCC_DXT5) + format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + + if (format == 0) { + printf("Unable to find a suitable DXT compression, falling back to uncompressed\n"); + return FALSE; + } + + blocksize = (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16; + for (i=0; i<ibuf->dds_data.nummipmaps && (width||height); ++i) { + if (width == 0) + width = 1; + if (height == 0) + height = 1; + + size = ((width+3)/4)*((height+3)/4)*blocksize; + + glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height, + 0, size, ibuf->dds_data.data + offset); + + offset += size; + width >>= 1; + height >>= 1; + } + + return TRUE; +#else + (void)ibuf; + return FALSE; +#endif +} + +void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, Image *ima, ImBuf *ibuf) +{ +#ifndef WITH_DDS + (void)ibuf; + /* Fall back to uncompressed if DDS isn't enabled */ + GPU_create_gl_tex(bind, pix, NULL, x, y, mipmap, 0, ima); +#else + + + glGenTextures(1, (GLuint *)bind); + glBindTexture(GL_TEXTURE_2D, *bind); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + if (GPU_upload_dxt_texture(ibuf) == 0) { + glDeleteTextures(1, (GLuint*)bind); + GPU_create_gl_tex(bind, pix, NULL, x, y, mipmap, 0, ima); + } +#endif +} static void gpu_verify_repeat(Image *ima) { /* set either clamp or repeat in X/Y */ diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index b9980b1401d..d544e6501fc 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -21,7 +21,7 @@ * The Original Code is: all of this file. * * Original author: Benoit Bolsee - * Contributor(s): + * Contributor(s): * * ***** END GPL LICENSE BLOCK ***** */ @@ -30,7 +30,6 @@ * \ingroup ikplugin */ - #include "MEM_guardedalloc.h" #include "BIK_api.h" @@ -75,25 +74,25 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t } } if (con == NULL) return; - + /* exclude tip from chain? */ if (!(data->flag & CONSTRAINT_IK_TIP)) pchan_tip = pchan_tip->parent; - + /* Find the chain's root & count the segments needed */ for (curchan = pchan_tip; curchan; curchan = curchan->parent) { pchan_root = curchan; - + curchan->flag |= POSE_CHAIN; // don't forget to clear this chanlist[segcount] = curchan; segcount++; - + if (segcount == data->rootbone || segcount > 255) break; // 255 is weak } if (!segcount) return; /* setup the chain data */ - + /* we make tree-IK, unless all existing targets are in this chain */ for (tree = pchan_root->iktree.first; tree; tree = tree->next) { for (target = tree->targets.first; target; target = target->next) { @@ -116,11 +115,11 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t tree = MEM_callocN(sizeof(PoseTree), "posetree"); tree->type = CONSTRAINT_TYPE_KINEMATIC; - + tree->iterations = data->iterations; tree->totchannel = segcount; tree->stretch = (data->flag & CONSTRAINT_IK_STRETCH); - + tree->pchan = MEM_callocN(segcount * sizeof(void *), "ik tree pchan"); tree->parent = MEM_callocN(segcount * sizeof(int), "ik tree parent"); for (a = 0; a < segcount; a++) { @@ -128,7 +127,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t tree->parent[a] = a - 1; } target->tip = segcount - 1; - + /* AND! link the tree to the root */ BLI_addtail(&pchan_root->iktree, tree); } @@ -154,7 +153,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t for (parent = a - 1; parent < tree->totchannel; parent++) if (tree->pchan[parent] == chanlist[segcount - 1]->parent) break; - + /* shouldn't happen, but could with dependency cycles */ if (parent == tree->totchannel) parent = a - 1; @@ -177,7 +176,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t tree->parent[tree->totchannel + a] = tree->totchannel + a - 1; } tree->parent[tree->totchannel] = parent; - + tree->totchannel = newsize; } @@ -210,12 +209,12 @@ static void make_dmats(bPoseChannel *pchan) static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = to detect if this is first bone { float vec[3], ikmat[4][4]; - + copy_m4_m3(ikmat, ik_mat); - + if (pchan->parent) mul_serie_m4(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat, NULL, NULL, NULL, NULL, NULL); - else + else mult_m4_m4m4(pchan->pose_mat, pchan->chan_mat, ikmat); /* calculate head */ @@ -253,13 +252,13 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) if (tree->totchannel == 0) return; - + iktree = MEM_mallocN(sizeof(void *) * tree->totchannel, "ik tree"); for (a = 0; a < tree->totchannel; a++) { pchan = tree->pchan[a]; bone = pchan->bone; - + /* set DoF flag */ flag = 0; if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP)) @@ -268,72 +267,72 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) flag |= IK_YDOF; if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP)) flag |= IK_ZDOF; - + if (tree->stretch && (pchan->ikstretch > 0.0f)) { flag |= IK_TRANS_YDOF; hasstretch = 1; } - + seg = iktree[a] = IK_CreateSegment(flag); - + /* find parent */ if (a == 0) parent = NULL; else parent = iktree[tree->parent[a]]; - + IK_SetParent(seg, parent); - + /* get the matrix that transforms from prevbone into this bone */ copy_m3_m4(R_bonemat, pchan->pose_mat); - + /* gather transformations for this IK segment */ - + if (pchan->parent) copy_m3_m4(R_parmat, pchan->parent->pose_mat); else unit_m3(R_parmat); - + /* bone offset */ if (pchan->parent && (a > 0)) sub_v3_v3v3(start, pchan->pose_head, pchan->parent->pose_tail); else /* only root bone (a = 0) has no parent */ start[0] = start[1] = start[2] = 0.0f; - + /* change length based on bone size */ length = bone->length * len_v3(R_bonemat[1]); - + /* compute rest basis and its inverse */ copy_m3_m3(rest_basis, bone->bone_mat); copy_m3_m3(irest_basis, bone->bone_mat); transpose_m3(irest_basis); - + /* compute basis with rest_basis removed */ invert_m3_m3(iR_parmat, R_parmat); mul_m3_m3m3(full_basis, iR_parmat, R_bonemat); mul_m3_m3m3(basis, irest_basis, full_basis); - + /* basis must be pure rotation */ normalize_m3(basis); - + /* transform offset into local bone space */ normalize_m3(iR_parmat); mul_m3_v3(iR_parmat, start); - + IK_SetTransform(seg, start, rest_basis, basis, length); - + if (pchan->ikflag & BONE_IK_XLIMIT) IK_SetLimit(seg, IK_X, pchan->limitmin[0], pchan->limitmax[0]); if (pchan->ikflag & BONE_IK_YLIMIT) IK_SetLimit(seg, IK_Y, pchan->limitmin[1], pchan->limitmax[1]); if (pchan->ikflag & BONE_IK_ZLIMIT) IK_SetLimit(seg, IK_Z, pchan->limitmin[2], pchan->limitmax[2]); - + IK_SetStiffness(seg, IK_X, pchan->stiffness[0]); IK_SetStiffness(seg, IK_Y, pchan->stiffness[1]); IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]); - + if (tree->stretch && (pchan->ikstretch > 0.0f)) { float ikstretch = pchan->ikstretch * pchan->ikstretch; IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0f - ikstretch, 0.99f)); @@ -359,31 +358,31 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) else unit_m4(rootmat); copy_v3_v3(rootmat[3], pchan->pose_head); - + mult_m4_m4m4(imat, ob->obmat, rootmat); invert_m4_m4(goalinv, imat); - + for (target = tree->targets.first; target; target = target->next) { float polepos[3]; int poleconstrain = 0; - + data = (bKinematicConstraint *)target->con->data; - + /* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though * strictly speaking, it is a posechannel) */ get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0); - + /* and set and transform goal */ mult_m4_m4m4(goal, goalinv, rootmat); - + copy_v3_v3(goalpos, goal[3]); copy_m3_m4(goalrot, goal); - + /* same for pole vector target */ if (data->poletar) { get_constraint_target_matrix(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0); - + if (data->flag & CONSTRAINT_IK_SETANGLE) { /* don't solve IK when we are setting the pole angle */ break; @@ -398,7 +397,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) * a smooth transition */ resultblend = 1; resultinf = target->con->enforce; - + if (data->flag & CONSTRAINT_IK_GETANGLE) { poleangledata = data; data->flag &= ~CONSTRAINT_IK_GETANGLE; @@ -411,28 +410,28 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) float q1[4], q2[4], q[4]; float fac = target->con->enforce; float mfac = 1.0f - fac; - + pchan = tree->pchan[target->tip]; - + /* end effector in world space */ copy_m4_m4(end_pose, pchan->pose_mat); copy_v3_v3(end_pose[3], pchan->pose_tail); mul_serie_m4(world_pose, goalinv, ob->obmat, end_pose, NULL, NULL, NULL, NULL, NULL); - + /* blend position */ goalpos[0] = fac * goalpos[0] + mfac * world_pose[3][0]; goalpos[1] = fac * goalpos[1] + mfac * world_pose[3][1]; goalpos[2] = fac * goalpos[2] + mfac * world_pose[3][2]; - + /* blend rotation */ mat3_to_quat(q1, goalrot); mat4_to_quat(q2, world_pose); interp_qt_qtqt(q, q1, q2, mfac); quat_to_mat3(goalrot, q); } - + iktarget = iktree[target->tip]; - + if (data->weight != 0.0f) { if (poleconstrain) IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos, @@ -457,30 +456,30 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) tree->basis_change = MEM_mallocN(sizeof(float[3][3]) * tree->totchannel, "ik basis change"); if (hasstretch) ikstretch = MEM_mallocN(sizeof(float) * tree->totchannel, "ik stretch"); - + for (a = 0; a < tree->totchannel; a++) { IK_GetBasisChange(iktree[a], tree->basis_change[a]); - + if (hasstretch) { /* have to compensate for scaling received from parent */ float parentstretch, stretch; - + pchan = tree->pchan[a]; parentstretch = (tree->parent[a] >= 0) ? ikstretch[tree->parent[a]] : 1.0f; - + if (tree->stretch && (pchan->ikstretch > 0.0f)) { float trans[3], length; - + IK_GetTranslationChange(iktree[a], trans); length = pchan->bone->length * len_v3(pchan->pose_mat[1]); - + ikstretch[a] = (length == 0.0f) ? 1.0f : (trans[1] + length) / length; } else ikstretch[a] = 1.0; - + stretch = (parentstretch == 0.0f) ? 1.0f : ikstretch[a] / parentstretch; - + mul_v3_fl(tree->basis_change[a][0], stretch); mul_v3_fl(tree->basis_change[a][1], stretch); mul_v3_fl(tree->basis_change[a][2], stretch); @@ -491,10 +490,10 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) blend_m3_m3m3(tree->basis_change[a], identity, tree->basis_change[a], resultinf); } - + IK_FreeSegment(iktree[a]); } - + MEM_freeN(iktree); if (ikstretch) MEM_freeN(ikstretch); } @@ -514,7 +513,7 @@ static void free_posetree(PoseTree *tree) void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime)) { bPoseChannel *pchan; - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->constflag & PCHAN_HAS_IK) // flag is set on editing constraints initialize_posetree(ob, pchan); // will attach it to root! @@ -527,11 +526,11 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose while (pchan->iktree.first) { PoseTree *tree = pchan->iktree.first; int a; - + /* stop on the first tree that isn't a standard IK chain */ if (tree->type != CONSTRAINT_TYPE_KINEMATIC) return; - + /* 4. walk over the tree for regular solving */ for (a = 0; a < tree->totchannel; a++) { if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag @@ -541,18 +540,18 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose } /* 5. execute the IK solver */ execute_posetree(scene, ob, tree); - - /* 6. apply the differences to the channels, + + /* 6. apply the differences to the channels, * we need to calculate the original differences first */ for (a = 0; a < tree->totchannel; a++) { make_dmats(tree->pchan[a]); } - + for (a = 0; a < tree->totchannel; a++) { /* sets POSE_DONE */ where_is_ik_bone(tree->pchan[a], tree->basis_change[a]); } - + /* 7. and free */ BLI_remlink(&pchan->iktree, tree); free_posetree(tree); diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 048dd955726..a0d7bfbaaf6 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -21,7 +21,7 @@ * The Original Code is: all of this file. * * Original author: Benoit Bolsee - * Contributor(s): + * Contributor(s): * * ***** END GPL LICENSE BLOCK ***** */ @@ -30,7 +30,6 @@ * \ingroup ikplugin */ - #include <stdlib.h> #include <string.h> #include <vector> @@ -73,23 +72,22 @@ extern "C" { bItasc DefIKParam; // in case of animation mode, feedback and timestep is fixed -#define ANIM_TIMESTEP 1.0 -#define ANIM_FEEDBACK 0.8 -#define ANIM_QMAX 0.52 +#define ANIM_TIMESTEP 1.0 +#define ANIM_FEEDBACK 0.8 +#define ANIM_QMAX 0.52 // Structure pointed by bPose.ikdata // It contains everything needed to simulate the armatures // There can be several simulation islands independent to each other -struct IK_Data -{ - struct IK_Scene* first; +struct IK_Data { + struct IK_Scene *first; }; typedef float Vector3[3]; typedef float Vector4[4]; struct IK_Target; -typedef void (*ErrorCallback)(const iTaSC::ConstraintValues* values, unsigned int nvalues, IK_Target* iktarget); +typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget); // one structure for each target in the scene struct IK_Target @@ -160,8 +158,7 @@ struct IK_Channel { } }; -struct IK_Scene -{ +struct IK_Scene { struct Scene *blscene; IK_Scene* next; int numchan; // number of channel in pchan @@ -201,11 +198,11 @@ struct IK_Scene // delete scene first if (scene) delete scene; - for (std::vector<IK_Target*>::iterator it = targets.begin(); it != targets.end(); ++it) + for (std::vector<IK_Target *>::iterator it = targets.begin(); it != targets.end(); ++it) delete (*it); targets.clear(); if (channels) - delete [] channels; + delete[] channels; if (solver) delete solver; if (armature) @@ -239,38 +236,38 @@ enum IK_SegmentAxis { static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *con) { - bPoseChannel *curchan, *pchan_root=NULL, *chanlist[256], **oldchan; + bPoseChannel *curchan, *pchan_root = NULL, *chanlist[256], **oldchan; PoseTree *tree; PoseTarget *target; bKinematicConstraint *data; - int a, t, segcount= 0, size, newsize, *oldparent, parent, rootbone, treecount; + int a, t, segcount = 0, size, newsize, *oldparent, parent, rootbone, treecount; + + data = (bKinematicConstraint *)con->data; - data=(bKinematicConstraint*)con->data; - /* exclude tip from chain? */ if (!(data->flag & CONSTRAINT_IK_TIP)) - pchan_tip= pchan_tip->parent; - + pchan_tip = pchan_tip->parent; + rootbone = data->rootbone; /* Find the chain's root & count the segments needed */ - for (curchan = pchan_tip; curchan; curchan=curchan->parent) { + for (curchan = pchan_tip; curchan; curchan = curchan->parent) { pchan_root = curchan; - - if (++segcount > 255) // 255 is weak + + if (++segcount > 255) // 255 is weak break; - if (segcount==rootbone) { - // reached this end of the chain but if the chain is overlapping with a + if (segcount == rootbone) { + // reached this end of the chain but if the chain is overlapping with a // previous one, we must go back up to the root of the other chain if ((curchan->flag & POSE_CHAIN) && curchan->iktree.first == NULL) { rootbone++; continue; } - break; + break; } if (curchan->iktree.first != NULL) - // Oh oh, there is already a chain starting from this channel and our chain is longer... + // Oh oh, there is already a chain starting from this channel and our chain is longer... // Should handle this by moving the previous chain up to the beginning of our chain // For now we just stop here break; @@ -280,86 +277,86 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co if ((pchan_root->flag & POSE_CHAIN) && pchan_root->iktree.first == NULL) return 0; // now that we know how many segment we have, set the flag - for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone; segcount++, curchan=curchan->parent) { - chanlist[segcount]=curchan; + for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone; segcount++, curchan = curchan->parent) { + chanlist[segcount] = curchan; curchan->flag |= POSE_CHAIN; } /* setup the chain data */ /* create a target */ - target= (PoseTarget*)MEM_callocN(sizeof(PoseTarget), "posetarget"); - target->con= con; + target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget"); + target->con = con; // by contruction there can be only one tree per channel and each channel can be part of at most one tree. - tree = (PoseTree*)pchan_root->iktree.first; + tree = (PoseTree *)pchan_root->iktree.first; - if (tree==NULL) { + if (tree == NULL) { /* make new tree */ - tree= (PoseTree*)MEM_callocN(sizeof(PoseTree), "posetree"); + tree = (PoseTree *)MEM_callocN(sizeof(PoseTree), "posetree"); - tree->iterations= data->iterations; - tree->totchannel= segcount; + tree->iterations = data->iterations; + tree->totchannel = segcount; tree->stretch = (data->flag & CONSTRAINT_IK_STRETCH); - - tree->pchan= (bPoseChannel**)MEM_callocN(segcount*sizeof(void*), "ik tree pchan"); - tree->parent= (int*)MEM_callocN(segcount*sizeof(int), "ik tree parent"); - for (a=0; a<segcount; a++) { - tree->pchan[a]= chanlist[segcount-a-1]; - tree->parent[a]= a-1; + + tree->pchan = (bPoseChannel **)MEM_callocN(segcount * sizeof(void *), "ik tree pchan"); + tree->parent = (int *)MEM_callocN(segcount * sizeof(int), "ik tree parent"); + for (a = 0; a < segcount; a++) { + tree->pchan[a] = chanlist[segcount - a - 1]; + tree->parent[a] = a - 1; } - target->tip= segcount-1; - + target->tip = segcount - 1; + /* AND! link the tree to the root */ BLI_addtail(&pchan_root->iktree, tree); // new tree treecount = 1; } else { - tree->iterations= MAX2(data->iterations, tree->iterations); - tree->stretch= tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH); + tree->iterations = MAX2(data->iterations, tree->iterations); + tree->stretch = tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH); /* skip common pose channels and add remaining*/ - size= MIN2(segcount, tree->totchannel); + size = MIN2(segcount, tree->totchannel); a = t = 0; - while (a<size && t<tree->totchannel) { + while (a < size && t < tree->totchannel) { // locate first matching channel - for (;t<tree->totchannel && tree->pchan[t]!=chanlist[segcount-a-1];t++); - if (t>=tree->totchannel) + for (; t < tree->totchannel && tree->pchan[t] != chanlist[segcount - a - 1]; t++) ; + if (t >= tree->totchannel) break; - for (; a<size && t<tree->totchannel && tree->pchan[t]==chanlist[segcount-a-1]; a++, t++); + for (; a < size && t < tree->totchannel && tree->pchan[t] == chanlist[segcount - a - 1]; a++, t++) ; } - segcount= segcount-a; - target->tip= tree->totchannel + segcount - 1; + segcount = segcount - a; + target->tip = tree->totchannel + segcount - 1; if (segcount > 0) { for (parent = a - 1; parent < tree->totchannel; parent++) - if (tree->pchan[parent] == chanlist[segcount-1]->parent) + if (tree->pchan[parent] == chanlist[segcount - 1]->parent) break; - + /* shouldn't happen, but could with dependency cycles */ if (parent == tree->totchannel) parent = a - 1; /* resize array */ - newsize= tree->totchannel + segcount; - oldchan= tree->pchan; - oldparent= tree->parent; - - tree->pchan= (bPoseChannel**)MEM_callocN(newsize*sizeof(void*), "ik tree pchan"); - tree->parent= (int*)MEM_callocN(newsize*sizeof(int), "ik tree parent"); - memcpy(tree->pchan, oldchan, sizeof(void*)*tree->totchannel); - memcpy(tree->parent, oldparent, sizeof(int)*tree->totchannel); + newsize = tree->totchannel + segcount; + oldchan = tree->pchan; + oldparent = tree->parent; + + tree->pchan = (bPoseChannel **)MEM_callocN(newsize * sizeof(void *), "ik tree pchan"); + tree->parent = (int *)MEM_callocN(newsize * sizeof(int), "ik tree parent"); + memcpy(tree->pchan, oldchan, sizeof(void *) * tree->totchannel); + memcpy(tree->parent, oldparent, sizeof(int) * tree->totchannel); MEM_freeN(oldchan); MEM_freeN(oldparent); /* add new pose channels at the end, in reverse order */ - for (a=0; a<segcount; a++) { - tree->pchan[tree->totchannel+a]= chanlist[segcount-a-1]; - tree->parent[tree->totchannel+a]= tree->totchannel+a-1; + for (a = 0; a < segcount; a++) { + tree->pchan[tree->totchannel + a] = chanlist[segcount - a - 1]; + tree->parent[tree->totchannel + a] = tree->totchannel + a - 1; } - tree->parent[tree->totchannel]= parent; - - tree->totchannel= newsize; + tree->parent[tree->totchannel] = parent; + + tree->totchannel = newsize; } // reusing tree treecount = 0; @@ -381,7 +378,7 @@ static bool is_cartesian_constraint(bConstraint *con) static bool constraint_valid(bConstraint *con) { - bKinematicConstraint* data=(bKinematicConstraint*)con->data; + bKinematicConstraint *data = (bKinematicConstraint *)con->data; if (data->flag & CONSTRAINT_IK_AUTO) return true; @@ -389,9 +386,9 @@ static bool constraint_valid(bConstraint *con) return false; if (is_cartesian_constraint(con)) { /* cartesian space constraint */ - if (data->tar==NULL) + if (data->tar == NULL) return false; - if (data->tar->type==OB_ARMATURE && data->subtarget[0]==0) + if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0) return false; } return true; @@ -404,8 +401,8 @@ int initialize_scene(Object *ob, bPoseChannel *pchan_tip) /* find all IK constraints and validate them */ treecount = 0; - for (con= (bConstraint *)pchan_tip->constraints.first; con; con= (bConstraint *)con->next) { - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + for (con = (bConstraint *)pchan_tip->constraints.first; con; con = (bConstraint *)con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { if (constraint_valid(con)) treecount += initialize_chain(ob, pchan_tip, con); } @@ -413,23 +410,23 @@ int initialize_scene(Object *ob, bPoseChannel *pchan_tip) return treecount; } -static IK_Data* get_ikdata(bPose *pose) +static IK_Data *get_ikdata(bPose *pose) { if (pose->ikdata) - return (IK_Data*)pose->ikdata; + return (IK_Data *)pose->ikdata; pose->ikdata = MEM_callocN(sizeof(IK_Data), "iTaSC ikdata"); // here init ikdata if needed // now that we have scene, make sure the default param are initialized if (!DefIKParam.iksolver) BKE_pose_itasc_init(&DefIKParam); - return (IK_Data*)pose->ikdata; + return (IK_Data *)pose->ikdata; } static double EulerAngleFromMatrix(const KDL::Rotation& R, int axis) { - double t = KDL::sqrt(R(0, 0)*R(0, 0) + R(0, 1)*R(0, 1)); + double t = KDL::sqrt(R(0, 0) * R(0, 0) + R(0, 1) * R(0, 1)); - if (t > 16.0*KDL::epsilon) { + if (t > 16.0 * KDL::epsilon) { if (axis == 0) return -KDL::atan2(R(1, 2), R(2, 2)); else if (axis == 1) return KDL::atan2(-R(0, 2), t); else return -KDL::atan2(R(0, 1), R(0, 0)); @@ -447,7 +444,7 @@ static double ComputeTwist(const KDL::Rotation& R) double qy = R(0, 2) - R(2, 0); double qw = R(0, 0) + R(1, 1) + R(2, 2) + 1; - double tau = 2*KDL::atan2(qy, qw); + double tau = 2 * KDL::atan2(qy, qw); return tau; } @@ -457,102 +454,102 @@ static void RemoveEulerAngleFromMatrix(KDL::Rotation& R, double angle, int axis) // compute twist parameter KDL::Rotation T; switch (axis) { - case 0: - T = KDL::Rotation::RotX(-angle); - break; - case 1: - T = KDL::Rotation::RotY(-angle); - break; - case 2: - T = KDL::Rotation::RotZ(-angle); - break; - default: - return; + case 0: + T = KDL::Rotation::RotX(-angle); + break; + case 1: + T = KDL::Rotation::RotY(-angle); + break; + case 2: + T = KDL::Rotation::RotZ(-angle); + break; + default: + return; } // remove angle - R = R*T; + R = R * T; } #if 0 static void GetEulerXZY(const KDL::Rotation& R, double& X, double& Z, double& Y) { - if (fabs(R(0, 1)) > 1.0 - KDL::epsilon ) { + if (fabs(R(0, 1)) > 1.0 - KDL::epsilon) { X = -KDL::sign(R(0, 1)) * KDL::atan2(R(1, 2), R(1, 0)); Z = -KDL::sign(R(0, 1)) * KDL::PI / 2; Y = 0.0; } else { X = KDL::atan2(R(2, 1), R(1, 1)); - Z = KDL::atan2(-R(0, 1), KDL::sqrt( KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 2)))); + Z = KDL::atan2(-R(0, 1), KDL::sqrt(KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 2)))); Y = KDL::atan2(R(0, 2), R(0, 0)); } } static void GetEulerXYZ(const KDL::Rotation& R, double& X, double& Y, double& Z) { - if (fabs(R(0, 2)) > 1.0 - KDL::epsilon ) { + if (fabs(R(0, 2)) > 1.0 - KDL::epsilon) { X = KDL::sign(R(0, 2)) * KDL::atan2(-R(1, 0), R(1, 1)); Y = KDL::sign(R(0, 2)) * KDL::PI / 2; Z = 0.0; } else { X = KDL::atan2(-R(1, 2), R(2, 2)); - Y = KDL::atan2(R(0, 2), KDL::sqrt( KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 1)))); + Y = KDL::atan2(R(0, 2), KDL::sqrt(KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 1)))); Z = KDL::atan2(-R(0, 1), R(0, 0)); } } #endif -static void GetJointRotation(KDL::Rotation& boneRot, int type, double* rot) +static void GetJointRotation(KDL::Rotation& boneRot, int type, double *rot) { switch (type & ~IK_TRANSY) { - default: - // fixed bone, no joint - break; - case IK_XDOF: - // RX only, get the X rotation - rot[0] = EulerAngleFromMatrix(boneRot, 0); - break; - case IK_YDOF: - // RY only, get the Y rotation - rot[0] = ComputeTwist(boneRot); - break; - case IK_ZDOF: - // RZ only, get the Z rotation - rot[0] = EulerAngleFromMatrix(boneRot, 2); - break; - case IK_XDOF|IK_YDOF: - rot[1] = ComputeTwist(boneRot); - RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); - rot[0] = EulerAngleFromMatrix(boneRot, 0); - break; - case IK_SWING: - // RX+RZ - boneRot.GetXZRot().GetValue(rot); - break; - case IK_YDOF|IK_ZDOF: - // RZ+RY - rot[1] = ComputeTwist(boneRot); - RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); - rot[0] = EulerAngleFromMatrix(boneRot, 2); - break; - case IK_SWING|IK_YDOF: - rot[2] = ComputeTwist(boneRot); - RemoveEulerAngleFromMatrix(boneRot, rot[2], 1); - boneRot.GetXZRot().GetValue(rot); - break; - case IK_REVOLUTE: - boneRot.GetRot().GetValue(rot); - break; + default: + // fixed bone, no joint + break; + case IK_XDOF: + // RX only, get the X rotation + rot[0] = EulerAngleFromMatrix(boneRot, 0); + break; + case IK_YDOF: + // RY only, get the Y rotation + rot[0] = ComputeTwist(boneRot); + break; + case IK_ZDOF: + // RZ only, get the Z rotation + rot[0] = EulerAngleFromMatrix(boneRot, 2); + break; + case IK_XDOF | IK_YDOF: + rot[1] = ComputeTwist(boneRot); + RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); + rot[0] = EulerAngleFromMatrix(boneRot, 0); + break; + case IK_SWING: + // RX+RZ + boneRot.GetXZRot().GetValue(rot); + break; + case IK_YDOF | IK_ZDOF: + // RZ+RY + rot[1] = ComputeTwist(boneRot); + RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); + rot[0] = EulerAngleFromMatrix(boneRot, 2); + break; + case IK_SWING | IK_YDOF: + rot[2] = ComputeTwist(boneRot); + RemoveEulerAngleFromMatrix(boneRot, rot[2], 1); + boneRot.GetXZRot().GetValue(rot); + break; + case IK_REVOLUTE: + boneRot.GetRot().GetValue(rot); + break; } } static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param) { - IK_Target* target = (IK_Target*)param; + IK_Target *target = (IK_Target *)param; // compute next target position // get target matrix from constraint. - bConstraint* constraint = (bConstraint*)target->blenderConstraint; + bConstraint *constraint = (bConstraint *)target->blenderConstraint; float tarmat[4][4]; get_constraint_target_matrix(target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0); @@ -564,14 +561,14 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram // eeRest is relative to the reference frame of the IK root // get this frame in world reference float restmat[4][4]; - bPoseChannel* pchan = target->rootChannel; + bPoseChannel *pchan = target->rootChannel; if (pchan->parent) { pchan = pchan->parent; float chanmat[4][4]; copy_m4_m4(chanmat, pchan->pose_mat); copy_v3_v3(chanmat[3], pchan->pose_tail); mul_serie_m4(restmat, target->owner->obmat, chanmat, target->eeRest, NULL, NULL, NULL, NULL, NULL); - } + } else { mult_m4_m4m4(restmat, target->owner->obmat, target->eeRest); } @@ -584,13 +581,13 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param) { - IK_Scene* ikscene = (IK_Scene*)param; + IK_Scene *ikscene = (IK_Scene *)param; // compute next armature base pose - // algorithm: + // algorithm: // ikscene->pchan[0] is the root channel of the tree // if it has a parent, get the pose matrix from it and replace [3] by parent pchan->tail // then multiply by the armature matrix to get ikscene->armature base position - bPoseChannel* pchan = ikscene->channels[0].pchan; + bPoseChannel *pchan = ikscene->channels[0].pchan; float rootmat[4][4]; if (pchan->parent) { pchan = pchan->parent; @@ -602,7 +599,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& // iTaSC armature is scaled to object scale, scale the base frame too ikscene->baseFrame.p *= ikscene->blScale; mult_m4_m4m4(rootmat, ikscene->blArmature->obmat, chanmat); - } + } else { copy_m4_m4(rootmat, ikscene->blArmature->obmat); ikscene->baseFrame = iTaSC::F_identity; @@ -611,11 +608,11 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& // if there is a polar target (only during solving otherwise we don't have end efffector) if (ikscene->polarConstraint && timestamp.update) { // compute additional rotation of base frame so that armature follows the polar target - float imat[4][4]; // IK tree base inverse matrix - float polemat[4][4]; // polar target in IK tree base frame - float goalmat[4][4]; // target in IK tree base frame - float mat[4][4]; // temp matrix - bKinematicConstraint* poledata = (bKinematicConstraint*)ikscene->polarConstraint->data; + float imat[4][4]; // IK tree base inverse matrix + float polemat[4][4]; // polar target in IK tree base frame + float goalmat[4][4]; // target in IK tree base frame + float mat[4][4]; // temp matrix + bKinematicConstraint *poledata = (bKinematicConstraint *)ikscene->polarConstraint->data; invert_m4_m4(imat, rootmat); // polar constraint imply only one target @@ -642,48 +639,48 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& KDL::Vector rootz = rootframe.M.UnitZ(); // and compute root bone head double q_rest[3], q[3], length; - const KDL::Joint* joint; - const KDL::Frame* tip; + const KDL::Joint *joint; + const KDL::Frame *tip; ikscene->armature->getSegment(rootchan.tail, 3, joint, q_rest[0], q[0], tip); length = (joint->getType() == KDL::Joint::TransY) ? q[0] : tip->p(1); - KDL::Vector rootpos = rootframe.p - length*rootframe.M.UnitY(); + KDL::Vector rootpos = rootframe.p - length *rootframe.M.UnitY(); - // compute main directions + // compute main directions KDL::Vector dir = KDL::Normalize(endpos - rootpos); - KDL::Vector poledir = KDL::Normalize(goalpos-rootpos); + KDL::Vector poledir = KDL::Normalize(goalpos - rootpos); // compute up directions - KDL::Vector poleup = KDL::Normalize(polepos-rootpos); - KDL::Vector up = rootx*KDL::cos(poledata->poleangle) + rootz*KDL::sin(poledata->poleangle); + KDL::Vector poleup = KDL::Normalize(polepos - rootpos); + KDL::Vector up = rootx * KDL::cos(poledata->poleangle) + rootz *KDL::sin(poledata->poleangle); // from which we build rotation matrix KDL::Rotation endrot, polerot; // for the armature, using the root bone orientation - KDL::Vector x = KDL::Normalize(dir*up); + KDL::Vector x = KDL::Normalize(dir * up); endrot.UnitX(x); - endrot.UnitY(KDL::Normalize(x*dir)); + endrot.UnitY(KDL::Normalize(x * dir)); endrot.UnitZ(-dir); - // for the polar target - x = KDL::Normalize(poledir*poleup); + // for the polar target + x = KDL::Normalize(poledir * poleup); polerot.UnitX(x); - polerot.UnitY(KDL::Normalize(x*poledir)); + polerot.UnitY(KDL::Normalize(x * poledir)); polerot.UnitZ(-poledir); // the difference between the two is the rotation we want to apply - KDL::Rotation result(polerot*endrot.Inverse()); + KDL::Rotation result(polerot * endrot.Inverse()); // apply on base frame as this is an artificial additional rotation - next.M = next.M*result; - ikscene->baseFrame.M = ikscene->baseFrame.M*result; + next.M = next.M * result; + ikscene->baseFrame.M = ikscene->baseFrame.M * result; } return true; } -static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues* const _values, unsigned int _nvalues, void* _param) +static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param) { - IK_Target* iktarget =(IK_Target*)_param; + IK_Target *iktarget = (IK_Target *)_param; bKinematicConstraint *condata = (bKinematicConstraint *)iktarget->blenderConstraint->data; - iTaSC::ConstraintValues* values = _values; - bItasc* ikparam = (bItasc*) iktarget->owner->pose->ikparam; + iTaSC::ConstraintValues *values = _values; + bItasc *ikparam = (bItasc *) iktarget->owner->pose->ikparam; // we need default parameters - if (!ikparam) + if (!ikparam) ikparam = &DefIKParam; if (iktarget->blenderConstraint->flag & CONSTRAINT_OFF) { @@ -702,14 +699,14 @@ static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) { // update error values->alpha = condata->weight; - values->action = iTaSC::ACT_ALPHA|iTaSC::ACT_FEEDBACK; + values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK; values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK; values++; } if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) { // update error values->alpha = condata->orientweight; - values->action = iTaSC::ACT_ALPHA|iTaSC::ACT_FEEDBACK; + values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK; values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK; values++; } @@ -717,36 +714,36 @@ static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai return true; } -static void copypose_error(const iTaSC::ConstraintValues* values, unsigned int nvalues, IK_Target* iktarget) +static void copypose_error(const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget) { - iTaSC::ConstraintSingleValue* value; + iTaSC::ConstraintSingleValue *value; double error; int i; if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) { // update error - for (i=0, error=0.0, value=values->values; i<values->number; ++i, ++value) + for (i = 0, error = 0.0, value = values->values; i < values->number; ++i, ++value) error += KDL::sqr(value->y - value->yd); iktarget->blenderConstraint->lin_error = (float)KDL::sqrt(error); values++; } if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) { // update error - for (i=0, error=0.0, value=values->values; i<values->number; ++i, ++value) + for (i = 0, error = 0.0, value = values->values; i < values->number; ++i, ++value) error += KDL::sqr(value->y - value->yd); iktarget->blenderConstraint->rot_error = (float)KDL::sqrt(error); values++; } } -static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues* const _values, unsigned int _nvalues, void* _param) +static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param) { - IK_Target* iktarget =(IK_Target*)_param; + IK_Target *iktarget = (IK_Target *)_param; bKinematicConstraint *condata = (bKinematicConstraint *)iktarget->blenderConstraint->data; - iTaSC::ConstraintValues* values = _values; - bItasc* ikparam = (bItasc*) iktarget->owner->pose->ikparam; + iTaSC::ConstraintValues *values = _values; + bItasc *ikparam = (bItasc *) iktarget->owner->pose->ikparam; // we need default parameters - if (!ikparam) + if (!ikparam) ikparam = &DefIKParam; // update weight according to mode @@ -755,30 +752,30 @@ static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai } else { switch (condata->mode) { - case LIMITDIST_INSIDE: - values->alpha = (values->values[0].y > condata->dist) ? condata->weight : 0.0; - break; - case LIMITDIST_OUTSIDE: - values->alpha = (values->values[0].y < condata->dist) ? condata->weight : 0.0; - break; - default: - values->alpha = condata->weight; - break; - } - if (!timestamp.substep) { - // only update value on first timestep - switch (condata->mode) { case LIMITDIST_INSIDE: - values->values[0].yd = condata->dist*0.95; + values->alpha = (values->values[0].y > condata->dist) ? condata->weight : 0.0; break; case LIMITDIST_OUTSIDE: - values->values[0].yd = condata->dist*1.05; + values->alpha = (values->values[0].y < condata->dist) ? condata->weight : 0.0; break; default: - values->values[0].yd = condata->dist; + values->alpha = condata->weight; break; + } + if (!timestamp.substep) { + // only update value on first timestep + switch (condata->mode) { + case LIMITDIST_INSIDE: + values->values[0].yd = condata->dist * 0.95; + break; + case LIMITDIST_OUTSIDE: + values->values[0].yd = condata->dist * 1.05; + break; + default: + values->values[0].yd = condata->dist; + break; } - values->values[0].action = iTaSC::ACT_VALUE|iTaSC::ACT_FEEDBACK; + values->values[0].action = iTaSC::ACT_VALUE | iTaSC::ACT_FEEDBACK; values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK; } } @@ -786,16 +783,16 @@ static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai return true; } -static void distance_error(const iTaSC::ConstraintValues* values, unsigned int _nvalues, IK_Target* iktarget) +static void distance_error(const iTaSC::ConstraintValues *values, unsigned int _nvalues, IK_Target *iktarget) { iktarget->blenderConstraint->lin_error = (float)(values->values[0].y - values->values[0].yd); } -static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues* const _values, unsigned int _nvalues, void* _param) +static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param) { - IK_Channel* ikchan = (IK_Channel*)_param; - bItasc* ikparam = (bItasc*)ikchan->owner->pose->ikparam; - bPoseChannel* chan = ikchan->pchan; + IK_Channel *ikchan = (IK_Channel *)_param; + bItasc *ikparam = (bItasc *)ikchan->owner->pose->ikparam; + bPoseChannel *chan = ikchan->pchan; int dof; // a channel can be splitted into multiple joints, so we get called multiple @@ -808,57 +805,57 @@ static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintV if (chan->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - eulO_to_mat3( rmat, chan->eul, chan->rotmode); + eulO_to_mat3(rmat, chan->eul, chan->rotmode); } else if (chan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - stored in quaternion data, but not really that great for 3D-changing orientations */ - axis_angle_to_mat3( rmat, &chan->quat[1], chan->quat[0]); + axis_angle_to_mat3(rmat, &chan->quat[1], chan->quat[0]); } else { - /* quats are normalised before use to eliminate scaling issues */ + /* quats are normalized before use to eliminate scaling issues */ normalize_qt(chan->quat); quat_to_mat3(rmat, chan->quat); } KDL::Rotation jointRot( - rmat[0][0], rmat[1][0], rmat[2][0], - rmat[0][1], rmat[1][1], rmat[2][1], - rmat[0][2], rmat[1][2], rmat[2][2]); + rmat[0][0], rmat[1][0], rmat[2][0], + rmat[0][1], rmat[1][1], rmat[2][1], + rmat[0][2], rmat[1][2], rmat[2][2]); GetJointRotation(jointRot, ikchan->jointType, ikchan->jointValue); ikchan->jointValid = 1; } // determine which part of jointValue is used for this joint // closely related to the way the joints are defined switch (ikchan->jointType & ~IK_TRANSY) { - case IK_XDOF: - case IK_YDOF: - case IK_ZDOF: - dof = 0; - break; - case IK_XDOF|IK_YDOF: - // X + Y - dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RX) ? 0 : 1; - break; - case IK_SWING: - // XZ - dof = 0; - break; - case IK_YDOF|IK_ZDOF: - // Z + Y - dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RZ) ? 0 : 1; - break; - case IK_SWING|IK_YDOF: - // XZ + Y - dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RY) ? 2 : 0; - break; - case IK_REVOLUTE: - dof = 0; - break; - default: - dof = -1; - break; + case IK_XDOF: + case IK_YDOF: + case IK_ZDOF: + dof = 0; + break; + case IK_XDOF | IK_YDOF: + // X + Y + dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RX) ? 0 : 1; + break; + case IK_SWING: + // XZ + dof = 0; + break; + case IK_YDOF | IK_ZDOF: + // Z + Y + dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RZ) ? 0 : 1; + break; + case IK_SWING | IK_YDOF: + // XZ + Y + dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RY) ? 2 : 0; + break; + case IK_REVOLUTE: + dof = 0; + break; + default: + dof = -1; + break; } if (dof >= 0) { - for (unsigned int i=0; i<_nvalues; i++, dof++) { + for (unsigned int i = 0; i < _nvalues; i++, dof++) { _values[i].values[0].yd = ikchan->jointValue[dof]; _values[i].alpha = chan->ikrotweight; _values[i].feedback = ikparam->feedback; @@ -875,30 +872,30 @@ static int convert_channels(IK_Scene *ikscene, PoseTree *tree) int a, flag, njoint; njoint = 0; - for (a=0, ikchan = ikscene->channels; a<ikscene->numchan; ++a, ++ikchan) { - pchan= tree->pchan[a]; + for (a = 0, ikchan = ikscene->channels; a < ikscene->numchan; ++a, ++ikchan) { + pchan = tree->pchan[a]; ikchan->pchan = pchan; - ikchan->parent = (a>0) ? tree->parent[a] : -1; + ikchan->parent = (a > 0) ? tree->parent[a] : -1; ikchan->owner = ikscene->blArmature; - + /* set DoF flag */ flag = 0; if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP) && - (!(pchan->ikflag & BONE_IK_XLIMIT) || pchan->limitmin[0]<0.f || pchan->limitmax[0]>0.f)) + (!(pchan->ikflag & BONE_IK_XLIMIT) || pchan->limitmin[0] < 0.f || pchan->limitmax[0] > 0.f)) { flag |= IK_XDOF; } if (!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP) && - (!(pchan->ikflag & BONE_IK_YLIMIT) || pchan->limitmin[1]<0.f || pchan->limitmax[1]>0.f)) + (!(pchan->ikflag & BONE_IK_YLIMIT) || pchan->limitmin[1] < 0.f || pchan->limitmax[1] > 0.f)) { flag |= IK_YDOF; } if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP) && - (!(pchan->ikflag & BONE_IK_ZLIMIT) || pchan->limitmin[2]<0.f || pchan->limitmax[2]>0.f)) + (!(pchan->ikflag & BONE_IK_ZLIMIT) || pchan->limitmin[2] < 0.f || pchan->limitmax[2] > 0.f)) { flag |= IK_ZDOF; } - + if (tree->stretch && (pchan->ikstretch > 0.0)) { flag |= IK_TRANSY; } @@ -929,49 +926,49 @@ static int convert_channels(IK_Scene *ikscene, PoseTree *tree) * bone length is computed from bone->length multiplied by the scaling factor of * the armature. Non-uniform scaling will give bad result! */ - switch (flag & (IK_XDOF|IK_YDOF|IK_ZDOF)) { - default: - ikchan->jointType = 0; - ikchan->ndof = 0; - break; - case IK_XDOF: - // RX only, get the X rotation - ikchan->jointType = IK_XDOF; - ikchan->ndof = 1; - break; - case IK_YDOF: - // RY only, get the Y rotation - ikchan->jointType = IK_YDOF; - ikchan->ndof = 1; - break; - case IK_ZDOF: - // RZ only, get the Zz rotation - ikchan->jointType = IK_ZDOF; - ikchan->ndof = 1; - break; - case IK_XDOF|IK_YDOF: - ikchan->jointType = IK_XDOF|IK_YDOF; - ikchan->ndof = 2; - break; - case IK_XDOF|IK_ZDOF: - // RX+RZ - ikchan->jointType = IK_SWING; - ikchan->ndof = 2; - break; - case IK_YDOF|IK_ZDOF: - // RZ+RY - ikchan->jointType = IK_ZDOF|IK_YDOF; - ikchan->ndof = 2; - break; - case IK_XDOF|IK_YDOF|IK_ZDOF: - // spherical joint - if (pchan->ikflag & (BONE_IK_XLIMIT|BONE_IK_YLIMIT|BONE_IK_ZLIMIT)) - // decompose in a Swing+RotY joint - ikchan->jointType = IK_SWING|IK_YDOF; - else - ikchan->jointType = IK_REVOLUTE; - ikchan->ndof = 3; - break; + switch (flag & (IK_XDOF | IK_YDOF | IK_ZDOF)) { + default: + ikchan->jointType = 0; + ikchan->ndof = 0; + break; + case IK_XDOF: + // RX only, get the X rotation + ikchan->jointType = IK_XDOF; + ikchan->ndof = 1; + break; + case IK_YDOF: + // RY only, get the Y rotation + ikchan->jointType = IK_YDOF; + ikchan->ndof = 1; + break; + case IK_ZDOF: + // RZ only, get the Zz rotation + ikchan->jointType = IK_ZDOF; + ikchan->ndof = 1; + break; + case IK_XDOF | IK_YDOF: + ikchan->jointType = IK_XDOF | IK_YDOF; + ikchan->ndof = 2; + break; + case IK_XDOF | IK_ZDOF: + // RX+RZ + ikchan->jointType = IK_SWING; + ikchan->ndof = 2; + break; + case IK_YDOF | IK_ZDOF: + // RZ+RY + ikchan->jointType = IK_ZDOF | IK_YDOF; + ikchan->ndof = 2; + break; + case IK_XDOF | IK_YDOF | IK_ZDOF: + // spherical joint + if (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_YLIMIT | BONE_IK_ZLIMIT)) + // decompose in a Swing+RotY joint + ikchan->jointType = IK_SWING | IK_YDOF; + else + ikchan->jointType = IK_REVOLUTE; + ikchan->ndof = 3; + break; } if (flag & IK_TRANSY) { ikchan->jointType |= IK_TRANSY; @@ -992,8 +989,8 @@ static void convert_pose(IK_Scene *ikscene) bPoseChannel *pchan; IK_Channel *ikchan; Bone *bone; - float rmat[4][4]; // rest pose of bone with parent taken into account - float bmat[4][4]; // difference + float rmat[4][4]; // rest pose of bone with parent taken into account + float bmat[4][4]; // difference float scale; double *rot; int a, joint; @@ -1001,10 +998,10 @@ static void convert_pose(IK_Scene *ikscene) // assume uniform scaling and take Y scale as general scale for the armature scale = len_v3(ikscene->blArmature->obmat[1]); rot = ikscene->jointArray(0); - for (joint=a=0, ikchan = ikscene->channels; a<ikscene->numchan && joint<ikscene->numjoint; ++a, ++ikchan) { - pchan= ikchan->pchan; - bone= pchan->bone; - + for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; ++a, ++ikchan) { + pchan = ikchan->pchan; + bone = pchan->bone; + if (pchan->parent) { unit_m4(bmat); mul_m4_m4m3(bmat, pchan->parent->pose_mat, bone->bone_mat); @@ -1018,9 +1015,9 @@ static void convert_pose(IK_Scene *ikscene) boneRot.setValue(bmat[0]); GetJointRotation(boneRot, ikchan->jointType, rot); if (ikchan->jointType & IK_TRANSY) { - // compute actual length - rot[ikchan->ndof-1] = len_v3v3(pchan->pose_tail, pchan->pose_head) * scale; - } + // compute actual length + rot[ikchan->ndof - 1] = len_v3v3(pchan->pose_tail, pchan->pose_head) * scale; + } rot += ikchan->ndof; joint += ikchan->ndof; } @@ -1038,32 +1035,32 @@ static void BKE_pose_rest(IK_Scene *ikscene) // assume uniform scaling and take Y scale as general scale for the armature scale = len_v3(ikscene->blArmature->obmat[1]); - // rest pose is 0 + // rest pose is 0 SetToZero(ikscene->jointArray); // except for transY joints rot = ikscene->jointArray(0); - for (joint=a=0, ikchan = ikscene->channels; a<ikscene->numchan && joint<ikscene->numjoint; ++a, ++ikchan) { - pchan= ikchan->pchan; - bone= pchan->bone; + for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; ++a, ++ikchan) { + pchan = ikchan->pchan; + bone = pchan->bone; if (ikchan->jointType & IK_TRANSY) - rot[ikchan->ndof-1] = bone->length*scale; + rot[ikchan->ndof - 1] = bone->length * scale; rot += ikchan->ndof; joint += ikchan->ndof; } } -static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) +static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) { - PoseTree *tree = (PoseTree*)pchan->iktree.first; + PoseTree *tree = (PoseTree *)pchan->iktree.first; PoseTarget *target; bKinematicConstraint *condata; bConstraint *polarcon; bItasc *ikparam; - iTaSC::Armature* arm; - iTaSC::Scene* scene; - IK_Scene* ikscene; - IK_Channel* ikchan; + iTaSC::Armature *arm; + iTaSC::Scene *scene; + IK_Scene *ikscene; + IK_Channel *ikchan; KDL::Frame initPose; KDL::Rotation boneRot; Bone *bone; @@ -1084,7 +1081,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikscene->numchan = tree->totchannel; ikscene->armature = arm; ikscene->scene = scene; - ikparam = (bItasc*)ob->pose->ikparam; + ikparam = (bItasc *)ob->pose->ikparam; ingame = (ob->pose->flag & POSE_GAME_ENGINE); if (!ikparam) { // you must have our own copy @@ -1096,7 +1093,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // shorter than in animation => move to auto step automatically and set // the target substep duration via min/max if (!(ikparam->flag & ITASC_AUTO_STEP)) { - float timestep = blscene->r.frs_sec_base/blscene->r.frs_sec; + float timestep = blscene->r.frs_sec_base / blscene->r.frs_sec; if (ikparam->numstep > 0) timestep /= ikparam->numstep; // with equal min and max, the algorythm will take this step and the indicative substep most of the time @@ -1109,24 +1106,24 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikscene->cache = new iTaSC::Cache(); switch (ikparam->solver) { - case ITASC_SOLVER_SDLS: - ikscene->solver = new iTaSC::WSDLSSolver(); - break; - case ITASC_SOLVER_DLS: - ikscene->solver = new iTaSC::WDLSSolver(); - break; - default: - delete ikscene; - return NULL; + case ITASC_SOLVER_SDLS: + ikscene->solver = new iTaSC::WSDLSSolver(); + break; + case ITASC_SOLVER_DLS: + ikscene->solver = new iTaSC::WDLSSolver(); + break; + default: + delete ikscene; + return NULL; } ikscene->blArmature = ob; // assume uniform scaling and take Y scale as general scale for the armature ikscene->blScale = len_v3(ob->obmat[1]); - ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f/ikscene->blScale; + ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f / ikscene->blScale; - std::string joint; - std::string root("root"); - std::string parent; + std::string joint; + std::string root("root"); + std::string parent; std::vector<double> weights; double weight[3]; // build the array of joints corresponding to the IK chain @@ -1141,22 +1138,22 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) BKE_pose_rest(ikscene); } rot = ikscene->jointArray(0); - for (a=0, ikchan = ikscene->channels; a<tree->totchannel; ++a, ++ikchan) { - pchan= ikchan->pchan; - bone= pchan->bone; + for (a = 0, ikchan = ikscene->channels; a < tree->totchannel; ++a, ++ikchan) { + pchan = ikchan->pchan; + bone = pchan->bone; KDL::Frame tip(iTaSC::F_identity); Vector3 *fl = bone->bone_mat; KDL::Rotation brot( - fl[0][0], fl[1][0], fl[2][0], - fl[0][1], fl[1][1], fl[2][1], - fl[0][2], fl[1][2], fl[2][2]); + fl[0][0], fl[1][0], fl[2][0], + fl[0][1], fl[1][1], fl[2][1], + fl[0][2], fl[1][2], fl[2][2]); KDL::Vector bpos(bone->head[0], bone->head[1], bone->head[2]); bpos *= ikscene->blScale; KDL::Frame head(brot, bpos); - + // rest pose length of the bone taking scaling into account - length= bone->length*ikscene->blScale; + length = bone->length * ikscene->blScale; parent = (a > 0) ? ikscene->channels[tree->parent[a]].tail : root; // first the fixed segment to the bone head if (head.p.Norm() > KDL::epsilon || head.M.GetRot().Norm() > KDL::epsilon) { @@ -1170,95 +1167,95 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) tip.p[1] = length; } joint = bone->name; - weight[0] = (1.0-pchan->stiffness[0]); - weight[1] = (1.0-pchan->stiffness[1]); - weight[2] = (1.0-pchan->stiffness[2]); + weight[0] = (1.0 - pchan->stiffness[0]); + weight[1] = (1.0 - pchan->stiffness[1]); + weight[2] = (1.0 - pchan->stiffness[2]); switch (ikchan->jointType & ~IK_TRANSY) { - case 0: - // fixed bone - if (!(ikchan->jointType & IK_TRANSY)) { - joint += ":F"; - ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip); - } - break; - case IK_XDOF: - // RX only, get the X rotation - joint += ":RX"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0], tip); - weights.push_back(weight[0]); - break; - case IK_YDOF: - // RY only, get the Y rotation - joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[0], tip); - weights.push_back(weight[1]); - break; - case IK_ZDOF: - // RZ only, get the Zz rotation - joint += ":RZ"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0], tip); - weights.push_back(weight[2]); - break; - case IK_XDOF|IK_YDOF: - joint += ":RX"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0]); - weights.push_back(weight[0]); - if (ret) { - parent = joint; - joint = bone->name; - joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); - weights.push_back(weight[1]); - } - break; - case IK_SWING: - joint += ":SW"; - ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0], tip); - weights.push_back(weight[0]); - weights.push_back(weight[2]); - break; - case IK_YDOF|IK_ZDOF: - // RZ+RY - joint += ":RZ"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0]); - weights.push_back(weight[2]); - if (ret) { - parent = joint; - joint = bone->name; + case 0: + // fixed bone + if (!(ikchan->jointType & IK_TRANSY)) { + joint += ":F"; + ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip); + } + break; + case IK_XDOF: + // RX only, get the X rotation + joint += ":RX"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0], tip); + weights.push_back(weight[0]); + break; + case IK_YDOF: + // RY only, get the Y rotation joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[0], tip); weights.push_back(weight[1]); - } - break; - case IK_SWING|IK_YDOF: - // decompose in a Swing+RotY joint - joint += ":SW"; - ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0]); - weights.push_back(weight[0]); - weights.push_back(weight[2]); - if (ret) { - parent = joint; - joint = bone->name; - joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[2], tip); + break; + case IK_ZDOF: + // RZ only, get the Zz rotation + joint += ":RZ"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0], tip); + weights.push_back(weight[2]); + break; + case IK_XDOF | IK_YDOF: + joint += ":RX"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0]); + weights.push_back(weight[0]); + if (ret) { + parent = joint; + joint = bone->name; + joint += ":RY"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); + weights.push_back(weight[1]); + } + break; + case IK_SWING: + joint += ":SW"; + ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0], tip); + weights.push_back(weight[0]); + weights.push_back(weight[2]); + break; + case IK_YDOF | IK_ZDOF: + // RZ+RY + joint += ":RZ"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0]); + weights.push_back(weight[2]); + if (ret) { + parent = joint; + joint = bone->name; + joint += ":RY"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); + weights.push_back(weight[1]); + } + break; + case IK_SWING | IK_YDOF: + // decompose in a Swing+RotY joint + joint += ":SW"; + ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0]); + weights.push_back(weight[0]); + weights.push_back(weight[2]); + if (ret) { + parent = joint; + joint = bone->name; + joint += ":RY"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[2], tip); + weights.push_back(weight[1]); + } + break; + case IK_REVOLUTE: + joint += ":SJ"; + ret = arm->addSegment(joint, parent, KDL::Joint::Sphere, rot[0], tip); + weights.push_back(weight[0]); weights.push_back(weight[1]); - } - break; - case IK_REVOLUTE: - joint += ":SJ"; - ret = arm->addSegment(joint, parent, KDL::Joint::Sphere, rot[0], tip); - weights.push_back(weight[0]); - weights.push_back(weight[1]); - weights.push_back(weight[2]); - break; + weights.push_back(weight[2]); + break; } if (ret && (ikchan->jointType & IK_TRANSY)) { parent = joint; joint = bone->name; joint += ":TY"; - ret = arm->addSegment(joint, parent, KDL::Joint::TransY, rot[ikchan->ndof-1]); - float ikstretch = pchan->ikstretch*pchan->ikstretch; - weight[1] = (1.0-MIN2(1.0-ikstretch, 0.99)); + ret = arm->addSegment(joint, parent, KDL::Joint::TransY, rot[ikchan->ndof - 1]); + float ikstretch = pchan->ikstretch * pchan->ikstretch; + weight[1] = (1.0 - MIN2(1.0 - ikstretch, 0.99)); weights.push_back(weight[1]); } if (!ret) @@ -1269,7 +1266,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikchan->head = parent; // in case of error ret = false; - if ((ikchan->jointType & IK_XDOF) && (pchan->ikflag & (BONE_IK_XLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_XDOF) && (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":RX"; if (pchan->ikflag & BONE_IK_XLIMIT) { @@ -1281,7 +1278,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; } } - if ((ikchan->jointType & IK_YDOF) && (pchan->ikflag & (BONE_IK_YLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_YDOF) && (pchan->ikflag & (BONE_IK_YLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":RY"; if (pchan->ikflag & BONE_IK_YLIMIT) { @@ -1293,7 +1290,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; } } - if ((ikchan->jointType & IK_ZDOF) && (pchan->ikflag & (BONE_IK_ZLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_ZDOF) && (pchan->ikflag & (BONE_IK_ZLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":RZ"; if (pchan->ikflag & BONE_IK_ZLIMIT) { @@ -1305,7 +1302,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; } } - if ((ikchan->jointType & IK_SWING) && (pchan->ikflag & (BONE_IK_XLIMIT|BONE_IK_ZLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_SWING) && (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ZLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":SW"; if (pchan->ikflag & BONE_IK_XLIMIT) { @@ -1336,13 +1333,13 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) return NULL; } // for each target, we need to add an end effector in the armature - for (numtarget=0, polarcon=NULL, ret = true, target=(PoseTarget*)tree->targets.first; target; target=(PoseTarget*)target->next) { - condata= (bKinematicConstraint*)target->con->data; + for (numtarget = 0, polarcon = NULL, ret = true, target = (PoseTarget *)tree->targets.first; target; target = (PoseTarget *)target->next) { + condata = (bKinematicConstraint *)target->con->data; pchan = tree->pchan[target->tip]; if (is_cartesian_constraint(target->con)) { // add the end effector - IK_Target* iktarget = new IK_Target(); + IK_Target *iktarget = new IK_Target(); ikscene->targets.push_back(iktarget); iktarget->ee = arm->addEndEffector(ikscene->channels[target->tip].tail); if (iktarget->ee == -1) { @@ -1372,7 +1369,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikscene->polarConstraint = polarcon; } // we can now add the armature - // the armature is based on a moving frame. + // the armature is based on a moving frame. // initialize with the correct position in case there is no cache base_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, ikscene); ikscene->base = new iTaSC::MovingFrame(initPose); @@ -1392,8 +1389,8 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // set the weight e_matrix& Wq = arm->getWq(); assert(Wq.cols() == (int)weights.size()); - for (int q=0; q<Wq.cols(); q++) - Wq(q, q)=weights[q]; + for (int q = 0; q < Wq.cols(); q++) + Wq(q, q) = weights[q]; // get the inverse rest pose frame of the base to compute relative rest pose of end effectors // this is needed to handle the enforce parameter // ikscene->pchan[0] is the root channel of the tree @@ -1401,9 +1398,9 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) float invBaseFrame[4][4]; pchan = ikscene->channels[0].pchan; if (pchan->parent) { - // it has a parent, get the pose matrix from it + // it has a parent, get the pose matrix from it float baseFrame[4][4]; - pchan = pchan->parent; + pchan = pchan->parent; copy_m4_m4(baseFrame, pchan->bone->arm_mat); // move to the tail and scale to get rest pose of armature base copy_v3_v3(baseFrame[3], pchan->bone->arm_tail); @@ -1413,10 +1410,10 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) unit_m4(invBaseFrame); } // finally add the constraint - for (t=0; t<ikscene->targets.size(); t++) { - IK_Target* iktarget = ikscene->targets[t]; + for (t = 0; t < ikscene->targets.size(); t++) { + IK_Target *iktarget = ikscene->targets[t]; iktarget->blscene = blscene; - condata= (bKinematicConstraint*)iktarget->blenderConstraint->data; + condata = (bKinematicConstraint *)iktarget->blenderConstraint->data; pchan = tree->pchan[iktarget->channel]; unsigned int controltype, bonecnt; double bonelen; @@ -1424,16 +1421,16 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // add the end effector // estimate the average bone length, used to clamp feedback error - for (bonecnt=0, bonelen=0.f, a=iktarget->channel; a>=0; a=tree->parent[a], bonecnt++) - bonelen += ikscene->blScale*tree->pchan[a]->bone->length; - bonelen /= bonecnt; + for (bonecnt = 0, bonelen = 0.f, a = iktarget->channel; a >= 0; a = tree->parent[a], bonecnt++) + bonelen += ikscene->blScale * tree->pchan[a]->bone->length; + bonelen /= bonecnt; // store the rest pose of the end effector to compute enforce target copy_m4_m4(mat, pchan->bone->arm_mat); copy_v3_v3(mat[3], pchan->bone->arm_tail); // get the rest pose relative to the armature base mult_m4_m4m4(iktarget->eeRest, invBaseFrame, mat); - iktarget->eeBlend = (!ikscene->polarConstraint && condata->type==CONSTRAINT_IK_COPYPOSE) ? true : false; + iktarget->eeBlend = (!ikscene->polarConstraint && condata->type == CONSTRAINT_IK_COPYPOSE) ? true : false; // use target_callback to make sure the initPose includes enforce coefficient target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget); iktarget->target = new iTaSC::MovingFrame(initPose); @@ -1443,59 +1440,59 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; switch (condata->type) { - case CONSTRAINT_IK_COPYPOSE: - controltype = 0; - if (condata->flag & CONSTRAINT_IK_ROT) { - if (!(condata->flag & CONSTRAINT_IK_NO_ROT_X)) - controltype |= iTaSC::CopyPose::CTL_ROTATIONX; - if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Y)) - controltype |= iTaSC::CopyPose::CTL_ROTATIONY; - if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Z)) - controltype |= iTaSC::CopyPose::CTL_ROTATIONZ; - } - if (condata->flag & CONSTRAINT_IK_POS) { - if (!(condata->flag & CONSTRAINT_IK_NO_POS_X)) - controltype |= iTaSC::CopyPose::CTL_POSITIONX; - if (!(condata->flag & CONSTRAINT_IK_NO_POS_Y)) - controltype |= iTaSC::CopyPose::CTL_POSITIONY; - if (!(condata->flag & CONSTRAINT_IK_NO_POS_Z)) - controltype |= iTaSC::CopyPose::CTL_POSITIONZ; - } - if (controltype) { - iktarget->constraint = new iTaSC::CopyPose(controltype, controltype, bonelen); - // set the gain - if (controltype & iTaSC::CopyPose::CTL_POSITION) - iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_POSITION, iTaSC::ACT_ALPHA, condata->weight); - if (controltype & iTaSC::CopyPose::CTL_ROTATION) - iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_ROTATION, iTaSC::ACT_ALPHA, condata->orientweight); - iktarget->constraint->registerCallback(copypose_callback, iktarget); - iktarget->errorCallback = copypose_error; - iktarget->controlType = controltype; + case CONSTRAINT_IK_COPYPOSE: + controltype = 0; + if (condata->flag & CONSTRAINT_IK_ROT) { + if (!(condata->flag & CONSTRAINT_IK_NO_ROT_X)) + controltype |= iTaSC::CopyPose::CTL_ROTATIONX; + if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Y)) + controltype |= iTaSC::CopyPose::CTL_ROTATIONY; + if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Z)) + controltype |= iTaSC::CopyPose::CTL_ROTATIONZ; + } + if (condata->flag & CONSTRAINT_IK_POS) { + if (!(condata->flag & CONSTRAINT_IK_NO_POS_X)) + controltype |= iTaSC::CopyPose::CTL_POSITIONX; + if (!(condata->flag & CONSTRAINT_IK_NO_POS_Y)) + controltype |= iTaSC::CopyPose::CTL_POSITIONY; + if (!(condata->flag & CONSTRAINT_IK_NO_POS_Z)) + controltype |= iTaSC::CopyPose::CTL_POSITIONZ; + } + if (controltype) { + iktarget->constraint = new iTaSC::CopyPose(controltype, controltype, bonelen); + // set the gain + if (controltype & iTaSC::CopyPose::CTL_POSITION) + iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_POSITION, iTaSC::ACT_ALPHA, condata->weight); + if (controltype & iTaSC::CopyPose::CTL_ROTATION) + iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_ROTATION, iTaSC::ACT_ALPHA, condata->orientweight); + iktarget->constraint->registerCallback(copypose_callback, iktarget); + iktarget->errorCallback = copypose_error; + iktarget->controlType = controltype; + // add the constraint + if (condata->flag & CONSTRAINT_IK_TARGETAXIS) + ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, iktarget->targetName, armname, "", ikscene->channels[iktarget->channel].tail); + else + ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); + } + break; + case CONSTRAINT_IK_DISTANCE: + iktarget->constraint = new iTaSC::Distance(bonelen); + iktarget->constraint->setControlParameter(iTaSC::Distance::ID_DISTANCE, iTaSC::ACT_VALUE, condata->dist); + iktarget->constraint->registerCallback(distance_callback, iktarget); + iktarget->errorCallback = distance_error; + // we can update the weight on each substep + iktarget->constraint->substep(true); // add the constraint - if (condata->flag & CONSTRAINT_IK_TARGETAXIS) - ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, iktarget->targetName, armname, "", ikscene->channels[iktarget->channel].tail); - else - ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); - } - break; - case CONSTRAINT_IK_DISTANCE: - iktarget->constraint = new iTaSC::Distance(bonelen); - iktarget->constraint->setControlParameter(iTaSC::Distance::ID_DISTANCE, iTaSC::ACT_VALUE, condata->dist); - iktarget->constraint->registerCallback(distance_callback, iktarget); - iktarget->errorCallback = distance_error; - // we can update the weight on each substep - iktarget->constraint->substep(true); - // add the constraint - ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); - break; + ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); + break; } if (!ret) break; } if (!ret || - !scene->addCache(ikscene->cache) || - !scene->addSolver(ikscene->solver) || - !scene->initialize()) { + !scene->addCache(ikscene->cache) || + !scene->addSolver(ikscene->solver) || + !scene->initialize()) { delete ikscene; ikscene = NULL; } @@ -1507,13 +1504,13 @@ static void create_scene(Scene *scene, Object *ob) bPoseChannel *pchan; // create the IK scene - for (pchan= (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) { + for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = (bPoseChannel *)pchan->next) { // by construction there is only one tree - PoseTree *tree = (PoseTree*)pchan->iktree.first; + PoseTree *tree = (PoseTree *)pchan->iktree.first; if (tree) { - IK_Data* ikdata = get_ikdata(ob->pose); + IK_Data *ikdata = get_ikdata(ob->pose); // convert tree in iTaSC::Scene - IK_Scene* ikscene = convert_tree(scene, ob, pchan); + IK_Scene *ikscene = convert_tree(scene, ob, pchan); if (ikscene) { ikscene->next = ikdata->first; ikdata->first = ikscene; @@ -1526,7 +1523,7 @@ static void create_scene(Scene *scene, Object *ob) if (tree->parent) MEM_freeN(tree->parent); if (tree->basis_change) MEM_freeN(tree->basis_change); MEM_freeN(tree); - tree = (PoseTree*)pchan->iktree.first; + tree = (PoseTree *)pchan->iktree.first; } } } @@ -1537,12 +1534,12 @@ static int init_scene(Object *ob) { // check also if scaling has changed float scale = len_v3(ob->obmat[1]); - IK_Scene* scene; + IK_Scene *scene; if (ob->pose->ikdata) { - for (scene = ((IK_Data*)ob->pose->ikdata)->first; - scene != NULL; - scene = scene->next) { + for (scene = ((IK_Data *)ob->pose->ikdata)->first; + scene != NULL; + scene = scene->next) { if (fabs(scene->blScale - scale) > KDL::epsilon) return 1; scene->channels[0].pchan->flag |= POSE_IKTREE; @@ -1551,31 +1548,31 @@ static int init_scene(Object *ob) return 0; } -static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, float ctime, float frtime) +static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime) { int i; - IK_Channel* ikchan; + IK_Channel *ikchan; if (ikparam->flag & ITASC_SIMULATION) { - for (i=0, ikchan=ikscene->channels; i<ikscene->numchan; i++, ++ikchan) { + for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) { // In simulation mode we don't allow external contraint to change our bones, mark the channel done // also tell Blender that this channel is part of IK tree (cleared on each BKE_pose_where_is() - ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN); + ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN); ikchan->jointValid = 0; } } else { // in animation mode, we must get the bone position from action and constraints - for (i=0, ikchan=ikscene->channels; i<ikscene->numchan; i++, ++ikchan) { + for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) { if (!(ikchan->pchan->flag & POSE_DONE)) BKE_pose_where_is_bone(blscene, ikscene->blArmature, ikchan->pchan, ctime, 1); // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() - ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN); + ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN); ikchan->jointValid = 0; } } // only run execute the scene if at least one of our target is enabled - for (i=ikscene->targets.size(); i > 0; --i) { - IK_Target* iktarget = ikscene->targets[i-1]; + for (i = ikscene->targets.size(); i > 0; --i) { + IK_Target *iktarget = ikscene->targets[i - 1]; if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF)) break; } @@ -1592,7 +1589,7 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl if (ikparam->flag & ITASC_SIMULATION) { ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, ikparam->maxvel); - } + } else { // in animation mode we start from the pose after action and constraint convert_pose(ikscene); @@ -1601,15 +1598,15 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl reiterate = true; simulation = false; // time is virtual, so take fixed value for velocity parameters (see itasc_update_param) - // and choose 1s timestep to allow having velocity parameters in radiant + // and choose 1s timestep to allow having velocity parameters in radiant timestep = 1.0; // use auto setup to let the solver test the variation of the joints numstep = 0; } - + if (ikscene->cache && !reiterate && simulation) { iTaSC::CacheTS sts, cts; - sts = cts = (iTaSC::CacheTS)(timestamp*1000.0+0.5); + sts = cts = (iTaSC::CacheTS)(timestamp * 1000.0 + 0.5); if (ikscene->cache->getPreviousCacheItem(ikscene->armature, 0, &cts) == NULL || cts == 0) { // the cache is empty before this time, reiterate if (ikparam->flag & ITASC_INITIAL_REITERATION) @@ -1618,14 +1615,14 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl else { // can take the cache as a start point. sts -= cts; - timestep = sts/1000.0; + timestep = sts / 1000.0; } } // don't cache if we are reiterating because we don't want to distroy the cache unnecessarily ikscene->scene->update(timestamp, timestep, numstep, false, !reiterate, simulation); if (reiterate) { // how many times do we reiterate? - for (i = 0; i<ikparam->numiter; i++) { + for (i = 0; i < ikparam->numiter; i++) { if (ikscene->armature->getMaxJointChange() < ikparam->precision || ikscene->armature->getMaxEndEffectorChange() < ikparam->precision) { @@ -1639,11 +1636,11 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl } } // compute constraint error - for (i=ikscene->targets.size(); i > 0; --i) { - IK_Target* iktarget = ikscene->targets[i-1]; + for (i = ikscene->targets.size(); i > 0; --i) { + IK_Target *iktarget = ikscene->targets[i - 1]; if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF)) { unsigned int nvalues; - const iTaSC::ConstraintValues* values; + const iTaSC::ConstraintValues *values; values = iktarget->constraint->getControlParameters(&nvalues); iktarget->errorCallback(values, nvalues, iktarget); } @@ -1654,22 +1651,22 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl // combine the parent and the joint frame to get the frame relative to armature // a backward translation of the bone length gives the head // if TY, compute the scale as the ratio of the joint length with rest pose length - iTaSC::Armature* arm = ikscene->armature; + iTaSC::Armature *arm = ikscene->armature; KDL::Frame frame; double q_rest[3], q[3]; - const KDL::Joint* joint; - const KDL::Frame* tip; - bPoseChannel* pchan; + const KDL::Joint *joint; + const KDL::Frame *tip; + bPoseChannel *pchan; float scale; float length; float yaxis[3]; - for (i=0, ikchan=ikscene->channels; i<ikscene->numchan; ++i, ++ikchan) { + for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; ++i, ++ikchan) { if (i == 0) { if (!arm->getRelativeFrame(frame, ikchan->tail)) break; // this frame is relative to base, make it relative to object ikchan->frame = ikscene->baseFrame * frame; - } + } else { if (!arm->getRelativeFrame(frame, ikchan->tail, ikscene->channels[ikchan->parent].tail)) break; @@ -1682,10 +1679,10 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl break; if (joint->getType() == KDL::Joint::TransY) { // stretch bones have a TY joint, compute the scale - scale = (float)(q[0]/q_rest[0]); + scale = (float)(q[0] / q_rest[0]); // the length is the joint itself length = (float)q[0]; - } + } else { scale = 1.0f; // for fixed bone, the length is in the tip (always along Y axis) @@ -1710,7 +1707,7 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl mul_v3_fl(pchan->pose_mat[1], scale); mul_v3_fl(pchan->pose_mat[2], scale); } - if (i<ikscene->numchan) { + if (i < ikscene->numchan) { // big problem ; } @@ -1732,11 +1729,11 @@ void itasc_initialize_tree(struct Scene *scene, Object *ob, float ctime) itasc_clear_data(ob->pose); // we should handle all the constraint and mark them all disabled // for blender but we'll start with the IK constraint alone - for (pchan= (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) { + for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = (bPoseChannel *)pchan->next) { if (pchan->constflag & PCHAN_HAS_IK) count += initialize_scene(ob, pchan); } - // if at least one tree, create the scenes from the PoseTree stored in the channels + // if at least one tree, create the scenes from the PoseTree stored in the channels if (count) create_scene(scene, ob); itasc_update_param(ob->pose); @@ -1747,14 +1744,14 @@ void itasc_initialize_tree(struct Scene *scene, Object *ob, float ctime) void itasc_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime) { if (ob->pose->ikdata) { - IK_Data* ikdata = (IK_Data*)ob->pose->ikdata; - bItasc* ikparam = (bItasc*) ob->pose->ikparam; + IK_Data *ikdata = (IK_Data *)ob->pose->ikdata; + bItasc *ikparam = (bItasc *) ob->pose->ikparam; // we need default parameters if (!ikparam) ikparam = &DefIKParam; - for (IK_Scene* ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { + for (IK_Scene *ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { if (ikscene->channels[0].pchan == pchan) { - float timestep = scene->r.frs_sec_base/scene->r.frs_sec; + float timestep = scene->r.frs_sec_base / scene->r.frs_sec; if (ob->pose->flag & POSE_GAME_ENGINE) { timestep = ob->pose->ctime; // limit the timestep to avoid excessive number of iteration @@ -1776,8 +1773,8 @@ void itasc_release_tree(struct Scene *scene, struct Object *ob, float ctime) void itasc_clear_data(struct bPose *pose) { if (pose->ikdata) { - IK_Data* ikdata = (IK_Data*)pose->ikdata; - for (IK_Scene* scene = ikdata->first; scene; scene = ikdata->first) { + IK_Data *ikdata = (IK_Data *)pose->ikdata; + for (IK_Scene *scene = ikdata->first; scene; scene = ikdata->first) { ikdata->first = scene->next; delete scene; } @@ -1789,8 +1786,8 @@ void itasc_clear_data(struct bPose *pose) void itasc_clear_cache(struct bPose *pose) { if (pose->ikdata) { - IK_Data* ikdata = (IK_Data*)pose->ikdata; - for (IK_Scene* scene = ikdata->first; scene; scene = scene->next) { + IK_Data *ikdata = (IK_Data *)pose->ikdata; + for (IK_Scene *scene = ikdata->first; scene; scene = scene->next) { if (scene->cache) // clear all cache but leaving the timestamp 0 (=rest pose) scene->cache->clearCacheFrom(NULL, 1); @@ -1801,12 +1798,12 @@ void itasc_clear_cache(struct bPose *pose) void itasc_update_param(struct bPose *pose) { if (pose->ikdata && pose->ikparam) { - IK_Data* ikdata = (IK_Data*)pose->ikdata; - bItasc* ikparam = (bItasc*)pose->ikparam; - for (IK_Scene* ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { + IK_Data *ikdata = (IK_Data *)pose->ikdata; + bItasc *ikparam = (bItasc *)pose->ikparam; + for (IK_Scene *ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { double armlength = ikscene->armature->getArmLength(); - ikscene->solver->setParam(iTaSC::Solver::DLS_LAMBDA_MAX, ikparam->dampmax*armlength); - ikscene->solver->setParam(iTaSC::Solver::DLS_EPSILON, ikparam->dampeps*armlength); + ikscene->solver->setParam(iTaSC::Solver::DLS_LAMBDA_MAX, ikparam->dampmax * armlength); + ikscene->solver->setParam(iTaSC::Solver::DLS_EPSILON, ikparam->dampeps * armlength); if (ikparam->flag & ITASC_SIMULATION) { ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, ikparam->minstep); ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, ikparam->maxstep); @@ -1814,7 +1811,7 @@ void itasc_update_param(struct bPose *pose) ikscene->armature->setControlParameter(CONSTRAINT_ID_ALL, iTaSC::Armature::ID_JOINT, iTaSC::ACT_FEEDBACK, ikparam->feedback); } else { - // in animation mode timestep is 1s by convention => + // in animation mode timestep is 1s by convention => // qmax becomes radiant and feedback becomes fraction of error gap corrected in one iteration ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, 1.0); ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, 1.0); @@ -1834,10 +1831,10 @@ void itasc_test_constraint(struct Object *ob, struct bConstraint *cons) return; switch (data->type) { - case CONSTRAINT_IK_COPYPOSE: - case CONSTRAINT_IK_DISTANCE: - /* cartesian space constraint */ - break; + case CONSTRAINT_IK_COPYPOSE: + case CONSTRAINT_IK_DISTANCE: + /* cartesian space constraint */ + break; } } diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 2cb1dfe149a..dcb5cdd7d32 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -50,6 +50,13 @@ struct ImMetaData; #define IB_MIPMAP_LEVELS 20 #define IB_FILENAME_SIZE 1024 +typedef struct DDSData { + unsigned int fourcc; /* DDS fourcc info */ + unsigned int nummipmaps; /* The number of mipmaps in the dds file */ + unsigned char *data; /* The compressed image data */ + unsigned int size; /* The size of the compressed data */ +} DDSData; + /** * \ingroup imbuf * This is the abstraction of an image. ImBuf is the basic type used for all @@ -119,6 +126,9 @@ typedef struct ImBuf { unsigned char *encodedbuffer; /* Compressed image only used with png currently */ unsigned int encodedsize; /* Size of data written to encodedbuffer */ unsigned int encodedbuffersize; /* Size of encodedbuffer */ + + /* information for compressed textures */ + struct DDSData dds_data; } ImBuf; /* Moved from BKE_bmfont_types.h because it is a userflag bit mask. */ @@ -215,6 +225,28 @@ typedef struct ImBuf { #define IB_PROFILE_SRGB 2 #define IB_PROFILE_CUSTOM 3 +/* dds */ +#ifdef WITH_DDS +#ifndef MAKEFOURCC +#define MAKEFOURCC(ch0, ch1, ch2, ch3)\ + ((unsigned long)(unsigned char)(ch0) | \ + ((unsigned long)(unsigned char)(ch1) << 8) | \ + ((unsigned long)(unsigned char)(ch2) << 16) | \ + ((unsigned long)(unsigned char)(ch3) << 24)) +#endif //MAKEFOURCC + +/* + * FOURCC codes for DX compressed-texture pixel formats + */ + +#define FOURCC_DDS (MAKEFOURCC('D','D','S',' ')) +#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) +#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) +#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) +#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) +#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + +#endif // DDS extern const char *imb_ext_image[]; extern const char *imb_ext_image_qt[]; extern const char *imb_ext_movie[]; diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 319e3f27bd8..68a094c26d0 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -162,6 +162,8 @@ void IMB_freeImBuf(ImBuf *ibuf) IMB_freezbuffloatImBuf(ibuf); freeencodedbufferImBuf(ibuf); IMB_metadata_free(ibuf); + if (ibuf->dds_data.data != NULL) + free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */ MEM_freeN(ibuf); } } @@ -351,7 +353,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int ibuf->planes = planes; ibuf->ftype = TGA; ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */ - ibuf->ppm[0] = ibuf->ppm[1] = 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */ + ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254; /* IMB_DPI_DEFAULT -> pixels-per-meter */ if (flags & IB_rect) { if (imb_addrectImBuf(ibuf) == FALSE) { diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index a908d4aa3b8..f0c2d754333 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -64,7 +64,7 @@ #include <io.h> #endif -#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail +#include "BLI_blenlib.h" /* BLI_remlink BLI_file_descriptor_size BLI_addtail * BLI_countlist BLI_stringdec */ #include "BLI_utildefines.h" #include "BLI_math_base.h" diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 8e996b97622..182e0a7e29d 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -83,7 +83,7 @@ static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, logImageGetSize(image, &width, &height, &depth); - if (depth != 3) { /*need to do greyscale loading eventually.*/ + if (depth != 3) { /*need to do grayscale loading eventually.*/ logImageClose(image); return NULL; } diff --git a/source/blender/imbuf/intern/cineon/dpxfile.h b/source/blender/imbuf/intern/cineon/dpxfile.h index 8846c7418d5..e1d95268a80 100644 --- a/source/blender/imbuf/intern/cineon/dpxfile.h +++ b/source/blender/imbuf/intern/cineon/dpxfile.h @@ -62,7 +62,7 @@ typedef struct { R32 ref_high_quantity;/* reference high quantity represented */ U8 designator1; U8 transfer_characteristics; - U8 colourimetry; + U8 colorimetry; U8 bits_per_pixel; U16 packing; U16 encoding; diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index a4b8c9d3f36..c1138225e93 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -53,7 +53,7 @@ fillDpxChannelInfo(DpxFile* dpx, DpxChannelInformation* chan, int des) { chan->ref_high_quantity = htonf(2.046); chan->designator1 = des; chan->transfer_characteristics = 0; - chan->colourimetry = 0; + chan->colorimetry = 0; chan->bits_per_pixel = 10; chan->packing = htons(1); chan->encoding = 0; diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index 438988fbe48..82f355e1bb2 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -1016,6 +1016,10 @@ uint DirectDrawSurface::mipmapCount() const else return 1; } +uint DirectDrawSurface::fourCC() const +{ + return header.pf.fourcc; +} uint DirectDrawSurface::width() const { @@ -1131,6 +1135,29 @@ void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) } } +// It was easier to copy this function from upstream than to resync. +// This should be removed if a resync ever occurs. +void* DirectDrawSurface::readData(uint &rsize) +{ + uint header_size = 128; // sizeof(DDSHeader); + if (header.hasDX10Header()) + { + header_size += 20; // sizeof(DDSHeader10); + } + + uint size = stream.size - header_size; + rsize = size; + + unsigned char *data = new unsigned char[size]; + + stream.seek(header_size); + mem_read(stream, data, size); + + // Maybe check if size == rsize? assert() isn't in this scope... + + return data; +} + void DirectDrawSurface::readLinearImage(Image * img) { diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h index ddae8826620..a851533b1f3 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h @@ -158,6 +158,7 @@ public: bool hasAlpha() const; uint mipmapCount() const; + uint fourCC() const; uint width() const; uint height() const; uint depth() const; @@ -171,6 +172,7 @@ public: void setUserVersion(int version); void mipmap(Image * img, uint f, uint m); + void* readData(uint &size); // void mipmap(FloatImage * img, uint f, uint m); void printInfo() const; diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 071d94c2076..fba326f7865 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -123,6 +123,8 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) ibuf->ftype = DDS; ibuf->profile = IB_PROFILE_SRGB; + ibuf->dds_data.fourcc = dds.fourCC(); + ibuf->dds_data.nummipmaps = dds.mipmapCount(); if ((flags & IB_test) == 0) { if (!imb_addrectImBuf(ibuf)) return(ibuf); @@ -136,10 +138,18 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) cp[0] = pixel.r; /* set R component of col */ cp[1] = pixel.g; /* set G component of col */ cp[2] = pixel.b; /* set B component of col */ - if (bits_per_pixel == 32) + if (dds.hasAlpha()) cp[3] = pixel.a; /* set A component of col */ rect[i] = col; } + + if (ibuf->dds_data.fourcc != FOURCC_DDS) + ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf->dds_data.size); + else { + ibuf->dds_data.data = NULL; + ibuf->dds_data.size = 0; + } + IMB_flipy(ibuf); } diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h index 47b4b7b6a58..999aae81cb7 100644 --- a/source/blender/imbuf/intern/imbuf.h +++ b/source/blender/imbuf/intern/imbuf.h @@ -72,5 +72,7 @@ typedef unsigned char uchar; #define TRUE 1 #define FALSE 0 +#define IMB_DPI_DEFAULT 72.0f + #endif /* __IMBUF_H__ */ diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 0ccd2680461..8b2e27ae1f3 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -313,7 +313,7 @@ int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size) { switch (pr_size) { case IMB_PROXY_NONE: /* if we got here, something is broken anyways, - so sane defaults... */ + * so sane defaults... */ return 0; case IMB_PROXY_25: return 0; @@ -333,7 +333,7 @@ int IMB_timecode_to_array_index(IMB_Timecode_Type tc) { switch (tc) { case IMB_TC_NONE: /* if we got here, something is broken anyways, - so sane defaults... */ + * so sane defaults... */ return 0; case IMB_TC_RECORD_RUN: return 0; @@ -906,11 +906,11 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, pts_time_base * frame_rate + 0.5f); /* decoding starts *always* on I-Frames, - so: P-Frames won't work, even if all the - information is in place, when we seek - to the I-Frame presented *after* the P-Frame, - but located before the P-Frame within - the stream */ + * so: P-Frames won't work, even if all the + * information is in place, when we seek + * to the I-Frame presented *after* the P-Frame, + * but located before the P-Frame within + * the stream */ if (pts < seek_pos_pts) { s_pos = last_seek_pos; @@ -966,7 +966,7 @@ static AviMovie *alloc_proxy_output_avi( double framerate; AviMovie *avi; short frs_sec = 25; /* it doesn't really matter for proxies, - but sane defaults help anyways...*/ + * but sane defaults help anyways...*/ float frs_sec_base = 1.0; IMB_anim_get_fps(anim, &frs_sec, &frs_sec_base); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 053d88c8c32..3008c233718 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -175,13 +175,13 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) h = image->comps[0].h; switch (image->numcomps) { - case 1: /* Greyscale */ + case 1: /* Grayscale */ case 3: /* Color */ planes = 24; use_alpha = FALSE; break; - default: /* 2 or 4 - Greyscale or Color + alpha */ - planes = 32; /* greyscale + alpha */ + default: /* 2 or 4 - Grayscale or Color + alpha */ + planes = 32; /* grayscale + alpha */ use_alpha = TRUE; break; } @@ -220,7 +220,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) r = image->comps[0].data; a = (use_alpha) ? image->comps[1].data : NULL; - /* greyscale 12bits+ */ + /* grayscale 12bits+ */ if (use_alpha) { a = image->comps[1].data; PIXEL_LOOPER_BEGIN(rect_float) { @@ -272,7 +272,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) r = image->comps[0].data; a = (use_alpha) ? image->comps[1].data : NULL; - /* greyscale */ + /* grayscale */ if (use_alpha) { a = image->comps[3].data; PIXEL_LOOPER_BEGIN(rect_uchar) { diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 556ec64e59a..615b420429a 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -36,7 +36,7 @@ * high-level routine that loads all images as 32-bit RGBA, handling all the * required conversions between many different TIFF types internally. * - * Saving supports RGB, RGBA and BW (greyscale) images correctly, with + * Saving supports RGB, RGBA and BW (grayscale) images correctly, with * 8 bits per channel in all cases. The "deflate" compression algorithm is * used to compress images. */ @@ -765,7 +765,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) PHOTOMETRIC_RGB); } else if (samplesperpixel == 1) { - /* greyscale images, 1 channel */ + /* grayscale images, 1 channel */ TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); } @@ -811,7 +811,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) yres = (float)(ibuf->ppm[1] * 0.0254); } else { - xres = yres = 150.0f; + xres = yres = IMB_DPI_DEFAULT; } TIFFSetField(image, TIFFTAG_XRESOLUTION, xres); diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index ea012090bbd..a8292d02463 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -43,7 +43,7 @@ struct Group; struct GHash; /* ************************************************ */ -/* Visualisation */ +/* Visualization */ /* Motion Paths ------------------------------------ */ /* (used for Pose Channels and Objects) */ @@ -83,10 +83,10 @@ typedef enum eMotionPath_Flag { MOTIONPATH_FLAG_EDIT = (1 << 1) } eMotionPath_Flag; -/* Visualisation General --------------------------- */ +/* Visualization General --------------------------- */ /* for Objects or Poses (but NOT PoseChannels) */ -/* Animation Visualisation Settings (avs) */ +/* Animation Visualization Settings (avs) */ typedef struct bAnimVizSettings { /* Onion-Skinning Settings ----------------- */ int ghost_sf, ghost_ef; /* start and end frames of ghost-drawing range (only used for GHOST_TYPE_RANGE) */ @@ -254,7 +254,7 @@ typedef enum ePchan_Flag { /* IK/Pose solving*/ POSE_CHAIN = (1 << 9), POSE_DONE = (1 << 10), - /* visualisation */ + /* visualization */ POSE_KEY = (1 << 11), POSE_STRIDE = (1 << 12), /* standard IK solving */ @@ -679,7 +679,7 @@ typedef struct bActionChannel { /* Action Channel flags (ONLY USED FOR DO_VERSIONS...) */ typedef enum ACHAN_FLAG { ACHAN_SELECTED = (1 << 0), - ACHAN_HILIGHTED = (1 << 1), + ACHAN_HIGHLIGHTED = (1 << 1), ACHAN_HIDDEN = (1 << 2), ACHAN_PROTECTED = (1 << 3), ACHAN_EXPANDED = (1 << 4), diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 55fb3322806..17ee8723e53 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -891,7 +891,7 @@ typedef enum eAnimData_Flag { typedef enum eAnimData_Recalc { ADT_RECALC_DRIVERS = (1<<0), ADT_RECALC_ANIM = (1<<1), - ADT_RECALC_ALL = (ADT_RECALC_DRIVERS|ADT_RECALC_ANIM) + ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM) } eAnimData_Recalc; /* Base Struct for Anim ------------------------------------- */ diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index cc08d0e92bd..0afe3773c94 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -127,9 +127,9 @@ typedef enum eArmature_Flag { ARM_AUTO_IK = (1<<9), ARM_NO_CUSTOM = (1<<10), /* made option negative, for backwards compat */ ARM_COL_CUSTOM = (1<<11), /* draw custom colors */ - ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ // XXX depreceated + ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ /* XXX depreceated */ ARM_DS_EXPAND = (1<<13), /* dopesheet channel is expanded */ - ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualising various states (hack for efficient updates) */ + ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualizing various states (hack for efficient updates) */ } eArmature_Flag; /* armature->drawtype */ diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 40362424532..b6036840401 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -464,7 +464,7 @@ typedef enum eBConstraint_Types { CONSTRAINT_TYPE_CLAMPTO = 18, /* clampto constraint */ CONSTRAINT_TYPE_TRANSFORM = 19, /* transformation (loc/rot/size -> loc/rot/size) constraint */ CONSTRAINT_TYPE_SHRINKWRAP = 20, /* shrinkwrap (loc/rot) constraint */ - CONSTRAINT_TYPE_DAMPTRACK = 21, /* New Tracking constraint that minimises twisting */ + CONSTRAINT_TYPE_DAMPTRACK = 21, /* New Tracking constraint that minimizes twisting */ CONSTRAINT_TYPE_SPLINEIK = 22, /* Spline-IK - Align 'n' bones to a curve */ CONSTRAINT_TYPE_TRANSLIKE = 23, /* Copy transform matrix */ CONSTRAINT_TYPE_SAMEVOL = 24, /* Maintain volume during scaling */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index f5c0148d9d0..56cf90d3d9d 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -116,7 +116,7 @@ typedef struct BPoint { float vec[4]; float alfa, weight; /* alfa: tilt in 3D View, weight: used for softbody goal weight */ short f1, hide; /* f1: selection status, hide: is point hidden or not */ - float radius, pad; /* user-set radius per point for bevelling etc */ + float radius, pad; /* user-set radius per point for beveling etc */ } BPoint; typedef struct Nurb { diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index f6c4822bb55..4a4b21017db 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -122,6 +122,7 @@ typedef struct Image { #define IMA_OLD_PREMUL 128 #define IMA_CM_PREDIVIDE 256 #define IMA_USED_FOR_RENDER 512 +#define IMA_USER_FRAME_IN_RANGE 1024 /* for image user, but these flags are mixed */ /* Image.tpageflag */ #define IMA_TILES 1 diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 0bd83e73271..5806d9a3947 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -259,19 +259,19 @@ typedef struct GridPaintMask { typedef enum MVertSkinFlag { /* Marks a vertex as the edge-graph root, used for calculating - rotations for all connected edges (recursively.) Also used to - choose a root when generating an armature. */ + * rotations for all connected edges (recursively.) Also used to + * choose a root when generating an armature. */ MVERT_SKIN_ROOT = 1, /* Marks a branch vertex (vertex with more than two connected - edges) so that it's neighbors are directly hulled together, - rather than the default of generating intermediate frames. */ + * edges) so that it's neighbors are directly hulled together, + * rather than the default of generating intermediate frames. */ MVERT_SKIN_LOOSE = 2 } MVertSkinFlag; typedef struct MVertSkin { /* Radii of the skin, define how big the generated frames - are. Currently only the first two elements are used. */ + * are. Currently only the first two elements are used. */ float radius[3]; /* MVertSkinFlag */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 15641d97709..e4b5a264ba3 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -166,6 +166,7 @@ typedef struct bNode { struct bNode *parent; /* parent node */ struct ID *id; /* optional link to libdata */ void *storage; /* custom data, must be struct, for storage in file */ + struct bNode *original; /* the original node in the tree (for localized tree) */ float locx, locy; /* root offset for drawing */ float width, height; /* node custom width and height */ @@ -177,10 +178,11 @@ typedef struct bNode { char label[64]; /* custom user-defined label, MAX_NAME */ short custom1, custom2; /* to be abused for buttons */ float custom3, custom4; + int highlight; /* 0 = not highlighted, 1-N = highlighted*/ + int pad; short need_exec, exec; /* need_exec is set as UI execution event, exec is flag during exec */ void *threaddata; /* optional extra storage for use in thread (read only then!) */ - rctf totr; /* entire boundbox */ rctf butr; /* optional buttons area */ rctf prvr; /* optional preview area */ @@ -302,6 +304,7 @@ typedef struct bNodeTree { /* ntree->flag */ #define NTREE_DS_EXPAND 1 /* for animation editors */ #define NTREE_COM_OPENCL 2 /* use opencl */ +#define NTREE_TWO_PASS 4 /* two pass */ /* XXX not nice, but needed as a temporary flags * for group updates after library linking. */ diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 854087b3b5b..1dd2aa6c59b 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -89,7 +89,7 @@ typedef struct PartDeflect { float pdef_perm; /* Chance of particle passing through mesh */ float pdef_frict; /* Friction factor for particle deflection */ float pdef_rfrict; /* Random element of friction for deflection */ - float pdef_stickness;/* surface particle stickness */ + float pdef_stickness;/* surface particle stickiness */ float absorption; /* used for forces */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 1b42d889c1d..3da6d0fc99d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -122,7 +122,7 @@ typedef struct Object { struct bGPdata *gpd; /* Grease Pencil data */ - bAnimVizSettings avs; /* settings for visualisation of object-transform animation */ + bAnimVizSettings avs; /* settings for visualization of object-transform animation */ bMotionPath *mpath; /* motion path cache for this object */ ListBase constraintChannels DNA_DEPRECATED; // XXX depreceated... old animation system diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 3bceb0277d5..02a7d0da325 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -625,7 +625,7 @@ typedef struct GameData { short ticrate, maxlogicstep, physubstep, maxphystep; short obstacleSimulation, pad1; float levelHeight; - float deactivationtime, lineardeactthreshold, angulardeactthreshold,pad2; + float deactivationtime, lineardeactthreshold, angulardeactthreshold, pad2; } GameData; #define STEREO_NOSTEREO 1 @@ -899,7 +899,7 @@ typedef struct ToolSettings { /* Subdivide Settings */ short cornertype; - short pad3; + short pad1; /*Triangle to Quad conversion threshold*/ float jointrilimit; /* Editmode Tools */ @@ -995,12 +995,13 @@ typedef struct ToolSettings { char edge_mode_live_unwrap; /* Transform */ - char snap_mode; + char snap_mode, snap_node_mode; + char pad3; short snap_flag, snap_target; short proportional, prop_mode; char proportional_objects; /* proportional edit, object mode */ char proportional_mask; /* proportional edit, object mode */ - char pad[4]; + char pad4[2]; char auto_normalize; /*auto normalizing mode in wpaint*/ char multipaint; /* paint multiple bones in wpaint */ @@ -1012,7 +1013,7 @@ typedef struct ToolSettings { int uv_relax_method; /* XXX: these sculpt_paint_* fields are deprecated, use the * unified_paint_settings field instead! */ - short sculpt_paint_settings DNA_DEPRECATED; short pad1; + short sculpt_paint_settings DNA_DEPRECATED; short pad5; int sculpt_paint_unified_size DNA_DEPRECATED; float sculpt_paint_unified_unprojected_radius DNA_DEPRECATED; float sculpt_paint_unified_alpha DNA_DEPRECATED; @@ -1370,6 +1371,9 @@ typedef struct Scene { #define SCE_SNAP_MODE_EDGE 2 #define SCE_SNAP_MODE_FACE 3 #define SCE_SNAP_MODE_VOLUME 4 +#define SCE_SNAP_MODE_NODE_X 5 +#define SCE_SNAP_MODE_NODE_Y 6 +#define SCE_SNAP_MODE_NODE_XY 7 /* toolsettings->selectmode */ #define SCE_SELECT_VERTEX 1 /* for mesh */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 2f6ea861cba..28c386241a7 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -875,11 +875,12 @@ typedef struct SpaceNode { /* snode->flag */ typedef enum eSpaceNode_Flag { - SNODE_BACKDRAW = (1 << 1), -/* SNODE_DISPGP = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */ - SNODE_USE_ALPHA = (1 << 3), - SNODE_SHOW_ALPHA = (1 << 4), - SNODE_AUTO_RENDER = (1 << 5), + SNODE_BACKDRAW = (1 << 1), +/* SNODE_DISPGP = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */ + SNODE_USE_ALPHA = (1 << 3), + SNODE_SHOW_ALPHA = (1 << 4), + SNODE_AUTO_RENDER = (1 << 5), + SNODE_SHOW_HIGHLIGHT = (1 << 6), } eSpaceNode_Flag; /* snode->texfrom */ diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 5a49e45cf5e..780ca0b5878 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -112,7 +112,7 @@ typedef struct ReportList { # typedef struct ReportTimerInfo { float col[3]; - float greyscale; + float grayscale; float widthfac; } ReportTimerInfo; diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 2498cba42ef..8be743335cc 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -659,10 +659,10 @@ static eSDNA_Type sdna_type_nr(const char *dna_type) if ((strcmp(dna_type, "char") == 0) || (strcmp(dna_type, "const char") == 0)) return SDNA_TYPE_CHAR; else if ((strcmp(dna_type, "uchar") == 0) || (strcmp(dna_type, "unsigned char") == 0)) return SDNA_TYPE_UCHAR; else if ( strcmp(dna_type, "short") == 0) return SDNA_TYPE_SHORT; - else if ((strcmp(dna_type, "ushort") == 0)||(strcmp(dna_type, "unsigned short") == 0)) return SDNA_TYPE_USHORT; + else if ((strcmp(dna_type, "ushort") == 0) || (strcmp(dna_type, "unsigned short") == 0)) return SDNA_TYPE_USHORT; else if ( strcmp(dna_type, "int") == 0) return SDNA_TYPE_INT; else if ( strcmp(dna_type, "long") == 0) return SDNA_TYPE_LONG; - else if ((strcmp(dna_type, "ulong") == 0)||(strcmp(dna_type, "unsigned long") == 0)) return SDNA_TYPE_ULONG; + else if ((strcmp(dna_type, "ulong") == 0) || (strcmp(dna_type, "unsigned long") == 0)) return SDNA_TYPE_ULONG; else if ( strcmp(dna_type, "float") == 0) return SDNA_TYPE_FLOAT; else if ( strcmp(dna_type, "double") == 0) return SDNA_TYPE_DOUBLE; else if ( strcmp(dna_type, "int64_t") == 0) return SDNA_TYPE_INT64; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index a8d176db767..a0614a9d82a 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -45,6 +45,7 @@ extern EnumPropertyItem proportional_falloff_curve_only_items[]; extern EnumPropertyItem proportional_editing_items[]; extern EnumPropertyItem snap_target_items[]; extern EnumPropertyItem snap_element_items[]; +extern EnumPropertyItem snap_node_element_items[]; extern EnumPropertyItem mesh_select_mode_items[]; extern EnumPropertyItem space_type_items[]; extern EnumPropertyItem region_type_items[]; diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 9cab08cbc34..32ca1bca107 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -51,6 +51,13 @@ # define __func__ __FUNCTION__ #endif +/* copied from BKE_utildefines.h ugh */ +#ifdef __GNUC__ +# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) +#else +# define UNUSED(x) x +#endif + /* Replace if different */ #define TMP_EXT ".tmp" @@ -310,7 +317,7 @@ static void rna_print_data_get(FILE *f, PropertyDefRNA *dp) fprintf(f, " %s *data= (%s*)(ptr->data);\n", dp->dnastructname, dp->dnastructname); } -static void rna_print_id_get(FILE *f, PropertyDefRNA *dp) +static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp)) { fprintf(f, " ID *id= ptr->id.data;\n"); } @@ -1179,7 +1186,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property return func; } -static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, +static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp), const char *manualfunc) { char *func, *getfunc; @@ -1206,7 +1213,7 @@ static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *p return func; } -static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, +static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp), const char *manualfunc) { char *func; @@ -2006,7 +2013,7 @@ static void rna_generate_blender(BlenderRNA *brna, FILE *f) fprintf(f, "};\n\n"); } -static void rna_generate_property_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f) +static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f) { PropertyRNA *prop; StructRNA *base; @@ -2029,7 +2036,7 @@ static void rna_generate_property_prototypes(BlenderRNA *brna, StructRNA *srna, fprintf(f, "\n"); } -static void rna_generate_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionRNA *func, FILE *f) +static void rna_generate_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionRNA *func, FILE *f) { PropertyRNA *parm; @@ -2068,7 +2075,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, fprintf(f, "\n"); } -static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionDefRNA *dfunc, FILE *f) +static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionDefRNA *dfunc, FILE *f) { FunctionRNA *func; PropertyDefRNA *dparm; @@ -2483,7 +2490,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } } -static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) +static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f) { FunctionRNA *func; FunctionDefRNA *dfunc; @@ -2761,7 +2768,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const } } -static void rna_generate_header(BlenderRNA *brna, FILE *f) +static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) { StructDefRNA *ds; PropertyDefRNA *dp; @@ -2929,7 +2936,7 @@ static const char *cpp_classes = "" "};\n" "\n"; -static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f) +static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) { StructDefRNA *ds; PropertyDefRNA *dp; diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 459482063b1..69f785c32de 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -24,7 +24,6 @@ * \ingroup RNA */ - #include <stdlib.h> #include "RNA_access.h" @@ -37,6 +36,8 @@ #include "DNA_action_types.h" #include "DNA_scene_types.h" +#include "BLI_utildefines.h" + #include "MEM_guardedalloc.h" #include "ED_keyframing.h" @@ -463,7 +464,8 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_ #else /* helper function for Keying Set -> keying settings */ -static void rna_def_common_keying_flags(StructRNA *srna, short reg) +/* TODO: use reg option! */ +static void rna_def_common_keying_flags(StructRNA *srna, short UNUSED(reg)) { PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c index 990d7c43309..68075823a86 100644 --- a/source/blender/makesrna/intern/rna_animviz.c +++ b/source/blender/makesrna/intern/rna_animviz.c @@ -183,7 +183,7 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna) srna = RNA_def_struct(brna, "AnimVizOnionSkinning", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); RNA_def_struct_nested(brna, srna, "AnimViz"); - RNA_def_struct_ui_text(srna, "Onion Skinning Settings", "Onion Skinning settings for animation visualisation"); + RNA_def_struct_ui_text(srna, "Onion Skinning Settings", "Onion Skinning settings for animation visualization"); /* Enums */ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -256,7 +256,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna) srna = RNA_def_struct(brna, "AnimVizMotionPaths", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); RNA_def_struct_nested(brna, srna, "AnimViz"); - RNA_def_struct_ui_text(srna, "Motion Path Settings", "Motion Path settings for animation visualisation"); + RNA_def_struct_ui_text(srna, "Motion Path Settings", "Motion Path settings for animation visualization"); /* Enums */ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -343,10 +343,10 @@ void rna_def_animviz_common(StructRNA *srna) { PropertyRNA *prop; - prop = RNA_def_property(srna, "animation_visualisation", PROP_POINTER, PROP_NONE); + prop = RNA_def_property(srna, "animation_visualization", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "avs"); - RNA_def_property_ui_text(prop, "Animation Visualisation", "Animation data for this datablock"); + RNA_def_property_ui_text(prop, "Animation Visualization", "Animation data for this datablock"); } static void rna_def_animviz(BlenderRNA *brna) @@ -356,21 +356,21 @@ static void rna_def_animviz(BlenderRNA *brna) srna = RNA_def_struct(brna, "AnimViz", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); - RNA_def_struct_ui_text(srna, "Animation Visualisation", "Settings for the visualisation of motion"); + RNA_def_struct_ui_text(srna, "Animation Visualization", "Settings for the visualization of motion"); /* onion-skinning settings (nested struct) */ prop = RNA_def_property(srna, "onion_skin_frames", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "AnimVizOnionSkinning"); RNA_def_property_pointer_funcs(prop, "rna_AnimViz_onion_skinning_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Onion Skinning", "Onion Skinning (ghosting) settings for visualisation"); + RNA_def_property_ui_text(prop, "Onion Skinning", "Onion Skinning (ghosting) settings for visualization"); /* motion path settings (nested struct) */ prop = RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "AnimVizMotionPaths"); RNA_def_property_pointer_funcs(prop, "rna_AnimViz_motion_paths_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Motion Paths", "Motion Path settings for visualisation"); + RNA_def_property_ui_text(prop, "Motion Paths", "Motion Path settings for visualization"); } /* --- */ diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index f803a8b67ea..2a6ea2994fa 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -50,7 +50,7 @@ EnumPropertyItem boidrule_type_items[] = { {eBoidRuleType_Goal, "GOAL", 0, "Goal", "Go to assigned object or loudest assigned signal source"}, {eBoidRuleType_Avoid, "AVOID", 0, "Avoid", "Get away from assigned object or loudest assigned signal source"}, {eBoidRuleType_AvoidCollision, "AVOID_COLLISION", 0, "Avoid Collision", - "Manoeuvre to avoid collisions with other boids and deflector objects in " + "Maneuver to avoid collisions with other boids and deflector objects in " "near future"}, {eBoidRuleType_Separate, "SEPARATE", 0, "Separate", "Keep from going through other boids"}, {eBoidRuleType_Flock, "FLOCK", 0, "Flock", "Move to center of neighbors and match their velocity"}, diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index ae8b0c51544..8d718715e5b 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -109,7 +109,7 @@ static EnumPropertyItem owner_space_pchan_items[] = { "The constraint is applied relative to the local coordinate system of the object, " "with the parent transformation added"}, {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space", - "The constraint is applied relative to the local coordinate sytem of the object"}, + "The constraint is applied relative to the local coordinate system of the object"}, {0, NULL, 0, NULL, NULL} }; @@ -1116,7 +1116,7 @@ static void rna_def_constraint_action(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object Action", "Bones only: apply the object's transformation channels of the action " "to the constrained bone, instead of bone's channels"); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "start"); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index f70fe9082af..c333c56a6b8 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -24,7 +24,6 @@ * \ingroup RNA */ - #include <stdlib.h> #include "RNA_define.h" @@ -36,6 +35,8 @@ #include "DNA_material_types.h" #include "DNA_scene_types.h" +#include "BLI_utildefines.h" + #include "BKE_font.h" #include "WM_types.h" @@ -753,7 +754,7 @@ static void rna_def_bpoint(BlenderRNA *brna) prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); + RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for beveling"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path"); @@ -839,13 +840,13 @@ static void rna_def_beztriple(BlenderRNA *brna) prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); + RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for beveling"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path"); } -static void rna_def_path(BlenderRNA *brna, StructRNA *srna) +static void rna_def_path(BlenderRNA *UNUSED(brna), StructRNA *srna) { PropertyRNA *prop; @@ -894,7 +895,7 @@ static void rna_def_path(BlenderRNA *brna, StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } -static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) +static void rna_def_nurbs(BlenderRNA *UNUSED(brna), StructRNA *srna) { PropertyRNA *prop; @@ -905,7 +906,7 @@ static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } -static void rna_def_font(BlenderRNA *brna, StructRNA *srna) +static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna) { PropertyRNA *prop; @@ -1002,7 +1003,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2); RNA_def_property_ui_text(prop, "Object Font", "Use Blender Objects as font characters (give font objects a common name " - "followed by the character they represent, eg. familya, familyb, etc, " + "followed by the character they represent, eg. family_a, family_b, etc, " "and turn on Verts Duplication)"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); @@ -1187,7 +1188,7 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); #endif } @@ -1435,7 +1436,7 @@ static void rna_def_curve(BlenderRNA *brna) prop = RNA_def_property(srna, "use_fill_caps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FILL_CAPS); - RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for bevelled curves"); + RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for beveled curves"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* texture space */ @@ -1639,7 +1640,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna) prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 1); - RNA_def_property_ui_text(prop, "Hide", "Hide this curve in editmode"); + RNA_def_property_ui_text(prop, "Hide", "Hide this curve in Edit mode"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 02d8cbef4a3..0320c0d7142 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -497,6 +497,9 @@ void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext) ext->free(ext->data); /* decref's the PyObject that the srna owns */ RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */ RNA_struct_py_type_set(srna, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */ +#else + (void)srna; + (void)ext; #endif } @@ -546,7 +549,8 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) if (srna->flag & STRUCT_RUNTIME) rna_freelinkN(&brna->structs, srna); - +#else + (void)brna, (void)srna; #endif } diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index 4bfcabc935b..6739e5b71fa 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -469,7 +469,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ANTIALIAS); - RNA_def_property_ui_text(prop, "Anti-aliasing", "Use 5x multisampling to smoothen paint edges"); + RNA_def_property_ui_text(prop, "Anti-aliasing", "Use 5x multisampling to smooth paint edges"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_reset"); prop = RNA_def_property(srna, "brush_influence_scale", PROP_FLOAT, PROP_FACTOR); @@ -677,7 +677,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop = RNA_def_property(srna, "wave_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 5.0); RNA_def_property_ui_range(prop, 0.20, 4.0, 1, 2); - RNA_def_property_ui_text(prop, "Speed", "Wave propogation speed"); + RNA_def_property_ui_text(prop, "Speed", "Wave propagation speed"); prop = RNA_def_property(srna, "wave_timescale", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 3.0); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 333f6878413..5eb15cf31b6 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -688,7 +688,7 @@ static void rna_def_fmodifier_function_generator(BlenderRNA *brna) {2, "TAN", 0, "Tangent", ""}, {3, "SQRT", 0, "Square Root", ""}, {4, "LN", 0, "Natural Logarithm", ""}, - {5, "SINC", 0, "Normalised Sine", "sin(x) / x"}, + {5, "SINC", 0, "Normalized Sine", "sin(x) / x"}, {0, NULL, 0, NULL, NULL} }; @@ -1136,9 +1136,9 @@ static void rna_def_drivertarget(BlenderRNA *brna) {0, "WORLD_SPACE", 0, "World Space", "Transforms include effects of parenting/restpose and constraints"}, {DTAR_FLAG_LOCALSPACE, "TRANSFORM_SPACE", 0, "Transform Space", "Transforms don't include parenting/restpose or constraints"}, - {DTAR_FLAG_LOCALSPACE|DTAR_FLAG_LOCAL_CONSTS, "LOCAL_SPACE", 0, "Local Space", - "Transforms include effects of constraints but not " - "parenting/restpose"}, + {DTAR_FLAG_LOCALSPACE | DTAR_FLAG_LOCAL_CONSTS, "LOCAL_SPACE", 0, "Local Space", + "Transforms include effects of constraints but not " + "parenting/restpose"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 8dd1bc86ca1..e84a290acb8 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -349,7 +349,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) prop = RNA_def_property(srna, "simulation_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "realsize"); RNA_def_property_range(prop, 0.001, 10); - RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in metres"); + RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in meters"); prop = RNA_def_property(srna, "simulation_rate", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "animRate"); @@ -461,8 +461,9 @@ static void rna_def_fluidsim_volume(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "domainNovecgen", 0); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Export Animated Mesh", - "Export this mesh as an animated one (slower, only use if really necessary [e.g. " - "armatures or parented objects], animated pos/rot/scale F-Curves do not require it)"); + "Export this mesh as an animated one (slower and enforces No Slip, only use if really " + "necessary [e.g. armatures or parented objects], animated pos/rot/scale F-Curves " + "do not require it)"); } static void rna_def_fluidsim_active(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 14d01444681..fa3f8d69c47 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -178,9 +178,11 @@ static void rna_Image_update(Image *image, ReportList *reports) IMB_rect_from_float(ibuf); } -static void rna_Image_scale(Image *image, int width, int height) +static void rna_Image_scale(Image *image, ReportList *reports, int width, int height) { - BKE_image_scale(image, width, height); + if (!BKE_image_scale(image, width, height)) { + BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + } } static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int mag) @@ -285,6 +287,7 @@ void RNA_api_image(StructRNA *srna) func = RNA_def_function(srna, "scale", "rna_Image_scale"); RNA_def_function_ui_description(func, "Scale the image in pixels"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_int(func, "width", 0, 1, 10000, "", "Width", 1, 10000); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_int(func, "height", 0, 1, 10000, "", "Height", 1, 10000); diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index c2d730f5ed9..5334c10c4c6 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -639,7 +639,7 @@ static void rna_def_key(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "slurph"); RNA_def_property_range(prop, -500, 500); RNA_def_property_ui_text(prop, "Slurph", - "Create a delay (in frames) in applying keypositions, first vertex goes first"); + "Create a delay (in frames) in applying key positions, first vertex goes first"); RNA_def_property_update(prop, 0, "rna_Key_update_data"); } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 6ac032e5d99..c98e1f3312b 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -255,7 +255,7 @@ static void rna_Main_movieclips_begin(CollectionPropertyIterator *iter, PointerR static void rna_Main_masks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Main *bmain= (Main*)ptr->data; + Main *bmain = (Main*)ptr->data; rna_iterator_listbase_begin(iter, &bmain->mask, NULL); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 98b3c0ab9f4..c702972b3b7 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -1548,12 +1548,12 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) PropertyRNA *parm; RNA_def_property_srna(cprop, "BlendDataMasks"); - srna= RNA_def_struct(brna, "BlendDataMasks", NULL); + srna = RNA_def_struct(brna, "BlendDataMasks", NULL); RNA_def_struct_sdna(srna, "Main"); RNA_def_struct_ui_text(srna, "Main Masks", "Collection of masks"); - func= RNA_def_function(srna, "tag", "rna_Main_masks_tag"); - parm= RNA_def_boolean(func, "value", 0, "Value", ""); + func = RNA_def_function(srna, "tag", "rna_Main_masks_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); /* new func */ @@ -1565,10 +1565,10 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); /* remove func */ - func= RNA_def_function(srna, "remove", "rna_Main_masks_remove"); + func = RNA_def_function(srna, "remove", "rna_Main_masks_remove"); RNA_def_function_ui_description(func, "Remove a masks from the current blendfile."); - parm= RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 51dfa020bea..b879d2b19f7 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -66,7 +66,7 @@ static void rna_Mask_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin { Mask *mask = ptr->id.data; - WM_main_add_notifier(NC_MASK|ND_DATA, mask); + WM_main_add_notifier(NC_MASK | ND_DATA, mask); DAG_id_tag_update( &mask->id, 0); } @@ -327,7 +327,7 @@ static MaskLayer *rna_Mask_layer_new(Mask *mask, const char *name) { MaskLayer *masklay = BKE_mask_layer_new(mask, name); - WM_main_add_notifier(NC_MASK|NA_EDITED, mask); + WM_main_add_notifier(NC_MASK | NA_EDITED, mask); return masklay; } @@ -336,7 +336,7 @@ void rna_Mask_layer_remove(Mask *mask, MaskLayer *masklay) { BKE_mask_layer_remove(mask, masklay); - WM_main_add_notifier(NC_MASK|NA_EDITED, mask); + WM_main_add_notifier(NC_MASK | NA_EDITED, mask); } static void rna_MaskLayer_spline_add(ID *id, MaskLayer *masklay, int number) @@ -347,7 +347,7 @@ static void rna_MaskLayer_spline_add(ID *id, MaskLayer *masklay, int number) for (i = 0; i < number; i++) BKE_mask_spline_add(masklay); - WM_main_add_notifier(NC_MASK|NA_EDITED, mask); + WM_main_add_notifier(NC_MASK | NA_EDITED, mask); } static void rna_Mask_start_frame_set(PointerRNA *ptr, int value) @@ -526,14 +526,14 @@ static void rna_def_mask_splines(BlenderRNA *brna) prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MaskSpline"); RNA_def_property_pointer_funcs(prop, "rna_MaskLayer_active_spline_get", "rna_MaskLayer_active_spline_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Spline", "Active spline of masking layer"); /* active point */ prop = RNA_def_property(srna, "active_point", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MaskSplinePoint"); RNA_def_property_pointer_funcs(prop, "rna_MaskLayer_active_spline_point_get", "rna_MaskLayer_active_spline_point_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Spline", "Active spline of masking layer"); } @@ -675,7 +675,7 @@ static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop) prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MaskLayer"); RNA_def_property_pointer_funcs(prop, "rna_Mask_layer_active_get", "rna_Mask_layer_active_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Shape", "Active layer in this mask"); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 8f1257690a0..7a95ea60276 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -782,7 +782,7 @@ static void rna_def_material_gamesettings(BlenderRNA *brna) }; static EnumPropertyItem prop_face_orientation_items[] = { - {GEMAT_NORMAL, "NORMAL", 0, "Normal", "No tranformation"}, + {GEMAT_NORMAL, "NORMAL", 0, "Normal", "No transformation"}, {GEMAT_HALO, "HALO", 0, "Halo", "Screen aligned billboard"}, {GEMAT_BILLBOARD, "BILLBOARD", 0, "Billboard", "Billboard with Z-axis constraint"}, {GEMAT_SHADOW, "SHADOW", 0, "Shadow", "Faces are used for shadow"}, diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 7daa0d97834..4f3e6081fcc 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1924,7 +1924,7 @@ static void rna_def_msticky(BlenderRNA *brna) srna = RNA_def_struct(brna, "MeshSticky", NULL); RNA_def_struct_sdna(srna, "MSticky"); - RNA_def_struct_ui_text(srna, "Mesh Vertex Sticky Texture Coordinate", "Stricky texture coordinate"); + RNA_def_struct_ui_text(srna, "Mesh Vertex Sticky Texture Coordinate", "Sticky texture coordinate"); RNA_def_struct_path_func(srna, "rna_MeshSticky_path"); prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ); @@ -2374,7 +2374,7 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); #endif prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); @@ -2551,7 +2551,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); #endif prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); @@ -2859,7 +2859,8 @@ static void rna_def_mesh(BlenderRNA *brna) prop = RNA_def_property(srna, "show_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEDGES); - RNA_def_property_ui_text(prop, "Draw Edges", "Display selected edges using hilights in the 3D view and UV editor"); + RNA_def_property_ui_text(prop, "Draw Edges", + "Display selected edges using highlights in the 3D view and UV editor"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 7846227cc4b..babcb7a3f52 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2786,8 +2786,8 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna) {MOD_WVG_MIX_SUB, "SUB", 0, "Subtract", "Subtract VGroup B's weights from VGroup A's ones"}, {MOD_WVG_MIX_MUL, "MUL", 0, "Multiply", "Multiply VGroup A's weights by VGroup B's ones"}, {MOD_WVG_MIX_DIV, "DIV", 0, "Divide", "Divide VGroup A's weights by VGroup B's ones"}, - {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", "Difference between VGroup A's and VGroup B's weigths"}, - {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weigths"}, + {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", "Difference between VGroup A's and VGroup B's weights"}, + {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weights"}, {0, NULL, 0, NULL, NULL} }; @@ -3211,17 +3211,17 @@ static void rna_def_modifier_skin(BlenderRNA *brna) prop = RNA_def_property(srna, "use_x_symmetry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_X); - RNA_def_property_ui_text(prop, "X", "Avoid making unsymmetric quads across the X axis"); + RNA_def_property_ui_text(prop, "X", "Avoid making unsymmetrical quads across the X axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_y_symmetry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Y); - RNA_def_property_ui_text(prop, "Y", "Avoid making unsymmetric quads across the Y axis"); + RNA_def_property_ui_text(prop, "Y", "Avoid making unsymmetrical quads across the Y axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_z_symmetry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Z); - RNA_def_property_ui_text(prop, "Z", "Avoid making unsymmetric quads across the Z axis"); + RNA_def_property_ui_text(prop, "Z", "Avoid making unsymmetrical quads across the Z axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } @@ -3267,7 +3267,7 @@ void RNA_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Editmode); - RNA_def_property_ui_text(prop, "Editmode", "Use modifier while in the edit mode"); + RNA_def_property_ui_text(prop, "Edit Mode", "Use modifier while in the Edit mode"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 33eb755a96d..a39c168c594 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1944,6 +1944,10 @@ static void def_cmp_image(StructRNA *srna) RNA_def_property_ui_text(prop, "Image", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + /* NB: image user properties used in the UI are redefined in def_node_image_user, + * to trigger correct updates of the node editor. RNA design problem that prevents + * updates from nested structs ... + */ RNA_def_struct_sdna_from(srna, "ImageUser", "storage"); def_node_image_user(srna); } @@ -2049,10 +2053,10 @@ static void def_cmp_dilate_erode(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {CMP_NODE_DILATEERODE_STEP, "STEP", 0, "Step", ""}, - {CMP_NODE_DILATEERODE_DISTANCE_THRESH, "THRESHOLD", 0, "Threshold", ""}, - {CMP_NODE_DILATEERODE_DISTANCE, "DISTANCE", 0, "Distance", ""}, - {CMP_NODE_DILATEERODE_DISTANCE_FEATHER,"FEATHER", 0, "Feather", ""}, + {CMP_NODE_DILATEERODE_STEP, "STEP", 0, "Step", ""}, + {CMP_NODE_DILATEERODE_DISTANCE_THRESH, "THRESHOLD", 0, "Threshold", ""}, + {CMP_NODE_DILATEERODE_DISTANCE, "DISTANCE", 0, "Distance", ""}, + {CMP_NODE_DILATEERODE_DISTANCE_FEATHER, "FEATHER", 0, "Feather", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3255,7 +3259,7 @@ static void def_cmp_ellipsemask(StructRNA *srna) RNA_def_property_float_sdna(prop, NULL, "rotation"); RNA_def_property_float_default(prop, 0.0f); RNA_def_property_range(prop, -1000.0f, 1000.0f); - RNA_def_property_ui_text(prop, "Rotation", "Rotationangle of the box"); + RNA_def_property_ui_text(prop, "Rotation", "Rotation angle of the box"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3551,14 +3555,14 @@ static void def_cmp_keyingscreen(StructRNA *srna) RNA_def_property_struct_type(prop, "MovieClip"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Movie Clip", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); RNA_def_struct_sdna_from(srna, "NodeKeyingScreenData", "storage"); prop = RNA_def_property(srna, "tracking_object", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "tracking_object"); RNA_def_property_ui_text(prop, "Tracking Object", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_cmp_keying(StructRNA *srna) @@ -3571,19 +3575,19 @@ static void def_cmp_keying(StructRNA *srna) RNA_def_property_float_sdna(prop, NULL, "screen_balance"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Screen Balance", "Balance between two non-primary channels primary channel is comparing against"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "despill_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "despill_factor"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Despill", "Factor of despilling screen color from image"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "clip_black", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "clip_black"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clip Black", "Value of non-scaled matte pixel which considers as fully background pixel"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "clip_white", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "clip_white"); @@ -3595,31 +3599,31 @@ static void def_cmp_keying(StructRNA *srna) RNA_def_property_int_sdna(prop, NULL, "blur_pre"); RNA_def_property_range(prop, 0, 2048); RNA_def_property_ui_text(prop, "Pre Blur", "Chroma pre-blur size which applies before running keyer"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "blur_post", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "blur_post"); RNA_def_property_range(prop, 0, 2048); RNA_def_property_ui_text(prop, "Post Blur", "Matte blur size which applies after clipping and dilate/eroding"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "dilate_distance", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "dilate_distance"); RNA_def_property_range(prop, -100, 100); RNA_def_property_ui_text(prop, "Dilate/Erode", "Matte dilate/erode side"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "edge_kernel_radius", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "edge_kernel_radius"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Edge Kernel Radius", "Radius of kernel used to detect whether pixel belongs to edge"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "edge_kernel_tolerance", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "edge_kernel_tolerance"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Edge Kernel Tolerance", "Tolerance to pixels inside kernel which are treating as belonging to the same plane"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "feather_falloff", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "feather_falloff"); @@ -4263,6 +4267,11 @@ static void rna_def_composite_nodetree(BlenderRNA *brna) prop = RNA_def_property(srna, "use_opencl", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_COM_OPENCL); RNA_def_property_ui_text(prop, "OpenCL", "Enable GPU calculations"); + + prop = RNA_def_property(srna, "two_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_TWO_PASS); + RNA_def_property_ui_text(prop, "Two Pass", "Use two pass execution during editing: first calculate fast nodes, " + "second pass calculate all nodes"); } static void rna_def_shader_nodetree(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 5072bda7508..ce6b028beb5 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -952,8 +952,8 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) break; case OB_BODY_TYPE_CHARACTER: ob->gameflag |= OB_COLLISION | OB_GHOST | OB_CHARACTER; - ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR - | OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH); + ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR | + OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH); break; case OB_BODY_TYPE_STATIC: ob->gameflag |= OB_COLLISION; @@ -1449,7 +1449,8 @@ static void rna_def_object_game_settings(BlenderRNA *brna) "Collision Sensor, detects static and dynamic objects but not the other " "collision sensor objects"}, {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"}, - {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character", "Simple kinematic physics appropiate for game characters"}, + {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character", + "Simple kinematic physics appropriate for game characters"}, {0, NULL, 0, NULL, NULL} }; @@ -1507,7 +1508,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST); - RNA_def_property_ui_text(prop, "Ghost", "Object does not restitute collisions, like a ghost"); + RNA_def_property_ui_text(prop, "Ghost", "Object does not react to collisions, like a ghost"); prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 10000.0); @@ -1544,17 +1545,17 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed"); - prop= RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "step_height"); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over"); - prop= RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "jump_speed"); RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping (with the Motion actuator)"); - prop= RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fall_speed"); RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall"); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 25866dd996f..1c896133408 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -901,10 +901,10 @@ static void rna_def_collision(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Kill Particles", "Kill collided particles"); RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); - prop = RNA_def_property(srna, "stickness", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "stickiness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_stickness"); RNA_def_property_range(prop, 0.0f, 10.0f); - RNA_def_property_ui_text(prop, "Stickness", "Amount of stickness to surface collision"); + RNA_def_property_ui_text(prop, "Stickiness", "Amount of stickiness to surface collision"); RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); /* Soft Body and Cloth Interaction */ diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index eaf1ae09524..35c85f0f40e 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -142,9 +142,9 @@ void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) /* ensure only valid values get set */ if ((value >= -1) && (value < 21)) { grp->customCol = value; - + /* sync colors stored with theme colors based on the index specified */ - action_group_colors_sync(grp); + action_group_colors_sync(grp, NULL); } } @@ -1118,8 +1118,8 @@ static void rna_def_pose_itasc(BlenderRNA *brna) {ITASC_INITIAL_REITERATION, "INITIAL", 0, "Initial", "The solver reiterates (converges) on the first frame but not on " "subsequent frame"}, - {ITASC_INITIAL_REITERATION|ITASC_REITERATION, "ALWAYS", 0, "Always", - "The solver reiterates (converges) on all frames"}, + {ITASC_INITIAL_REITERATION | ITASC_REITERATION, "ALWAYS", 0, "Always", + "The solver reiterates (converges) on all frames"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 072df099cea..070db8d23d8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -136,6 +136,14 @@ EnumPropertyItem snap_element_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem snap_node_element_items[] = { + {SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"}, + {SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_SNAP_EDGE, "Node X", "Snap to left/right node border"}, + {SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_SNAP_EDGE, "Node Y", "Snap to top/bottom node border"}, + {SCE_SNAP_MODE_NODE_XY, "NODE_XY", ICON_SNAP_EDGE, "Node X / Y", "Snap to any node border"}, + {0, NULL, 0, NULL, NULL} +}; + /* workaround for duplice enums, * have each enum line as a defne then conditionally set it or not @@ -736,7 +744,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) } static EnumPropertyItem *rna_ImageFormatSettings_file_format_itemf(bContext *C, PointerRNA *ptr, - PropertyRNA *UNUSED(prop), int *free) + PropertyRNA *UNUSED(prop), int *UNUSED(free)) { ID *id = ptr->id.data; if (id && GS(id->name) == ID_SCE) { @@ -755,7 +763,7 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, P const char is_render = (id && GS(id->name) == ID_SCE); /* note, we need to act differently for render - * where 'BW' will force greyscale even if the output format writes + * where 'BW' will force grayscale even if the output format writes * as RGBA, this is age old blender convention and not sure how useful * it really is but keep it for now - campbell */ char chan_flag = BKE_imtype_valid_channels(imf->imtype) | (is_render ? IMA_CHAN_FLAG_BW : 0); @@ -1626,6 +1634,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, snap_element_items); RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ + + /* node editor uses own set of snap modes */ + prop = RNA_def_property(srna, "snap_node_element", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "snap_node_mode"); + RNA_def_property_enum_items(prop, snap_node_element_items); + RNA_def_property_ui_text(prop, "Snap Node Element", "Type of element to snap to"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "snap_target", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "snap_target"); @@ -1651,7 +1666,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Project to Self", "Snap onto itself (editmode)"); RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ - + /* Grease Pencil */ prop = RNA_def_property(srna, "use_grease_pencil_sessions", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON); @@ -2460,7 +2475,7 @@ static void rna_def_scene_game_data(BlenderRNA *brna) prop = RNA_def_property(srna, "use_desktop", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "playerflag", GAME_PLAYER_DESKTOP_RESOLUTION); - RNA_def_property_ui_text(prop, "Desktop", "Uses the current desktop resultion in fullscreen mode"); + RNA_def_property_ui_text(prop, "Desktop", "Use the current desktop resolution in fullscreen mode"); RNA_def_property_update(prop, NC_SCENE, NULL); /* Framing */ @@ -2854,7 +2869,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) RNA_def_property_enum_items(prop, image_color_mode_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ImageFormatSettings_color_mode_itemf"); RNA_def_property_ui_text(prop, "Color Mode", - "Choose BW for saving greyscale images, RGB for saving red, green and blue channels, " + "Choose BW for saving grayscale images, RGB for saving red, green and blue channels, " "and RGBA for saving red, green, blue and alpha channels"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 6e5aa78b8bd..d405cba6607 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -296,7 +296,7 @@ static void rna_def_screen(BlenderRNA *brna) prop = RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL); - RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximised, filling this screen"); + RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximized, filling this screen"); /* Define Anim Playback Areas */ prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index cce0612bd68..00e8ed5289f 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -231,7 +231,7 @@ static void rna_Sensor_level_set(struct PointerRNA *ptr, int value) sens->tap = 0; } -static void rna_Sensor_Armature_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Sensor_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { bSensor *sens = (bSensor *)ptr->data; bArmatureSensor *as = sens->data; diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 3a534cd22b4..6c54b7c2cf3 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -99,7 +99,7 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start return seq; } -static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports, +static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, const char *name, MovieClip *clip, int channel, int start_frame) { @@ -118,7 +118,7 @@ static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports return seq; } -static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, ReportList *reports, +static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, const char *name, Mask *mask, int channel, int start_frame) { @@ -137,7 +137,7 @@ static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, ReportList *reports return seq; } -static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed, ReportList *reports, +static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed, const char *name, Scene *sce_seq, int channel, int start_frame) { @@ -455,7 +455,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Sequences", "Collection of Sequences"); func = RNA_def_function(srna, "new_clip", "rna_Sequences_new_clip"); - RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new movie clip sequence"); parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -472,7 +472,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "new_mask", "rna_Sequences_new_mask"); - RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new movie clip sequence"); parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -489,7 +489,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "new_scene", "rna_Sequences_new_scene"); - RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new scene sequence"); parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 25e714b59a6..5314ec39709 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -319,7 +319,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "smooth_emitter", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGH_SMOOTH); - RNA_def_property_ui_text(prop, "Smooth Emitter", "Smoothen emitted smoke to avoid blockiness"); + RNA_def_property_ui_text(prop, "Smooth Emitter", "Smooth emitted smoke to avoid blockiness"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e4af06a5012..f6286333111 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2303,7 +2303,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NODRAWGCOLORS); RNA_def_property_ui_text(prop, "Show Group Colors", - "Draw groups and channels with colours matching their corresponding groups"); + "Draw groups and channels with colors matching their corresponding groups"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL); /* editing */ @@ -2414,7 +2414,7 @@ static void rna_def_space_graph(BlenderRNA *brna) prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NODRAWGCOLORS); RNA_def_property_ui_text(prop, "Show Group Colors", - "Draw groups and channels with colours matching their corresponding groups"); + "Draw groups and channels with colors matching their corresponding groups"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); /* editing */ @@ -2926,6 +2926,11 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_enum_items(prop, backdrop_channels_items); RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); + + prop = RNA_def_property(srna, "show_highlight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_SHOW_HIGHLIGHT); + RNA_def_property_ui_text(prop, "Highlight", "Highlight nodes that are being calculated"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); } static void rna_def_space_logic(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index ffd06c4bf19..d99ba18dec4 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -841,7 +841,7 @@ static void rna_def_texture_clouds(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_clouds_stype[] = { - {TEX_DEFAULT, "GREYSCALE", 0, "Greyscale", ""}, + {TEX_DEFAULT, "GRAYSCALE", 0, "Grayscale", ""}, {TEX_COLOR, "COLOR", 0, "Color", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1783,7 +1783,7 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) static EnumPropertyItem file_format_items[] = { {TEX_VD_BLENDERVOXEL, "BLENDER_VOXEL", 0, "Blender Voxel", "Default binary voxel file format"}, - {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit greyscale binary data"}, + {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit grayscale binary data"}, /*{TEX_VD_RAW_16BIT, "RAW_16BIT", 0, "16 bit RAW", ""}, */ {TEX_VD_IMAGE_SEQUENCE, "IMAGE_SEQUENCE", 0, "Image Sequence", "Generate voxels from a sequence of image slices"}, diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 801bec30ecf..63e650d5867 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -636,7 +636,7 @@ static void rna_def_trackingSettings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_sdna(prop, NULL, "default_margin"); RNA_def_property_range(prop, 0, 300); - RNA_def_property_ui_text(prop, "Margin", "Default distance from image boudary at which marker stops tracking"); + RNA_def_property_ui_text(prop, "Margin", "Default distance from image boundary at which marker stops tracking"); /* default_tracking_motion_model */ prop = RNA_def_property(srna, "default_motion_model", PROP_ENUM, PROP_NONE); @@ -952,7 +952,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "margin"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 300); - RNA_def_property_ui_text(prop, "Margin", "Distance from image boudary at which marker stops tracking"); + RNA_def_property_ui_text(prop, "Margin", "Distance from image boundary at which marker stops tracking"); /* tracking motion model */ prop = RNA_def_property(srna, "motion_model", PROP_ENUM, PROP_NONE); @@ -1170,7 +1170,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_AUTOSCALE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Autoscale", - "Automatically scale footage to cover unfilled areas when stabilizating"); + "Automatically scale footage to cover unfilled areas when stabilizing"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); /* max scale */ @@ -1242,7 +1242,7 @@ static void rna_def_reconstructedCamera(BlenderRNA *brna) prop = RNA_def_property(srna, "average_error", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "error"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Average Error", "Average error of resonctruction"); + RNA_def_property_ui_text(prop, "Average Error", "Average error of reconstruction"); } static void rna_def_trackingReconstruction(BlenderRNA *brna) @@ -1266,7 +1266,7 @@ static void rna_def_trackingReconstruction(BlenderRNA *brna) prop = RNA_def_property(srna, "average_error", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "error"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Average Error", "Average error of resonctruction"); + RNA_def_property_ui_text(prop, "Average Error", "Average error of reconstruction"); /* cameras */ prop = RNA_def_property(srna, "cameras", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 7c9cb04b66a..70d94bfc7ed 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -617,7 +617,7 @@ static void rna_def_ui_layout(BlenderRNA *brna) prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set"); - RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is greyed out"); + RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is grayed out"); prop = RNA_def_property(srna, "alert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_UILayout_alert_get", "rna_UILayout_alert_set"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f4cb4fc58f4..54178516d50 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -463,7 +463,7 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) prop = RNA_def_property(srna, "shadowcolor", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Shadow Brightness", "Shadow color in grey value"); + RNA_def_property_ui_text(prop, "Shadow Brightness", "Shadow color in gray value"); RNA_def_property_update(prop, 0, "rna_userdef_update"); } @@ -2093,7 +2093,7 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna) prop = RNA_def_property(srna, "marker_outline", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "marker_outline"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Marker Outline Color", "Color of marker's outile"); + RNA_def_property_ui_text(prop, "Marker Outline Color", "Color of marker's outline"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "marker", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -2756,7 +2756,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "ipo_new"); RNA_def_property_ui_text(prop, "New Interpolation Type", "Interpolation mode used for first keyframe on newly added F-Curves " - "(subsequent keyframes take interpolation from preceeding keyframe)"); + "(subsequent keyframes take interpolation from preceding keyframe)"); prop = RNA_def_property(srna, "keyframe_new_handle_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, keyframe_handle_type_items); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 8c6a2809ef8..61c75e306cb 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -183,7 +183,7 @@ EnumPropertyItem event_type_items[] = { {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""}, {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""}, - {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "Inbetween Move", ""}, + {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "In-between Move", ""}, {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""}, {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""}, {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""}, diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index cec66831916..a84b1124d44 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -316,7 +316,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop = RNA_def_property(srna, "passes", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ao_approx_passes"); RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce overocclusion"); + RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce over-occlusion"); RNA_def_property_update(prop, 0, "rna_World_update"); prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 41057234d9b..a4ba9ba35bb 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -173,7 +173,7 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, int *index_map, i; BMO_op_initf(bm, &find_op, - "finddoubles verts=%av dist=%f keepverts=%s", + "find_doubles verts=%av dist=%f keep_verts=%s", amd->merge_dist, dupe_op, "geom"); BMO_op_exec(bm, &find_op); @@ -224,8 +224,8 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], BMIter iter; /* Add the DerivedMesh's elements to the BMesh. The pre-existing - elements were already tagged, so the new elements can be - identified by not having the BM_ELEM_TAG flag set. */ + * elements were already tagged, so the new elements can be + * identified by not having the BM_ELEM_TAG flag set. */ DM_to_bmesh_ex(dm, bm); if (amd->flags & MOD_ARR_MERGE) { @@ -235,7 +235,7 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], BMOperator find_op; BMO_op_initf(bm, &find_op, - "finddoubles verts=%Hv dist=%f keepverts=%s", + "find_doubles verts=%Hv dist=%f keep_verts=%s", BM_ELEM_TAG, amd->merge_dist, dupe_op, dupe_slot_name); @@ -287,7 +287,7 @@ static void merge_first_last(BMesh *bm, BMVert *v, *v2; BMO_op_initf(bm, &find_op, - "finddoubles verts=%s dist=%f keepverts=%s", + "find_doubles verts=%s dist=%f keep_verts=%s", dupe_first, "geom", amd->merge_dist, dupe_first, "geom"); @@ -410,9 +410,9 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, bmesh_edit_begin(em->bm, 0); if (amd->flags & MOD_ARR_MERGE) - BMO_op_init(em->bm, &weld_op, "weldverts"); + BMO_op_init(em->bm, &weld_op, "weld_verts"); - BMO_op_initf(em->bm, &dupe_op, "dupe geom=%avef"); + BMO_op_initf(em->bm, &dupe_op, "duplicate geom=%avef"); first_dupe_op = dupe_op; for (j = 0; j < count - 1; j++) { @@ -422,7 +422,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMOIter oiter; if (j != 0) - BMO_op_initf(em->bm, &dupe_op, "dupe geom=%s", &old_dupe_op, "newout"); + BMO_op_initf(em->bm, &dupe_op, "duplicate geom=%s", &old_dupe_op, "newout"); BMO_op_exec(em->bm, &dupe_op); geom_slot = BMO_slot_get(&dupe_op, "geom"); diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 1b3e3c16486..39d78f777a0 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -103,7 +103,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj } } - BMO_op_callf(bm, "edgesplit edges=%fe", EDGE_MARK); + BMO_op_callf(bm, "split_edges edges=%fe", EDGE_MARK); BMO_pop(bm); diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index d3ea3fd4ebd..46987f30205 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -318,7 +318,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) BMO_op_finish(bm, &op); - BMO_op_callf(bm, "del geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); + BMO_op_callf(bm, "delete geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); return TRUE; } @@ -1035,7 +1035,7 @@ static BMFace *collapse_face_corners(BMesh *bm, BMFace *f, int n, int i; shortest_edge = BM_face_find_shortest_loop(f)->e; - BMO_op_initf(bm, &op, "weldverts"); + BMO_op_initf(bm, &op, "weld_verts"); /* Note: could probably calculate merges in one go to be * faster */ @@ -1175,7 +1175,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f /* Extrude the split face */ BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); BM_elem_flag_enable(split_face, BM_ELEM_TAG); - BMO_op_initf(bm, &op, "extrude_face_indiv faces=%hf", BM_ELEM_TAG); + BMO_op_initf(bm, &op, "extrude_discrete_faces faces=%hf", BM_ELEM_TAG); BMO_op_exec(bm, &op); /* Update split face (should only be one new face created @@ -1198,7 +1198,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f BM_mesh_elem_hflag_disable_all(bm, BM_EDGE, BM_ELEM_TAG, FALSE); BM_elem_flag_enable(longest_edge, BM_ELEM_TAG); - BMO_op_callf(bm, "esubd edges=%he numcuts=%i quadcornertype=%i", + BMO_op_callf(bm, "subdivide_edges edges=%he numcuts=%i quadcornertype=%i", BM_ELEM_TAG, 1, SUBD_STRAIGHT_CUT); } else if (split_face->len > 4) { @@ -1230,7 +1230,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f /* Delete split face and merge */ BM_face_kill(bm, split_face); - BMO_op_init(bm, &op, "weldverts"); + BMO_op_init(bm, &op, "weld_verts"); for (i = 0; i < 4; i++) { BMO_slot_map_ptr_insert(bm, &op, "targetmap", verts[i], frame->verts[best_order[i]]); @@ -1395,7 +1395,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) } } - BMO_op_callf(so->bm, "del geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); + BMO_op_callf(so->bm, "delete geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); BLI_heap_free(heap, NULL); } diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 99d0b95a7c5..d359bae84e2 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -35,7 +35,6 @@ set(INC ../makesrna ../render/extern/include ../../../intern/guardedalloc - ../compositor ) set(INC_SYS @@ -244,4 +243,11 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() +if(WITH_COMPOSITOR) + list(APPEND INC + ../compositor + ) + add_definitions(-DWITH_COMPOSITOR) +endif() + blender_add_lib(bf_nodes "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript index 86178b31688..bf70b5a6ed5 100644 --- a/source/blender/nodes/SConscript +++ b/source/blender/nodes/SConscript @@ -13,7 +13,6 @@ incs += ' ../imbuf ../avi ' incs += ' ../blenloader' incs += ' ../blenfont ../blenkernel ../renderconverter ' incs += ' ../gpu #/extern/glew/include ' -incs += ' ../compositor ' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] @@ -36,6 +35,10 @@ if env['OURPLATFORM'] == 'linux': if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] + +if env['WITH_BF_COMPOSITOR']: + incs += ' ../compositor ' + defs.append("WITH_COMPOSITOR") env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [190,105] ) env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] ) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index b716f19a697..b9acf821efe 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -59,7 +59,10 @@ #include "NOD_composite.h" #include "node_composite_util.h" -#include "COM_compositor.h" + +#ifdef WITH_COMPOSITOR +# include "COM_compositor.h" +#endif static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) { @@ -115,7 +118,6 @@ static void update_node(bNodeTree *ntree, bNode *node) } } node->need_exec= 1; - /* individual node update call */ if (node->typeinfo->updatefunc) node->typeinfo->updatefunc(ntree, node); @@ -130,6 +132,7 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) for (node= ntree->nodes.first; node; node= node->next) { /* ensure new user input gets handled ok */ node->need_exec= 0; + node->new_node->original = node; /* move over the compbufs */ /* right after ntreeCopyTree() oldsock pointers are valid */ @@ -197,6 +200,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) lnode->new_node->preview= lnode->preview; lnode->preview= NULL; } + } } } @@ -218,8 +222,8 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) } else if (lnode->type==CMP_NODE_MOVIEDISTORTION) { /* special case for distortion node: distortion context is allocating in exec function - and to achive much better performance on further calls this context should be - copied back to original node */ + * and to achive much better performance on further calls this context should be + * copied back to original node */ if (lnode->storage) { if (lnode->new_node->storage) BKE_tracking_distortion_free(lnode->new_node->storage); @@ -351,6 +355,8 @@ void ntreeCompositEndExecTree(bNodeTreeExec *exec, int use_tree_data) } } +#ifdef WITH_COMPOSITOR + /* ***************************** threaded version for execute composite nodes ************* */ /* these are nodes without input, only giving values */ /* or nodes with only value inputs */ @@ -586,7 +592,6 @@ static void ntree_composite_texnode(bNodeTree *ntree, int init) } /* optimized tree execute test for compositing */ -/* optimized tree execute test for compositing */ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_preview) { bNodeExec *nodeexec; @@ -677,13 +682,18 @@ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_pr /* XXX top-level tree uses the ntree->execdata pointer */ ntreeCompositEndExecTree(exec, 1); } +#endif void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview) { +#ifdef WITH_COMPOSITOR if (G.rt == 200) ntreeCompositExecTreeOld(ntree, rd, do_preview); else COM_execute(rd, ntree, rendering); +#else + (void)ntree, (void)rd, (void)rendering, (void)do_preview; +#endif } /* *********************************************** */ diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index f6011843b8a..98ded3ea3b3 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -872,8 +872,8 @@ static void FHT(fREAL* data, unsigned int M, unsigned int inverse) } //------------------------------------------------------------------------------ /* 2D Fast Hartley Transform, Mx/My -> log2 of width/height, - nzp -> the row where zero pad data starts, - inverse -> see above */ + * nzp -> the row where zero pad data starts, + * inverse -> see above */ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, unsigned int nzp, unsigned int inverse) { diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index 62e8138f5e1..0137093658c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -59,7 +59,7 @@ static bNodeSocketTemplate cmp_node_bilateralblur_out[] = { (c1[3] - c2[3]) * (c1[3] - c2[3])) /* this is the main kernel function for comparing color distances - and adding them weighted to the final color */ + * and adding them weighted to the final color */ #define KERNEL_ELEMENT_C3(k) \ temp_color = src + deltas[k]; \ ref_color = ref + deltas[k]; \ diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index 046623f5b26..fb163222781 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -384,7 +384,7 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa float fi = (float)i / radxf; float dist = sqrt(fj * fj + fi * fi); - //*dgauss= hexagon_filter(fi, fj); + // *dgauss= hexagon_filter(fi, fj); *dgauss = RE_filter_value(nbd->filtertype, dist); val += *dgauss; diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 7c6b4ad1f95..0c6ce79c51f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -26,8 +26,8 @@ */ /** \file blender/nodes/composite/nodes/node_composite_chromaMatte.c -* \ingroup cmpnodes -*/ + * \ingroup cmpnodes + */ #include "node_composite_util.h" diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index 0569f5c68ef..53061366b8b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -26,8 +26,8 @@ */ /** \file blender/nodes/composite/nodes/node_composite_diffMatte.c -* \ingroup cmpnodes -*/ + * \ingroup cmpnodes + */ #include "node_composite_util.h" @@ -48,10 +48,10 @@ static bNodeSocketTemplate cmp_node_diff_matte_out[]={ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float *inColor2) { NodeChroma *c= (NodeChroma *)node->storage; - float tolerence=c->t1; + float tolerance=c->t1; float fper=c->t2; - /* get falloff amount over tolerence size */ - float falloff=(1.0f-fper) * tolerence; + /* get falloff amount over tolerance size */ + float falloff=(1.0f-fper) * tolerance; float difference; float alpha; float maxInputAlpha; @@ -64,13 +64,13 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * copy_v3_v3(outColor, inColor1); - if (difference <= tolerence) { + if (difference <= tolerance) { if (difference <= falloff) { alpha = 0.0f; } else { /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ - alpha=(difference-falloff)/(tolerence-falloff); + alpha=(difference-falloff)/(tolerance-falloff); } /*only change if more transparent than either image */ diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c index c1a85a0071b..49cba801d5a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.c +++ b/source/blender/nodes/composite/nodes/node_composite_displace.c @@ -126,7 +126,7 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * /* simple method for reference, linear interpolation */ -/* +#if 0 int x, y; float dx, dy; float u, v; @@ -147,7 +147,7 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * qd_setPixel(stackbuf, x, y, col); } } -*/ +#endif } diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index a456f45c57e..86634487776 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -26,8 +26,8 @@ */ /** \file blender/nodes/composite/nodes/node_composite_distanceMatte.c -* \ingroup cmpnodes -*/ + * \ingroup cmpnodes + */ #include "node_composite_util.h" @@ -50,10 +50,10 @@ static bNodeSocketTemplate cmp_node_distance_matte_out[]={ static void do_distance_matte(bNode *node, float *out, float *in) { NodeChroma *c= (NodeChroma *)node->storage; - float tolerence=c->t1; + float tolerance=c->t1; float fper=c->t2; - /* get falloff amount over tolerence size */ - float falloff=(1.0f-fper) * tolerence; + /* get falloff amount over tolerance size */ + float falloff=(1.0f-fper) * tolerance; float distance; float alpha; @@ -63,13 +63,13 @@ static void do_distance_matte(bNode *node, float *out, float *in) copy_v3_v3(out, in); - if (distance <= tolerence) { + if (distance <= tolerance) { if (distance <= falloff) { alpha = 0.0f; } else { /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ - alpha=(distance-falloff)/(tolerence-falloff); + alpha=(distance-falloff)/(tolerance-falloff); } /*only change if more transparent than before */ @@ -88,10 +88,10 @@ static void do_distance_matte(bNode *node, float *out, float *in) static void do_chroma_distance_matte(bNode *node, float *out, float *in) { NodeChroma *c= (NodeChroma *)node->storage; - float tolerence=c->t1; + float tolerance=c->t1; float fper=c->t2; - /* get falloff amount over tolerence size */ - float falloff=(1.0f-fper) * tolerence; + /* get falloff amount over tolerance size */ + float falloff=(1.0f-fper) * tolerance; float y_key, cb_key, cr_key; float y_pix, cb_pix, cr_pix; float distance; @@ -114,13 +114,13 @@ static void do_chroma_distance_matte(bNode *node, float *out, float *in) copy_v3_v3(out, in); - if (distance <= tolerence) { + if (distance <= tolerance) { if (distance <= falloff) { alpha = 0.0f; } else { /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ - alpha=(distance-falloff)/(tolerence-falloff); + alpha=(distance-falloff)/(tolerance-falloff); } /*only change if more transparent than before */ @@ -139,9 +139,9 @@ static void do_chroma_distance_matte(bNode *node, float *out, float *in) static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { /* - Loosely based on the Sequencer chroma key plug-in, but enhanced to work in other color spaces and - uses a different difference function (suggested in forums of vfxtalk.com). - */ + * Loosely based on the Sequencer chroma key plug-in, but enhanced to work in other color spaces and + * uses a different difference function (suggested in forums of vfxtalk.com). + */ CompBuf *workbuf; CompBuf *inbuf; NodeChroma *c; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index ba03a2697be..3060496bb9e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -368,9 +368,11 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i stackbuf->malloc= alloc; } - /*code to respect the premul flag of images; I'm - not sure if this is a good idea for multilayer images, - since it never worked before for them. + /* code to respect the premul flag of images; I'm + * not sure if this is a good idea for multilayer images, + * since it never worked before for them. + */ +#if 0 if (type==CB_RGBA && ima->flag & IMA_DO_PREMUL) { //premul the image int i; @@ -382,7 +384,7 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i pixel[2] *= pixel[3]; } } - */ +#endif return stackbuf; } @@ -481,8 +483,8 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE int i; float *pixel; - /*first duplicate stackbuf->rect, since it's just a pointer - to the source imbuf, and we don't want to change that.*/ + /* first duplicate stackbuf->rect, since it's just a pointer + * to the source imbuf, and we don't want to change that.*/ stackbuf->rect = MEM_dupallocN(stackbuf->rect); /* since stackbuf now has allocated memory, rather than just a pointer, diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 0aeeb69210d..1952756d397 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -291,10 +291,11 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * mean=brightness_mean(node, in[0]->data); std_dev=brightness_standard_deviation(node, in[0]->data, mean); - /* Printf debuging ;) + /* Printf debuging ;) */ +#if 0 printf("Mean: %f\n", mean); printf("Std Dev: %f\n", std_dev); - */ +#endif if (out[0]->hasoutput) out[0]->vec[0]= mean; diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index b5400244efe..8b393dd740a 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -319,7 +319,7 @@ void node_socket_copy_default_value(int type, void *to_default_value, void *from * In the interface this could be implemented by a pseudo-script textbox on linked inputs, * with quick selection from a predefined list of conversion options. Some Examples: * - vector component 'z' (vector->float): "z" - * - greyscale color (float->color): "grey" + * - grayscale color (float->color): "gray" * - color luminance (color->float): "lum" * - matrix column 2 length (matrix->vector->float): "col[1].len" * - mesh vertex coordinate 'y' (mesh->vertex->vector->float): "vertex.co.y" diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index c84436a84b7..1a11a7075b8 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -282,7 +282,7 @@ int ntreeTexExecTree( if (texres->nor) retval |= TEX_NOR; retval |= TEX_RGB; /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set - however, the texture code checks this for other reasons (namely, a normal is required for material) */ + * however, the texture code checks this for other reasons (namely, a normal is required for material) */ texres->nor= nor; return retval; diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 28d03db1687..53f1aa82f60 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -31,20 +31,20 @@ /* - HOW TEXTURE NODES WORK - - In contrast to Shader nodes, which place a color into the output - stack when executed, Texture nodes place a TexDelegate* there. To - obtain a color value from this, a node further up the chain reads - the TexDelegate* from its input stack, and uses tex_call_delegate to - retrieve the color from the delegate. - - comments: (ton) - - This system needs recode, a node system should rely on the stack, and - callbacks for nodes only should evaluate own node, not recursively go - over other previous ones. -*/ + * HOW TEXTURE NODES WORK + * + * In contrast to Shader nodes, which place a color into the output + * stack when executed, Texture nodes place a TexDelegate* there. To + * obtain a color value from this, a node further up the chain reads + * the TexDelegate* from its input stack, and uses tex_call_delegate to + * retrieve the color from the delegate. + * + * comments: (ton) + * + * This system needs recode, a node system should rely on the stack, and + * callbacks for nodes only should evaluate own node, not recursively go + * over other previous ones. + */ #include <assert.h> #include "node_texture_util.h" diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h index 0fe685996b1..7d8c4ce232c 100644 --- a/source/blender/nodes/texture/node_texture_util.h +++ b/source/blender/nodes/texture/node_texture_util.h @@ -97,7 +97,7 @@ typedef struct TexParams { int osatex; /* optional. we don't really want these here, but image - textures need to do mapping & color correction */ + * textures need to do mapping & color correction */ ShadeInput *shi; MTex *mtex; } TexParams; diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index fe2082d1442..3b33383c73b 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -36,8 +36,8 @@ #include "RE_shader_ext.h" /* - In this file: wrappers to use procedural textures as nodes -*/ + * In this file: wrappers to use procedural textures as nodes + */ static bNodeSocketTemplate outputs_both[]= { diff --git a/source/blender/opencl/CMakeLists.txt b/source/blender/opencl/CMakeLists.txt index 9c8ce830316..20dcf33d363 100644 --- a/source/blender/opencl/CMakeLists.txt +++ b/source/blender/opencl/CMakeLists.txt @@ -28,11 +28,15 @@ set(INC . ) +set(INC_SYS + +) + set(SRC - OCL_opencl.h - intern/clew.h - intern/clew.c - intern/OCL_opencl.c + OCL_opencl.h + intern/clew.h + intern/clew.c + intern/OCL_opencl.c ) diff --git a/source/blender/python/bmesh/CMakeLists.txt b/source/blender/python/bmesh/CMakeLists.txt index 40bde7161b6..032a914fb70 100644 --- a/source/blender/python/bmesh/CMakeLists.txt +++ b/source/blender/python/bmesh/CMakeLists.txt @@ -33,6 +33,7 @@ set(INC_SYS set(SRC bmesh_py_api.c + bmesh_py_ops.c bmesh_py_types.c bmesh_py_types_customdata.c bmesh_py_types_meshdata.c @@ -40,6 +41,7 @@ set(SRC bmesh_py_utils.c bmesh_py_api.h + bmesh_py_ops.h bmesh_py_types.h bmesh_py_types_customdata.h bmesh_py_types_meshdata.h diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c index 4d8d4e3bc23..f3e5b300ced 100644 --- a/source/blender/python/bmesh/bmesh_py_api.c +++ b/source/blender/python/bmesh/bmesh_py_api.c @@ -40,6 +40,7 @@ #include "bmesh_py_types_customdata.h" #include "bmesh_py_types_meshdata.h" +#include "bmesh_py_ops.h" #include "bmesh_py_utils.h" #include "BKE_tessmesh.h" @@ -72,7 +73,7 @@ PyDoc_STRVAR(bpy_bm_from_edit_mesh_doc, "\n" " Return a BMesh from this mesh, currently the mesh must already be in editmode.\n" "\n" -" :return: the BMesh assosiated with this mesh.\n" +" :return: the BMesh associated with this mesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n" ); static PyObject *bpy_bm_from_edit_mesh(PyObject *UNUSED(self), PyObject *value) @@ -143,6 +144,11 @@ PyObject *BPyInit_bmesh(void) PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); Py_INCREF(submodule); + PyModule_AddObject(mod, "ops", (submodule = BPyInit_bmesh_ops())); + /* PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); */ + PyDict_SetItemString(sys_modules, "bmesh.ops", submodule); /* fake module */ + Py_INCREF(submodule); + PyModule_AddObject(mod, "utils", (submodule = BPyInit_bmesh_utils())); PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); Py_INCREF(submodule); diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c new file mode 100644 index 00000000000..53ddcecd7a8 --- /dev/null +++ b/source/blender/python/bmesh/bmesh_py_ops.c @@ -0,0 +1,543 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/bmesh/bmesh_py_ops.c + * \ingroup pybmesh + * + * This file defines the 'bmesh.ops' module. + * Operators from 'opdefines' are wrapped. + */ + +#include <Python.h> + +#include "BLI_utildefines.h" + +#include "MEM_guardedalloc.h" + +#include "../generic/py_capi_utils.h" + +#include "../mathutils/mathutils.h" + +#include "bmesh.h" + +#include "bmesh_py_types.h" + +#include "bmesh_py_utils.h" /* own include */ + +static int bpy_bm_op_as_py_error(BMesh *bm) +{ + if (BMO_error_occurred(bm)) { + const char *errmsg; + if (BMO_error_get(bm, &errmsg, NULL)) { + PyErr_Format(PyExc_RuntimeError, + "bmesh operator: %.200s", + errmsg); + return -1; + } + } + return 0; +} + +/* bmesh operator 'bmesh.ops.*' callable types + * ******************************************* */ +PyTypeObject bmesh_op_Type; + +typedef struct { + PyObject_HEAD /* required python macro */ + const char *opname; +} BPy_BMeshOpFunc; + +PyObject *bpy_bmesh_op_CreatePyObject(const char *opname) +{ + BPy_BMeshOpFunc *self = PyObject_New(BPy_BMeshOpFunc, &bmesh_op_Type); + + self->opname = opname; + + return (PyObject *)self; +} + +static PyObject *bpy_bmesh_op_repr(BPy_BMeshOpFunc *self) +{ + return PyUnicode_FromFormat("<%.200s bmesh.ops.%.200s()>", + Py_TYPE(self)->tp_name, + self->opname); +} + + +static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) +{ + BPy_BMesh *py_bm; + BMesh *bm; + + BMOperator bmop; + + if ((PyTuple_GET_SIZE(args) == 1) && + (py_bm = (BPy_BMesh *)PyTuple_GET_ITEM(args, 0)) && + (BPy_BMesh_Check(py_bm)) + ) + { + BPY_BM_CHECK_OBJ(py_bm); + bm = py_bm->bm; + } + else { + PyErr_SetString(PyExc_TypeError, + "calling a bmesh operator expects a single BMesh (non keyword) " + "as the first argument"); + return NULL; + } + + /* TODO - error check this!, though we do the error check on attribute access */ + BMO_op_init(bm, &bmop, self->opname); + + if (kw && PyDict_Size(kw) > 0) { + /* setup properties, see bpy_rna.c: pyrna_py_to_prop() + * which shares this logic for parsing properties */ + + PyObject *key, *value; + Py_ssize_t pos = 0; + while (PyDict_Next(kw, &pos, &key, &value)) { + const char *slot_name = _PyUnicode_AsString(key); + BMOpSlot *slot = BMO_slot_get(&bmop, slot_name); + + if (slot == NULL) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" is invalid for this operator", + self->opname, slot_name); + return NULL; + } + + /* now assign the value */ + switch (slot->slot_type) { + case BMO_OP_SLOT_BOOL: + { + int param; + + param = PyLong_AsLong(value); + + if (param < 0) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected True/False or 0/1, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else { + slot->data.i = param; + } + + break; + } + case BMO_OP_SLOT_INT: + { + int overflow; + long param = PyLong_AsLongAndOverflow(value, &overflow); + if (overflow || (param > INT_MAX) || (param < INT_MIN)) { + PyErr_Format(PyExc_ValueError, + "%.200s: keyword \"%.200s\" value not in 'int' range " + "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else if (param == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected an int, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else { + slot->data.i = (int)param; + } + break; + } + case BMO_OP_SLOT_FLT: + { + float param = PyFloat_AsDouble(value); + if (param == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected a float, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else { + slot->data.f = param; + } + break; + } + case BMO_OP_SLOT_MAT: + { + /* XXX - BMesh operator design is crappy here, operator slot should define matrix size, + * not the caller! */ + unsigned short size; + if (!MatrixObject_Check(value)) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected a Matrix, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else if (BaseMath_ReadCallback((MatrixObject *)value) == -1) { + return NULL; + } + else if (((size = ((MatrixObject *)value)->num_col) != ((MatrixObject *)value)->num_row) || + (ELEM(size, 3, 4) == FALSE)) + { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix Matrix", + self->opname, slot_name); + return NULL; + } + + BMO_slot_mat_set(&bmop, slot_name, ((MatrixObject *)value)->matrix, size); + break; + } + case BMO_OP_SLOT_VEC: + { + /* passing slot name here is a bit non-descriptive */ + if (mathutils_array_parse(slot->data.vec, 3, 3, value, slot_name) == -1) { + return NULL; + } + break; + } + case BMO_OP_SLOT_ELEMENT_BUF: + { + /* there are many ways we could interpret arguments, for now... + * - verts/edges/faces from the mesh direct, + * this way the operator takes every item. + * - `TODO` a plain python sequence (list) of elements. + * - `TODO` an iterator. eg. + * face.verts + * - `TODO` (type, flag) pair, eg. + * ('VERT', {'TAG'}) + */ + +#define BPY_BM_GENERIC_MESH_TEST(type_string) \ + if (((BPy_BMGeneric *)value)->bm != bm) { \ + PyErr_Format(PyExc_NotImplementedError, \ + "%.200s: keyword \"%.200s\" " type_string " are from another bmesh", \ + self->opname, slot_name, slot->slot_type); \ + return NULL; \ + } (void)0 + + if (BPy_BMVertSeq_Check(value)) { + BPY_BM_GENERIC_MESH_TEST("verts"); + BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_VERT); + } + else if (BPy_BMEdgeSeq_Check(value)) { + BPY_BM_GENERIC_MESH_TEST("edges"); + BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_EDGE); + } + else if (BPy_BMFaceSeq_Check(value)) { + BPY_BM_GENERIC_MESH_TEST("faces"); + BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_FACE); + } + else if (BPy_BMElemSeq_Check(value)) { + BMIter iter; + BMHeader *ele; + int tot; + unsigned int i; + + BPY_BM_GENERIC_MESH_TEST("elements"); + + /* this will loop over all elements which is a shame but + * we need to know this before alloc */ + /* calls bpy_bmelemseq_length() */ + tot = Py_TYPE(value)->tp_as_sequence->sq_length((PyObject *)self); + + BMO_slot_buffer_alloc(&bmop, slot_name, tot); + + i = 0; + BM_ITER_BPY_BM_SEQ (ele, &iter, ((BPy_BMElemSeq *)value)) { + ((void **)slot->data.buf)[i] = (void *)ele; + i++; + } + } + /* keep this last */ + else if (PySequence_Check(value)) { + BMElem **elem_array = NULL; + Py_ssize_t elem_array_len; + + elem_array = BPy_BMElem_PySeq_As_Array(&bm, value, 0, PY_SSIZE_T_MAX, + &elem_array_len, BM_VERT | BM_EDGE | BM_FACE, + TRUE, TRUE, slot_name); + + /* error is set above */ + if (elem_array == NULL) { + return NULL; + } + + BMO_slot_buffer_alloc(&bmop, slot_name, elem_array_len); + memcpy(slot->data.buf, elem_array, sizeof(void *) * elem_array_len); + PyMem_FREE(elem_array); + } + else { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected " + "a bmesh sequence, list, (htype, flag) pair, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + +#undef BPY_BM_GENERIC_MESH_TEST + + break; + } + default: + /* TODO --- many others */ + PyErr_Format(PyExc_NotImplementedError, + "%.200s: keyword \"%.200s\" type %d not working yet!", + self->opname, slot_name, slot->slot_type); + return NULL; + break; + } + } + } + + BMO_op_exec(bm, &bmop); + BMO_op_finish(bm, &bmop); + + if (bpy_bm_op_as_py_error(bm) == -1) { + return NULL; + } + + Py_RETURN_NONE; +} + + +PyTypeObject bmesh_op_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BMeshOpFunc", /* tp_name */ + sizeof(BPy_BMeshOpFunc), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) bpy_bmesh_op_repr, /* tp_repr */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + (ternaryfunc)pyrna_op_call, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + + /* will only use these if this is a subtype of a py class */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + NULL, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + NULL, /* newfunc tp_new; */ + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + + +/* bmesh fake module 'bmesh.ops' + * ***************************** */ + +static PyObject *bpy_bmesh_fmod_getattro(PyObject *UNUSED(self), PyObject *pyname) +{ + const unsigned int tot = bmesh_total_ops; + unsigned int i; + const char *name = _PyUnicode_AsString(pyname); + + for (i = 0; i < tot; i++) { + if (strcmp(opdefines[i]->name, name) == 0) { + return bpy_bmesh_op_CreatePyObject(opdefines[i]->name); + } + } + + PyErr_Format(PyExc_AttributeError, + "BMeshOpsModule: , operator \"%.200s\" doesn't exist", + name); + return NULL; +} + +static PyObject *bpy_bmesh_fmod_dir(PyObject *UNUSED(self)) +{ + const unsigned int tot = bmesh_total_ops; + unsigned int i; + PyObject *ret; + + ret = PyList_New(bmesh_total_ops); + + for (i = 0; i < tot; i++) { + PyList_SET_ITEM(ret, i, PyUnicode_FromString(opdefines[i]->name)); + } + + return ret; +} + +static struct PyMethodDef bpy_bmesh_fmod_methods[] = { + {"__dir__", (PyCFunction)bpy_bmesh_fmod_dir, METH_NOARGS, NULL}, + {NULL, NULL, 0, NULL} +}; + +static PyTypeObject bmesh_ops_fakemod_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BMeshOpsModule", /* tp_name */ + 0, /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_repr */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + + /* will only use these if this is a subtype of a py class */ + bpy_bmesh_fmod_getattro, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + bpy_bmesh_fmod_methods, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + NULL, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + NULL, /* newfunc tp_new; */ + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + +PyObject *BPyInit_bmesh_ops(void) +{ + PyObject *submodule; + + if (PyType_Ready(&bmesh_ops_fakemod_Type) < 0) + return NULL; + + if (PyType_Ready(&bmesh_op_Type) < 0) + return NULL; + + submodule = PyObject_New(PyObject, &bmesh_ops_fakemod_Type); + + /* prevent further creation of instances */ + bmesh_ops_fakemod_Type.tp_init = NULL; + bmesh_ops_fakemod_Type.tp_new = NULL; + + return submodule; +} diff --git a/source/blender/python/bmesh/bmesh_py_ops.h b/source/blender/python/bmesh/bmesh_py_ops.h new file mode 100644 index 00000000000..56c980b57ea --- /dev/null +++ b/source/blender/python/bmesh/bmesh_py_ops.h @@ -0,0 +1,35 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/bmesh/bmesh_py_ops.h + * \ingroup pybmesh + */ + +#ifndef __BMESH_PY_OPS_H__ +#define __BMESH_PY_OPS_H__ + +PyObject *BPyInit_bmesh_ops(void); + +#endif /* __BMESH_PY_OPS_H__ */ diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 053dac71fe6..f7a7d379ba4 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -1024,7 +1024,7 @@ PyDoc_STRVAR(bpy_bm_elem_select_set_doc, ".. method:: select_set(select)\n" "\n" " Set the selection.\n" -" This is different from the *select* attribute because it updates the selection state of assosiated geometry.\n" +" This is different from the *select* attribute because it updates the selection state of associated geometry.\n" "\n" " :arg select: Select or de-select.\n" " :type select: boolean\n" @@ -1057,7 +1057,7 @@ PyDoc_STRVAR(bpy_bm_elem_hide_set_doc, ".. method:: hide_set(hide)\n" "\n" " Set the hide state.\n" -" This is different from the *hide* attribute because it updates the selection and hide state of assosiated geometry.\n" +" This is different from the *hide* attribute because it updates the selection and hide state of associated geometry.\n" "\n" " :arg hide: Hidden or visible.\n" " :type hide: boolean\n" diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h index 85bbd5d7b09..947e66bf24e 100644 --- a/source/blender/python/bmesh/bmesh_py_types.h +++ b/source/blender/python/bmesh/bmesh_py_types.h @@ -186,4 +186,13 @@ char *BPy_BMElem_StringFromHType(const char htype); ele; \ ele = BM_iter_step(iter)) + +#ifdef __PY_CAPI_UTILS_H__ +struct PyC_FlagSet; +extern struct PyC_FlagSet bpy_bm_scene_vert_edge_face_flags[]; +extern struct PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[]; +extern struct PyC_FlagSet bpy_bm_htype_all_flags[]; +extern struct PyC_FlagSet bpy_bm_hflag_all_flags[]; +#endif + #endif /* __BMESH_TYPES_H__ */ diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index 6a2ba90a330..4417bc2ce8d 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -668,13 +668,13 @@ static struct PyMethodDef BPy_BM_utils_methods[] = { }; -PyDoc_STRVAR(BPy_BM_doc, +PyDoc_STRVAR(BPy_BM_utils_doc, "This module provides access to blenders bmesh data structures." ); -static struct PyModuleDef BPy_BM_types_module_def = { +static struct PyModuleDef BPy_BM_utils_module_def = { PyModuleDef_HEAD_INIT, "bmesh.utils", /* m_name */ - BPy_BM_doc, /* m_doc */ + BPy_BM_utils_doc, /* m_doc */ 0, /* m_size */ BPy_BM_utils_methods, /* m_methods */ NULL, /* m_reload */ @@ -688,7 +688,7 @@ PyObject *BPyInit_bmesh_utils(void) { PyObject *submodule; - submodule = PyModule_Create(&BPy_BM_types_module_def); + submodule = PyModule_Create(&BPy_BM_utils_module_def); return submodule; } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 10562271941..7375ad454a0 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -147,6 +147,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) /* note that context is an int, python does the conversion in this case */ int context = WM_OP_EXEC_DEFAULT; + int is_undo = FALSE; /* XXX Todo, work out a better solution for passing on context, * could make a tuple from self and pack the name and Context into it... */ @@ -157,7 +158,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) return NULL; } - if (!PyArg_ParseTuple(args, "sO|O!s:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context_str)) + if (!PyArg_ParseTuple(args, "sO|O!si:_bpy.ops.call", + &opname, &context_dict, &PyDict_Type, &kw, &context_str, &is_undo)) return NULL; ot = WM_operatortype_find(opname, TRUE); @@ -236,7 +238,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) PyThreadState *ts = PyEval_SaveThread(); #endif - operator_ret = WM_operator_call_py(C, ot, context, &ptr, reports); + operator_ret = WM_operator_call_py(C, ot, context, &ptr, reports, is_undo); #ifdef BPY_RELEASE_GIL /* regain GIL */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 04f9a90f0d2..4bba7ba6838 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -873,7 +873,7 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self) if (path) { if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */ ret = PyUnicode_FromFormat("bpy.data...%s", - path); + path); } else { ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", @@ -980,7 +980,7 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) if (path) { if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */ ret = PyUnicode_FromFormat("bpy.data...%s", - path); + path); } else { ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", @@ -2040,12 +2040,12 @@ static int pyrna_prop_collection_bool(BPy_PropertyRNA *self) * This is done for faster lookups. */ #define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err) \ if (keynum < 0) { \ - keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \ - if (keynum_abs < 0) { \ - PyErr_Format(PyExc_IndexError, \ - "bpy_prop_collection[%d]: out of range.", keynum); \ - return ret_err; \ - } \ + keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \ + if (keynum_abs < 0) { \ + PyErr_Format(PyExc_IndexError, \ + "bpy_prop_collection[%d]: out of range.", keynum); \ + return ret_err; \ + } \ } (void)0 @@ -3508,8 +3508,8 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) PyList_Append(ret, linkptr); Py_DECREF(linkptr); } + break; } - break; default: /* should never happen */ BLI_assert(!"Invalid context type"); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 5c4c6414f39..5f372abcc69 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1640,7 +1640,7 @@ static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) * sequence length */ static int Matrix_len(MatrixObject *self) { - return (self->num_row); + return self->num_row; } /*----------------------------object[]--------------------------- * sequence accessor (get) diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 4d05b837952..524515ac460 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -944,6 +944,109 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); } +PyDoc_STRVAR(M_Geometry_points_in_planes_doc, +".. function:: points_in_planes(planes)\n" +"\n" +" Returns a list of points inside all planes given and a list of index values for the planes used.\n" +"\n" +" :arg planes: List of planes (4D vectors).\n" +" :type planes: list of :class:`mathutils.Vector`\n" +" :return: two lists, once containing the vertices inside the planes, another containing the plane indicies used\n" +" :rtype: pair of lists\n" +); +/* note: this function could be optimized by some spatial structure */ +static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *args) +{ + PyObject *py_planes; + float (*planes)[4]; + unsigned int planes_len; + + if (!PyArg_ParseTuple(args, "O:points_in_planes", + &py_planes)) + { + return NULL; + } + + if ((planes_len = mathutils_array_parse_alloc_v((float **)&planes, 4, py_planes, "points_in_planes")) == -1) { + return NULL; + } + else { + /* note, this could be refactored into plain C easy - py bits are noted */ + const float eps = 0.0001f; + const unsigned int len = (unsigned int)planes_len; + unsigned int i, j, k, l; + + float n1n2[3], n2n3[3], n3n1[3]; + float potentialVertex[3]; + char *planes_used = MEM_callocN(sizeof(char) * len, __func__); + + /* python */ + PyObject *py_verts = PyList_New(0); + PyObject *py_plene_index = PyList_New(0); + + for (i = 0; i < len; i++) { + const float *N1 = planes[i]; + for (j = i + 1; j < len; j++) { + const float *N2 = planes[j]; + cross_v3_v3v3(n1n2, N1, N2); + if (len_squared_v3(n1n2) > eps) { + for (k = j + 1; k < len; k++) { + const float *N3 = planes[k]; + cross_v3_v3v3(n2n3, N2, N3); + if (len_squared_v3(n2n3) > eps) { + cross_v3_v3v3(n3n1, N3, N1); + if (len_squared_v3(n3n1) > eps) { + const float quotient = dot_v3v3(N1, n2n3); + if (fabsf(quotient) > eps) { + /* potentialVertex = (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) * (-1.0 / quotient); */ + const float quotient_ninv = -1.0f / quotient; + potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) + (n1n2[0] * N3[3])) * quotient_ninv; + potentialVertex[1] = ((n2n3[1] * N1[3]) + (n3n1[1] * N2[3]) + (n1n2[1] * N3[3])) * quotient_ninv; + potentialVertex[2] = ((n2n3[2] * N1[3]) + (n3n1[2] * N2[3]) + (n1n2[2] * N3[3])) * quotient_ninv; + for (l = 0; l < len; l++) { + const float *NP = planes[l]; + if ((dot_v3v3(NP, potentialVertex) + NP[3]) > 0.000001f) { + break; + } + } + + if (l == len) { /* ok */ + /* python */ + PyObject *item = Vector_CreatePyObject(potentialVertex, 3, Py_NEW, NULL); + PyList_Append(py_verts, item); + Py_DECREF(item); + + planes_used[i] = planes_used[j] = planes_used[k] = TRUE; + } + } + } + } + } + } + } + } + + PyMem_Free(planes); + + /* now make a list of used planes */ + for (i = 0; i < len; i++) { + if (planes_used[i]) { + PyObject *item = PyLong_FromLong(i); + PyList_Append(py_plene_index, item); + Py_DECREF(item); + } + } + MEM_freeN(planes_used); + + { + PyObject *ret = PyTuple_New(2); + PyTuple_SET_ITEM(ret, 0, py_verts); + PyTuple_SET_ITEM(ret, 1, py_plene_index); + return ret; + } + } +} + #ifndef MATH_STANDALONE PyDoc_STRVAR(M_Geometry_interpolate_bezier_doc, @@ -1279,6 +1382,7 @@ static PyMethodDef M_Geometry_methods[] = { {"area_tri", (PyCFunction) M_Geometry_area_tri, METH_VARARGS, M_Geometry_area_tri_doc}, {"normal", (PyCFunction) M_Geometry_normal, METH_VARARGS, M_Geometry_normal_doc}, {"barycentric_transform", (PyCFunction) M_Geometry_barycentric_transform, METH_VARARGS, M_Geometry_barycentric_transform_doc}, + {"points_in_planes", (PyCFunction) M_Geometry_points_in_planes, METH_VARARGS, M_Geometry_points_in_planes_doc}, #ifndef MATH_STANDALONE {"interpolate_bezier", (PyCFunction) M_Geometry_interpolate_bezier, METH_VARARGS, M_Geometry_interpolate_bezier_doc}, {"tessellate_polygon", (PyCFunction) M_Geometry_tessellate_polygon, METH_O, M_Geometry_tessellate_polygon_doc}, diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h index fab0bb94618..9318e1758a6 100644 --- a/source/blender/render/intern/raytrace/bvh.h +++ b/source/blender/render/intern/raytrace/bvh.h @@ -75,7 +75,7 @@ inline int test_bb_group4(__m128 *bb_group, const Isect *isec) * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] */ -static int rayobject_bb_intersect_test(const Isect *isec, const float *_bb) +static inline int rayobject_bb_intersect_test(const Isect *isec, const float *_bb) { const float *bb = _bb; diff --git a/source/blender/render/intern/raytrace/rayobject_instance.cpp b/source/blender/render/intern/raytrace/rayobject_instance.cpp index 92a412103ba..bfbc1c64133 100644 --- a/source/blender/render/intern/raytrace/rayobject_instance.cpp +++ b/source/blender/render/intern/raytrace/rayobject_instance.cpp @@ -77,32 +77,32 @@ typedef struct InstanceRayObject { RayObject *RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob) { - InstanceRayObject *obj= (InstanceRayObject*)MEM_callocN(sizeof(InstanceRayObject), "InstanceRayObject"); - assert( RE_rayobject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */ - + InstanceRayObject *obj = (InstanceRayObject *)MEM_callocN(sizeof(InstanceRayObject), "InstanceRayObject"); + assert(RE_rayobject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */ + obj->rayobj.api = &instance_api; obj->target = target; obj->ob = ob; obj->target_ob = target_ob; - + copy_m4_m4(obj->target2global, transform); invert_m4_m4(obj->global2target, obj->target2global); - - return RE_rayobject_unalignRayAPI((RayObject*) obj); + + return RE_rayobject_unalignRayAPI((RayObject *) obj); } static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) { - InstanceRayObject *obj = (InstanceRayObject*)o; + InstanceRayObject *obj = (InstanceRayObject *)o; float start[3], dir[3], idot_axis[3], dist; int changed = 0, i, res; - + // TODO - this is disabling self intersection on instances if (isec->orig.ob == obj->ob && obj->ob) { changed = 1; isec->orig.ob = obj->target_ob; } - + // backup old values copy_v3_v3(start, isec->start); copy_v3_v3(dir, isec->dir); @@ -113,16 +113,16 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) mul_m4_v3(obj->global2target, isec->start); mul_mat3_m4_v3(obj->global2target, isec->dir); isec->dist *= normalize_v3(isec->dir); - + // update idot_axis and bv_index - for (i=0; i<3; i++) { - isec->idot_axis[i] = 1.0f / isec->dir[i]; - - isec->bv_index[2*i] = isec->idot_axis[i] < 0.0 ? 1 : 0; - isec->bv_index[2*i+1] = 1 - isec->bv_index[2*i]; - - isec->bv_index[2*i] = i+3*isec->bv_index[2*i]; - isec->bv_index[2*i+1] = i+3*isec->bv_index[2*i+1]; + for (i = 0; i < 3; i++) { + isec->idot_axis[i] = 1.0f / isec->dir[i]; + + isec->bv_index[2 * i] = isec->idot_axis[i] < 0.0 ? 1 : 0; + isec->bv_index[2 * i + 1] = 1 - isec->bv_index[2 * i]; + + isec->bv_index[2 * i] = i + 3 * isec->bv_index[2 * i]; + isec->bv_index[2 * i + 1] = i + 3 * isec->bv_index[2 * i + 1]; } // raycast @@ -143,11 +143,11 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) isec->dist = len_v3(vec); isec->hit.ob = obj->ob; -#ifdef RT_USE_LAST_HIT +#ifdef RT_USE_LAST_HIT // TODO support for last hit optimization in instances that can jump // directly to the last hit face. // For now it jumps directly to the last-hit instance root node. - isec->last_hit = RE_rayobject_unalignRayAPI((RayObject*) obj); + isec->last_hit = RE_rayobject_unalignRayAPI((RayObject *) obj); #endif } @@ -155,19 +155,19 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) copy_v3_v3(isec->start, start); copy_v3_v3(isec->dir, dir); copy_v3_v3(isec->idot_axis, idot_axis); - + if (changed) isec->orig.ob = obj->ob; // restore bv_index - for (i=0; i<3; i++) { - isec->bv_index[2*i] = isec->idot_axis[i] < 0.0 ? 1 : 0; - isec->bv_index[2*i+1] = 1 - isec->bv_index[2*i]; - - isec->bv_index[2*i] = i+3*isec->bv_index[2*i]; - isec->bv_index[2*i+1] = i+3*isec->bv_index[2*i+1]; + for (i = 0; i < 3; i++) { + isec->bv_index[2 * i] = isec->idot_axis[i] < 0.0 ? 1 : 0; + isec->bv_index[2 * i + 1] = 1 - isec->bv_index[2 * i]; + + isec->bv_index[2 * i] = i + 3 * isec->bv_index[2 * i]; + isec->bv_index[2 * i + 1] = i + 3 * isec->bv_index[2 * i + 1]; } - + return res; } @@ -188,7 +188,7 @@ static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max) //TODO: // *better bb.. calculated without rotations of bb // *maybe cache that better-fitted-BB at the InstanceRayObject - InstanceRayObject *obj = (InstanceRayObject*)o; + InstanceRayObject *obj = (InstanceRayObject *)o; float m[3], M[3], t[3]; int i, j; @@ -196,8 +196,8 @@ static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max) RE_rayobject_merge_bb(obj->target, m, M); //There must be a faster way than rotating all the 8 vertexs of the BB - for (i=0; i<8; i++) { - for (j=0; j<3; j++) t[j] = i&(1<<j) ? M[j] : m[j]; + for (i = 0; i < 8; i++) { + for (j = 0; j < 3; j++) t[j] = i & (1 << j) ? M[j] : m[j]; mul_m4_v3(obj->target2global, t); DO_MINMAX(t, min, max); } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 4eebc967823..d21a22f553b 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -327,16 +327,16 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), #define UVTOINDEX(u,v) (startvlak + (u) * sizev + (v)) /* - -NOTE THAT U/V COORDINATES ARE SOMETIMES SWAPPED !! - -^ ()----p4----p3----() -| | | | | -u | | F1 | F2 | - | | | | - ()----p1----p2----() - v -> -*/ + * + * NOTE THAT U/V COORDINATES ARE SOMETIMES SWAPPED !! + * + * ^ ()----p4----p3----() + * | | | | | + * u | | F1 | F2 | + * | | | | + * ()----p1----p2----() + * v -> + */ /* ------------------------------------------------------------------------- */ @@ -3226,12 +3226,15 @@ static void init_camera_inside_volumes(Render *re) } } - /* debug { - MatInside *m; - for (m=re->render_volumes_inside.first; m; m=m->next) { - printf("matinside: ma: %s\n", m->ma->id.name+2); + +#if 0 /* debug */ + { + MatInside *m; + for (m = re->render_volumes_inside.first; m; m = m->next) { + printf("matinside: ma: %s\n", m->ma->id.name + 2); + } } - }*/ +#endif } static void add_volume(Render *re, ObjectRen *obr, Material *ma) diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 6f572b43a15..8e8483839b1 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1041,7 +1041,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) } } - /* color -> greyscale */ + /* color -> grayscale */ /* editing directly would alter the render view */ if (rd->im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw = IMB_dupImBuf(ibuf); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index bfea3f3c40b..5011c785e90 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -193,13 +193,13 @@ struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType * int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot); -int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context); +int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context); int WM_operator_call (struct bContext *C, struct wmOperator *op); int WM_operator_call_notest(struct bContext *C, struct wmOperator *op); int WM_operator_repeat (struct bContext *C, struct wmOperator *op); int WM_operator_repeat_check(const struct bContext *C, struct wmOperator *op); -int WM_operator_name_call (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties); -int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports); +int WM_operator_name_call (struct bContext *C, const char *opstring, short context, struct PointerRNA *properties); +int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, struct PointerRNA *properties, struct ReportList *reports, short is_undo); void WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */ void WM_operator_properties_sanitize(struct PointerRNA *ptr, const short no_context); /* make props context sensitive or not */ diff --git a/source/blender/windowmanager/intern/wm_apple.c b/source/blender/windowmanager/intern/wm_apple.c index 161725386c5..71d074e340f 100644 --- a/source/blender/windowmanager/intern/wm_apple.c +++ b/source/blender/windowmanager/intern/wm_apple.c @@ -41,7 +41,7 @@ #include <Carbon/Carbon.h> /* To avoid killing small end comps, we want to allow - * blender to start maximised if all the followings are true : + * blender to start maximized if all the followings are true : * - Renderer is OpenGL capable * - Hardware acceleration * - VRAM > 16 Mo diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e55f7404798..9795c482af2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -417,7 +417,7 @@ int WM_operator_poll(bContext *C, wmOperatorType *ot) } /* sets up the new context and calls 'wm_operator_invoke()' with poll_only */ -int WM_operator_poll_context(bContext *C, wmOperatorType *ot, int context) +int WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context) { return wm_operator_call_internal(C, ot, NULL, NULL, context, TRUE); } @@ -1068,7 +1068,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* invokes operator in context */ -int WM_operator_name_call(bContext *C, const char *opstring, int context, PointerRNA *properties) +int WM_operator_name_call(bContext *C, const char *opstring, short context, PointerRNA *properties) { wmOperatorType *ot = WM_operatortype_find(opstring, 0); if (ot) @@ -1082,7 +1082,7 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe * - poll() must be called by python before this runs. * - reports can be passed to this function (so python can report them as exceptions) */ -int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA *properties, ReportList *reports) +int WM_operator_call_py(bContext *C, wmOperatorType *ot, short context, PointerRNA *properties, ReportList *reports, short is_undo) { int retval = OPERATOR_CANCELLED; @@ -1091,13 +1091,13 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA op = wm_operator_create(wm, ot, properties, reports); if (op->type->exec) { - if (op->type->flag & OPTYPE_UNDO) + if (is_undo && op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); - if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) + if (is_undo && op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } else @@ -1110,11 +1110,11 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA * we could have some more obvious way of doing this like passing a flag. */ wmWindowManager *wm = CTX_wm_manager(C); - if (wm) wm->op_undo_depth++; + if (!is_undo && wm) wm->op_undo_depth++; retval = wm_operator_call_internal(C, ot, properties, reports, context, FALSE); - if (wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--; + if (!is_undo && wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--; /* keep the reports around if needed later */ if ((retval & OPERATOR_RUNNING_MODAL) || diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 73f59a5fbae..bd7b4694471 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -54,7 +54,7 @@ #include "wm_event_types.h" #include "wm.h" - +#include "PIL_time.h" /* ********************** Threaded Jobs Manager ****************************** */ @@ -127,6 +127,7 @@ struct wmJob { /* we use BLI_threads api, but per job only 1 thread runs */ ListBase threads; + double start_time; }; /* finds: @@ -343,6 +344,9 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) /* restarted job has timer already */ if (steve->wt == NULL) steve->wt = WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep); + + if (G.debug & G_DEBUG_JOBS) + steve->start_time = PIL_check_seconds_timer(); } else printf("job fails, not initialized\n"); } @@ -465,6 +469,11 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) // if (steve->stop) printf("job ready but stopped %s\n", steve->name); // else printf("job finished %s\n", steve->name); + if (G.debug & G_DEBUG_JOBS) { + printf("Job '%s' finished in %f seconds\n", steve->name, + PIL_check_seconds_timer() - steve->start_time); + } + steve->running = 0; BLI_end_threads(&steve->threads); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 4acc9191aef..2aa010f012e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1052,7 +1052,10 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); + + /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogs have many items + * where quitting by accident is very annoying */ + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); @@ -2062,12 +2065,17 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) ot->check = blend_save_check; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, + FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); - RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory"); - RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active"); + RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", + "Remap relative paths when saving in a different directory"); + RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", + "Save a copy of the actual working state but does not make saved file active"); #ifdef USE_BMESH_SAVE_AS_COMPAT - RNA_def_boolean(ot->srna, "use_mesh_compat", 0, "Legacy Mesh Format", "Save using legacy mesh format (no ngons)"); + RNA_def_boolean(ot->srna, "use_mesh_compat", 0, "Legacy Mesh Format", + "Save using legacy mesh format (no ngons) - WARNING: only saves tris and quads, other ngons will " + "be lost (no implicit triangulation)"); #endif } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index dd501e6d880..28e50f1655e 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -368,7 +368,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); - /* until screens get drawn, make it nice grey */ + /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 6fd4ced9c23..6360cfd4802 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -56,7 +56,7 @@ void wm_window_raise (wmWindow *win); void wm_window_lower (wmWindow *win); void wm_window_set_size (wmWindow *win, int width, int height); void wm_window_get_size (wmWindow *win, int *width_r, int *height_r); -void wm_window_get_size_ghost (wmWindow *win, int *width_r, int *height_r); +void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r); void wm_window_get_position (wmWindow *win, int *posx_r, int *posy_r); void wm_window_swap_buffers (wmWindow *win); diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 97fb9435180..53f3dacbffa 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -449,7 +449,7 @@ struct wmOperatorType *WM_operatortype_find(const char *idname, int quiet) {retu struct GHashIterator *WM_operatortype_iter() {return (struct GHashIterator *) NULL;} struct wmOperatorType *WM_operatortype_exists(const char *idname) {return (struct wmOperatorType *) NULL;} struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname) {return (struct wmOperatorTypeMacro *) NULL;} -int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports) {return 0;} +int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, short is_undo, struct PointerRNA *properties, struct ReportList *reports) {return 0;} int WM_operatortype_remove(const char *idname) {return 0;} int WM_operator_poll(struct bContext *C, struct wmOperatorType *ot) {return 0;} int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context) {return 0;} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 033b1352e51..d9ac43d7622 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -894,11 +894,15 @@ endif() cycles_kernel cycles_util cycles_subd - bf_compositor #added for opencl compositor - bf_opencl #added for opencl compositor bf_intern_raskter ) + if(WITH_COMPOSITOR) + #added for opencl compositor + list(APPEND BLENDER_SORTED_LIBS bf_compositor) + list(APPEND BLENDER_SORTED_LIBS bf_opencl) + endif() + if(WITH_LIBMV) list(APPEND BLENDER_SORTED_LIBS extern_libmv) list(APPEND BLENDER_SORTED_LIBS extern_ceres) diff --git a/source/creator/SConscript b/source/creator/SConscript deleted file mode 100644 index 80428ba7bb6..00000000000 --- a/source/creator/SConscript +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/python - -# dummy, code has been moved to Blender.creator() diff --git a/source/creator/creator.c b/source/creator/creator.c index 713c9220fd7..8c9cc45a050 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1144,6 +1144,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) #endif BLI_argsAdd(ba, 1, NULL, "--debug-value", "<value>\n\tSet debug value of <value> on startup\n", set_debug_value, NULL); + BLI_argsAdd(ba, 1, NULL, "--debug-jobs", "\n\tEnable time profiling for background jobs.", debug_mode_generic, (void *)G_DEBUG_JOBS); BLI_argsAdd(ba, 1, NULL, "--verbose", "<verbose>\n\tSet logging verbosity level.", set_verbosity, NULL); diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 9869dfb9424..b580fc31585 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -350,6 +350,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame) PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) { + PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead"); + return NULL; +#if 0 // XXX To be removed in a later version (first removed in 2.64) const char *string= _PyUnicode_AsString(value); if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE) @@ -407,6 +410,7 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) pchan->size[0], pchan->size[1], pchan->size[2], pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] ); #endif +#endif } /* setChannel */ @@ -416,6 +420,10 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, "\t - matrix : A 4x4 matrix specifying the overriding transformation\n" "\t as an offset from the bone's rest position.\n") { + PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.setChannel() no longer works, please use BL_ArmatureObject.channels instead"); + return NULL; + +#if 0 // XXX To be removed in a later version (first removed in 2.64) BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent(); char *string; PyObject *pymat= NULL; @@ -497,6 +505,7 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, } Py_RETURN_NONE; +#endif } /* ------------------------------------------------------------------------- */ @@ -583,6 +592,10 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { + PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.channelNames no longer works, please use BL_ArmatureObject.channels instead"); + return NULL; + +#if 0 // XXX To be removed in a later version (first removed in 2.64) BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); PyObject *ret= PyList_New(0); PyObject *item; @@ -605,6 +618,7 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA } return ret; +#endif } PyObject* BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 30bc33adddd..6507cc32cf1 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -406,7 +406,7 @@ CValue* CValue::GetProperty(int inIndex) std::map<STR_String,CValue*>::iterator it; for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++) { - if (count++==inIndex) + if (count++ == inIndex) { result = (*it).second; break; diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 64f198f72a0..e511704c7f4 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../../../intern/container ../../../intern/moto/include ../../../intern/string + ../../../intern/ghost ) set(INC_SYS diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index 01f525f8eb7..0382a2efd21 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -274,14 +274,14 @@ public: protected: /** - m_eventStatusTables are two tables that contain current and previous - status of all events - */ + * m_eventStatusTables are two tables that contain current and previous + * status of all events + */ SCA_InputEvent m_eventStatusTables[2][SCA_IInputDevice::KX_MAX_KEYS]; /** - m_currentTable is index for m_keyStatusTable that toggle between 0 or 1 - */ + * m_currentTable is index for m_keyStatusTable that toggle between 0 or 1 + */ int m_currentTable; void ClearStatusTable(int tableid); diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 6543d16d469..1263514d475 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -56,7 +56,7 @@ SCA_LogicManager::~SCA_LogicManager() assert(m_activeActuators.Empty()); } -/* +#if 0 // this kind of fixes bug 398 but breakes games, so better leave it out for now. // a removed object's gameobject (and logicbricks and stuff) didn't get released // because it was still in the m_mapStringToGameObjects map. @@ -77,7 +77,7 @@ void SCA_LogicManager::RemoveGameObject(const STR_String& gameobjname) m_mapStringToGameObjects.remove(gameobjname); } -*/ +#endif void SCA_LogicManager::RegisterEventManager(SCA_EventManager* eventmgr) diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index ce183b37498..a92ffac4129 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -318,9 +318,9 @@ CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername) int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*) { - /* If someone actually do type checking please make sure the 'max' and 'min' - are checked as well (currently they are calling the PrecalculateRangeExpression - function directly */ + /* If someone actually do type checking please make sure the 'max' and 'min' + * are checked as well (currently they are calling the PrecalculateRangeExpression + * function directly */ /* There is no type checking at this moment, unfortunately... */ return 0; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 94a8628ca79..ab7f57a5454 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -71,21 +71,19 @@ SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode) } -/* +#if 0 //debugging -CValue* SCA_PythonController::AddRef() +CValue *SCA_PythonController::AddRef() { //printf("AddRef refcount = %i\n",GetRefCount()); return CValue::AddRef(); } -int SCA_PythonController::Release() +int SCA_PythonController::Release() { //printf("Release refcount = %i\n",GetRefCount()); return CValue::Release(); } -*/ - - +#endif SCA_PythonController::~SCA_PythonController() { @@ -122,13 +120,14 @@ CValue* SCA_PythonController::GetReplica() if (m_pythondictionary) replica->m_pythondictionary = PyDict_Copy(m_pythondictionary); - /* +#if 0 // The other option is to incref the replica->m_pythondictionary - // the replica objects can then share data. if (m_pythondictionary) Py_INCREF(replica->m_pythondictionary); - */ #endif + +#endif /* WITH_PYTHON */ // this will copy properties and so on... replica->ProcessReplica(); diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp index 46c43b5e339..f83b23f510c 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp @@ -28,6 +28,8 @@ #include "SCA_PythonKeyboard.h" #include "SCA_IInputDevice.h" +#include "GHOST_C-api.h" + /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ @@ -55,6 +57,23 @@ SCA_PythonKeyboard::~SCA_PythonKeyboard() /* Python functions */ /* ------------------------------------------------------------------------- */ +/* clipboard */ +static PyObject* gPyGetClipboard(PyObject* args, PyObject* kwds) +{ + char *buf = (char *)GHOST_getClipboard(0); + return PyUnicode_FromString(buf?buf:""); +} + +static PyObject* gPySetClipboard(PyObject* args, PyObject* value) +{ + char* buf; + if (!PyArg_ParseTuple(value,"s:setClipboard",&buf)) + Py_RETURN_NONE; + + GHOST_putClipboard((GHOST_TInt8 *)buf, 0); + Py_RETURN_NONE; +} + /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PythonKeyboard::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -79,6 +98,8 @@ PyTypeObject SCA_PythonKeyboard::Type = { }; PyMethodDef SCA_PythonKeyboard::Methods[] = { + {"getClipboard", (PyCFunction) gPyGetClipboard, METH_VARARGS, "getCliboard doc"}, + {"setClipboard", (PyCFunction) gPySetClipboard, METH_VARARGS, "setCliboard doc"}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index e33169bada7..da3c0fadb51 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp') -incs = '. #/intern/string #intern/container' +incs = '. #/intern/string #intern/container #intern/ghost' incs += ' #/source/gameengine/Expressions #/intern/moto/include' incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph' incs += ' #/source/blender/blenlib' diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index cd2bc7e374e..0e26c5ad729 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -87,7 +87,7 @@ protected: /** Height of the context. */ int m_height; /** Rect that defines the area used for rendering, - relative to the context */ + * relative to the context */ RAS_Rect m_displayarea; /** Storage for the banners to display. */ diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 576da0d3f40..19247664dfa 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -144,7 +144,15 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) mNeedsDeleted = 1; glGenTextures(1, (GLuint*)&mTexture); + +#ifdef WITH_DDS + if (ibuf->ftype & DDS) + InitGLCompressedTex(ibuf, mipmap); + else + InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); +#else InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); +#endif // track created units BL_TextureObject obj; @@ -183,6 +191,26 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } +void BL_Texture::InitGLCompressedTex(ImBuf* ibuf, bool mipmap) +{ +#ifndef WITH_DDS + // Fall back to uncompressed if DDS isn't enabled + InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); + return; +#else + glBindTexture(GL_TEXTURE_2D, mTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + + if (GPU_upload_dxt_texture(ibuf) == 0) { + InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); + return; + } +#endif +} void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap) { diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h index 2673be2bc42..a6bd354d260 100644 --- a/source/gameengine/Ketsji/BL_Texture.h +++ b/source/gameengine/Ketsji/BL_Texture.h @@ -35,6 +35,7 @@ private: void InitNonPow2Tex(unsigned int *p,int x,int y,bool mipmap ); void InitGLTex(unsigned int *p,int x,int y,bool mipmap ); + void InitGLCompressedTex(struct ImBuf *p, bool mipmap); public: BL_Texture(); ~BL_Texture( ); diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index c7f54838c10..4b3426e0784 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -221,6 +221,10 @@ set(SRC add_definitions(-DGLEW_STATIC) +if(WITH_IMAGE_DDS) + add_definitions(-DWITH_DDS) +endif() + if(WITH_SDL) list(APPEND INC_SYS ${SDL_INCLUDE_DIR} diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index f149b676aa5..d87bb937b41 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -469,7 +469,7 @@ bool KX_Dome::ParseWarpMesh(STR_String text) * First line is the image type the mesh is support to be applied to: 2 = fisheye, 1=radial * Tthe next line has the mesh dimensions * Rest of the lines are the nodes of the mesh. Each line has x y u v i - * (x,y) are the normalised screen coordinates + * (x,y) are the normalized screen coordinates * (u,v) texture coordinates * i a multiplicative intensity factor * diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index 170c9977296..ae8b4166238 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -69,10 +69,6 @@ protected: class RAS_IRenderTools* m_rendertools; //needed for drawing routine -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_FontObject") -#endif - #ifdef WITH_PYTHON static PyObject* pyattr_get_text(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 04113607531..21c3198b8f9 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -603,7 +603,7 @@ else /* Suspension holds the physics and logic processing for an * entire scene. Objects can be suspended individually, and - * the settings for that preceed the logic and physics + * the settings for that precede the logic and physics * update. */ m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true); diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index b8169899c78..fd47587e2c8 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -40,7 +40,7 @@ namespace inline float vdist(const float* a, const float* b) { return sqrtf(vdistsqr(a,b)); } inline void vcpy(float* a, const float* b) { a[0]=b[0]; a[1]=b[1]; } inline float vdot(const float* a, const float* b) { return a[0]*b[0] + a[1]*b[1]; } - inline float vperp(const float* a, const float* b) { return a[0]*b[1] - a[1]*b[0]; } +/* inline float vperp(const float* a, const float* b) { return a[0]*b[1] - a[1]*b[0]; } */ /* UNUSED */ inline void vsub(float* v, const float* a, const float* b) { v[0] = a[0]-b[0]; v[1] = a[1]-b[1]; } inline void vadd(float* v, const float* a, const float* b) { v[0] = a[0]+b[0]; v[1] = a[1]+b[1]; } inline void vscale(float* v, const float* a, const float s) { v[0] = a[0]*s; v[1] = a[1]*s; } @@ -48,7 +48,7 @@ namespace inline float vlensqr(const float* v) { return vdot(v,v); } inline float vlen(const float* v) { return sqrtf(vlensqr(v)); } inline void vlerp(float* v, const float* a, const float* b, float t) { v[0] = lerp(a[0], b[0], t); v[1] = lerp(a[1], b[1], t); } - inline void vmad(float* v, const float* a, const float* b, float s) { v[0] = a[0] + b[0]*s; v[1] = a[1] + b[1]*s; } +/* inline void vmad(float* v, const float* a, const float* b, float s) { v[0] = a[0] + b[0]*s; v[1] = a[1] + b[1]*s; } */ /* UNUSED */ inline void vnorm(float* v) { float d = vlen(v); @@ -549,6 +549,9 @@ void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMes p1, p2, ob->m_rad, htmin, htmax)) continue; } + else { + continue; + } if (htmin > 0.0f) { @@ -743,6 +746,9 @@ static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM // Avoid less when facing walls. htmin *= 2.0f; } + else { + continue; + } if (htmin >= 0.0f) { diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 2a648303c52..823363dfd11 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1130,8 +1130,8 @@ static int getGLSLSettingFlag(const char *setting) } static PyObject* gPySetGLSLMaterialSetting(PyObject*, - PyObject* args, - PyObject*) + PyObject* args, + PyObject*) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); char *setting; @@ -1142,7 +1142,7 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, flag = getGLSLSettingFlag(setting); - if (flag==-1) { + if (flag == -1) { PyErr_SetString(PyExc_ValueError, "Rasterizer.setGLSLMaterialSetting(string): glsl setting is not known"); return NULL; } @@ -1173,8 +1173,8 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, } static PyObject* gPyGetGLSLMaterialSetting(PyObject*, - PyObject* args, - PyObject*) + PyObject* args, + PyObject*) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); char *setting; @@ -1185,7 +1185,7 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, flag = getGLSLSettingFlag(setting); - if (flag==-1) { + if (flag == -1) { PyErr_SetString(PyExc_ValueError, "Rasterizer.getGLSLMaterialSetting(string): glsl setting is not known"); return NULL; } diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 5183f77176c..9c109168b18 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -35,13 +35,13 @@ #include "PHY_IPhysicsEnvironment.h" /** -* DummyPhysicsEnvironment is an empty placeholder -* Alternatives are ODE,Sumo and Dynamo PhysicsEnvironments -* Use DummyPhysicsEnvironment as a base to integrate your own physics engine -* Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.) -* -* A derived class may be able to 'construct' entities by loading and/or converting -*/ + * DummyPhysicsEnvironment is an empty placeholder + * Alternatives are ODE,Sumo and Dynamo PhysicsEnvironments + * Use DummyPhysicsEnvironment as a base to integrate your own physics engine + * Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.) + * + * A derived class may be able to 'construct' entities by loading and/or converting + */ class DummyPhysicsEnvironment : public PHY_IPhysicsEnvironment { diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 0a1958e509a..43acb9e5f8a 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -323,23 +323,24 @@ void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas) { - RAS_Rect canvas_rect = canvas->GetWindowArea(); - canvaswidth = canvas->GetWidth(); - canvasheight = canvas->GetHeight(); - - texturewidth = canvaswidth + canvas_rect.GetLeft(); - textureheight = canvasheight + canvas_rect.GetBottom(); + /* RAS_Rect canvas_rect = canvas->GetWindowArea(); */ /* UNUSED */ + texturewidth = canvas->GetWidth(); + textureheight = canvas->GetHeight(); GLint i,j; - i = 0; - while ((1 << i) <= texturewidth) - i++; - texturewidth = (1 << (i)); - // Now for height - i = 0; - while ((1 << i) <= textureheight) - i++; - textureheight = (1 << (i)); + if (!GL_ARB_texture_non_power_of_two) + { + i = 0; + while ((1 << i) <= texturewidth) + i++; + texturewidth = (1 << (i)); + + // Now for height + i = 0; + while ((1 << i) <= textureheight) + i++; + textureheight = (1 << (i)); + } GLfloat xInc = 1.0f / (GLfloat)texturewidth; GLfloat yInc = 1.0f / (GLfloat)textureheight; @@ -400,6 +401,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) GLuint viewport[4]={0}; glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); + RAS_Rect rect = canvas->GetWindowArea(); if (canvaswidth != canvas->GetWidth() || canvasheight != canvas->GetHeight()) { @@ -417,19 +419,19 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) if (need_depth) { glActiveTextureARB(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texname[1]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0, 0, texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, rect.GetLeft(), rect.GetBottom(), rect.GetWidth(), rect.GetHeight(), 0); } if (need_luminance) { glActiveTextureARB(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, texname[2]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0, 0, texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, rect.GetLeft(), rect.GetBottom(), rect.GetWidth(), rect.GetHeight(), 0); } // reverting to texunit 0, without this we get bug [#28462] glActiveTextureARB(GL_TEXTURE0); - glViewport(0,0, texturewidth, textureheight); + glViewport(rect.GetLeft(), rect.GetBottom(), texturewidth, textureheight); glDisable(GL_DEPTH_TEST); // in case the previous material was wire @@ -452,7 +454,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glActiveTextureARB(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texname[0]); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, texturewidth, textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, rect.GetLeft(), rect.GetBottom(), rect.GetWidth(), rect.GetHeight(), 0); // Don't use texturewidth and textureheight in case we don't have NPOT support glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_QUADS); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index ff24bd639ba..a36229c35d1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -42,7 +42,7 @@ RAS_VAOpenGLRasterizer::RAS_VAOpenGLRasterizer(RAS_ICanvas* canvas, bool lock) : RAS_OpenGLRasterizer(canvas), - m_Lock(lock && GLEW_EXT_compiled_vertex_array), + /* m_Lock(lock && GLEW_EXT_compiled_vertex_array), */ /* UNUSED */ m_last_texco_num(0), m_last_attrib_num(0) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index 730431d3108..deda1c4603a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -37,7 +37,7 @@ class RAS_VAOpenGLRasterizer : public RAS_OpenGLRasterizer { void TexCoordPtr(const RAS_TexVert *tv); - bool m_Lock; + /* bool m_Lock; */ /* UNUSED */ TexCoGen m_last_texco[RAS_MAX_TEXCO]; TexCoGen m_last_attrib[RAS_MAX_ATTRIB]; diff --git a/source/gameengine/SceneGraph/SG_Tree.h b/source/gameengine/SceneGraph/SG_Tree.h index e0d5c712b73..339862c652f 100644 --- a/source/gameengine/SceneGraph/SG_Tree.h +++ b/source/gameengine/SceneGraph/SG_Tree.h @@ -122,7 +122,7 @@ public: /** * SG_TreeFactory generates an SG_Tree from a list of SG_Nodes. - * It joins pairs of SG_Nodes to minimise the size of the resultant + * It joins pairs of SG_Nodes to minimize the size of the resultant * bounding box. * cf building an optimized Huffman tree. * \warning O(n^3)!!! |