diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-03 04:02:45 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-03 04:02:45 +0400 |
commit | 98a7ca61fa905792bd3fdfa6c29f44691c9582ac (patch) | |
tree | 47455f2482f6eca0352c10c57482641eec6afb57 /source/blender | |
parent | 4e39a854b4589cddff484649d95cce4c71d4e9f4 (diff) | |
parent | 2ed69a95f499081aacc15c0295f3461c38430554 (diff) |
Merged changes in the trunk up to revision 48505.
Diffstat (limited to 'source/blender')
548 files changed, 8180 insertions, 5866 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index e9bae71feec..1b9533bbd8c 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -96,12 +96,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) @@ -110,6 +108,11 @@ add_subdirectory(makesdna) add_subdirectory(makesrna) ADD_SUBDIRECTORY(freestyle) +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 f602c93a208..8fb160ba09a 100644 --- a/source/blender/SConscript +++ b/source/blender/SConscript @@ -8,12 +8,10 @@ SConscript(['avi/SConscript', 'blenlib/SConscript', 'blenloader/SConscript', 'gpu/SConscript', - 'opencl/SConscript', 'editors/SConscript', 'freestyle/SConscript', 'imbuf/SConscript', 'makesdna/SConscript', - 'compositor/SConscript', 'render/SConscript', 'nodes/SConscript', 'modifiers/SConscript', @@ -40,3 +38,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_blender.h b/source/blender/blenkernel/BKE_blender.h index 5fe28d2b254..171b62461a0 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -51,7 +51,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE alpha +#define BLENDER_VERSION_CYCLE beta extern char versionstr[]; /* from blender.c */ diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 593b4afb85c..2d30844af80 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -119,7 +119,8 @@ enum { G_DEBUG_FFMPEG = (1 << 1), G_DEBUG_PYTHON = (1 << 2), /* extra python info */ G_DEBUG_EVENTS = (1 << 3), /* input/window/screen events */ - G_DEBUG_WM = (1 << 4) /* operator, undo */ + G_DEBUG_WM = (1 << 4), /* operator, undo */ + G_DEBUG_JOBS = (1 << 5) /* jobs time profiling */ }; #define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM) diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index e2263a5edb7..699eb0a9f02 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -191,7 +191,7 @@ struct Image *BKE_image_copy(struct Image *ima); void BKE_image_merge(struct Image *dest, struct Image *source); /* scale the image */ -void BKE_image_scale(struct Image *image, int width, int height); +int BKE_image_scale(struct Image *image, int width, int height); /* check if texture has alpha (depth=32) */ int BKE_image_has_alpha(struct Image *image); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 887340622ad..abd0c4d96db 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -296,6 +296,7 @@ int BKE_mesh_validate_arrays( struct Mesh *me, struct MVert *mverts, unsigned int totvert, struct MEdge *medges, unsigned int totedge, + struct MFace *mfaces, unsigned int totface, struct MLoop *mloops, unsigned int totloop, struct MPoly *mpolys, unsigned int totpoly, struct MDeformVert *dverts, /* assume totvert length */ diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 1ff53291044..82a791348dd 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -47,6 +47,9 @@ struct Scene; /* Delete mesh mdisps and grid paint masks */ void multires_customdata_delete(struct Mesh *me); +void multires_set_tot_level(struct Object *ob, + struct MultiresModifierData *mmd, int lvl); + void multires_mark_as_modified(struct Object *ob, enum MultiresModifiedFlags flags); void multires_force_update(struct Object *ob); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 170638f0e8d..a0cfc4295ef 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1490,7 +1490,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } /* only counts visible particles */ - ++index; + index++; } /* restore objects since they were changed in BKE_object_where_is_calc_time */ diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 1bd650ef568..d99c36b6c91 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -325,8 +325,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM result = 1; } - else - { + else { // Apply repulse impulse if distance too short // I_r = -min(dt*kd, max(0, 1d/dt - v_n)) // DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index eb5e4e4f8b5..a6467af2773 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_group_types.h" /*GroupObject*/ @@ -46,6 +47,7 @@ #include "DNA_texture_types.h" #include "BKE_animsys.h" +#include "BKE_armature.h" #include "BKE_bvhutils.h" /* bvh tree */ #include "BKE_blender.h" #include "BKE_cdderivedmesh.h" @@ -528,11 +530,6 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram } } } - /* for curve following objects, parented curve has to be updated too */ - if (ob->type == OB_CURVE) { - Curve *cu = ob->data; - BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); - } /* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; @@ -547,6 +544,18 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram else BKE_object_where_is_calc_time(scene, ob, frame); + /* for curve following objects, parented curve has to be updated too */ + if (ob->type == OB_CURVE) { + Curve *cu = ob->data; + BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); + } + /* and armatures... */ + if (ob->type == OB_ARMATURE) { + bArmature *arm = ob->data; + BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM); + BKE_pose_where_is(scene, ob); + } + return 0; } @@ -734,7 +743,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) /* deactivate zero axises */ for (i = 0; i < 3; i++) { - if (td[i] < min_dim) {td[i] = 1.0f; axis -= 1; } + if (td[i] < min_dim) { td[i] = 1.0f; axis -= 1; } } if (axis == 0 || MAX3(td[0], td[1], td[2]) < 0.0001f) { @@ -2016,11 +2025,11 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh /* Dist to second edge */ t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[1]], tface[cPoint->face_index].uv[uindex[2]]); - if (t_dist < dist) {e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; } + if (t_dist < dist) { e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; } /* Dist to third edge */ t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[2]], tface[cPoint->face_index].uv[uindex[0]]); - if (t_dist < dist) {e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; } + if (t_dist < dist) { e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; } /* @@ -2284,7 +2293,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; - if ((u > 0) && (v > 0) && (u + v < 1)) {isInside = 1; } /* is inside a triangle */ + if ((u > 0) && (v > 0) && (u + v < 1)) { isInside = 1; } /* is inside a triangle */ /* If collision wasn't found but the face is a quad * do another check for the second half */ @@ -2304,7 +2313,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; - if ((u > 0) && (v > 0) && (u + v < 1)) {isInside = 2; } /* is inside the second half of the quad */ + if ((u > 0) && (v > 0) && (u + v < 1)) { isInside = 2; } /* is inside the second half of the quad */ } @@ -2583,7 +2592,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_IMF_IMTYPE_OPENEXR : R_IMF_IMTYPE_PNG; char output_file[FILE_MAX]; - if (!sData || !sData->type_data) {setError(surface->canvas, "Image save failed: Invalid surface."); return; } + if (!sData || !sData->type_data) { setError(surface->canvas, "Image save failed: Invalid surface."); return; } /* if selected format is openexr, but current build doesnt support one */ #ifndef WITH_OPENEXR if (format == R_IMF_IMTYPE_OPENEXR) format = R_IMF_IMTYPE_PNG; @@ -2597,7 +2606,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam /* Init image buffer */ ibuf = IMB_allocImBuf(surface->image_resolution, surface->image_resolution, 32, IB_rectfloat); - if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory."); return; } + if (ibuf == NULL) { setError(surface->canvas, "Image save failed: Not enough free memory."); return; } #pragma omp parallel for schedule(static) for (index = 0; index < sData->total_points; index++) { @@ -3287,7 +3296,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, int v1 = mface[hit.index].v1, v2 = mface[hit.index].v2, v3 = mface[hit.index].v3, quad = (hit.no[0] == 1.0f); float dot; - if (quad) {v2 = mface[hit.index].v3; v3 = mface[hit.index].v4; } + if (quad) { v2 = mface[hit.index].v3; v3 = mface[hit.index].v4; } normal_tri_v3(hit.no, mvert[v1].co, mvert[v2].co, mvert[v3].co); dot = ray_dir[0] * hit.no[0] + ray_dir[1] * hit.no[1] + ray_dir[2] * hit.no[2]; @@ -3580,7 +3589,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, /* for debug purposes check if any NAN particle proceeds * For some reason they get past activity check, this should rule most of them out */ - if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) {invalidParticles++; continue; } + if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) { invalidParticles++; continue; } /* make sure particle is close enough to canvas */ if (!boundIntersectPoint(&grid->grid_bounds, pa->state.co, range)) continue; @@ -3953,7 +3962,7 @@ void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, floa int n_index = sData->adj_data->n_index[index] + i; float dir_dot = dot_v3v3(bNeighs[n_index].dir, force); - if (dir_dot > closest_d[0] && dir_dot > 0.0f) {closest_d[0] = dir_dot; closest_id[0] = n_index; } + if (dir_dot > closest_d[0] && dir_dot > 0.0f) { closest_d[0] = dir_dot; closest_id[0] = n_index; } } if (closest_d[0] < 0.0f) return; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index b5254b97844..b32ac24084f 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -789,6 +789,12 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3); if (mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */ + /* generate intensity if texture only has rgb value */ + if (hasrgb & TEX_RGB) { + int i; + for (i=0; i<4; i++) + result[i].tin = (1.0f / 3.0f) * (result[i].tr + result[i].tg + result[i].tb); + } force[0] = (result[0].tin - result[1].tin) * strength; force[1] = (result[0].tin - result[2].tin) * strength; force[2] = (result[0].tin - result[3].tin) * strength; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index e20a74e713c..d072ffb72ec 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -811,7 +811,7 @@ void calchandles_fcurve(FCurve *fcu) if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0] = bezt->vec[1][0]; /* calculate auto-handles */ - BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ + BKE_nurb_handle_calc(bezt, prev, next, 1); /* (1 == special) autohandle */ /* for automatic ease in and out */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ea396b6d88c..beaf8f719e3 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -514,17 +514,21 @@ void BKE_image_merge(Image *dest, Image *source) } /* note, we could be clever and scale all imbuf's but since some are mipmaps its not so simple */ -void BKE_image_scale(Image *image, int width, int height) +int BKE_image_scale(Image *image, int width, int height) { ImBuf *ibuf; void *lock; ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); - IMB_scaleImBuf(ibuf, width, height); - ibuf->userflags |= IB_BITMAPDIRTY; + if (ibuf) { + IMB_scaleImBuf(ibuf, width, height); + ibuf->userflags |= IB_BITMAPDIRTY; + } BKE_image_release_ibuf(image, lock); + + return (ibuf != NULL); } Image *BKE_image_load(const char *filepath) @@ -2851,7 +2855,7 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath) if (ima->source == IMA_SRC_SEQUENCE) { char head[FILE_MAX], tail[FILE_MAX]; unsigned short numlen; - int frame = iuser->framenr; + int frame = iuser ? iuser->framenr : ima->lastframe; BLI_stringdec(filepath, head, tail, &numlen); BLI_stringenc(filepath, head, tail, numlen, frame); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index deb294a6738..bed70bbd780 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -771,7 +771,7 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k ofsp = ofs; - while (cp[0]) { /* cp[0]==amount */ + while (cp[0]) { /* (cp[0] == amount) */ switch (cp[1]) { case IPO_FLOAT: @@ -936,7 +936,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key ofsp = ofs; - while (cp[0]) { /* cp[0]==amount */ + while (cp[0]) { /* (cp[0] == amount) */ switch (cp[1]) { case IPO_FLOAT: diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 2fe6999c6e8..1cd2d159431 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1336,7 +1336,7 @@ void clear_id_newpoins(void) } } -#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 +#define LIBTAG(a) if (a && a->id.lib) { a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 static void lib_indirect_test_id(ID *id, Library *lib) { diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index d85722931a7..2767a67086b 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -64,7 +64,7 @@ static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoi if (spline->flag & MASK_SPLINE_CYCLIC) { return &points_array[0]; } - else { + else { return NULL; } } @@ -79,7 +79,7 @@ static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline, MaskSplinePoi if (spline->flag & MASK_SPLINE_CYCLIC) { return &points_array[spline->tot_point - 1]; } - else { + else { return NULL; } } @@ -94,7 +94,7 @@ static BezTriple *mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoin if (spline->flag & MASK_SPLINE_CYCLIC) { return &(points_array[0].bezt); } - else { + else { return NULL; } } diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 669ae4f198a..4528b748412 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -50,6 +50,16 @@ #define SELECT 1 +typedef union { + uint32_t verts[2]; + int64_t edval; +} EdgeUUID; + +typedef struct SortFace { + EdgeUUID es[4]; + unsigned int index; +} SortFace; + /* Used to detect polys (faces) using exactly the same vertices. */ /* Used to detect loops used by no (disjoint) or more than one (intersect) polys. */ typedef struct SortPoly { @@ -60,6 +70,84 @@ typedef struct SortPoly { int invalid; /* Poly index. */ } SortPoly; +static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint32_t v2) +{ + if (v1 < v2) { + verts[0] = v1; + verts[1] = v2; + } + else { + verts[0] = v2; + verts[1] = v1; + } +} + +static void edge_store_from_mface_quad(EdgeUUID es[4], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v4); + edge_store_assign(es[3].verts, mf->v4, mf->v1); +} + +static void edge_store_from_mface_tri(EdgeUUID es[4], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v1); + es[3].verts[0] = es[3].verts[1] = UINT_MAX; +} + +static int int64_cmp(const void *v1, const void *v2) +{ + const int64_t x1 = *(const int64_t *)v1; + const int64_t x2 = *(const int64_t *)v2; + + if (x1 > x2) { + return 1; + } + else if (x1 < x2) { + return -1; + } + + return 0; +} + +static int search_face_cmp(const void *v1, const void *v2) +{ + const SortFace *sfa = v1, *sfb = v2; + + if (sfa->es[0].edval > sfb->es[0].edval) { + return 1; + } + else if (sfa->es[0].edval < sfb->es[0].edval) { + return -1; + } + + else if (sfa->es[1].edval > sfb->es[1].edval) { + return 1; + } + else if (sfa->es[1].edval < sfb->es[1].edval) { + return -1; + } + + else if (sfa->es[2].edval > sfb->es[2].edval) { + return 1; + } + else if (sfa->es[2].edval < sfb->es[2].edval) { + return -1; + } + + else if (sfa->es[3].edval > sfb->es[3].edval) { + return 1; + } + else if (sfa->es[3].edval < sfb->es[3].edval) { + return -1; + } + + return 0; +} + /* TODO check there is not some standard define of this somewhere! */ static int int_cmp(const void *v1, const void *v2) { @@ -98,6 +186,7 @@ static int search_polyloop_cmp(const void *v1, const void *v2) int BKE_mesh_validate_arrays(Mesh *mesh, MVert *mverts, unsigned int totvert, MEdge *medges, unsigned int totedge, + MFace *mfaces, unsigned int totface, MLoop *mloops, unsigned int totloop, MPoly *mpolys, unsigned int totpoly, MDeformVert *dverts, /* assume totvert length */ @@ -117,10 +206,12 @@ int BKE_mesh_validate_arrays(Mesh *mesh, int *v; short do_edge_free = FALSE; + short do_face_free = FALSE; short do_polyloop_free = FALSE; /* This regroups loops and polys! */ short verts_fixed = FALSE; short vert_weights_fixed = FALSE; + int msel_fixed = FALSE; int do_edge_recalc = FALSE; @@ -193,6 +284,143 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } + if (mfaces && !mpolys) { +# define REMOVE_FACE_TAG(_mf) { _mf->v3 = 0; do_face_free = TRUE; } (void)0 +# define CHECK_FACE_VERT_INDEX(a, b) \ + if (mf->a == mf->b) { \ + PRINT(" face %u: verts invalid, " STRINGIFY(a) "/" STRINGIFY(b) " both %u\n", i, mf->a); \ + remove = do_fixes; \ + } (void)0 +# define CHECK_FACE_EDGE(a, b) \ + if (!BLI_edgehash_haskey(edge_hash, mf->a, mf->b)) { \ + PRINT(" face %u: edge " STRINGIFY(a) "/" STRINGIFY(b) \ + " (%u,%u) is missing egde data\n", i, mf->a, mf->b); \ + do_edge_recalc = TRUE; \ + } + + MFace *mf; + MFace *mf_prev; + + SortFace *sort_faces = MEM_callocN(sizeof(SortFace) * totface, "search faces"); + SortFace *sf; + SortFace *sf_prev; + unsigned int totsortface = 0; + + for (i = 0, mf = mfaces, sf = sort_faces; i < totface; i++, mf++) { + int remove = FALSE; + int fidx; + unsigned int fv[4]; + + fidx = mf->v4 ? 3 : 2; + do { + fv[fidx] = *(&(mf->v1) + fidx); + if (fv[fidx] >= totvert) { + PRINT(" face %u: 'v%d' index out of range, %u\n", i, fidx + 1, fv[fidx]); + remove = do_fixes; + } + } while (fidx--); + + if (remove == FALSE) { + if (mf->v4) { + CHECK_FACE_VERT_INDEX(v1, v2); + CHECK_FACE_VERT_INDEX(v1, v3); + CHECK_FACE_VERT_INDEX(v1, v4); + + CHECK_FACE_VERT_INDEX(v2, v3); + CHECK_FACE_VERT_INDEX(v2, v4); + + CHECK_FACE_VERT_INDEX(v3, v4); + } + else { + CHECK_FACE_VERT_INDEX(v1, v2); + CHECK_FACE_VERT_INDEX(v1, v3); + + CHECK_FACE_VERT_INDEX(v2, v3); + } + + if (remove == FALSE) { + if (totedge) { + if (mf->v4) { + CHECK_FACE_EDGE(v1, v2); + CHECK_FACE_EDGE(v2, v3); + CHECK_FACE_EDGE(v3, v4); + CHECK_FACE_EDGE(v4, v1); + } + else { + CHECK_FACE_EDGE(v1, v2); + CHECK_FACE_EDGE(v2, v3); + CHECK_FACE_EDGE(v3, v1); + } + } + + sf->index = i; + + if (mf->v4) { + edge_store_from_mface_quad(sf->es, mf); + + qsort(sf->es, 4, sizeof(int64_t), int64_cmp); + } + else { + edge_store_from_mface_tri(sf->es, mf); + qsort(sf->es, 3, sizeof(int64_t), int64_cmp); + } + + totsortface++; + sf++; + } + } + + if (remove) { + REMOVE_FACE_TAG(mf); + } + } + + qsort(sort_faces, totsortface, sizeof(SortFace), search_face_cmp); + + sf = sort_faces; + sf_prev = sf; + sf++; + + for (i = 1; i < totsortface; i++, sf++) { + int remove = FALSE; + + /* on a valid mesh, code below will never run */ + if (memcmp(sf->es, sf_prev->es, sizeof(sf_prev->es)) == 0) { + mf = mfaces + sf->index; + + if (do_verbose) { + mf_prev = mfaces + sf_prev->index; + + if (mf->v4) { + PRINT(" face %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)\n", + sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4, + mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); + } + else { + PRINT(" face %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)\n", + sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, + mf_prev->v1, mf_prev->v2, mf_prev->v3); + } + } + + remove = do_fixes; + } + else { + sf_prev = sf; + } + + if (remove) { + REMOVE_FACE_TAG(mf); + } + } + + MEM_freeN(sort_faces); + +# undef REMOVE_FACE_TAG +# undef CHECK_FACE_VERT_INDEX +# undef CHECK_FACE_EDGE + } + /* Checking loops and polys is a bit tricky, as they are quite intricated... * * Polys must have: @@ -527,14 +755,16 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - PRINT("BKE_mesh_validate: finished\n\n"); - # undef REMOVE_EDGE_TAG # undef IS_REMOVED_EDGE # undef REMOVE_LOOP_TAG # undef REMOVE_POLY_TAG if (mesh) { + if (do_face_free) { + BKE_mesh_strip_loose_faces(mesh); + } + if (do_polyloop_free) { BKE_mesh_strip_loose_polysloops(mesh); } @@ -548,7 +778,51 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc); + if (mesh && mesh->mselect) { + MSelect *msel; + int free_msel = FALSE; + + for (i = 0, msel = mesh->mselect; i < mesh->totselect; i++, msel++) { + int tot_elem; + + if (msel->index < 0) { + PRINT("Mesh select element %d type %d index is negative, " + "resetting selection stack.\n", i, msel->type); + free_msel = TRUE; + break; + } + + switch (msel->type) { + case ME_VSEL: + tot_elem = mesh->totvert; + break; + case ME_ESEL: + tot_elem = mesh->totedge; + break; + case ME_FSEL: + tot_elem = mesh->totface; + break; + } + + if (msel->index > tot_elem) { + PRINT("Mesh select element %d type %d index %d is larger than data array size %d, " + "resetting selection stack.\n", i, msel->type, msel->index, tot_elem); + + free_msel = TRUE; + break; + } + } + + if (free_msel) { + MEM_freeN(mesh->mselect); + mesh->mselect = NULL; + mesh->totselect = 0; + } + } + + PRINT("BKE_mesh_validate: finished\n\n"); + + return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc || msel_fixed); } static int mesh_validate_customdata(CustomData *data, short do_verbose, const short do_fixes) @@ -605,6 +879,7 @@ int BKE_mesh_validate(Mesh *me, int do_verbose) arrays_fixed = BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, + me->mface, me->totface, me->mloop, me->totloop, me->mpoly, me->totpoly, me->dvert, @@ -622,6 +897,7 @@ int BKE_mesh_validate_dm(DerivedMesh *dm) return BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), + dm->getTessFaceArray(dm), dm->getNumTessFaces(dm), dm->getLoopArray(dm), dm->getNumLoops(dm), dm->getPolyArray(dm), dm->getNumPolys(dm), dm->getVertDataArray(dm, CD_MDEFORMVERT), diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 99bb3468320..72c3cda9272 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -72,8 +72,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm) BM_data_layer_add(bm, &bm->edata, CD_BWEIGHT); BM_data_layer_add(bm, &bm->vdata, CD_BWEIGHT); - vtable = MEM_callocN(sizeof(void**) * totvert, "vert table in BMDM_Copy"); - etable = MEM_callocN(sizeof(void**) * totedge, "edge table in BMDM_Copy"); + vtable = MEM_callocN(sizeof(void **) * totvert, "vert table in BMDM_Copy"); + etable = MEM_callocN(sizeof(void **) * totedge, "edge table in BMDM_Copy"); /*do verts*/ mv = mvert = dm->dupVertArray(dm); diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 44169cd3d6a..54e93f58307 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1067,6 +1067,9 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); + scopes->marker = marker; + scopes->track = track; + if (marker->flag & MARKER_DISABLED) { scopes->track_disabled = TRUE; } @@ -1074,8 +1077,6 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user); scopes->track_disabled = FALSE; - scopes->marker = marker; - scopes->track = track; if (ibuf && (ibuf->rect || ibuf->rect_float)) { ImBuf *search_ibuf; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index cb6f6823f48..2bc5c37b41b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -347,7 +347,7 @@ static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl) : mmd->lvl; } -static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) +void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) { mmd->totlvl = lvl; @@ -2105,6 +2105,8 @@ void multires_load_old(Object *ob, Mesh *me) me->mr = NULL; } +/* If 'ob' and 'to_ob' both have multires modifiers, syncronize them + * such that 'ob' has the same total number of levels as 'to_ob'. */ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) { MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1); @@ -2119,10 +2121,12 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) multires_customdata_delete(ob->data); } - if (!mmd || !to_mmd) return; - - if (mmd->totlvl > to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); - else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); + if (mmd && to_mmd) { + if (mmd->totlvl > to_mmd->totlvl) + multires_del_higher(mmd, ob, to_mmd->totlvl); + else + multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); + } } static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9537a31838c..a1fe1f7b8a9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3752,7 +3752,7 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co } #define SET_PARTICLE_TEXTURE(type, pvalue, texfac) \ - if ((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } (void)0 + if ((event & mtex->mapto) & type) { pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } (void)0 #define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) \ if (event & type) { if (pvalue < 0.0f) pvalue = 1.0f + pvalue; CLAMP(pvalue, 0.0f, 1.0f); } (void)0 diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 8cb47118e7d..78ccdc425e5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1220,7 +1220,11 @@ static void seq_open_anim_file(Sequence *seq) } if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) { - IMB_anim_set_index_dir(seq->anim, seq->strip->proxy->dir); + char dir[FILE_MAX]; + BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); + BLI_path_abs(dir, G.main->name); + + IMB_anim_set_index_dir(seq->anim, dir); } } @@ -2089,7 +2093,7 @@ static ImBuf *seq_render_mask_strip( fp_src = maskbuf; fp_dst = ibuf->rect_float; i = context.rectx * context.recty; - while(--i) { + while (--i) { fp_dst[0] = fp_dst[1] = fp_dst[2] = *fp_src; fp_dst[3] = 1.0f; @@ -2115,7 +2119,7 @@ static ImBuf *seq_render_mask_strip( fp_src = maskbuf; ub_dst = (unsigned char *)ibuf->rect; i = context.rectx * context.recty; - while(--i) { + while (--i) { ub_dst[0] = ub_dst[1] = ub_dst[2] = (unsigned char)(*fp_src * 255.0f); /* already clamped */ ub_dst[3] = 255; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index a5c04387b68..3dea8a85915 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2551,7 +2551,8 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in if ((marker->flag & MARKER_DISABLED) == 0) { libmv_tracksInsert(tracks, marker->framenr, tracknr, - marker->pos[0] * width, marker->pos[1] * height); + (marker->pos[0] + track->offset[0]) * width, + (marker->pos[1] + track->offset[1]) * height); } } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index aa9cc40f71f..1180d2c72d5 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -125,7 +125,7 @@ static struct bUnitDef buMetricLenDef[] = { #endif {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialLenDef[] = { {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -137,7 +137,7 @@ static struct bUnitDef buImperialLenDef[] = { {"thou", "thou", "thou", "mil", "Thou", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef) / sizeof(bUnitDef)}; /* Areas */ static struct bUnitDef buMetricAreaDef[] = { @@ -151,7 +151,7 @@ static struct bUnitDef buMetricAreaDef[] = { {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAreaDef[] = { {"square mile", "square miles", "sq mi", "sq m","Square Miles", UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -163,7 +163,7 @@ static struct bUnitDef buImperialAreaDef[] = { {"square thou", "square thous", "sq mil",NULL, "Square Thous", UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef) / sizeof(bUnitDef)}; /* Volumes */ static struct bUnitDef buMetricVolDef[] = { @@ -177,7 +177,7 @@ static struct bUnitDef buMetricVolDef[] = { {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM*UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVolDef[] = { {"cubic mile", "cubic miles", "cu mi", "cu m","Cubic Miles", UN_SC_MI*UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -189,7 +189,7 @@ static struct bUnitDef buImperialVolDef[] = { {"cubic thou", "cubic thous", "cu mil",NULL, "Cubic Thous", UN_SC_MIL*UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef) / sizeof(bUnitDef)}; /* Mass */ static struct bUnitDef buMetricMassDef[] = { @@ -201,7 +201,7 @@ static struct bUnitDef buMetricMassDef[] = { {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialMassDef[] = { {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, @@ -211,7 +211,7 @@ static struct bUnitDef buImperialMassDef[] = { {"ounce", "ounces", "oz", NULL, "Ounces", UN_SC_OZ, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef) / sizeof(bUnitDef)}; /* Even if user scales the system to a point where km^3 is used, velocity and * acceleration aren't scaled: that's why we have so few units for them */ @@ -222,27 +222,27 @@ static struct bUnitDef buMetricVelDef[] = { {"kilometer per hour", "kilometers per hour", "km/h", NULL, "Kilometers per hour", UN_SC_KM/3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVelDef[] = { {"foot per second", "feet per second", "ft/s", "fps", "Feet per second", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"mile per hour", "miles per hour", "mph", NULL, "Miles per hour", UN_SC_MI/3600.0f, 0.0,B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef) / sizeof(bUnitDef)}; /* Acceleration */ static struct bUnitDef buMetricAclDef[] = { {"meter per second squared", "meters per second squared", "m/s²", "m/s2", "Meters per second squared", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAclDef[] = { {"foot per second squared", "feet per second squared", "ft/s²", "ft/s2", "Feet per second squared", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef) / sizeof(bUnitDef)}; /* Time */ static struct bUnitDef buNaturalTimeDef[] = { @@ -255,7 +255,7 @@ static struct bUnitDef buNaturalTimeDef[] = { {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)}; static struct bUnitDef buNaturalRotDef[] = { @@ -264,7 +264,7 @@ static struct bUnitDef buNaturalRotDef[] = { // {"turn", "turns", "t", NULL, "Turns", 1.0/(M_PI*2.0), 0.0,B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef) / sizeof(bUnitDef)}; #define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1) static struct bUnitCollection *bUnitSystems[][9] = { diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index b3101638a4e..f72942df8b3 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -924,7 +924,7 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd) fe++; } - if (!*fe) { + if (*fe == NULL) { strcat(string, autosplit); BLI_path_frame_range(string, rd->sfra, rd->efra, 4); diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index 4fbed23d5e6..18258014529 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -25,7 +25,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* +/** \file BLI_array.h + * \ingroup bli + * \brief A macro array library. + * * this library needs to be changed to not use macros quite so heavily, * and to be more of a complete array API. The way arrays are * exposed to client code as normal C arrays is very useful though, imho. @@ -118,7 +121,7 @@ /* grow an array by a specified number of items */ #define BLI_array_grow_items(arr, num) ( \ ((void *)(arr) == NULL && (void *)(_##arr##_static) != NULL) ? \ - ((arr = (void *)_##arr##_static), (_##arr##_count += num)) : \ + ((arr = (void *)_##arr##_static), (_##arr##_count += num)) : \ _bli_array_grow_items(arr, num) \ ) @@ -184,6 +187,5 @@ MEM_mallocN(sizeof(*(arr)) * (realsize), allocstr) \ ) \ -#define BLI_array_fixedstack_free(arr) \ - if (_##arr##_is_static) MEM_freeN(arr) \ - +#define BLI_array_fixedstack_free(arr) \ + if (_##arr##_is_static) MEM_freeN(arr) 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/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index be492fb6fdd..8499a7f219c 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -191,6 +191,7 @@ float angle_v2v2v2(const float a[2], const float b[2], const float c[2]); float angle_normalized_v2v2(const float a[2], const float b[2]); float angle_v3v3(const float a[3], const float b[3]); float angle_v3v3v3(const float a[3], const float b[3], const float c[3]); +float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]); float angle_normalized_v3v3(const float v1[3], const float v2[3]); float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]); void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]); 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 23d70bd148b..58ee898ea28 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -222,8 +222,16 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack) r_col[2] = ((pack) >> 16) & 0xFF; } -/* XXX - investigate when/why rgb_to_bw & rgb_to_grayscale are different, - * and why we use both! whats the purpose of this? */ +/* TODO: + * + * regarding #rgb_to_bw vs #rgb_to_grayscale, + * it seems nobody knows why we have both functions which convert color to greys + * 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 + * + * Only conclusion is that rgb_to_grayscale is used more for compositing. + */ MINLINE float rgb_to_bw(const float rgb[3]) { return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2]; 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/math_vector.c b/source/blender/blenlib/intern/math_vector.c index d939576904e..5cda1c0b81f 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -136,6 +136,19 @@ float angle_v3v3v3(const float v1[3], const float v2[3], const float v3[3]) return angle_normalized_v3v3(vec1, vec2); } +/* Quicker than full angle computation */ +float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]) +{ + float vec1[3], vec2[3]; + + sub_v3_v3v3(vec1, p2, p1); + sub_v3_v3v3(vec2, p2, p3); + normalize_v3(vec1); + normalize_v3(vec2); + + return dot_v3v3(vec1, vec2); +} + /* Return the shortest angle in radians between the 2 vectors */ float angle_v3v3(const float v1[3], const float v2[3]) { 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 727e42dc8de..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 */ @@ -790,16 +790,15 @@ void BLI_voronoi_triangulate(const VoronoiSite *sites, int sites_total, ListBase int ok_start = TRUE, ok_end = TRUE; while (test_edge) { - float v1[2], v2[2]; - - sub_v2_v2v2(v1, edge->start, sites[i].co); - sub_v2_v2v2(v2, edge->end, sites[i].co); - - if (ok_start && !testVoronoiEdge(sites[i].co, edge->start, test_edge)) + if (ok_start && !testVoronoiEdge(sites[i].co, edge->start, test_edge)) { ok_start = FALSE; + break; + } - if (ok_end && !testVoronoiEdge(sites[i].co, edge->end, test_edge)) + if (ok_end && !testVoronoiEdge(sites[i].co, edge->end, test_edge)) { ok_end = FALSE; + break; + } test_edge = test_edge->next; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a45e517d6c3..d8b2ce8680b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -160,52 +160,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 */ @@ -4427,7 +4427,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); @@ -4437,7 +4437,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; @@ -5510,7 +5510,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; } @@ -5520,7 +5520,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; @@ -5923,11 +5923,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; @@ -7610,7 +7619,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 332a00f9440..d40e216be1e 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1381,14 +1381,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..931937263e4 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,7 +1034,7 @@ 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 */ @@ -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 72eb4cb89e9..094b5af9a00 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -642,7 +642,7 @@ static int bm_face_goodline(float const (*projectverts)[3], BMFace *f, //if (linecrossesf(pv1, pv2, v1, v3)) return FALSE; if (isect_point_tri_v2(pv1, v1, v2, v3) || - isect_point_tri_v2(pv1, v3, v2, v1)) + isect_point_tri_v2(pv2, v3, v2, v1)) { return FALSE; } @@ -658,18 +658,22 @@ static int bm_face_goodline(float const (*projectverts)[3], BMFace *f, * of a polygon while tessellating. * * \param use_beauty Currently only applies to quads, can be extended later on. + * \param abscoss Must be allocated by caller, and at least f->len length + * (allow to avoid allocating a new one for each tri!). */ -static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty) +static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty, float *abscoss) { BMLoop *bestear = NULL; BMLoop *l_iter; BMLoop *l_first; + const float cos_threshold = 0.9f; + if (f->len == 4) { BMLoop *larr[4]; - int i = 0; - + int i = 0, i4; + float cos1, cos2; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { larr[i] = l_iter; @@ -677,17 +681,64 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int } while ((l_iter = l_iter->next) != l_first); /* pick 0/1 based on best lenth */ - bestear = larr[(((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > - len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty)]; + /* XXX Can't only rely on such test, also must check we do not get (too much) degenerated triangles!!! */ + i = (((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > + len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty); + i4 = (i + 3) % 4; + /* Check produced tris aren’t too flat/narrow... + * Probably not the best test, but is quite efficient and should at least avoid null-area faces! */ + cos1 = fabsf(cos_v3v3v3(larr[i4]->v->co, larr[i]->v->co, larr[i + 1]->v->co)); + cos2 = fabsf(cos_v3v3v3(larr[i4]->v->co, larr[i + 2]->v->co, larr[i + 1]->v->co)); +#if 0 + printf("%d, (%f, %f), (%f, %f)\n", i, cos1, cos2, + fabsf(cos_v3v3v3(larr[i]->v->co, larr[i4]->v->co, larr[i + 2]->v->co)), + fabsf(cos_v3v3v3(larr[i]->v->co, larr[i + 1]->v->co, larr[i + 2]->v->co))); +#endif + if (cos1 < cos2) + cos1 = cos2; + 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]; } else { BMVert *v1, *v2, *v3; /* float angle, bestangle = 180.0f; */ - int isear /*, i = 0 */; + float cos, tcos, bestcos = 1.0f; + float *tcoss; + int isear, i = 0, j, len; + /* Compute cos of all corners! */ l_iter = l_first = BM_FACE_FIRST_LOOP(f); + len = l_iter->f->len; + tcoss = abscoss; + do { + v1 = l_iter->prev->v; + v2 = l_iter->v; + v3 = l_iter->next->v; + + *tcoss = fabsf(cos_v3v3v3(v1->co, v2->co, v3->co)); +/* printf("tcoss: %f\n", *tcoss);*/ + tcoss++; + } while ((l_iter = l_iter->next) != l_first); + + l_iter = l_first; + tcoss = abscoss; do { isear = TRUE; @@ -695,6 +746,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int v2 = l_iter->v; v3 = l_iter->next->v; + /* We may have already internal edges... */ if (BM_edge_exists(v1, v3)) { isear = FALSE; } @@ -706,7 +758,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int } if (isear) { - #if 0 +#if 0 /* Old, already commented code */ /* if this code comes back, it needs to be converted to radians */ angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]); if (!bestear || ABS(angle - 45.0f) < bestangle) { @@ -717,11 +769,46 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int if (angle > 20 && angle < 90) break; if (angle < 100 && i > 5) break; i += 1; - #endif +#endif - bestear = l_iter; - break; + /* Compute highest cos (i.e. narrowest angle) of this tri. */ + cos = *tcoss; + tcos = fabsf(cos_v3v3v3(v2->co, v3->co, v1->co)); + if (tcos > cos) + cos = tcos; + tcos = fabsf(cos_v3v3v3(v3->co, v1->co, v2->co)); + if (tcos > cos) + cos = tcos; + + /* Compare to prev best (i.e. lowest) cos. */ + if (cos < bestcos) { + /* We must check this tri would not leave a (too much) degenerated remaining face! */ + /* For now just assume if the average of cos of all "remaining face"'s corners is below a given threshold, it’s OK. */ + float avgcos = fabsf(cos_v3v3v3(v1->co, v3->co, l_iter->next->next->v->co)); + const int i_limit = (i - 1 + len) % len; + avgcos += fabsf(cos_v3v3v3(l_iter->prev->prev->v->co, v1->co, v3->co)); + j = (i + 2) % len; + do { + avgcos += abscoss[j]; + } while ((j = (j + 1) % len) != i_limit); + avgcos /= len - 1; + + /* We need a best ear in any case... */ + if (avgcos < cos_threshold || (!bestear && avgcos < 1.0f)) { + /* OKI, keep this ear (corner...) as a potential best one! */ + bestear = l_iter; + bestcos = cos; + } +#if 0 + else + printf("Had a nice tri (higest cos of %f, current bestcos is %f), " + "but average cos of all \"remaining face\"'s corners is too high (%f)!\n", + cos, bestcos, avgcos); +#endif + } } + tcoss++; + i++; } while ((l_iter = l_iter->next) != l_first); } @@ -731,14 +818,20 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int /** * \brief BMESH TRIANGULATE FACE * + * --- Prev description (wasn’t correct, ear clipping was currently simply picking the first tri in the loop!) * Triangulates a face using a simple 'ear clipping' algorithm that tries to * favor non-skinny triangles (angles less than 90 degrees). * * If the triangulator has bits left over (or cannot triangulate at all) * it uses a simple fan triangulation, + * --- End of prev description + * + * Currently tries to repeatedly find the best triangle (i.e. the most "open" one), provided it does not + * produces a "remaining" face with too much wide/narrow angles + * (using cos (i.e. dot product of normalized vectors) of angles). * * newfaces, if non-null, must be an array of BMFace pointers, - * with a length equal to f->len. it will be filled with the new + * with a length equal to f->len. It will be filled with the new * triangles, and will be NULL-terminated. * * \note newedgeflag sets a flag layer flag, obviously not the header flag. @@ -748,10 +841,11 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], const short use_beauty) { int i, done, nvert, nf_i = 0; - BMLoop *newl, *nextloop; + BMLoop *newl; BMLoop *l_iter; BMLoop *l_first; - /* BMVert *v; */ /* UNUSED */ + float *abscoss = NULL; + BLI_array_fixedstack_declare(abscoss, 16, f->len, "BM_face_triangulate: temp absolute cosines of face corners"); /* copy vertex coordinates to vertspace arra */ i = 0; @@ -764,14 +858,14 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], bm->elem_index_dirty |= BM_VERT; /* see above */ - ///bmesh_face_normal_update(bm, f, f->no, projectverts); + /* bmesh_face_normal_update(bm, f, f->no, projectverts); */ calc_poly_normal(f->no, projectverts, f->len); poly_rotate_plane(f->no, projectverts, i); nvert = f->len; - //calc_poly_plane(projectverts, i); + /* calc_poly_plane(projectverts, i); */ for (i = 0; i < nvert; i++) { projectverts[i][2] = 0.0f; } @@ -779,10 +873,10 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], done = FALSE; while (!done && f->len > 3) { done = TRUE; - l_iter = find_ear(f, projectverts, nvert, use_beauty); + l_iter = find_ear(f, projectverts, nvert, use_beauty, abscoss); if (l_iter) { done = FALSE; - /* v = l->v; */ /* UNUSED */ +/* printf("Subdividing face...\n");*/ f = BM_face_split(bm, l_iter->f, l_iter->prev->v, l_iter->next->v, &newl, NULL, TRUE); @@ -812,6 +906,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], } } +#if 0 /* XXX find_ear should now always return a corner, so no more need for this piece of code... */ if (f->len > 3) { l_iter = BM_FACE_FIRST_LOOP(f); while (l_iter->f->len > 3) { @@ -833,7 +928,10 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], l_iter = nextloop; } } - +#endif + + BLI_array_fixedstack_free(abscoss); + /* NULL-terminate */ if (newfaces) newfaces[nf_i] = NULL; } 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 b076d835ea1..f47781241e8 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; @@ -691,7 +691,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 */ @@ -896,7 +896,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 */ @@ -1010,7 +1010,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 */ @@ -1077,7 +1077,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 */ @@ -1117,7 +1117,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 */ @@ -1183,7 +1183,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 */ @@ -1227,7 +1227,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..653e11c80a7 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 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_ChannelInfo.cpp b/source/blender/compositor/intern/COM_ChannelInfo.cpp index f2fa62006d5..557075cdc80 100644 --- a/source/blender/compositor/intern/COM_ChannelInfo.cpp +++ b/source/blender/compositor/intern/COM_ChannelInfo.cpp @@ -29,7 +29,7 @@ */ ChannelInfo::ChannelInfo() { - this->number = 0; - this->premultiplied = true; - this->type = COM_CT_UNUSED; + this->m_number = 0; + this->m_premultiplied = true; + this->m_type = COM_CT_UNUSED; } diff --git a/source/blender/compositor/intern/COM_ChannelInfo.h b/source/blender/compositor/intern/COM_ChannelInfo.h index 399fdc62fa2..44664442359 100644 --- a/source/blender/compositor/intern/COM_ChannelInfo.h +++ b/source/blender/compositor/intern/COM_ChannelInfo.h @@ -61,23 +61,23 @@ private: /** * @brief the channel number, in the connection. [0-3] */ - int number; + int m_number; /** * @brief type of channel */ - ChannelType type; + ChannelType m_type; /** * @brieg Is this value in this channel premultiplied with its alpha * @note only valid if type = ColorComponent; */ - bool premultiplied; + bool m_premultiplied; // /** -// * Color space of this value. -// * only valid when type = ColorComponent; -// */ +// * Color space of this value. +// * only valid when type = ColorComponent; +// */ // string colorspacename; public: @@ -89,32 +89,32 @@ public: /** * @brief set the index of this channel in the SocketConnection */ - void setNumber(const int number) { this->number = number; } + void setNumber(const int number) { this->m_number = number; } /** * @brief get the index of this channel in the SocketConnection */ - const int getNumber() const { return this->number; } + const int getNumber() const { return this->m_number; } /** * @brief set the type of channel */ - void setType(const ChannelType type) { this->type = type; } + void setType(const ChannelType type) { this->m_type = type; } /** * @brief get the type of channel */ - const ChannelType getType() const { return this->type; } + const ChannelType getType() const { return this->m_type; } /** * @brief set the premultiplicatioin of this channel */ - void setPremultiplied(const bool premultiplied) { this->premultiplied = premultiplied; } + void setPremultiplied(const bool premultiplied) { this->m_premultiplied = premultiplied; } /** * @brief is this channel premultiplied */ - const bool isPremultiplied() const { return this->premultiplied; } + const bool isPremultiplied() const { return this->m_premultiplied; } }; diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp index 02c28a1997a..38a3350c263 100644 --- a/source/blender/compositor/intern/COM_ChunkOrder.cpp +++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp @@ -25,10 +25,10 @@ ChunkOrder::ChunkOrder() { - this->distance = 0.0; - this->number = 0; - this->x = 0; - this->y = 0; + this->m_distance = 0.0; + this->m_number = 0; + this->m_x = 0; + this->m_y = 0; } void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots) @@ -37,15 +37,15 @@ void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int nu double distance = MAXFLOAT; for (index = 0; index < numberOfHotspots; index++) { ChunkOrderHotspot *hotspot = hotspots[index]; - double ndistance = hotspot->determineDistance(this->x, this->y); + double ndistance = hotspot->determineDistance(this->m_x, this->m_y); if (ndistance < distance) { distance = ndistance; } } - this->distance = distance; + this->m_distance = distance; } bool operator<(const ChunkOrder& a, const ChunkOrder& b) { - return a.distance < b.distance; + return a.m_distance < b.m_distance; } diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h index f096ebeebfe..190ecb9c380 100644 --- a/source/blender/compositor/intern/COM_ChunkOrder.h +++ b/source/blender/compositor/intern/COM_ChunkOrder.h @@ -26,20 +26,20 @@ #include "COM_ChunkOrderHotspot.h" class ChunkOrder { private: - unsigned int number; - int x; - int y; - double distance; + unsigned int m_number; + int m_x; + int m_y; + double m_distance; public: ChunkOrder(); void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots); friend bool operator<(const ChunkOrder& a, const ChunkOrder& b); - void setChunkNumber(unsigned int chunknumber) { this->number = chunknumber; } - void setX(int x) { this->x = x; } - void setY(int y) { this->y = y; } - unsigned int getChunkNumber() { return this->number; } - double getDistance() { return this->distance; } + void setChunkNumber(unsigned int chunknumber) { this->m_number = chunknumber; } + void setX(int x) { this->m_x = x; } + void setY(int y) { this->m_y = y; } + unsigned int getChunkNumber() { return this->m_number; } + double getDistance() { return this->m_distance; } }; #endif diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp index 96568092b72..1e64e0b9ea0 100644 --- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp +++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp @@ -25,16 +25,16 @@ ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition) { - this->x = x; - this->y = y; - this->addition = addition; + this->m_x = x; + this->m_y = y; + this->m_addition = addition; } double ChunkOrderHotspot::determineDistance(int x, int y) { - int dx = x - this->x; - int dy = y - this->y; + int dx = x - this->m_x; + int dy = y - this->m_y; double result = sqrt((double)(dx * dx + dy * dy)); - result += (double)this->addition; + result += (double)this->m_addition; return result; } diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h index ceb5934a7df..b166a7af57f 100644 --- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h +++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h @@ -23,15 +23,24 @@ #ifndef _COM_ChunkOrderHotSpot_h_ #define _COM_ChunkOrderHotSpot_h_ +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class ChunkOrderHotspot { private: - int x; - int y; - float addition; + int m_x; + int m_y; + float m_addition; public: ChunkOrderHotspot(int x, int y, float addition); double determineDistance(int x, int y); + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index c3470f0a16e..56335630b80 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -26,16 +26,16 @@ CompositorContext::CompositorContext() { - this->rd = NULL; - this->quality = COM_QUALITY_HIGH; - this->hasActiveOpenCLDevices = false; - this->activegNode = NULL; + this->m_rd = NULL; + this->m_quality = COM_QUALITY_HIGH; + this->m_hasActiveOpenCLDevices = false; + this->m_activegNode = NULL; } const int CompositorContext::getFramenumber() const { - if (this->rd) { - return this->rd->cfra; + if (this->m_rd) { + return this->m_rd->cfra; } else { return -1; /* this should never happen */ @@ -44,8 +44,8 @@ const int CompositorContext::getFramenumber() const const int CompositorContext::isColorManaged() const { - if (this->rd) { - return this->rd->color_mgt_flag & R_COLOR_MANAGEMENT; + if (this->m_rd) { + return this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT; } else { return 0; /* this should never happen */ diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 81fd81b4117..49acda811f1 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -41,38 +41,38 @@ private: * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - bool rendering; + bool m_rendering; /** * @brief The quality of the composite. * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - CompositorQuality quality; + CompositorQuality m_quality; /** * @brief Reference to the render data that is being composited. * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - RenderData *rd; + RenderData *m_rd; /** * @brief reference to the bNodeTree * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - bNodeTree *bnodetree; + bNodeTree *m_bnodetree; /** * @brief activegNode the group node that is currently being edited. */ - bNode *activegNode; + bNode *m_activegNode; /** * @brief does this system have active opencl devices? */ - bool hasActiveOpenCLDevices; + bool m_hasActiveOpenCLDevices; public: /** @@ -83,56 +83,52 @@ public: /** * @brief set the rendering field of the context */ - void setRendering(bool rendering) { this->rendering = rendering; } + void setRendering(bool rendering) { this->m_rendering = rendering; } /** * @brief get the rendering field of the context */ - bool isRendering() const { return this->rendering; } + bool isRendering() const { return this->m_rendering; } /** * @brief set the scene of the context */ - void setRenderData(RenderData *rd) { this->rd = rd; } + void setRenderData(RenderData *rd) { this->m_rd = rd; } /** * @brief set the bnodetree of the context */ - void setbNodeTree(bNodeTree *bnodetree) { this->bnodetree = bnodetree; } + void setbNodeTree(bNodeTree *bnodetree) { this->m_bnodetree = bnodetree; } /** * @brief get the bnodetree of the context */ - const bNodeTree *getbNodeTree() const { return this->bnodetree; } + const bNodeTree *getbNodeTree() const { return this->m_bnodetree; } /** * @brief set the active groupnode of the context */ - void setActivegNode(bNode *gnode) { this->activegNode = gnode; } + void setActivegNode(bNode *gnode) { this->m_activegNode = gnode; } /** * @brief get the active groupnode of the context */ - const bNode *getActivegNode() const { return this->activegNode; } + const bNode *getActivegNode() const { return this->m_activegNode; } /** * @brief get the scene of the context */ - const RenderData *getRenderData() const { return this->rd; } + const RenderData *getRenderData() const { return this->m_rd; } /** * @brief set the quality */ - void setQuality(CompositorQuality quality) { - this->quality = quality; - } + void setQuality(CompositorQuality quality) { this->m_quality = quality; } /** * @brief get the quality */ - const CompositorQuality getQuality() const { - return quality; - } + const CompositorQuality getQuality() const { return this->m_quality; } /** * @brief get the current framenumber of the scene in this context @@ -142,16 +138,12 @@ public: /** * @brief has this system active openclDevices? */ - const bool getHasActiveOpenCLDevices() const { - return this->hasActiveOpenCLDevices; - } + const bool getHasActiveOpenCLDevices() const { return this->m_hasActiveOpenCLDevices; } /** * @brief set has this system active openclDevices? */ - void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) { - this->hasActiveOpenCLDevices = hasAvtiveOpenCLDevices; - } + void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) { this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices; } int getChunksize() { return this->getbNodeTree()->chunksize; } diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 0a8862e4017..38c514d8e99 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -117,253 +117,253 @@ #include "COM_ViewerNode.h" #include "COM_ZCombineNode.h" -Node *Converter::convert(bNode *bNode) +Node *Converter::convert(bNode *b_node) { Node *node; - if (bNode->flag & NODE_MUTED) { - node = new MuteNode(bNode); + if (b_node->flag & NODE_MUTED) { + node = new MuteNode(b_node); return node; } - switch (bNode->type) { + switch (b_node->type) { case CMP_NODE_COMPOSITE: - node = new CompositorNode(bNode); + node = new CompositorNode(b_node); break; case CMP_NODE_R_LAYERS: - node = new RenderLayersNode(bNode); + node = new RenderLayersNode(b_node); break; case CMP_NODE_TEXTURE: - node = new TextureNode(bNode); + node = new TextureNode(b_node); break; case CMP_NODE_RGBTOBW: - node = new ColourToBWNode(bNode); + node = new ColourToBWNode(b_node); break; case CMP_NODE_MIX_RGB: - node = new MixNode(bNode); + node = new MixNode(b_node); break; case CMP_NODE_TRANSLATE: - node = new TranslateNode(bNode); + node = new TranslateNode(b_node); break; case CMP_NODE_SCALE: - node = new ScaleNode(bNode); + node = new ScaleNode(b_node); break; case CMP_NODE_ROTATE: - node = new RotateNode(bNode); + node = new RotateNode(b_node); break; case CMP_NODE_FLIP: - node = new FlipNode(bNode); + node = new FlipNode(b_node); break; case CMP_NODE_FILTER: - node = new FilterNode(bNode); + node = new FilterNode(b_node); break; case CMP_NODE_ID_MASK: - node = new IDMaskNode(bNode); + node = new IDMaskNode(b_node); break; case CMP_NODE_BRIGHTCONTRAST: - node = new BrightnessNode(bNode); + node = new BrightnessNode(b_node); break; case CMP_NODE_SEPRGBA: - node = new SeparateRGBANode(bNode); + node = new SeparateRGBANode(b_node); break; case CMP_NODE_COMBRGBA: - node = new CombineRGBANode(bNode); + node = new CombineRGBANode(b_node); break; case CMP_NODE_SEPHSVA: - node = new SeparateHSVANode(bNode); + node = new SeparateHSVANode(b_node); break; case CMP_NODE_COMBHSVA: - node = new CombineHSVANode(bNode); + node = new CombineHSVANode(b_node); break; case CMP_NODE_SEPYUVA: - node = new SeparateYUVANode(bNode); + node = new SeparateYUVANode(b_node); break; case CMP_NODE_COMBYUVA: - node = new CombineYUVANode(bNode); + node = new CombineYUVANode(b_node); break; case CMP_NODE_SEPYCCA: - node = new SeparateYCCANode(bNode); + node = new SeparateYCCANode(b_node); break; case CMP_NODE_COMBYCCA: - node = new CombineYCCANode(bNode); + node = new CombineYCCANode(b_node); break; case CMP_NODE_ALPHAOVER: - node = new AlphaOverNode(bNode); + node = new AlphaOverNode(b_node); break; case CMP_NODE_COLORBALANCE: - node = new ColorBalanceNode(bNode); + node = new ColorBalanceNode(b_node); break; case CMP_NODE_VIEWER: - node = new ViewerNode(bNode); + node = new ViewerNode(b_node); break; case CMP_NODE_SPLITVIEWER: - node = new SplitViewerNode(bNode); + node = new SplitViewerNode(b_node); break; case CMP_NODE_INVERT: - node = new InvertNode(bNode); + node = new InvertNode(b_node); break; case NODE_GROUP: - node = new GroupNode(bNode); + node = new GroupNode(b_node); break; case CMP_NODE_NORMAL: - node = new NormalNode(bNode); + node = new NormalNode(b_node); break; case CMP_NODE_NORMALIZE: - node = new NormalizeNode(bNode); + node = new NormalizeNode(b_node); break; case CMP_NODE_IMAGE: - node = new ImageNode(bNode); + node = new ImageNode(b_node); break; case CMP_NODE_SETALPHA: - node = new SetAlphaNode(bNode); + node = new SetAlphaNode(b_node); break; case CMP_NODE_PREMULKEY: - node = new ConvertAlphaNode(bNode); + node = new ConvertAlphaNode(b_node); break; case CMP_NODE_MATH: - node = new MathNode(bNode); + node = new MathNode(b_node); break; case CMP_NODE_HUE_SAT: - node = new HueSaturationValueNode(bNode); + node = new HueSaturationValueNode(b_node); break; case CMP_NODE_COLORCORRECTION: - node = new ColorCorrectionNode(bNode); + node = new ColorCorrectionNode(b_node); break; case CMP_NODE_MASK_BOX: - node = new BoxMaskNode(bNode); + node = new BoxMaskNode(b_node); break; case CMP_NODE_MASK_ELLIPSE: - node = new EllipseMaskNode(bNode); + node = new EllipseMaskNode(b_node); break; case CMP_NODE_GAMMA: - node = new GammaNode(bNode); + node = new GammaNode(b_node); break; case CMP_NODE_CURVE_RGB: - node = new ColorCurveNode(bNode); + node = new ColorCurveNode(b_node); break; case CMP_NODE_CURVE_VEC: - node = new VectorCurveNode(bNode); + node = new VectorCurveNode(b_node); break; case CMP_NODE_HUECORRECT: - node = new HueSaturationValueCorrectNode(bNode); + node = new HueSaturationValueCorrectNode(b_node); break; case CMP_NODE_MAP_UV: - node = new MapUVNode(bNode); + node = new MapUVNode(b_node); break; case CMP_NODE_DISPLACE: - node = new DisplaceNode(bNode); + node = new DisplaceNode(b_node); break; case CMP_NODE_VALTORGB: - node = new ColorRampNode(bNode); + node = new ColorRampNode(b_node); break; case CMP_NODE_DIFF_MATTE: - node = new DifferenceMatteNode(bNode); + node = new DifferenceMatteNode(b_node); break; case CMP_NODE_LUMA_MATTE: - node = new LuminanceMatteNode(bNode); + node = new LuminanceMatteNode(b_node); break; case CMP_NODE_DIST_MATTE: - node = new DistanceMatteNode(bNode); + node = new DistanceMatteNode(b_node); break; case CMP_NODE_CHROMA_MATTE: - node = new ChromaMatteNode(bNode); + node = new ChromaMatteNode(b_node); break; case CMP_NODE_COLOR_MATTE: - node = new ColorMatteNode(bNode); + node = new ColorMatteNode(b_node); break; case CMP_NODE_CHANNEL_MATTE: - node = new ChannelMatteNode(bNode); + node = new ChannelMatteNode(b_node); break; case CMP_NODE_BLUR: - node = new BlurNode(bNode); + node = new BlurNode(b_node); break; case CMP_NODE_BOKEHIMAGE: - node = new BokehImageNode(bNode); + node = new BokehImageNode(b_node); break; case CMP_NODE_BOKEHBLUR: - node = new BokehBlurNode(bNode); + node = new BokehBlurNode(b_node); break; case CMP_NODE_DILATEERODE: - node = new DilateErodeNode(bNode); + node = new DilateErodeNode(b_node); break; case CMP_NODE_LENSDIST: - node = new LensDistortionNode(bNode); + node = new LensDistortionNode(b_node); break; case CMP_NODE_RGB: - node = new ColorNode(bNode); + node = new ColorNode(b_node); break; case CMP_NODE_VALUE: - node = new ValueNode(bNode); + node = new ValueNode(b_node); break; case CMP_NODE_TIME: - node = new TimeNode(bNode); + node = new TimeNode(b_node); break; case CMP_NODE_DBLUR: - node = new DirectionalBlurNode(bNode); + node = new DirectionalBlurNode(b_node); break; case CMP_NODE_ZCOMBINE: - node = new ZCombineNode(bNode); + node = new ZCombineNode(b_node); break; case CMP_NODE_TONEMAP: - node = new TonemapNode(bNode); + node = new TonemapNode(b_node); break; case CMP_NODE_SWITCH: - node = new SwitchNode(bNode); + node = new SwitchNode(b_node); break; case CMP_NODE_GLARE: - node = new GlareNode(bNode); + node = new GlareNode(b_node); break; case CMP_NODE_MOVIECLIP: - node = new MovieClipNode(bNode); + node = new MovieClipNode(b_node); break; case CMP_NODE_COLOR_SPILL: - node = new ColorSpillNode(bNode); + node = new ColorSpillNode(b_node); break; case CMP_NODE_OUTPUT_FILE: - node = new OutputFileNode(bNode); + node = new OutputFileNode(b_node); break; case CMP_NODE_MAP_VALUE: - node = new MapValueNode(bNode); + node = new MapValueNode(b_node); break; case CMP_NODE_TRANSFORM: - node = new TransformNode(bNode); + node = new TransformNode(b_node); break; case CMP_NODE_STABILIZE2D: - node = new Stabilize2dNode(bNode); + node = new Stabilize2dNode(b_node); break; case CMP_NODE_BILATERALBLUR: - node = new BilateralBlurNode(bNode); + node = new BilateralBlurNode(b_node); break; case CMP_NODE_VECBLUR: - node = new VectorBlurNode(bNode); + node = new VectorBlurNode(b_node); break; case CMP_NODE_MOVIEDISTORTION: - node = new MovieDistortionNode(bNode); + node = new MovieDistortionNode(b_node); break; case CMP_NODE_VIEW_LEVELS: - node = new ViewLevelsNode(bNode); + node = new ViewLevelsNode(b_node); break; case CMP_NODE_DEFOCUS: - node = new DefocusNode(bNode); + node = new DefocusNode(b_node); break; case CMP_NODE_DOUBLEEDGEMASK: - node = new DoubleEdgeMaskNode(bNode); + node = new DoubleEdgeMaskNode(b_node); break; case CMP_NODE_CROP: - node = new CropNode(bNode); + node = new CropNode(b_node); break; case CMP_NODE_MASK: - node = new MaskNode(bNode); + node = new MaskNode(b_node); break; case CMP_NODE_KEYINGSCREEN: - node = new KeyingScreenNode(bNode); + node = new KeyingScreenNode(b_node); break; case CMP_NODE_KEYING: - node = new KeyingNode(bNode); + node = new KeyingNode(b_node); break; /* not inplemented yet */ default: - node = new MuteNode(bNode); + node = new MuteNode(b_node); break; } return node; diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h index d01556cc79c..dbe98871c50 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 *bNode); + static Node *convert(bNode *b_node); /** * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type. @@ -60,11 +60,15 @@ 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 */ static void convertResolution(SocketConnection *connection, ExecutionSystem *system); + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:Converter") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h index 2a86382a191..e33a2a4288f 100644 --- a/source/blender/compositor/intern/COM_Device.h +++ b/source/blender/compositor/intern/COM_Device.h @@ -48,6 +48,9 @@ public: */ virtual void execute(WorkPackage *work) = 0; +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:Device") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 4dfb9c7d26c..2d3d24b296f 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -43,20 +43,20 @@ ExecutionGroup::ExecutionGroup() { - this->isOutput = false; - this->complex = false; - this->chunkExecutionStates = NULL; - this->bTree = NULL; - this->height = 0; - this->width = 0; - this->cachedMaxReadBufferOffset = 0; - this->numberOfXChunks = 0; - this->numberOfYChunks = 0; - this->numberOfChunks = 0; - this->initialized = false; - this->openCL = false; - this->singleThreaded = false; - this->chunksFinished = 0; + this->m_isOutput = false; + this->m_complex = false; + this->m_chunkExecutionStates = NULL; + this->m_bTree = NULL; + this->m_height = 0; + this->m_width = 0; + this->m_cachedMaxReadBufferOffset = 0; + this->m_numberOfXChunks = 0; + this->m_numberOfYChunks = 0; + this->m_numberOfChunks = 0; + this->m_initialized = false; + this->m_openCL = false; + this->m_singleThreaded = false; + this->m_chunksFinished = 0; } CompositorPriority ExecutionGroup::getRenderPriotrity() @@ -66,7 +66,7 @@ CompositorPriority ExecutionGroup::getRenderPriotrity() bool ExecutionGroup::containsOperation(NodeOperation *operation) { - for (vector<NodeOperation *>::const_iterator iterator = this->operations.begin(); iterator != this->operations.end(); ++iterator) { + for (vector<NodeOperation *>::const_iterator iterator = this->m_operations.begin(); iterator != this->m_operations.end(); ++iterator) { NodeOperation *inListOperation = *iterator; if (inListOperation == operation) { return true; @@ -77,12 +77,12 @@ bool ExecutionGroup::containsOperation(NodeOperation *operation) const bool ExecutionGroup::isComplex() const { - return this->complex; + return this->m_complex; } bool ExecutionGroup::canContainOperation(NodeOperation *operation) { - if (!this->initialized) { return true; } + if (!this->m_initialized) { return true; } if (operation->isReadBufferOperation()) { return true; } if (operation->isWriteBufferOperation()) { return false; } if (operation->isSetOperation()) { return true; } @@ -100,12 +100,12 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat if (containsOperation(operation)) return; if (canContainOperation(operation)) { if (!operation->isBufferOperation()) { - this->complex = operation->isComplex(); - this->openCL = operation->isOpenCL(); - this->singleThreaded = operation->isSingleThreaded(); - this->initialized = true; + this->m_complex = operation->isComplex(); + this->m_openCL = operation->isOpenCL(); + this->m_singleThreaded = operation->isSingleThreaded(); + this->m_initialized = true; } - this->operations.push_back(operation); + this->m_operations.push_back(operation); if (operation->isReadBufferOperation()) { ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; WriteBufferOperation *writeOperation = readOperation->getMemoryProxy()->getWriteBufferOperation(); @@ -137,52 +137,52 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat NodeOperation *ExecutionGroup::getOutputNodeOperation() const { - return this->operations[0]; // the first operation of the group is always the output operation. + return this->m_operations[0]; // the first operation of the group is always the output operation. } void ExecutionGroup::initExecution() { - if (this->chunkExecutionStates != NULL) { - delete[] this->chunkExecutionStates; + if (this->m_chunkExecutionStates != NULL) { + delete[] this->m_chunkExecutionStates; } unsigned int index; determineNumberOfChunks(); - this->chunkExecutionStates = NULL; - if (this->numberOfChunks != 0) { - this->chunkExecutionStates = new ChunkExecutionState[numberOfChunks]; - for (index = 0; index < numberOfChunks; index++) { - this->chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED; + this->m_chunkExecutionStates = NULL; + if (this->m_numberOfChunks != 0) { + this->m_chunkExecutionStates = new ChunkExecutionState[this->m_numberOfChunks]; + for (index = 0; index < this->m_numberOfChunks; index++) { + this->m_chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED; } } unsigned int maxNumber = 0; - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; if (operation->isReadBufferOperation()) { ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; - this->cachedReadOperations.push_back(readOperation); + this->m_cachedReadOperations.push_back(readOperation); maxNumber = max(maxNumber, readOperation->getOffset()); } } maxNumber++; - this->cachedMaxReadBufferOffset = maxNumber; + this->m_cachedMaxReadBufferOffset = maxNumber; } void ExecutionGroup::deinitExecution() { - if (this->chunkExecutionStates != NULL) { - delete[] this->chunkExecutionStates; - this->chunkExecutionStates = NULL; - } - this->numberOfChunks = 0; - this->numberOfXChunks = 0; - this->numberOfYChunks = 0; - this->cachedReadOperations.clear(); - this->bTree = NULL; + if (this->m_chunkExecutionStates != NULL) { + delete[] this->m_chunkExecutionStates; + this->m_chunkExecutionStates = NULL; + } + this->m_numberOfChunks = 0; + this->m_numberOfXChunks = 0; + this->m_numberOfYChunks = 0; + this->m_cachedReadOperations.clear(); + this->m_bTree = NULL; } void ExecutionGroup::determineResolution(unsigned int resolution[]) { @@ -194,16 +194,16 @@ void ExecutionGroup::determineResolution(unsigned int resolution[]) void ExecutionGroup::determineNumberOfChunks() { - if (singleThreaded) { - this->numberOfXChunks = 1; - this->numberOfYChunks = 1; - this->numberOfChunks = 1; + if (this->m_singleThreaded) { + this->m_numberOfXChunks = 1; + this->m_numberOfYChunks = 1; + this->m_numberOfChunks = 1; } else { - const float chunkSizef = this->chunkSize; - this->numberOfXChunks = ceil(this->width / chunkSizef); - this->numberOfYChunks = ceil(this->height / chunkSizef); - this->numberOfChunks = this->numberOfXChunks * this->numberOfYChunks; + const float chunkSizef = this->m_chunkSize; + this->m_numberOfXChunks = ceil(this->m_width / chunkSizef); + this->m_numberOfYChunks = ceil(this->m_height / chunkSizef); + this->m_numberOfChunks = this->m_numberOfXChunks * this->m_numberOfYChunks; } } @@ -214,17 +214,17 @@ void ExecutionGroup::execute(ExecutionSystem *graph) { CompositorContext& context = graph->getContext(); const bNodeTree *bTree = context.getbNodeTree(); - if (this->width == 0 || this->height == 0) {return; } /// @note: break out... no pixels to calculate. + if (this->m_width == 0 || this->m_height == 0) {return; } /// @note: break out... no pixels to calculate. if (bTree->test_break && bTree->test_break(bTree->tbh)) {return; } /// @note: early break out for blur and preview nodes - if (this->numberOfChunks == 0) {return; } /// @note: early break out + if (this->m_numberOfChunks == 0) {return; } /// @note: early break out unsigned int chunkNumber; - this->chunksFinished = 0; - this->bTree = bTree; + this->m_chunksFinished = 0; + this->m_bTree = bTree; unsigned int index; - unsigned int *chunkOrder = new unsigned int[this->numberOfChunks]; + unsigned int *chunkOrder = new unsigned int[this->m_numberOfChunks]; - for (chunkNumber = 0; chunkNumber < this->numberOfChunks; chunkNumber++) { + for (chunkNumber = 0; chunkNumber < this->m_numberOfChunks; chunkNumber++) { chunkOrder[chunkNumber] = chunkNumber; } NodeOperation *operation = this->getOutputNodeOperation(); @@ -241,9 +241,9 @@ void ExecutionGroup::execute(ExecutionSystem *graph) switch (chunkorder) { case COM_TO_RANDOM: - for (index = 0; index < 2 * numberOfChunks; index++) { - int index1 = rand() % numberOfChunks; - int index2 = rand() % numberOfChunks; + for (index = 0; index < 2 * this->m_numberOfChunks; index++) { + int index1 = rand() % this->m_numberOfChunks; + int index2 = rand() % this->m_numberOfChunks; int s = chunkOrder[index1]; chunkOrder[index1] = chunkOrder[index2]; chunkOrder[index2] = s; @@ -252,10 +252,10 @@ void ExecutionGroup::execute(ExecutionSystem *graph) case COM_TO_CENTER_OUT: { ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[1]; - hotspots[0] = new ChunkOrderHotspot(this->width * centerX, this->height * centerY, 0.0f); + hotspots[0] = new ChunkOrderHotspot(this->m_width * centerX, this->m_height * centerY, 0.0f); rcti rect; - ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks]; - for (index = 0; index < this->numberOfChunks; index++) { + ChunkOrder *chunkOrders = new ChunkOrder[this->m_numberOfChunks]; + for (index = 0; index < this->m_numberOfChunks; index++) { determineChunkRect(&rect, index); chunkOrders[index].setChunkNumber(index); chunkOrders[index].setX(rect.xmin); @@ -263,8 +263,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph) chunkOrders[index].determineDistance(hotspots, 1); } - sort(&chunkOrders[0], &chunkOrders[numberOfChunks - 1]); - for (index = 0; index < numberOfChunks; index++) { + sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks - 1]); + for (index = 0; index < this->m_numberOfChunks; index++) { chunkOrder[index] = chunkOrders[index].getChunkNumber(); } @@ -276,14 +276,14 @@ void ExecutionGroup::execute(ExecutionSystem *graph) case COM_TO_RULE_OF_THIRDS: { ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[9]; - unsigned int tx = this->width / 6; - unsigned int ty = this->height / 6; - unsigned int mx = this->width / 2; - unsigned int my = this->height / 2; + unsigned int tx = this->m_width / 6; + unsigned int ty = this->m_height / 6; + unsigned int mx = this->m_width / 2; + unsigned int my = this->m_height / 2; unsigned int bx = mx + 2 * tx; unsigned int by = my + 2 * ty; - float addition = numberOfChunks / COM_RULE_OF_THIRDS_DIVIDER; + float addition = this->m_numberOfChunks / COM_RULE_OF_THIRDS_DIVIDER; hotspots[0] = new ChunkOrderHotspot(mx, my, addition * 0); hotspots[1] = new ChunkOrderHotspot(tx, my, addition * 1); hotspots[2] = new ChunkOrderHotspot(bx, my, addition * 2); @@ -294,8 +294,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph) hotspots[7] = new ChunkOrderHotspot(mx, ty, addition * 7); hotspots[8] = new ChunkOrderHotspot(mx, by, addition * 8); rcti rect; - ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks]; - for (index = 0; index < this->numberOfChunks; index++) { + ChunkOrder *chunkOrders = new ChunkOrder[this->m_numberOfChunks]; + for (index = 0; index < this->m_numberOfChunks; index++) { determineChunkRect(&rect, index); chunkOrders[index].setChunkNumber(index); chunkOrders[index].setX(rect.xmin); @@ -303,9 +303,9 @@ void ExecutionGroup::execute(ExecutionSystem *graph) chunkOrders[index].determineDistance(hotspots, 9); } - sort(&chunkOrders[0], &chunkOrders[numberOfChunks]); + sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks]); - for (index = 0; index < numberOfChunks; index++) { + for (index = 0; index < this->m_numberOfChunks; index++) { chunkOrder[index] = chunkOrders[index].getChunkNumber(); } @@ -333,16 +333,15 @@ void ExecutionGroup::execute(ExecutionSystem *graph) const int maxNumberEvaluated = BLI_system_thread_count() * 2; while (!finished && !breaked) { - unsigned int index; bool startEvaluated = false; finished = true; int numberEvaluated = 0; - for (index = startIndex; index < numberOfChunks && numberEvaluated < maxNumberEvaluated; index++) { - int chunkNumber = chunkOrder[index]; - int yChunk = chunkNumber / this->numberOfXChunks; - int xChunk = chunkNumber - (yChunk * this->numberOfXChunks); - const ChunkExecutionState state = this->chunkExecutionStates[chunkNumber]; + for (index = startIndex; index < this->m_numberOfChunks && numberEvaluated < maxNumberEvaluated; index++) { + chunkNumber = chunkOrder[index]; + int yChunk = chunkNumber / this->m_numberOfXChunks; + int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks); + const ChunkExecutionState state = this->m_chunkExecutionStates[chunkNumber]; if (state == COM_ES_NOT_SCHEDULED) { scheduleChunkWhenPossible(graph, xChunk, yChunk); finished = false; @@ -375,12 +374,12 @@ MemoryBuffer **ExecutionGroup::getInputBuffersCPU() unsigned int index; this->determineDependingMemoryProxies(&memoryproxies); - MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->cachedMaxReadBufferOffset]; - for (index = 0; index < this->cachedMaxReadBufferOffset; index++) { + MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->m_cachedMaxReadBufferOffset]; + for (index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { memoryBuffers[index] = NULL; } - for (index = 0; index < this->cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)this->cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; memoryBuffers[readOperation->getOffset()] = readOperation->getMemoryProxy()->getBuffer(); } return memoryBuffers; @@ -394,13 +393,13 @@ MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) determineChunkRect(&rect, chunkNumber); this->determineDependingMemoryProxies(&memoryproxies); - MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->cachedMaxReadBufferOffset]; - for (index = 0; index < this->cachedMaxReadBufferOffset; index++) { + MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->m_cachedMaxReadBufferOffset]; + for (index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { memoryBuffers[index] = NULL; } rcti output; - for (index = 0; index < this->cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)this->cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; MemoryProxy *memoryProxy = readOperation->getMemoryProxy(); this->determineDependingAreaOfInterest(&rect, readOperation, &output); MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(memoryProxy, &output); @@ -419,12 +418,12 @@ MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *mem void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers) { - if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) - this->chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED; + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) + this->m_chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED; - this->chunksFinished++; + this->m_chunksFinished++; if (memoryBuffers) { - for (unsigned int index = 0; index < this->cachedMaxReadBufferOffset; index++) { + for (unsigned int index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { MemoryBuffer *buffer = memoryBuffers[index]; if (buffer) { if (buffer->isTemporarily()) { @@ -435,30 +434,30 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo } delete[] memoryBuffers; } - if (bTree) { + if (this->m_bTree) { // status report is only performed for top level Execution Groups. - float progress = chunksFinished; - progress /= numberOfChunks; - bTree->progress(bTree->prh, progress); + float progress = this->m_chunksFinished; + progress /= this->m_numberOfChunks; + this->m_bTree->progress(this->m_bTree->prh, progress); } } inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const { - if (singleThreaded) { - BLI_init_rcti(rect, 0, this->width, 0, this->height); + if (this->m_singleThreaded) { + BLI_init_rcti(rect, 0, this->m_width, 0, this->m_height); } else { - const unsigned int minx = xChunk * chunkSize; - const unsigned int miny = yChunk * chunkSize; - BLI_init_rcti(rect, minx, min(minx + this->chunkSize, this->width), miny, min(miny + this->chunkSize, this->height)); + const unsigned int minx = xChunk * this->m_chunkSize; + const unsigned int miny = yChunk * this->m_chunkSize; + BLI_init_rcti(rect, minx, min(minx + this->m_chunkSize, this->m_width), miny, min(miny + this->m_chunkSize, this->m_height)); } } void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumber) const { - const unsigned int yChunk = chunkNumber / numberOfXChunks; - const unsigned int xChunk = chunkNumber - (yChunk * numberOfXChunks); + const unsigned int yChunk = chunkNumber / this->m_numberOfXChunks; + const unsigned int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks); determineChunkRect(rect, xChunk, yChunk); } @@ -477,23 +476,27 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti *rect) bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area) { - if (singleThreaded) { + if (this->m_singleThreaded) { return scheduleChunkWhenPossible(graph, 0, 0); } // find all chunks inside the rect // determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers - float chunkSizef = this->chunkSize; + 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; } @@ -505,8 +508,8 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) { - if (this->chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) { - this->chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED; + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) { + this->m_chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED; WorkScheduler::schedule(this, chunkNumber); return true; } @@ -515,20 +518,20 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk) { - if (xChunk < 0 || xChunk >= (int)this->numberOfXChunks) { + if (xChunk < 0 || xChunk >= (int)this->m_numberOfXChunks) { return true; } - if (yChunk < 0 || yChunk >= (int)this->numberOfYChunks) { + if (yChunk < 0 || yChunk >= (int)this->m_numberOfYChunks) { return true; } - int chunkNumber = yChunk * this->numberOfXChunks + xChunk; + int chunkNumber = yChunk * this->m_numberOfXChunks + xChunk; // chunk is already executed - if (this->chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) { + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) { return true; } // chunk is scheduled, but not executed - if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) { + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) { return false; } @@ -542,8 +545,8 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChun bool canBeExecuted = true; rcti area; - for (index = 0; index < cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; BLI_init_rcti(&area, 0, 0, 0, 0); MemoryProxy *memoryProxy = memoryProxies[index]; determineDependingAreaOfInterest(&rect, readOperation, &area); @@ -574,13 +577,13 @@ void ExecutionGroup::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies) { unsigned int index; - for (index = 0; index < this->cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *) this->cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *) this->m_cachedReadOperations[index]; memoryProxies->push_back(readOperation->getMemoryProxy()); } } bool ExecutionGroup::isOpenCL() { - return this->openCL; + return this->m_openCL; } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h index 541b3e4866d..43c2bfac52e 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.h +++ b/source/blender/compositor/intern/COM_ExecutionGroup.h @@ -67,81 +67,81 @@ private: /** * @brief list of operations in this ExecutionGroup */ - vector<NodeOperation *> operations; + vector<NodeOperation *> m_operations; /** * @brief is this ExecutionGroup an input ExecutionGroup * an input execution group is a group that is at the end of the calculation (the output is important for the user) */ - int isOutput; + int m_isOutput; /** * @brief Width of the output */ - unsigned int width; + unsigned int m_width; /** * @brief Height of the output */ - unsigned int height; + unsigned int m_height; /** * @brief size of a single chunk, being Width or of height * a chunk is always a square, except at the edges of the MemoryBuffer */ - unsigned int chunkSize; + unsigned int m_chunkSize; /** * @brief number of chunks in the x-axis */ - unsigned int numberOfXChunks; + unsigned int m_numberOfXChunks; /** * @brief number of chunks in the y-axis */ - unsigned int numberOfYChunks; + unsigned int m_numberOfYChunks; /** * @brief total number of chunks */ - unsigned int numberOfChunks; + unsigned int m_numberOfChunks; /** * @brief contains this ExecutionGroup a complex NodeOperation. */ - bool complex; + bool m_complex; /** * @brief can this ExecutionGroup be scheduled on an OpenCLDevice */ - bool openCL; + bool m_openCL; /** * @brief Is this Execution group SingleThreaded */ - bool singleThreaded; + bool m_singleThreaded; /** * @brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup. * @note this is used to construct the MemoryBuffers that will be passed during execution. */ - unsigned int cachedMaxReadBufferOffset; + unsigned int m_cachedMaxReadBufferOffset; /** * @brief a cached vector of all read operations in the execution group. */ - vector<NodeOperation *> cachedReadOperations; + vector<NodeOperation *> m_cachedReadOperations; /** * @brief reference to the original bNodeTree, this field is only set for the 'top' execution group. * @note can only be used to call the callbacks for progress, status and break */ - const bNodeTree *bTree; + const bNodeTree *m_bTree; /** * @brief total number of chunks that have been calculated for this ExecutionGroup */ - unsigned int chunksFinished; + unsigned int m_chunksFinished; /** * @brief the chunkExecutionStates holds per chunk the execution state. this state can be @@ -149,7 +149,7 @@ private: * - COM_ES_SCHEDULED: scheduled * - COM_ES_EXECUTED: executed */ - ChunkExecutionState *chunkExecutionStates; + ChunkExecutionState *m_chunkExecutionStates; /** * @brief indicator when this ExecutionGroup has valid NodeOperations in its vector for Execution @@ -160,7 +160,7 @@ private: * @see complex * @see openCL */ - bool initialized; + bool m_initialized; // methods /** @@ -258,13 +258,13 @@ public: * @note ViewerOperation, CompositeOperation, PreviewOperation. * @see NodeOperation.isOutputOperation */ - const int isOutputExecutionGroup() const { return this->isOutput; } + const int isOutputExecutionGroup() const { return this->m_isOutput; } /** * @brief set whether this ExecutionGroup is an output * @param isOutput */ - void setOutputExecutionGroup(int isOutput) { this->isOutput = isOutput; } + void setOutputExecutionGroup(int isOutput) { this->m_isOutput = isOutput; } /** * @brief determine the resolution of this ExecutionGroup @@ -276,17 +276,17 @@ public: * @brief set the resolution of this executiongroup * @param resolution */ - void setResolution(unsigned int resolution[]) { this->width = resolution[0]; this->height = resolution[1]; } + void setResolution(unsigned int resolution[]) { this->m_width = resolution[0]; this->m_height = resolution[1]; } /** * @brief get the width of this execution group */ - const unsigned int getWidth() { return this->width; } + const unsigned int getWidth() { return this->m_width; } /** * @brief get the height of this execution group */ - const unsigned int getHeight() { return this->height; } + const unsigned int getHeight() { return this->m_height; } /** * @brief does this ExecutionGroup contains a complex NodeOperation @@ -387,14 +387,17 @@ public: */ bool isOpenCL(); - void setChunksize(int chunksize) { this->chunkSize = chunksize; } + void setChunksize(int chunksize) { this->m_chunkSize = chunksize; } /** * @brief get the Render priority of this ExecutionGroup * @see ExecutionSystem.execute */ CompositorPriority getRenderPriotrity(); - + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 7e09486fd0b..23e243187d5 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -23,7 +23,6 @@ #include "COM_ExecutionSystem.h" #include <sstream> -#include <stdio.h> #include "PIL_time.h" #include "BKE_node.h" @@ -41,38 +40,42 @@ #include "BKE_global.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering) { - context.setbNodeTree(editingtree); + this->m_context.setbNodeTree(editingtree); bNode *gnode; for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) { if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) { - context.setActivegNode(gnode); + this->m_context.setActivegNode(gnode); break; } } /* initialize the CompositorContext */ if (rendering) { - context.setQuality((CompositorQuality)editingtree->render_quality); + this->m_context.setQuality((CompositorQuality)editingtree->render_quality); } else { - context.setQuality((CompositorQuality)editingtree->edit_quality); + this->m_context.setQuality((CompositorQuality)editingtree->edit_quality); } - context.setRendering(rendering); - context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL)); + this->m_context.setRendering(rendering); + this->m_context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL)); ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); - context.setRenderData(rd); + this->m_context.setRenderData(rd); this->convertToOperations(); this->groupOperations(); /* group operations in ExecutionGroups */ unsigned int index; unsigned int resolution[2]; - for (index = 0; index < this->groups.size(); index++) { + for (index = 0; index < this->m_groups.size(); index++) { resolution[0] = 0; resolution[1] = 0; - ExecutionGroup *executionGroup = groups[index]; + ExecutionGroup *executionGroup = this->m_groups[index]; executionGroup->determineResolution(resolution); } @@ -84,32 +87,32 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool re ExecutionSystem::~ExecutionSystem() { unsigned int index; - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; delete connection; } - this->connections.clear(); - for (index = 0; index < this->nodes.size(); index++) { - Node *node = this->nodes[index]; + this->m_connections.clear(); + for (index = 0; index < this->m_nodes.size(); index++) { + Node *node = this->m_nodes[index]; delete node; } - this->nodes.clear(); - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; + this->m_nodes.clear(); + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; delete operation; } - this->operations.clear(); - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *group = this->groups[index]; + this->m_operations.clear(); + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *group = this->m_groups[index]; delete group; } - this->groups.clear(); + this->m_groups.clear(); } void ExecutionSystem::execute() { unsigned int order = 0; - for (vector<NodeOperation *>::iterator iter = this->operations.begin(); iter != operations.end(); ++iter) { + for (vector<NodeOperation *>::iterator iter = this->m_operations.begin(); iter != this->m_operations.end(); ++iter) { NodeBase *node = *iter; NodeOperation *operation = (NodeOperation *) node; if (operation->isReadBufferOperation()) { @@ -120,18 +123,18 @@ void ExecutionSystem::execute() } unsigned int index; - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; - operation->setbNodeTree(this->context.getbNodeTree()); + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + operation->setbNodeTree(this->m_context.getbNodeTree()); operation->initExecution(); } - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *executionGroup = this->groups[index]; - executionGroup->setChunksize(context.getChunksize()); + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *executionGroup = this->m_groups[index]; + executionGroup->setChunksize(this->m_context.getChunksize()); executionGroup->initExecution(); } - WorkScheduler::start(this->context); + WorkScheduler::start(this->m_context); executeGroups(COM_PRIORITY_HIGH); executeGroups(COM_PRIORITY_MEDIUM); @@ -140,12 +143,12 @@ void ExecutionSystem::execute() WorkScheduler::finish(); WorkScheduler::stop(); - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; operation->deinitExecution(); } - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *executionGroup = this->groups[index]; + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *executionGroup = this->m_groups[index]; executionGroup->deinitExecution(); } } @@ -164,7 +167,7 @@ void ExecutionSystem::executeGroups(CompositorPriority priority) void ExecutionSystem::addOperation(NodeOperation *operation) { - ExecutionSystemHelper::addOperation(this->operations, operation); + ExecutionSystemHelper::addOperation(this->m_operations, operation); // operation->setBTree } @@ -205,7 +208,6 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) */ OutputSocket *outputsocket = operation->getOutputSocket(); if (outputsocket->isConnected()) { - int index; WriteBufferOperation *writeOperation; writeOperation = new WriteBufferOperation(); writeOperation->setbNodeTree(this->getContext().getbNodeTree()); @@ -227,13 +229,13 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) void ExecutionSystem::convertToOperations() { unsigned int index; - for (index = 0; index < this->nodes.size(); index++) { - Node *node = (Node *)this->nodes[index]; - node->convertToOperations(this, &this->context); + for (index = 0; index < this->m_nodes.size(); index++) { + Node *node = (Node *)this->m_nodes[index]; + node->convertToOperations(this, &this->m_context); } - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; if (connection->isValid()) { if (connection->getFromSocket()->getDataType() != connection->getToSocket()->getDataType()) { Converter::convertDataType(connection, this); @@ -242,18 +244,18 @@ void ExecutionSystem::convertToOperations() } // determine all resolutions of the operations (Width/Height) - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; - if (operation->isOutputOperation(context.isRendering()) && !operation->isPreviewOperation()) { + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + if (operation->isOutputOperation(this->m_context.isRendering()) && !operation->isPreviewOperation()) { unsigned int resolution[2] = {0, 0}; unsigned int preferredResolution[2] = {0, 0}; operation->determineResolution(resolution, preferredResolution); operation->setResolution(resolution); } } - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; - if (operation->isOutputOperation(context.isRendering()) && operation->isPreviewOperation()) { + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + if (operation->isOutputOperation(this->m_context.isRendering()) && operation->isPreviewOperation()) { unsigned int resolution[2] = {0, 0}; unsigned int preferredResolution[2] = {0, 0}; operation->determineResolution(resolution, preferredResolution); @@ -262,8 +264,8 @@ void ExecutionSystem::convertToOperations() } // add convert resolution operations when needed. - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; if (connection->isValid()) { if (connection->needsResolutionConversion()) { Converter::convertResolution(connection, this); @@ -278,13 +280,13 @@ void ExecutionSystem::groupOperations() NodeOperation *operation; unsigned int index; // surround complex operations with ReadBufferOperation and WriteBufferOperation - for (index = 0; index < this->operations.size(); index++) { - operation = this->operations[index]; + for (index = 0; index < this->m_operations.size(); index++) { + operation = this->m_operations[index]; if (operation->isComplex()) { this->addReadWriteBufferOperations(operation); } } - ExecutionSystemHelper::findOutputNodeOperations(&outputOperations, this->getOperations(), this->context.isRendering()); + ExecutionSystemHelper::findOutputNodeOperations(&outputOperations, this->getOperations(), this->m_context.isRendering()); for (vector<NodeOperation *>::iterator iter = outputOperations.begin(); iter != outputOperations.end(); ++iter) { operation = *iter; ExecutionGroup *group = new ExecutionGroup(); @@ -296,15 +298,15 @@ void ExecutionSystem::groupOperations() void ExecutionSystem::addSocketConnection(SocketConnection *connection) { - this->connections.push_back(connection); + this->m_connections.push_back(connection); } void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const { unsigned int index; - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *group = this->groups[index]; + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *group = this->m_groups[index]; if (group->isOutputExecutionGroup() && group->getRenderPriotrity() == priority) { result->push_back(group); } @@ -314,8 +316,8 @@ void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result) const { unsigned int index; - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *group = this->groups[index]; + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *group = this->m_groups[index]; if (group->isOutputExecutionGroup()) { result->push_back(group); } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 48ff2ef6af9..e51bd7f3026 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -108,27 +108,27 @@ private: /** * @brief the context used during execution */ - CompositorContext context; + CompositorContext m_context; /** * @brief vector of nodes */ - vector<Node *> nodes; + vector<Node *> m_nodes; /** * @brief vector of operations */ - vector<NodeOperation *> operations; + vector<NodeOperation *> m_operations; /** * @brief vector of groups */ - vector<ExecutionGroup *> groups + vector<ExecutionGroup *> m_groups; /** * @brief vector of connections - */; - vector<SocketConnection *> connections; + */ + vector<SocketConnection *> m_connections; private: //methods /** @@ -200,27 +200,27 @@ public: /** * @brief get the reference to the compositor context */ - CompositorContext& getContext() { return this->context; } + CompositorContext& getContext() { return this->m_context; } /** * @brief get the reference to the compositor nodes */ - vector<Node *>& getNodes() { return this->nodes; } + vector<Node *>& getNodes() { return this->m_nodes; } /** * @brief get the reference to the compositor connections */ - vector<SocketConnection *>& getConnections() { return this->connections; } + vector<SocketConnection *>& getConnections() { return this->m_connections; } /** * @brief get the reference to the list of execution groups */ - vector<ExecutionGroup *>& getExecutionGroups() { return this->groups; } + vector<ExecutionGroup *>& getExecutionGroups() { return this->m_groups; } /** * @brief get the reference to the list of operations */ - vector<NodeOperation *>& getOperations() { return this->operations; } + vector<NodeOperation *>& getOperations() { return this->m_operations; } private: @@ -232,5 +232,9 @@ private: void executeGroups(CompositorPriority priority); -}; +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystem") #endif +}; + +#endif /* _COM_ExecutionSystem_h */ diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index e5376567077..0f6ba1f4ac9 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -77,11 +77,11 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node) nodes.push_back(node); } -Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *bNode, bool inActiveGroup) +Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup) { Converter converter; Node *node; - node = converter.convert(bNode); + node = converter.convert(b_node); node->setIsInActiveGroup(inActiveGroup); if (node != NULL) { addNode(nodes, node); @@ -153,17 +153,17 @@ static OutputSocket *find_output(NodeRange &node_range, bNode *bnode, bNodeSocke } return NULL; } -SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *bNodeLink) +SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *b_nodelink) { /// @note: cyclic lines will be ignored. This has been copied from node.c - if (bNodeLink->tonode != 0 && bNodeLink->fromnode != 0) { - if (!(bNodeLink->fromnode->level >= bNodeLink->tonode->level && bNodeLink->tonode->level != 0xFFF)) { // only add non cyclic lines! so execution will procede + if (b_nodelink->tonode != 0 && b_nodelink->fromnode != 0) { + if (!(b_nodelink->fromnode->level >= b_nodelink->tonode->level && b_nodelink->tonode->level != 0xFFF)) { // only add non cyclic lines! so execution will procede return NULL; } } - InputSocket *inputSocket = find_input(node_range, bNodeLink->tonode, bNodeLink->tosock); - OutputSocket *outputSocket = find_output(node_range, bNodeLink->fromnode, bNodeLink->fromsock); + InputSocket *inputSocket = find_input(node_range, b_nodelink->tonode, b_nodelink->tosock); + OutputSocket *outputSocket = find_output(node_range, b_nodelink->fromnode, b_nodelink->fromsock); if (inputSocket == NULL || outputSocket == NULL) { return NULL; } diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index 8dbd308153b..4b65ed15577 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 *bNode, bool isInActiveGroup); + static Node *addNode(vector<Node *>& nodes, bNode *b_node, bool isInActiveGroup); /** * @brief Add a Node to a list @@ -123,5 +123,10 @@ public: * @param system the execution system to dump */ static void debugDump(ExecutionSystem *system); -}; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystemHelper") #endif +}; + +#endif /* _COM_ExecutionSystemHelper_h */ diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp index 3ca74f157b4..94cb5ff5396 100644 --- a/source/blender/compositor/intern/COM_InputSocket.cpp +++ b/source/blender/compositor/intern/COM_InputSocket.cpp @@ -27,37 +27,37 @@ InputSocket::InputSocket(DataType datatype) : Socket(datatype) { - this->connection = NULL; - this->resizeMode = COM_SC_CENTER; + this->m_connection = NULL; + this->m_resizeMode = COM_SC_CENTER; } InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) : Socket(datatype) { - this->connection = NULL; - this->resizeMode = resizeMode; + this->m_connection = NULL; + this->m_resizeMode = resizeMode; } InputSocket::InputSocket(InputSocket *from) : Socket(from->getDataType()) { - this->connection = NULL; - this->resizeMode = from->getResizeMode(); + this->m_connection = NULL; + this->m_resizeMode = from->getResizeMode(); } int InputSocket::isInputSocket() const { return true; } -const int InputSocket::isConnected() const { return this->connection != NULL; } +const int InputSocket::isConnected() const { return this->m_connection != NULL; } void InputSocket::setConnection(SocketConnection *connection) { - this->connection = connection; + this->m_connection = connection; } SocketConnection *InputSocket::getConnection() { - return this->connection; + return this->m_connection; } void InputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { if (this->isConnected()) { - this->connection->getFromSocket()->determineResolution(resolution, preferredResolution); + this->m_connection->getFromSocket()->determineResolution(resolution, preferredResolution); } else { return; @@ -140,7 +140,7 @@ SocketReader *InputSocket::getReader() NodeOperation *InputSocket::getOperation() const { if (isConnected()) { - return (NodeOperation *)this->connection->getFromSocket()->getNode(); + return (NodeOperation *)this->m_connection->getFromSocket()->getNode(); } else { return NULL; diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h index c066b5d8303..5d0923ff204 100644 --- a/source/blender/compositor/intern/COM_InputSocket.h +++ b/source/blender/compositor/intern/COM_InputSocket.h @@ -65,12 +65,12 @@ private: * @brief connection connected to this InputSocket. * An input socket can only have a single connection */ - SocketConnection *connection; + SocketConnection *m_connection; /** * @brief resize mode of this socket */ - InputSocketResizeMode resizeMode; + InputSocketResizeMode m_resizeMode; public: @@ -126,7 +126,7 @@ public: * @param resizeMode the new resize mode. */ void setResizeMode(InputSocketResizeMode resizeMode) { - this->resizeMode = resizeMode; + this->m_resizeMode = resizeMode; } /** @@ -134,7 +134,7 @@ public: * @return InputSocketResizeMode */ InputSocketResizeMode getResizeMode() const { - return this->resizeMode; + return this->m_resizeMode; } const ChannelInfo *getChannelInfo(const int channelnumber); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index ceed53c4c0d..8dd1e55274f 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -32,43 +32,43 @@ unsigned int MemoryBuffer::determineBufferSize() int MemoryBuffer::getWidth() const { - return this->rect.xmax - this->rect.xmin; + return this->m_rect.xmax - this->m_rect.xmin; } int MemoryBuffer::getHeight() const { - return this->rect.ymax - this->rect.ymin; + return this->m_rect.ymax - this->m_rect.ymin; } MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect) { - BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); - this->memoryProxy = memoryProxy; - this->chunkNumber = chunkNumber; - this->buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); - this->state = COM_MB_ALLOCATED; - this->datatype = COM_DT_COLOR; - this->chunkWidth = this->rect.xmax - this->rect.xmin; + BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + this->m_memoryProxy = memoryProxy; + this->m_chunkNumber = chunkNumber; + this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); + this->m_state = COM_MB_ALLOCATED; + this->m_datatype = COM_DT_COLOR; + this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin; } MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) { - BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); - this->memoryProxy = memoryProxy; - this->chunkNumber = -1; - this->buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); - this->state = COM_MB_TEMPORARILY; - this->datatype = COM_DT_COLOR; - this->chunkWidth = this->rect.xmax - this->rect.xmin; + BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + this->m_memoryProxy = memoryProxy; + this->m_chunkNumber = -1; + this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); + this->m_state = COM_MB_TEMPORARILY; + this->m_datatype = COM_DT_COLOR; + this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin; } MemoryBuffer *MemoryBuffer::duplicate() { - MemoryBuffer *result = new MemoryBuffer(this->memoryProxy, &this->rect); - memcpy(result->buffer, this->buffer, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); + MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, &this->m_rect); + memcpy(result->m_buffer, this->m_buffer, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); return result; } void MemoryBuffer::clear() { - memset(this->buffer, 0, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); + memset(this->m_buffer, 0, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); } float *MemoryBuffer::convertToValueBuffer() @@ -78,7 +78,7 @@ float *MemoryBuffer::convertToValueBuffer() float *result = new float[size]; - const float *fp_src = this->buffer; + const float *fp_src = this->m_buffer; float *fp_dst = result; for (i = 0; i < size; i++, fp_dst++, fp_src += COM_NUMBER_OF_CHANNELS) { @@ -90,9 +90,9 @@ float *MemoryBuffer::convertToValueBuffer() MemoryBuffer::~MemoryBuffer() { - if (this->buffer) { - MEM_freeN(this->buffer); - this->buffer = NULL; + if (this->m_buffer) { + MEM_freeN(this->m_buffer); + this->m_buffer = NULL; } } @@ -102,30 +102,30 @@ void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) return; } unsigned int otherY; - unsigned int minX = max(this->rect.xmin, otherBuffer->rect.xmin); - unsigned int maxX = min(this->rect.xmax, otherBuffer->rect.xmax); - unsigned int minY = max(this->rect.ymin, otherBuffer->rect.ymin); - unsigned int maxY = min(this->rect.ymax, otherBuffer->rect.ymax); + unsigned int minX = max(this->m_rect.xmin, otherBuffer->m_rect.xmin); + unsigned int maxX = min(this->m_rect.xmax, otherBuffer->m_rect.xmax); + unsigned int minY = max(this->m_rect.ymin, otherBuffer->m_rect.ymin); + unsigned int maxY = min(this->m_rect.ymax, otherBuffer->m_rect.ymax); int offset; int otherOffset; for (otherY = minY; otherY < maxY; otherY++) { - otherOffset = ((otherY - otherBuffer->rect.ymin) * otherBuffer->chunkWidth + minX - otherBuffer->rect.xmin) * COM_NUMBER_OF_CHANNELS; - offset = ((otherY - this->rect.ymin) * this->chunkWidth + minX - this->rect.xmin) * COM_NUMBER_OF_CHANNELS; - memcpy(&this->buffer[offset], &otherBuffer->buffer[otherOffset], (maxX - minX) * COM_NUMBER_OF_CHANNELS * sizeof(float)); + otherOffset = ((otherY - otherBuffer->m_rect.ymin) * otherBuffer->m_chunkWidth + minX - otherBuffer->m_rect.xmin) * COM_NUMBER_OF_CHANNELS; + offset = ((otherY - this->m_rect.ymin) * this->m_chunkWidth + minX - this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS; + memcpy(&this->m_buffer[offset], &otherBuffer->m_buffer[otherOffset], (maxX - minX) * COM_NUMBER_OF_CHANNELS * sizeof(float)); } } void MemoryBuffer::read(float result[4], int x, int y) { - if (x >= this->rect.xmin && x < this->rect.xmax && - y >= this->rect.ymin && y < this->rect.ymax) + if (x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int dx = x - this->rect.xmin; - const int dy = y - this->rect.ymin; - const int offset = (this->chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; - copy_v4_v4(result, &this->buffer[offset]); + const int dx = x - this->m_rect.xmin; + const int dy = y - this->m_rect.ymin; + const int offset = (this->m_chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; + copy_v4_v4(result, &this->m_buffer[offset]); } else { zero_v4(result); @@ -133,21 +133,21 @@ void MemoryBuffer::read(float result[4], int x, int y) } void MemoryBuffer::writePixel(int x, int y, const float color[4]) { - if (x >= this->rect.xmin && x < this->rect.xmax && - y >= this->rect.ymin && y < this->rect.ymax) + if (x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int offset = (this->chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; - copy_v4_v4(&this->buffer[offset], color); + const int offset = (this->m_chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; + copy_v4_v4(&this->m_buffer[offset], color); } } void MemoryBuffer::addPixel(int x, int y, const float color[4]) { - if (x >= this->rect.xmin && x < this->rect.xmax && - y >= this->rect.ymin && y < this->rect.ymax) + if (x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int offset = (this->chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; - add_v4_v4(&this->buffer[offset], color); + const int offset = (this->m_chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; + add_v4_v4(&this->m_buffer[offset], color); } } diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index dd24a30e85e..63b41aeddde 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -56,39 +56,39 @@ private: /** * @brief proxy of the memory (same for all chunks in the same buffer) */ - MemoryProxy *memoryProxy; + MemoryProxy *m_memoryProxy; /** * @brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR */ - DataType datatype; + DataType m_datatype; /** * @brief region of this buffer inside reative to the MemoryProxy */ - rcti rect; + rcti m_rect; /** * brief refers to the chunknumber within the executiongroup where related to the MemoryProxy * @see memoryProxy */ - unsigned int chunkNumber; + unsigned int m_chunkNumber; /** * @brief width of the chunk */ - unsigned int chunkWidth; + unsigned int m_chunkWidth; /** * @brief state of the buffer */ - MemoryBufferState state; + MemoryBufferState m_state; /** * @brief the actual float buffer/data */ - float *buffer; + float *m_buffer; public: /** @@ -109,19 +109,19 @@ public: /** * @brief read the ChunkNumber of this MemoryBuffer */ - unsigned int getChunkNumber() { return this->chunkNumber; } + unsigned int getChunkNumber() { return this->m_chunkNumber; } /** * @brief get the data of this MemoryBuffer * @note buffer should already be available in memory */ - float *getBuffer() { return this->buffer; } + float *getBuffer() { return this->m_buffer; } /** * @brief after execution the state will be set to available by calling this method */ void setCreatedState() { - this->state = COM_MB_AVAILABLE; + this->m_state = COM_MB_AVAILABLE; } void read(float result[4], int x, int y); @@ -133,7 +133,7 @@ public: /** * @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk) */ - inline const bool isTemporarily() const { return this->state == COM_MB_TEMPORARILY; } + inline const bool isTemporarily() const { return this->m_state == COM_MB_TEMPORARILY; } /** * @brief add the content from otherBuffer to this MemoryBuffer @@ -144,7 +144,7 @@ public: /** * @brief get the rect of this MemoryBuffer */ - rcti *getRect() { return &this->rect; } + rcti *getRect() { return &this->m_rect; } /** * @brief get the width of this MemoryBuffer @@ -166,6 +166,10 @@ public: float *convertToValueBuffer(); private: unsigned int determineBufferSize(); + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cpp b/source/blender/compositor/intern/COM_MemoryProxy.cpp index 3a2c690d7de..90ca0baea06 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.cpp +++ b/source/blender/compositor/intern/COM_MemoryProxy.cpp @@ -25,8 +25,8 @@ MemoryProxy::MemoryProxy() { - this->writeBufferOperation = NULL; - this->executor = NULL; + this->m_writeBufferOperation = NULL; + this->m_executor = NULL; } void MemoryProxy::allocate(unsigned int width, unsigned int height) @@ -37,14 +37,14 @@ void MemoryProxy::allocate(unsigned int width, unsigned int height) result.ymin = 0; result.ymax = height; - buffer = new MemoryBuffer(this, 1, &result); + this->m_buffer = new MemoryBuffer(this, 1, &result); } void MemoryProxy::free() { - if (buffer) { - delete buffer; - buffer = NULL; + if (this->m_buffer) { + delete this->m_buffer; + this->m_buffer = NULL; } } diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h index e7e7f1cf3a0..130c5f5057a 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.h +++ b/source/blender/compositor/intern/COM_MemoryProxy.h @@ -23,8 +23,8 @@ class MemoryProxy; -#ifndef _COM_MemoryProxy_h -#define _COM_MemoryProxy_h +#ifndef _COM_MemoryProxy_h_ +#define _COM_MemoryProxy_h_ #include "COM_ExecutionGroup.h" class ExecutionGroup; @@ -40,27 +40,27 @@ private: /** * @brief reference to the ouput operation of the executiongroup */ - WriteBufferOperation *writeBufferOperation; + WriteBufferOperation *m_writeBufferOperation; /** * @brief reference to the executor. the Execution group that can fill a chunk */ - ExecutionGroup *executor; + ExecutionGroup *m_executor; /** * @brief datatype of this MemoryProxy */ - DataType datatype; + /* DataType m_datatype; */ /* UNUSED */ /** * @brief channel information of this buffer */ - ChannelInfo channelInfo[COM_NUMBER_OF_CHANNELS]; + /* ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS]; */ /* UNUSED */ /** * @brief the allocated memory */ - MemoryBuffer *buffer; + MemoryBuffer *m_buffer; public: MemoryProxy(); @@ -69,24 +69,24 @@ public: * @brief set the ExecutionGroup that can be scheduled to calculate a certain chunk. * @param group the ExecutionGroup to set */ - void setExecutor(ExecutionGroup *executor) { this->executor = executor; } + void setExecutor(ExecutionGroup *executor) { this->m_executor = executor; } /** * @brief get the ExecutionGroup that can be scheduled to calculate a certain chunk. */ - ExecutionGroup *getExecutor() { return this->executor; } + ExecutionGroup *getExecutor() { return this->m_executor; } /** * @brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy * @param operation */ - void setWriteBufferOperation(WriteBufferOperation *operation) { this->writeBufferOperation = operation; } + void setWriteBufferOperation(WriteBufferOperation *operation) { this->m_writeBufferOperation = operation; } /** * @brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy * @return WriteBufferOperation */ - WriteBufferOperation *getWriteBufferOperation() { return this->writeBufferOperation; } + WriteBufferOperation *getWriteBufferOperation() { return this->m_writeBufferOperation; } /** * @brief allocate memory of size widht x height @@ -101,7 +101,11 @@ public: /** * @brief get the allocated memory */ - inline MemoryBuffer *getBuffer() { return this->buffer; } + inline MemoryBuffer *getBuffer() { return this->m_buffer; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryProxy") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 06b6164be3c..15b8a3933a7 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -41,7 +41,7 @@ Node::Node(bNode *editorNode, bool create_sockets) { - this->editorNode = editorNode; + this->m_editorNode = editorNode; if (create_sockets) { bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first; @@ -66,12 +66,12 @@ Node::Node(bNode *editorNode, bool create_sockets) } Node::Node() { - this->editorNode = NULL; + this->m_editorNode = NULL; } bNode *Node::getbNode() { - return this->editorNode; + 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 090b1455440..5d6d232f37a 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -51,12 +51,12 @@ private: /** * @brief stores the reference to the SDNA bNode struct */ - bNode *editorNode; + bNode *m_editorNode; /** * @brief Is this node part of the active group */ - bool inActiveGroup; + bool m_inActiveGroup; public: Node(bNode *editorNode, bool create_sockets = true); @@ -70,7 +70,7 @@ public: * @brief Is this node in the active group (the group that is being edited) * @param isInActiveGroup */ - void setIsInActiveGroup(bool isInActiveGroup) { this->inActiveGroup = isInActiveGroup; } + void setIsInActiveGroup(bool value) { this->m_inActiveGroup = value; } /** * @brief Is this node part of the active group @@ -78,7 +78,7 @@ public: * the active group will be the main tree (all nodes that are not part of a group will be active) * @return bool [false:true] */ - inline bool isInActiveGroup() { return this->inActiveGroup; } + inline bool isInActiveGroup() { return this->m_inActiveGroup; } /** * @brief convert node to operation diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp index 1a895cf93b1..8dbda5f649c 100644 --- a/source/blender/compositor/intern/COM_NodeBase.cpp +++ b/source/blender/compositor/intern/COM_NodeBase.cpp @@ -39,13 +39,13 @@ NodeBase::NodeBase() NodeBase::~NodeBase() { - while (!this->outputsockets.empty()) { - delete (this->outputsockets.back()); - this->outputsockets.pop_back(); + while (!this->m_outputsockets.empty()) { + delete (this->m_outputsockets.back()); + this->m_outputsockets.pop_back(); } - while (!this->inputsockets.empty()) { - delete (this->inputsockets.back()); - this->inputsockets.pop_back(); + while (!this->m_inputsockets.empty()) { + delete (this->m_inputsockets.back()); + this->m_inputsockets.pop_back(); } } @@ -63,7 +63,7 @@ void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMod InputSocket *socket = new InputSocket(datatype, resizeMode); socket->setEditorSocket(bSocket); socket->setNode(this); - this->inputsockets.push_back(socket); + this->m_inputsockets.push_back(socket); } void NodeBase::addOutputSocket(DataType datatype) @@ -76,21 +76,21 @@ void NodeBase::addOutputSocket(DataType datatype, bNodeSocket *bSocket) OutputSocket *socket = new OutputSocket(datatype); socket->setEditorSocket(bSocket); socket->setNode(this); - this->outputsockets.push_back(socket); + this->m_outputsockets.push_back(socket); } const bool NodeBase::isInputNode() const { - return this->inputsockets.size() == 0; + return this->m_inputsockets.size() == 0; } OutputSocket *NodeBase::getOutputSocket(unsigned int index) { - BLI_assert(index < this->outputsockets.size()); - return this->outputsockets[index]; + BLI_assert(index < this->m_outputsockets.size()); + return this->m_outputsockets[index]; } InputSocket *NodeBase::getInputSocket(unsigned int index) { - BLI_assert(index < this->inputsockets.size()); - return this->inputsockets[index]; + BLI_assert(index < this->m_inputsockets.size()); + return this->m_inputsockets[index]; } diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h index 54f80926b84..7095cda39e3 100644 --- a/source/blender/compositor/intern/COM_NodeBase.h +++ b/source/blender/compositor/intern/COM_NodeBase.h @@ -47,23 +47,23 @@ private: /** * @brief the list of actual inputsockets @see InputSocket */ - vector<InputSocket *> inputsockets; + vector<InputSocket *> m_inputsockets; /** * @brief the list of actual outputsockets @see OutputSocket */ - vector<OutputSocket *> outputsockets; + vector<OutputSocket *> m_outputsockets; protected: /** * @brief get access to the vector of input sockets */ - inline vector<InputSocket *>& getInputSockets() { return this->inputsockets; } + inline vector<InputSocket *>& getInputSockets() { return this->m_inputsockets; } /** * @brief get access to the vector of input sockets */ - inline vector<OutputSocket *>& getOutputSockets() { return this->outputsockets; } + inline vector<OutputSocket *>& getOutputSockets() { return this->m_outputsockets; } public: @@ -91,12 +91,12 @@ public: /** * @brief Return the number of input sockets of this node. */ - const unsigned int getNumberOfInputSockets() const { return this->inputsockets.size(); } + const unsigned int getNumberOfInputSockets() const { return this->m_inputsockets.size(); } /** * @brief Return the number of output sockets of this node. */ - const unsigned int getNumberOfOutputSockets() const { return this->outputsockets.size(); } + const unsigned int getNumberOfOutputSockets() const { return this->m_outputsockets.size(); } /** * get the reference to a certain outputsocket @@ -141,6 +141,11 @@ protected: */ void addOutputSocket(DataType datatype); void addOutputSocket(DataType datatype, bNodeSocket *socket); + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeBase") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index 33989fa5787..6ef8a5ff078 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -30,12 +30,12 @@ NodeOperation::NodeOperation() { - this->resolutionInputSocketIndex = 0; - this->complex = false; - this->width = 0; - this->height = 0; - this->openCL = false; - this->btree = NULL; + this->m_resolutionInputSocketIndex = 0; + this->m_complex = false; + this->m_width = 0; + this->m_height = 0; + this->m_openCL = false; + this->m_btree = NULL; } void NodeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -47,7 +47,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int for (unsigned int index = 0; index < inputsockets.size(); index++) { InputSocket *inputSocket = inputsockets[index]; if (inputSocket->isConnected()) { - if (index == this->resolutionInputSocketIndex) { + if (index == this->m_resolutionInputSocketIndex) { inputSocket->determineResolution(resolution, preferredResolution); temp2[0] = resolution[0]; temp2[1] = resolution[1]; @@ -58,7 +58,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int for (unsigned int index = 0; index < inputsockets.size(); index++) { InputSocket *inputSocket = inputsockets[index]; if (inputSocket->isConnected()) { - if (index != resolutionInputSocketIndex) { + if (index != this->m_resolutionInputSocketIndex) { inputSocket->determineResolution(temp, temp2); } } @@ -66,7 +66,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int } void NodeOperation::setResolutionInputSocketIndex(unsigned int index) { - this->resolutionInputSocketIndex = index; + this->m_resolutionInputSocketIndex = index; } void NodeOperation::initExecution() { @@ -75,22 +75,22 @@ void NodeOperation::initExecution() void NodeOperation::initMutex() { - BLI_mutex_init(&mutex); + BLI_mutex_init(&this->m_mutex); } void NodeOperation::lockMutex() { - BLI_mutex_lock(&mutex); + BLI_mutex_lock(&this->m_mutex); } void NodeOperation::unlockMutex() { - BLI_mutex_unlock(&mutex); + BLI_mutex_unlock(&this->m_mutex); } void NodeOperation::deinitMutex() { - BLI_mutex_end(&mutex); + BLI_mutex_end(&this->m_mutex); } void NodeOperation::deinitExecution() diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index f96b994685a..d316cfa0aa4 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -49,7 +49,7 @@ private: /** * @brief the index of the input socket that will be used to determine the resolution */ - unsigned int resolutionInputSocketIndex; + unsigned int m_resolutionInputSocketIndex; /** * @brief is this operation a complex one. @@ -57,13 +57,13 @@ private: * Complex operations are typically doing many reads to calculate the output of a single pixel. * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true. */ - bool complex; + bool m_complex; /** * @brief can this operation be scheduled on an OpenCL device. * @note Only applicable if complex is True */ - bool openCL; + bool m_openCL; /** * @brief mutex reference for very special node initializations @@ -74,12 +74,12 @@ private: * @see NodeOperation.deinitMutex deinitializes this mutex * @see NodeOperation.getMutex retrieve a pointer to this mutex. */ - ThreadMutex mutex; + ThreadMutex m_mutex; /** * @brief reference to the editing bNodeTree only used for break callback */ - const bNodeTree *btree; + const bNodeTree *m_btree; public: /** @@ -124,7 +124,7 @@ public: virtual int isBufferOperation() { return false; } virtual int isSingleThreaded() { return false; } - void setbNodeTree(const bNodeTree *tree) { this->btree = tree; } + void setbNodeTree(const bNodeTree *tree) { this->m_btree = tree; } virtual void initExecution(); /** @@ -167,7 +167,7 @@ public: virtual void deinitExecution(); bool isResolutionSet() { - return this->width != 0 && height != 0; + return this->m_width != 0 && this->m_height != 0; } /** @@ -176,8 +176,8 @@ public: */ void setResolution(unsigned int resolution[]) { if (!isResolutionSet()) { - this->width = resolution[0]; - this->height = resolution[1]; + this->m_width = resolution[0]; + this->m_height = resolution[1]; } } @@ -190,7 +190,7 @@ public: * Complex operations are typically doing many reads to calculate the output of a single pixel. * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true. */ - const bool isComplex() const { return this->complex; } + const bool isComplex() const { return this->m_complex; } virtual const bool isSetOperation() const { return false; } /** @@ -235,20 +235,20 @@ public: * @see WorkScheduler.schedule * @see ExecutionGroup.addOperation */ - bool isOpenCL() { return this->openCL; } + bool isOpenCL() { return this->m_openCL; } virtual bool isViewerOperation() { return false; } virtual bool isPreviewOperation() { return false; } inline bool isBreaked() { - return btree->test_break(btree->tbh); + return this->m_btree->test_break(this->m_btree->tbh); } protected: NodeOperation(); - void setWidth(unsigned int width) { this->width = width; } - void setHeight(unsigned int height) { this->height = height; } + void setWidth(unsigned int width) { this->m_width = width; } + void setHeight(unsigned int height) { this->m_height = height; } SocketReader *getInputSocketReader(unsigned int inputSocketindex); NodeOperation *getInputOperation(unsigned int inputSocketindex); @@ -264,12 +264,16 @@ protected: * Complex operations are typically doing many reads to calculate the output of a single pixel. * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true. */ - void setComplex(bool complex) { this->complex = complex; } + void setComplex(bool complex) { this->m_complex = complex; } /** * @brief set if this NodeOperation can be scheduled on a OpenCLDevice */ - void setOpenCL(bool openCL) { this->openCL = openCL; } + void setOpenCL(bool openCL) { this->m_openCL = openCL; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp index c9d27b8543c..eae1ffeb08a 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp @@ -23,28 +23,28 @@ #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) { - this->device = device; - this->context = context; - this->program = program; - this->queue = NULL; - this->vendorID = vendorId; + this->m_device = device; + this->m_context = context; + this->m_program = program; + this->m_queue = NULL; + this->m_vendorID = vendorId; } bool OpenCLDevice::initialize() { cl_int error; - queue = clCreateCommandQueue(context, device, 0, &error); + this->m_queue = clCreateCommandQueue(this->m_context, this->m_device, 0, &error); return false; } void OpenCLDevice::deinitialize() { - if (queue) { - clReleaseCommandQueue(queue); + if (this->m_queue) { + clReleaseCommandQueue(this->m_queue); } } @@ -76,8 +76,8 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, CL_FLOAT }; - cl_mem clBuffer = clCreateImage2D(this->context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), - result->getHeight(), 0, result->getBuffer(), &error); + cl_mem clBuffer = clCreateImage2D(this->m_context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), + result->getHeight(), 0, result->getBuffer(), &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } if (error == CL_SUCCESS) cleanup->push_back(clBuffer); @@ -124,7 +124,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo cl_int error; const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()}; - error = clEnqueueNDRangeKernel(this->queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } } @@ -139,7 +139,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo size_t size[2]; cl_int2 offset; - if (this->vendorID == NVIDIA){localSize = 32;} + if (this->m_vendorID == NVIDIA) {localSize = 32;} bool breaked = false; for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { offset[1] = offsety; @@ -160,9 +160,9 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - error = clEnqueueNDRangeKernel(this->queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - clFlush(this->queue); + clFlush(this->m_queue); if (operation->isBreaked()) { breaked = false; } @@ -173,7 +173,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp) { cl_int error; - cl_kernel kernel = clCreateKernel(this->program, kernelname, &error); + cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } else { if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel); diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h index d132f330651..30a90dabc3e 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.h +++ b/source/blender/compositor/intern/COM_OpenCLDevice.h @@ -38,27 +38,27 @@ private: /** * @brief opencl context */ - cl_context context; + cl_context m_context; /** * @brief opencl device */ - cl_device_id device; + cl_device_id m_device; /** * @brief opencl program */ - cl_program program; + cl_program m_program; /** * @brief opencl command queue */ - cl_command_queue queue; + cl_command_queue m_queue; /** * @brief opencl vendor ID */ - cl_int vendorID; + cl_int m_vendorID; public: /** @@ -91,9 +91,9 @@ public: */ void execute(WorkPackage *work); - cl_context getContext(){return this->context;} + cl_context getContext(){ return this->m_context; } - cl_command_queue getQueue(){return this->queue;} + cl_command_queue getQueue(){ return this->m_queue; } cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp index 484254fe6de..865ab0472e8 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.cpp +++ b/source/blender/compositor/intern/COM_OutputSocket.cpp @@ -31,7 +31,7 @@ OutputSocket::OutputSocket(DataType datatype) : Socket(datatype) } int OutputSocket::isOutputSocket() const { return true; } -const int OutputSocket::isConnected() const { return this->connections.size() != 0; } +const int OutputSocket::isConnected() const { return this->m_connections.size() != 0; } void OutputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { @@ -51,37 +51,37 @@ void OutputSocket::determineResolution(unsigned int resolution[], unsigned int p void OutputSocket::addConnection(SocketConnection *connection) { - this->connections.push_back(connection); + this->m_connections.push_back(connection); } void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single) { if (isConnected()) { if (single) { - SocketConnection *connection = this->connections[0]; + SocketConnection *connection = this->m_connections[0]; connection->setFromSocket(relinkToSocket); relinkToSocket->addConnection(connection); - this->connections.erase(this->connections.begin()); + this->m_connections.erase(this->m_connections.begin()); } else { unsigned int index; - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; connection->setFromSocket(relinkToSocket); relinkToSocket->addConnection(connection); } - this->connections.clear(); + this->m_connections.clear(); } } } void OutputSocket::removeFirstConnection() { - SocketConnection *connection = this->connections[0]; + SocketConnection *connection = this->m_connections[0]; InputSocket *inputSocket = connection->getToSocket(); if (inputSocket != NULL) { inputSocket->setConnection(NULL); } - this->connections.erase(this->connections.begin()); + this->m_connections.erase(this->m_connections.begin()); } void OutputSocket::clearConnections() @@ -94,8 +94,8 @@ void OutputSocket::clearConnections() WriteBufferOperation *OutputSocket::findAttachedWriteBufferOperation() const { unsigned int index; - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; NodeBase *node = connection->getToNode(); if (node->isOperation()) { NodeOperation *operation = (NodeOperation *)node; diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h index c073703c423..4810e1ae065 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.h +++ b/source/blender/compositor/intern/COM_OutputSocket.h @@ -42,7 +42,7 @@ class WriteBufferOperation; */ class OutputSocket : public Socket { private: - vector<SocketConnection *> connections; + vector<SocketConnection *> m_connections; void removeFirstConnection(); public: @@ -50,7 +50,7 @@ public: OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex); OutputSocket(OutputSocket *from); void addConnection(SocketConnection *connection); - SocketConnection *getConnection(unsigned int index) { return this->connections[index]; } + SocketConnection *getConnection(unsigned int index) { return this->m_connections[index]; } const int isConnected() const; int isOutputSocket() const; @@ -66,7 +66,7 @@ public: */ void relinkConnections(OutputSocket *relinkToSocket) { this->relinkConnections(relinkToSocket, false); }; void relinkConnections(OutputSocket *relinkToSocket, bool single); - const int getNumberOfConnections() { return connections.size(); } + const int getNumberOfConnections() { return this->m_connections.size(); } void clearConnections(); diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp index 01043664412..a6f81410b74 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp +++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp @@ -24,7 +24,7 @@ SingleThreadedNodeOperation::SingleThreadedNodeOperation() : NodeOperation() { - this->cachedInstance = NULL; + this->m_cachedInstance = NULL; setComplex(true); } @@ -35,26 +35,26 @@ void SingleThreadedNodeOperation::initExecution() void SingleThreadedNodeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - this->cachedInstance->read(color, x, y); + this->m_cachedInstance->read(color, x, y); } void SingleThreadedNodeOperation::deinitExecution() { deinitMutex(); - if (this->cachedInstance) { - delete cachedInstance; - this->cachedInstance = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; + this->m_cachedInstance = NULL; } } void *SingleThreadedNodeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cachedInstance) return this->cachedInstance; + if (this->m_cachedInstance) return this->m_cachedInstance; lockMutex(); - if (this->cachedInstance == NULL) { + if (this->m_cachedInstance == NULL) { // - this->cachedInstance = createMemoryBuffer(rect, memoryBuffers); + this->m_cachedInstance = createMemoryBuffer(rect, memoryBuffers); } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h index b1bf28c9c07..c6db5381f48 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h +++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h @@ -26,11 +26,11 @@ class SingleThreadedNodeOperation : public NodeOperation { private: - MemoryBuffer *cachedInstance; + MemoryBuffer *m_cachedInstance; protected: inline bool isCached() { - return cachedInstance != NULL; + return this->m_cachedInstance != NULL; } public: diff --git a/source/blender/compositor/intern/COM_Socket.cpp b/source/blender/compositor/intern/COM_Socket.cpp index 11739a4e9c5..30f28f9dddb 100644 --- a/source/blender/compositor/intern/COM_Socket.cpp +++ b/source/blender/compositor/intern/COM_Socket.cpp @@ -26,18 +26,18 @@ Socket::Socket(DataType datatype) { - this->datatype = datatype; - this->editorSocket = NULL; - this->node = NULL; + this->m_datatype = datatype; + this->m_editorSocket = NULL; + this->m_node = NULL; } DataType Socket::getDataType() const { - return this->datatype; + return this->m_datatype; } int Socket::isInputSocket() const { return false; } int Socket::isOutputSocket() const { return false; } const int Socket::isConnected() const { return false; } -void Socket::setNode(NodeBase *node) { this->node = node; } -NodeBase *Socket::getNode() const { return this->node; } +void Socket::setNode(NodeBase *node) { this->m_node = node; } +NodeBase *Socket::getNode() const { return this->m_node; } diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h index 7c5c2198a16..5607d2f4569 100644 --- a/source/blender/compositor/intern/COM_Socket.h +++ b/source/blender/compositor/intern/COM_Socket.h @@ -29,6 +29,10 @@ #include "DNA_node_types.h" #include "COM_defines.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + using namespace std; class SocketConnection; class NodeBase; @@ -49,15 +53,15 @@ private: /** * Reference to the node where this Socket belongs to */ - NodeBase *node; + NodeBase *m_node; /** * the datatype of this socket. Is used for automatically data transformation. * @section data-conversion */ - DataType datatype; + DataType m_datatype; - bNodeSocket *editorSocket; + bNodeSocket *m_editorSocket; public: Socket(DataType datatype); @@ -71,9 +75,12 @@ public: int isOutputSocket() const; virtual void determineResolution(int resolution[], unsigned int preferredResolution[]) {} - void setEditorSocket(bNodeSocket *editorSocket) { this->editorSocket = editorSocket; } - bNodeSocket *getbNodeSocket() const { return this->editorSocket; } + void setEditorSocket(bNodeSocket *editorSocket) { this->m_editorSocket = editorSocket; } + bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; } +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:Socket") +#endif }; diff --git a/source/blender/compositor/intern/COM_SocketConnection.cpp b/source/blender/compositor/intern/COM_SocketConnection.cpp index 1edeb6158b9..1f2cba72dc0 100644 --- a/source/blender/compositor/intern/COM_SocketConnection.cpp +++ b/source/blender/compositor/intern/COM_SocketConnection.cpp @@ -25,8 +25,8 @@ SocketConnection::SocketConnection() { - this->fromSocket = NULL; - this->toSocket = NULL; + this->m_fromSocket = NULL; + this->m_toSocket = NULL; this->setIgnoreResizeCheck(false); } @@ -35,19 +35,19 @@ void SocketConnection::setFromSocket(OutputSocket *fromsocket) if (fromsocket == NULL) { throw "ERROR"; } - this->fromSocket = fromsocket; + this->m_fromSocket = fromsocket; } -OutputSocket *SocketConnection::getFromSocket() const { return this->fromSocket; } +OutputSocket *SocketConnection::getFromSocket() const { return this->m_fromSocket; } void SocketConnection::setToSocket(InputSocket *tosocket) { if (tosocket == NULL) { throw "ERROR"; } - this->toSocket = tosocket; + this->m_toSocket = tosocket; } -InputSocket *SocketConnection::getToSocket() const { return this->toSocket; } +InputSocket *SocketConnection::getToSocket() const { return this->m_toSocket; } NodeBase *SocketConnection::getFromNode() const { @@ -79,10 +79,10 @@ bool SocketConnection::isValid() const bool SocketConnection::needsResolutionConversion() const { - if (this->ignoreResizeCheck) { return false; } + if (this->m_ignoreResizeCheck) { return false; } NodeOperation *fromOperation = (NodeOperation *)this->getFromNode(); NodeOperation *toOperation = (NodeOperation *)this->getToNode(); - if (this->toSocket->getResizeMode() == COM_SC_NO_RESIZE) { return false; } + if (this->m_toSocket->getResizeMode() == COM_SC_NO_RESIZE) { return false; } const unsigned int fromWidth = fromOperation->getWidth(); const unsigned int fromHeight = fromOperation->getHeight(); const unsigned int toWidth = toOperation->getWidth(); diff --git a/source/blender/compositor/intern/COM_SocketConnection.h b/source/blender/compositor/intern/COM_SocketConnection.h index 5385c5be49b..9777bd45be2 100644 --- a/source/blender/compositor/intern/COM_SocketConnection.h +++ b/source/blender/compositor/intern/COM_SocketConnection.h @@ -48,17 +48,17 @@ private: /** * @brief Startpoint of the connection */ - OutputSocket *fromSocket; + OutputSocket *m_fromSocket; /** * @brief Endpoint of the connection */ - InputSocket *toSocket; + InputSocket *m_toSocket; /** * @brief has the resize already been done for this connection */ - bool ignoreResizeCheck; + bool m_ignoreResizeCheck; public: SocketConnection(); @@ -104,12 +104,12 @@ public: /** * @brief set, whether the resize has already been done for this SocketConnection */ - void setIgnoreResizeCheck(bool check) { this->ignoreResizeCheck = check; } + void setIgnoreResizeCheck(bool check) { this->m_ignoreResizeCheck = check; } /** * @brief has the resize already been done for this SocketConnection */ - bool isIgnoreResizeCheck() const { return this->ignoreResizeCheck; } + bool isIgnoreResizeCheck() const { return this->m_ignoreResizeCheck; } /** * @brief does this SocketConnection need resolution conversion @@ -118,6 +118,10 @@ public: * @return needs conversion [true:false] */ bool needsResolutionConversion() const; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketConnection") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index 3eb39e4bf02..0f35fcfb0df 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -25,6 +25,10 @@ #include "BLI_rect.h" #include "COM_defines.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + typedef enum PixelSampler { COM_PS_NEAREST, COM_PS_BILINEAR, @@ -43,12 +47,12 @@ protected: /** * @brief Holds the width of the output of this operation. */ - unsigned int width; + unsigned int m_width; /** * @brief Holds the height of the output of this operation. */ - unsigned int height; + unsigned int m_height; /** @@ -104,8 +108,12 @@ public: virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; } - inline const unsigned int getWidth() const { return this->width; } - inline const unsigned int getHeight() const { return this->height; } -}; + inline const unsigned int getWidth() const { return this->m_width; } + inline const unsigned int getHeight() const { return this->m_height; } +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader") #endif +}; + +#endif /* _COM_SocketReader_h */ diff --git a/source/blender/compositor/intern/COM_WorkPackage.cpp b/source/blender/compositor/intern/COM_WorkPackage.cpp index 07974b9aafc..fa332ffa23e 100644 --- a/source/blender/compositor/intern/COM_WorkPackage.cpp +++ b/source/blender/compositor/intern/COM_WorkPackage.cpp @@ -24,6 +24,6 @@ WorkPackage::WorkPackage(ExecutionGroup *group, unsigned int chunkNumber) { - this->executionGroup = group; - this->chunkNumber = chunkNumber; + this->m_executionGroup = group; + this->m_chunkNumber = chunkNumber; } diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h index fed87186d20..953a164e95e 100644 --- a/source/blender/compositor/intern/COM_WorkPackage.h +++ b/source/blender/compositor/intern/COM_WorkPackage.h @@ -36,12 +36,12 @@ private: /** * @brief executionGroup with the operations-setup to be evaluated */ - ExecutionGroup *executionGroup; + ExecutionGroup *m_executionGroup; /** * @brief number of the chunk to be executed */ - unsigned int chunkNumber; + unsigned int m_chunkNumber; public: /** * @constructor @@ -53,12 +53,16 @@ public: /** * @brief get the ExecutionGroup */ - ExecutionGroup *getExecutionGroup() const { return this->executionGroup; } + ExecutionGroup *getExecutionGroup() const { return this->m_executionGroup; } /** * @brief get the number of the chunk */ - unsigned int getChunkNumber() const { return this->chunkNumber; } + unsigned int getChunkNumber() const { return this->m_chunkNumber; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkPackage") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index 619c5bea71e..c49ac24e018 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -43,24 +43,24 @@ /// @brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created -static vector<CPUDevice *> cpudevices; +static vector<CPUDevice *> g_cpudevices; #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE /// @brief list of all thread for every CPUDevice in cpudevices a thread exists -static ListBase cputhreads; +static ListBase g_cputhreads; /// @brief all scheduled work for the cpu -static ThreadQueue *cpuqueue; -static ThreadQueue *gpuqueue; +static ThreadQueue *g_cpuqueue; +static ThreadQueue *g_gpuqueue; #ifdef COM_OPENCL_ENABLED -static cl_context context; -static cl_program program; +static cl_context g_context; +static cl_program g_program; /// @brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is created -static vector<OpenCLDevice *> gpudevices; +static vector<OpenCLDevice *> g_gpudevices; /// @brief list of all thread for every GPUDevice in cpudevices a thread exists -static ListBase gputhreads; +static ListBase g_gputhreads; /// @brief all scheduled work for the gpu #ifdef COM_OPENCL_ENABLED -static bool openclActive = false; +static bool g_openclActive = false; #endif #endif #endif @@ -72,7 +72,7 @@ void *WorkScheduler::thread_execute_cpu(void *data) Device *device = (Device *)data; WorkPackage *work; - while ((work = (WorkPackage *)BLI_thread_queue_pop(cpuqueue))) { + while ((work = (WorkPackage *)BLI_thread_queue_pop(g_cpuqueue))) { device->execute(work); delete work; } @@ -85,7 +85,7 @@ void *WorkScheduler::thread_execute_gpu(void *data) Device *device = (Device *)data; WorkPackage *work; - while ((work = (WorkPackage *)BLI_thread_queue_pop(gpuqueue))) { + while ((work = (WorkPackage *)BLI_thread_queue_pop(g_gpuqueue))) { device->execute(work); delete work; } @@ -105,11 +105,11 @@ void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber) delete package; #elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE #ifdef COM_OPENCL_ENABLED - if (group->isOpenCL() && openclActive) { - BLI_thread_queue_push(gpuqueue, package); + if (group->isOpenCL() && g_openclActive) { + BLI_thread_queue_push(g_gpuqueue, package); } else { - BLI_thread_queue_push(cpuqueue, package); + BLI_thread_queue_push(g_cpuqueue, package); } #else BLI_thread_queue_push(cpuqueue, package); @@ -121,24 +121,24 @@ void WorkScheduler::start(CompositorContext &context) { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE unsigned int index; - cpuqueue = BLI_thread_queue_init(); - BLI_init_threads(&cputhreads, thread_execute_cpu, cpudevices.size()); - for (index = 0; index < cpudevices.size(); index++) { - Device *device = cpudevices[index]; - BLI_insert_thread(&cputhreads, device); + g_cpuqueue = BLI_thread_queue_init(); + BLI_init_threads(&g_cputhreads, thread_execute_cpu, g_cpudevices.size()); + for (index = 0; index < g_cpudevices.size(); index++) { + Device *device = g_cpudevices[index]; + BLI_insert_thread(&g_cputhreads, device); } #ifdef COM_OPENCL_ENABLED if (context.getHasActiveOpenCLDevices()) { - gpuqueue = BLI_thread_queue_init(); - BLI_init_threads(&gputhreads, thread_execute_gpu, gpudevices.size()); - for (index = 0; index < gpudevices.size(); index++) { - Device *device = gpudevices[index]; - BLI_insert_thread(&gputhreads, device); + g_gpuqueue = BLI_thread_queue_init(); + BLI_init_threads(&g_gputhreads, thread_execute_gpu, g_gpudevices.size()); + for (index = 0; index < g_gpudevices.size(); index++) { + Device *device = g_gpudevices[index]; + BLI_insert_thread(&g_gputhreads, device); } - openclActive = true; + g_openclActive = true; } else { - openclActive = false; + g_openclActive = false; } #endif #endif @@ -147,12 +147,12 @@ void WorkScheduler::finish() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE #ifdef COM_OPENCL_ENABLED - if (openclActive) { - BLI_thread_queue_wait_finish(gpuqueue); - BLI_thread_queue_wait_finish(cpuqueue); + if (g_openclActive) { + BLI_thread_queue_wait_finish(g_gpuqueue); + BLI_thread_queue_wait_finish(g_cpuqueue); } else { - BLI_thread_queue_wait_finish(cpuqueue); + BLI_thread_queue_wait_finish(g_cpuqueue); } #else BLI_thread_queue_wait_finish(cpuqueue); @@ -162,16 +162,16 @@ void WorkScheduler::finish() void WorkScheduler::stop() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE - BLI_thread_queue_nowait(cpuqueue); - BLI_end_threads(&cputhreads); - BLI_thread_queue_free(cpuqueue); - cpuqueue = NULL; + BLI_thread_queue_nowait(g_cpuqueue); + BLI_end_threads(&g_cputhreads); + BLI_thread_queue_free(g_cpuqueue); + g_cpuqueue = NULL; #ifdef COM_OPENCL_ENABLED - if (openclActive) { - BLI_thread_queue_nowait(gpuqueue); - BLI_end_threads(&gputhreads); - BLI_thread_queue_free(gpuqueue); - gpuqueue = NULL; + if (g_openclActive) { + BLI_thread_queue_nowait(g_gpuqueue); + BLI_end_threads(&g_gputhreads); + BLI_thread_queue_free(g_gpuqueue); + g_gpuqueue = NULL; } #endif #endif @@ -181,7 +181,7 @@ bool WorkScheduler::hasGPUDevices() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE #ifdef COM_OPENCL_ENABLED - return gpudevices.size() > 0; + return g_gpudevices.size() > 0; #else return 0; #endif @@ -203,11 +203,11 @@ void WorkScheduler::initialize() for (int index = 0; index < numberOfCPUThreads; index++) { CPUDevice *device = new CPUDevice(); device->initialize(); - cpudevices.push_back(device); + g_cpudevices.push_back(device); } #ifdef COM_OPENCL_ENABLED - context = NULL; - program = NULL; + g_context = NULL; + g_program = NULL; if (clCreateContextFromType) { cl_uint numberOfPlatforms = 0; cl_int error; @@ -225,18 +225,18 @@ void WorkScheduler::initialize() cl_device_id *cldevices = new cl_device_id[numberOfDevices]; clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0); - context = clCreateContext(NULL, numberOfDevices, cldevices, clContextError, NULL, &error); + g_context = clCreateContext(NULL, numberOfDevices, cldevices, clContextError, NULL, &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - program = clCreateProgramWithSource(context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); - error = clBuildProgram(program, numberOfDevices, cldevices, 0, 0, 0); + g_program = clCreateProgramWithSource(g_context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); + error = clBuildProgram(g_program, numberOfDevices, cldevices, 0, 0, 0); if (error != CL_SUCCESS) { cl_int error2; size_t ret_val_size = 0; printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); + error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } char *build_log = new char[ret_val_size + 1]; - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); + error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } build_log[ret_val_size] = '\0'; printf("%s", build_log); @@ -247,14 +247,14 @@ void WorkScheduler::initialize() for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) { cl_device_id device = cldevices[indexDevices]; cl_int vendorID = 0; - cl_int error = clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL); - if (error!= CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - OpenCLDevice *clDevice = new OpenCLDevice(context, device, program, vendorID); + cl_int error2 = clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error2, clewErrorString(error2)); } + OpenCLDevice *clDevice = new OpenCLDevice(g_context, device, g_program, vendorID); clDevice->initialize(); - gpudevices.push_back(clDevice); + g_gpudevices.push_back(clDevice); } } - delete cldevices; + delete[] cldevices; } } delete[] platforms; @@ -267,26 +267,26 @@ void WorkScheduler::deinitialize() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE Device *device; - while (cpudevices.size() > 0) { - device = cpudevices.back(); - cpudevices.pop_back(); + while (g_cpudevices.size() > 0) { + device = g_cpudevices.back(); + g_cpudevices.pop_back(); device->deinitialize(); delete device; } #ifdef COM_OPENCL_ENABLED - while (gpudevices.size() > 0) { - device = gpudevices.back(); - gpudevices.pop_back(); + while (g_gpudevices.size() > 0) { + device = g_gpudevices.back(); + g_gpudevices.pop_back(); device->deinitialize(); delete device; } - if (program) { - clReleaseProgram(program); - program = NULL; + if (g_program) { + clReleaseProgram(g_program); + g_program = NULL; } - if (context) { - clReleaseContext(context); - context = NULL; + if (g_context) { + clReleaseContext(g_context); + g_context = NULL; } #endif #endif diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h index e52e0295607..f56fe94201e 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.h +++ b/source/blender/compositor/intern/COM_WorkScheduler.h @@ -110,5 +110,10 @@ public: * @see CompositorContext.getHasActiveOpenCLDevices */ static bool hasGPUDevices(); -}; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkScheduler") #endif +}; + +#endif /* _COM_WorkScheduler_h_ */ diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index bec9ff95eed..7282cf65bc3 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -33,20 +33,22 @@ extern "C" { #include "COM_WorkScheduler.h" #include "OCL_opencl.h" -static ThreadMutex *compositorMutex; +static ThreadMutex compositorMutex; +static char is_compositorMutex_init = FALSE; void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) { - if (compositorMutex == NULL) { /// TODO: move to blender startup phase - compositorMutex = new ThreadMutex(); - BLI_mutex_init(compositorMutex); + if (is_compositorMutex_init == FALSE) { /// TODO: move to blender startup phase + memset(&compositorMutex, 0, sizeof(compositorMutex)); + BLI_mutex_init(&compositorMutex); OCL_init(); WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere + is_compositorMutex_init = TRUE; } - BLI_mutex_lock(compositorMutex); + BLI_mutex_lock(&compositorMutex); 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); + BLI_mutex_unlock(&compositorMutex); return; } @@ -60,5 +62,5 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) system->execute(); delete system; - BLI_mutex_unlock(compositorMutex); + BLI_mutex_unlock(&compositorMutex); } diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h index f7375d9a7c5..e25e9e11975 100644 --- a/source/blender/compositor/nodes/COM_AlphaOverNode.h +++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_AlphaOverNode_h -#define _COM_AlphaOverNode_h +#ifndef _COM_AlphaOverNode_h_ +#define _COM_AlphaOverNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h index e7daff1c414..95b0516dae0 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.h +++ b/source/blender/compositor/nodes/COM_BlurNode.h @@ -29,7 +29,6 @@ * @brief BlurNode * @ingroup Node */ - class BlurNode : public Node { public: BlurNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h index 5ce75a7d42b..c2bc7552ac0 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.h +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h @@ -29,7 +29,6 @@ * @brief BokehBlurNode * @ingroup Node */ - class BokehBlurNode : public Node { public: BokehBlurNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h index 45d03e18a6a..4efb06c9f87 100644 --- a/source/blender/compositor/nodes/COM_ChannelMatteNode.h +++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_ChannelMatteNODE_H -#define COM_ChannelMatteNODE_H +#ifndef _COM_ChannelMatteNode_h_ +#define _COM_ChannelMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief ChannelMatteNode * @ingroup Node */ -class ChannelMatteNode : public Node -{ +class ChannelMatteNode : public Node { public: ChannelMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h index ed8250b0329..ddd350aab40 100644 --- a/source/blender/compositor/nodes/COM_ChromaMatteNode.h +++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_ChromaMatteNODE_H -#define COM_ChromaMatteNODE_H +#ifndef _COM_ChromaMatteNode_h_ +#define _COM_ChromaMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief ChromaMatteNode * @ingroup Node */ -class ChromaMatteNode : public Node -{ +class ChromaMatteNode : public Node { public: ChromaMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h index c2bdc306e20..cdad02fc831 100644 --- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_ColorBalanceNODE_H -#define COM_ColorBalanceNODE_H +#ifndef _COM_ColorBalanceNode_h_ +#define _COM_ColorBalanceNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief ColorBalanceNode * @ingroup Node */ -class ColorBalanceNode : public Node -{ +class ColorBalanceNode : public Node { public: ColorBalanceNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h index 375c914a122..92a4fa79408 100644 --- a/source/blender/compositor/nodes/COM_ColorMatteNode.h +++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_ColorMatteNODE_H -#define COM_ColorMatteNODE_H +#ifndef _COM_ColorMatteNode_h_ +#define _COM_ColorMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief ColorMatteNode * @ingroup Node */ -class ColorMatteNode : public Node -{ +class ColorMatteNode : public Node { public: ColorMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h index 4d706e126e1..6c256c09e68 100644 --- a/source/blender/compositor/nodes/COM_ColorRampNode.h +++ b/source/blender/compositor/nodes/COM_ColorRampNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_ColorRampNODE_H -#define COM_ColorRampNODE_H +#ifndef _COM_ColorRampNode_h_ +#define _COM_ColorRampNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief ColorRampNode * @ingroup Node */ -class ColorRampNode : public Node -{ +class ColorRampNode : public Node { public: ColorRampNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h index d8ce6878fa0..1d976fc65ae 100644 --- a/source/blender/compositor/nodes/COM_ColorSpillNode.h +++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_ColorSpillNODE_H -#define COM_ColorSpillNODE_H +#ifndef _COM_ColorSpillNode_h_ +#define _COM_ColorSpillNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief ColorSpillNode * @ingroup Node */ -class ColorSpillNode : public Node -{ +class ColorSpillNode : public Node { public: ColorSpillNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h index 34a157c73d8..9262634edda 100644 --- a/source/blender/compositor/nodes/COM_ColorToBWNode.h +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_ColourToBWNode_h -#define _COM_ColourToBWNode_h +#ifndef _COM_ColourToBWNode_h_ +#define _COM_ColourToBWNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.h b/source/blender/compositor/nodes/COM_CombineHSVANode.h index d8aba71d456..95d3cf9ecdd 100644 --- a/source/blender/compositor/nodes/COM_CombineHSVANode.h +++ b/source/blender/compositor/nodes/COM_CombineHSVANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_CombineHSVANode_h -#define _COM_CombineHSVANode_h +#ifndef _COM_CombineHSVANode_h_ +#define _COM_CombineHSVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.h b/source/blender/compositor/nodes/COM_CombineRGBANode.h index 1f25d8deed9..5cc0b1ea6da 100644 --- a/source/blender/compositor/nodes/COM_CombineRGBANode.h +++ b/source/blender/compositor/nodes/COM_CombineRGBANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_CombineRGBANode_h -#define _COM_CombineRGBANode_h +#ifndef _COM_CombineRGBANode_h_ +#define _COM_CombineRGBANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.h b/source/blender/compositor/nodes/COM_CombineYCCANode.h index 3b143aabc7f..6ff2938c161 100644 --- a/source/blender/compositor/nodes/COM_CombineYCCANode.h +++ b/source/blender/compositor/nodes/COM_CombineYCCANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_CombineYCCANode_h -#define _COM_CombineYCCANode_h +#ifndef _COM_CombineYCCANode_h_ +#define _COM_CombineYCCANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.h b/source/blender/compositor/nodes/COM_CombineYUVANode.h index 1eae44c83a5..e3d8f36a5dd 100644 --- a/source/blender/compositor/nodes/COM_CombineYUVANode.h +++ b/source/blender/compositor/nodes/COM_CombineYUVANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_CombineYUVANode_h -#define _COM_CombineYUVANode_h +#ifndef _COM_CombineYUVANode_h_ +#define _COM_CombineYUVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h index 585dae7761e..54d52d7db9e 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.h +++ b/source/blender/compositor/nodes/COM_CompositorNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_CompositorNode_h -#define _COM_CompositorNode_h +#ifndef _COM_CompositorNode_h_ +#define _COM_CompositorNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h index d9077c23a02..a80f8de1607 100644 --- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h +++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_ConvertAlphaNode_h -#define _COM_ConvertAlphaNode_h +#ifndef _COM_ConvertAlphaNode_h_ +#define _COM_ConvertAlphaNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h index 44fdeecc180..1003728a9d4 100644 --- a/source/blender/compositor/nodes/COM_CropNode.h +++ b/source/blender/compositor/nodes/COM_CropNode.h @@ -25,6 +25,10 @@ #include "COM_Node.h" +/** + * @brief CropNode + * @ingroup Node + */ class CropNode : public Node { public: CropNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h index a3cffbd98c4..7d69b6413bb 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.h +++ b/source/blender/compositor/nodes/COM_DefocusNode.h @@ -29,7 +29,6 @@ * @brief DefocusNode * @ingroup Node */ - class DefocusNode : public Node { public: DefocusNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h index faaf235bf34..191b7361c3c 100644 --- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h +++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_DifferenceMatteNODE_H -#define COM_DifferenceMatteNODE_H +#ifndef _COM_DifferenceMatteNode_h_ +#define _COM_DifferenceMatteNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief DifferenceMatteNode * @ingroup Node */ -class DifferenceMatteNode : public Node -{ +class DifferenceMatteNode : public Node { public: DifferenceMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp index 285bfa0470e..3f4e3736bbe 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -77,7 +77,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont CompositorQuality quality = context->getQuality(); /* initialize node data */ - NodeBlurData *data = (NodeBlurData *)&this->alpha_blur; + NodeBlurData *data = (NodeBlurData *)&this->m_alpha_blur; memset(data, 0, sizeof(*data)); data->filtertype = R_FILTER_GAUSS; @@ -119,9 +119,9 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont operationy->setSubtract(editorNode->custom2 < 0); if (editorNode->storage) { - NodeDilateErode *data = (NodeDilateErode *)editorNode->storage; - operationx->setFalloff(data->falloff); - operationy->setFalloff(data->falloff); + NodeDilateErode *data_storage = (NodeDilateErode *)editorNode->storage; + operationx->setFalloff(data_storage->falloff); + operationy->setFalloff(data_storage->falloff); } } else { diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h index ac374d7375b..4b02042ffc9 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.h +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h @@ -30,7 +30,7 @@ * @ingroup Node */ class DilateErodeNode : public Node { - NodeBlurData alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ + NodeBlurData m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ public: DilateErodeNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.h b/source/blender/compositor/nodes/COM_DisplaceNode.h index ecbe07b06b9..af6afc25366 100644 --- a/source/blender/compositor/nodes/COM_DisplaceNode.h +++ b/source/blender/compositor/nodes/COM_DisplaceNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_DisplaceNode_h -#define _COM_DisplaceNode_h +#ifndef _COM_DisplaceNode_h_ +#define _COM_DisplaceNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h index 42582ef10a0..4e6682424e8 100644 --- a/source/blender/compositor/nodes/COM_DistanceMatteNode.h +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_DistanceMatteNODE_H -#define COM_DistanceMatteNODE_H +#ifndef _COM_DistanceMatteNode_h_ +#define _COM_DistanceMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief DistanceMatteNode * @ingroup Node */ -class DistanceMatteNode : public Node -{ +class DistanceMatteNode : public Node { public: DistanceMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h index 17f590b9cfc..d65166944d8 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.h +++ b/source/blender/compositor/nodes/COM_FilterNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_FILTERNODE_H -#define COM_FILTERNODE_H +#ifndef _COM_FilterNode_h_ +#define _COM_FilterNode_h_ #include "COM_Node.h" @@ -29,11 +29,10 @@ * @brief FilterNode * @ingroup Node */ -class FilterNode : public Node -{ +class FilterNode : public Node { public: FilterNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; -#endif // COM_FILTERNODE_H +#endif // _COM_FilterNode_h_ diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h index ed5f2b51ce3..dd5f70f6579 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_HueSaturationValueCorrectNode_h -#define _COM_HueSaturationValueCorrectNode_h +#ifndef _COM_HueSaturationValueCorrectNode_h_ +#define _COM_HueSaturationValueCorrectNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h index 92c18019196..47b89a35269 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_HueSaturationValueNode_h -#define _COM_HueSaturationValueNode_h +#ifndef _COM_HueSaturationValueNode_h_ +#define _COM_HueSaturationValueNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h index 384dd6c09ff..49006efbed5 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.h +++ b/source/blender/compositor/nodes/COM_ImageNode.h @@ -34,7 +34,6 @@ extern "C" { * @ingroup Node */ class ImageNode : public Node { - private: NodeOperation *doMultilayerCheck(ExecutionSystem *system, RenderLayer *rl, Image *image, ImageUser *user, int framenumber, int outputsocketIndex, int pass, DataType datatype); public: diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index 50c1903982e..cc6fc6e1236 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -34,13 +34,15 @@ #include "COM_CombineChannelsOperation.h" #include "COM_ConvertRGBToYCCOperation.h" #include "COM_ConvertYCCToRGBOperation.h" -#include "COM_GaussianBokehBlurOperation.h" #include "COM_SetValueOperation.h" #include "COM_DilateErodeOperation.h" #include "COM_SetAlphaOperation.h" +#include "COM_GaussianAlphaXBlurOperation.h" +#include "COM_GaussianAlphaYBlurOperation.h" + KeyingNode::KeyingNode(bNode *editorNode) : Node(editorNode) { /* pass */ @@ -67,13 +69,21 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); } else { - KeyingBlurOperation *blurOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); + + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); + + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); - blurOperation->setSize(size); + addLink(graph, separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0)); + addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); + addLink(graph, blurYOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); - addLink(graph, separateOperation->getOutputSocket(0), blurOperation->getInputSocket(0)); - addLink(graph, blurOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); - graph->addOperation(blurOperation); + graph->addOperation(blurXOperation); + graph->addOperation(blurYOperation); } } @@ -87,30 +97,37 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu return convertYCCToRGBOperation->getOutputSocket(0); } -OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size) +OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size) { - KeyingBlurOperation *blurOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); - blurOperation->setSize(size); + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); - addLink(graph, postBLurInput, blurOperation->getInputSocket(0)); + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); - graph->addOperation(blurOperation); + addLink(graph, postBlurInput, blurXOperation->getInputSocket(0)); + addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); - return blurOperation->getOutputSocket(); + graph->addOperation(blurXOperation); + graph->addOperation(blurYOperation); + + return blurYOperation->getOutputSocket(); } OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance) { - DilateStepOperation *dilateErodeOperation; + DilateDistanceOperation *dilateErodeOperation; if (distance > 0) { - dilateErodeOperation = new DilateStepOperation(); - dilateErodeOperation->setIterations(distance); + dilateErodeOperation = new DilateDistanceOperation(); + dilateErodeOperation->setDistance(distance); } else { - dilateErodeOperation = new ErodeStepOperation(); - dilateErodeOperation->setIterations(-distance); + dilateErodeOperation = new ErodeDistanceOperation(); + dilateErodeOperation->setDistance(-distance); } addLink(graph, dilateErodeInput, dilateErodeOperation->getInputSocket(0)); @@ -120,6 +137,46 @@ OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket return dilateErodeOperation->getOutputSocket(0); } +OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext *context, + OutputSocket *featherInput, int falloff, int distance) +{ + /* this uses a modified gaussian blur function otherwise its far too slow */ + CompositorQuality quality = context->getQuality(); + + /* initialize node data */ + NodeBlurData *data = (NodeBlurData *)&this->m_alpha_blur; + memset(data, 0, sizeof(*data)); + data->filtertype = R_FILTER_GAUSS; + + if (distance > 0) { + data->sizex = data->sizey = distance; + } + else { + data->sizex = data->sizey = -distance; + } + + GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setData(data); + operationx->setQuality(quality); + operationx->setSize(1.0f); + operationx->setSubtract(distance < 0); + operationx->setFalloff(falloff); + graph->addOperation(operationx); + + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setData(data); + operationy->setQuality(quality); + operationy->setSize(1.0f); + operationy->setSubtract(distance < 0); + operationy->setFalloff(falloff); + graph->addOperation(operationy); + + addLink(graph, featherInput, operationx->getInputSocket(0)); + addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); + + return operationy->getOutputSocket(); +} + OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, float factor) { KeyingDespillOperation *despillOperation = new KeyingDespillOperation(); @@ -162,7 +219,7 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * OutputSocket *outputImage = this->getOutputSocket(0); OutputSocket *outputMatte = this->getOutputSocket(1); OutputSocket *outputEdges = this->getOutputSocket(2); - OutputSocket *postprocessedMatte, *postprocessedImage, *originalImage, *edgesMatte; + OutputSocket *postprocessedMatte = NULL, *postprocessedImage = NULL, *originalImage = NULL, *edgesMatte = NULL; bNode *editorNode = this->getbNode(); NodeKeyingData *keying_data = (NodeKeyingData *) editorNode->storage; @@ -196,9 +253,11 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * keying_data->clip_black, keying_data->clip_white, false); } - edgesMatte = setupClip(graph, postprocessedMatte, - keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance, - keying_data->clip_black, keying_data->clip_white, true); + if (outputEdges->isConnected()) { + edgesMatte = setupClip(graph, postprocessedMatte, + keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance, + keying_data->clip_black, keying_data->clip_white, true); + } /* apply blur on matte if needed */ if (keying_data->blur_post) @@ -209,6 +268,12 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * postprocessedMatte = setupDilateErode(graph, postprocessedMatte, keying_data->dilate_distance); } + /* matte feather */ + if (keying_data->feather_distance != 0) { + postprocessedMatte = setupFeather(graph, context, postprocessedMatte, keying_data->feather_falloff, + keying_data->feather_distance); + } + /* set alpha channel to output image */ SetAlphaOperation *alphaOperation = new SetAlphaOperation(); addLink(graph, originalImage, alphaOperation->getInputSocket(0)); @@ -226,7 +291,9 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * /* connect result to output sockets */ outputImage->relinkConnections(postprocessedImage); outputMatte->relinkConnections(postprocessedMatte); - outputEdges->relinkConnections(edgesMatte); + + if (edgesMatte) + outputEdges->relinkConnections(edgesMatte); graph->addOperation(alphaOperation); } diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h index cc1d447c66e..294a27bb52c 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.h +++ b/source/blender/compositor/nodes/COM_KeyingNode.h @@ -24,14 +24,18 @@ #include "COM_Node.h" /** - * @brief KeyingNode - * @ingroup Node - */ + * @brief KeyingNode + * @ingroup Node + */ class KeyingNode : public Node { protected: + NodeBlurData m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ + OutputSocket *setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage); - OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size); + OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size); OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance); + OutputSocket *setupFeather(ExecutionSystem *graph, CompositorContext *context, OutputSocket *featherInput, + int falloff, int distance); OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, float factor); OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance, float clipBlack, float clipWhite, bool edgeMatte); diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.h b/source/blender/compositor/nodes/COM_KeyingScreenNode.h index 7c87219ef6e..9b8ac88bb6e 100644 --- a/source/blender/compositor/nodes/COM_KeyingScreenNode.h +++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.h @@ -25,9 +25,9 @@ #include "DNA_node_types.h" /** - * @brief KeyingScreenNode - * @ingroup Node - */ + * @brief KeyingScreenNode + * @ingroup Node + */ class KeyingScreenNode : public Node { public: KeyingScreenNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h index c699a0d1168..37f3c31113f 100644 --- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h +++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_LuminanceMatteNODE_H -#define COM_LuminanceMatteNODE_H +#ifndef _COM_LuminanceMatteNode_h_ +#define _COM_LuminanceMatteNode_h_ #include "COM_Node.h" @@ -28,11 +28,10 @@ * @brief LuminanceMatteNode * @ingroup Node */ -class LuminanceMatteNode : public Node -{ +class LuminanceMatteNode : public Node { public: LuminanceMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; -#endif // COM_LuminanceMatteNODE_H +#endif // _COM_LuminanceMatteNode_h_ diff --git a/source/blender/compositor/nodes/COM_MapUVNode.h b/source/blender/compositor/nodes/COM_MapUVNode.h index a1df790f192..2e5616e0bd0 100644 --- a/source/blender/compositor/nodes/COM_MapUVNode.h +++ b/source/blender/compositor/nodes/COM_MapUVNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_MapUVNode_h -#define _COM_MapUVNode_h +#ifndef _COM_MapUVNode_h_ +#define _COM_MapUVNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h index c7a842dff95..22aa5459ec0 100644 --- a/source/blender/compositor/nodes/COM_MapValueNode.h +++ b/source/blender/compositor/nodes/COM_MapValueNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_MapValueNode_h -#define _COM_MapValueNode_h +#ifndef _COM_MapValueNode_h_ +#define _COM_MapValueNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" @@ -34,4 +34,5 @@ public: MapValueNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; -#endif + +#endif // _COM_MapValueNode_h_ diff --git a/source/blender/compositor/nodes/COM_MaskNode.h b/source/blender/compositor/nodes/COM_MaskNode.h index 8a9bc50eac7..cdd5d3c362e 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.h +++ b/source/blender/compositor/nodes/COM_MaskNode.h @@ -21,6 +21,9 @@ * Sergey Sharybin */ +#ifndef _COM_MaskNode_h_ +#define _COM_MaskNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -29,10 +32,10 @@ * @ingroup Node */ class MaskNode : public Node { - - public: MaskNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; + +#endif // _COM_MaskNode_h_ diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp index 6e9b49253e7..300c9967cc4 100644 --- a/source/blender/compositor/nodes/COM_MathNode.cpp +++ b/source/blender/compositor/nodes/COM_MathNode.cpp @@ -28,8 +28,7 @@ void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co { MathBaseOperation *operation = NULL; - switch (this->getbNode()->custom1) - { + switch (this->getbNode()->custom1) { case 0: /* Add */ operation = new MathAddOperation(); break; diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h index 16d65843b0d..4f8e64754e7 100644 --- a/source/blender/compositor/nodes/COM_MathNode.h +++ b/source/blender/compositor/nodes/COM_MathNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_MathNode_h -#define _COM_MathNode_h +#ifndef _COM_MathNode_h_ +#define _COM_MathNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h index 99e8b4d48f0..76076d01427 100644 --- a/source/blender/compositor/nodes/COM_MixNode.h +++ b/source/blender/compositor/nodes/COM_MixNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_MixNode_h -#define _COM_MixNode_h +#ifndef _COM_MixNode_h_ +#define _COM_MixNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h index d70881a6725..52ea11ea8e9 100644 --- a/source/blender/compositor/nodes/COM_MovieClipNode.h +++ b/source/blender/compositor/nodes/COM_MovieClipNode.h @@ -20,6 +20,9 @@ * Monique Dewanchand */ +#ifndef _COM_MovieClipNode_h_ +#define _COM_MovieClipNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -28,10 +31,9 @@ * @ingroup Node */ class MovieClipNode : public Node { - - public: MovieClipNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); - }; + +#endif // _COM_MovieClipNode_h_ diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h index bf684298e65..660d90040bd 100644 --- a/source/blender/compositor/nodes/COM_NormalNode.h +++ b/source/blender/compositor/nodes/COM_NormalNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_NORMALNODE_H -#define COM_NORMALNODE_H +#ifndef _COM_NormalNode_h_ +#define _COM_NormalNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief NormalNode * @ingroup Node */ -class NormalNode : public Node -{ +class NormalNode : public Node { public: NormalNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h index 79c9b577643..e3194436f7f 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.h +++ b/source/blender/compositor/nodes/COM_OutputFileNode.h @@ -21,8 +21,8 @@ * Lukas Tönne */ -#ifndef _COM_OutputFileNode_h -#define _COM_OutputFileNode_h +#ifndef _COM_OutputFileNode_h_ +#define _COM_OutputFileNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.h b/source/blender/compositor/nodes/COM_SeparateHSVANode.h index 4a7e86849dc..6199237ebda 100644 --- a/source/blender/compositor/nodes/COM_SeparateHSVANode.h +++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SeparateHSVANode_h -#define _COM_SeparateHSVANode_h +#ifndef _COM_SeparateHSVANode_h_ +#define _COM_SeparateHSVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.h b/source/blender/compositor/nodes/COM_SeparateRGBANode.h index c1be02753da..35321304d99 100644 --- a/source/blender/compositor/nodes/COM_SeparateRGBANode.h +++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SeparateRGBANode_h -#define _COM_SeparateRGBANode_h +#ifndef _COM_SeparateRGBANode_h_ +#define _COM_SeparateRGBANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.h b/source/blender/compositor/nodes/COM_SeparateYCCANode.h index 4b216841e2a..542e1693932 100644 --- a/source/blender/compositor/nodes/COM_SeparateYCCANode.h +++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_SeparateYCCANode_h -#define _COM_SeparateYCCANode_h +#ifndef _COM_SeparateYCCANode_h_ +#define _COM_SeparateYCCANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.h b/source/blender/compositor/nodes/COM_SeparateYUVANode.h index e1763e37dff..e51c0ce4fa6 100644 --- a/source/blender/compositor/nodes/COM_SeparateYUVANode.h +++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_SeparateYUVANode_h -#define _COM_SeparateYUVANode_h +#ifndef _COM_SeparateYUVANode_h_ +#define _COM_SeparateYUVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h index 0707cf5dac1..e82fa210a89 100644 --- a/source/blender/compositor/nodes/COM_SetAlphaNode.h +++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SetAlphaNode_h -#define _COM_SetAlphaNode_h +#ifndef _COM_SetAlphaNode_h_ +#define _COM_SetAlphaNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h index 6c532d4e813..f17cfd57cbf 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.h +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SplitViewerNode_h -#define _COM_SplitViewerNode_h +#ifndef _COM_SplitViewerNode_h_ +#define _COM_SplitViewerNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h index 589e090b48c..3363ff4142c 100644 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.h +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h @@ -20,6 +20,9 @@ * Monique Dewanchand */ +#ifndef _COM_Stabilize2dNode_h_ +#define _COM_Stabilize2dNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -32,3 +35,5 @@ public: Stabilize2dNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; + +#endif diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h index be3d54c3000..16d9e18885b 100644 --- a/source/blender/compositor/nodes/COM_SwitchNode.h +++ b/source/blender/compositor/nodes/COM_SwitchNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SwitchNode_h -#define _COM_SwitchNode_h +#ifndef _COM_SwitchNode_h_ +#define _COM_SwitchNode_h_ #include "COM_Node.h" #include "COM_NodeOperation.h" diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h index da40b655f29..57a7a0229ec 100644 --- a/source/blender/compositor/nodes/COM_TransformNode.h +++ b/source/blender/compositor/nodes/COM_TransformNode.h @@ -20,6 +20,9 @@ * Monique Dewanchand */ +#ifndef _COM_TransformNode_h_ +#define _COM_TransformNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -32,3 +35,5 @@ public: TransformNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; + +#endif // _COM_TransformNode_h_ diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h index e1f1226f1f1..3a9954b8aea 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.h +++ b/source/blender/compositor/nodes/COM_ViewerNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_ViewerNode_h -#define _COM_ViewerNode_h +#ifndef _COM_ViewerNode_h_ +#define _COM_ViewerNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h index a2ceedfc2cd..61f4037be90 100644 --- a/source/blender/compositor/nodes/COM_ZCombineNode.h +++ b/source/blender/compositor/nodes/COM_ZCombineNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_ZCombineNode_h -#define _COM_ZCombineNode_h +#ifndef _COM_ZCombineNode_h_ +#define _COM_ZCombineNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp index e614e1fa15a..e688332a039 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp @@ -33,9 +33,9 @@ void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, P float inputOverColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(outputValue, inputColor1); diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp index 81c1e4d2587..e56fb9151f2 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp @@ -24,7 +24,7 @@ AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation() { - this->x = 0.0f; + this->m_x = 0.0f; } void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -33,9 +33,9 @@ void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float float inputOverColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(outputValue, inputColor1); @@ -44,7 +44,7 @@ void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float copy_v4_v4(outputValue, inputOverColor); } else { - float addfac = 1.0f - this->x + inputOverColor[3] * this->x; + float addfac = 1.0f - this->m_x + inputOverColor[3] * this->m_x; float premul = value[0] * addfac; float mul = 1.0f - value[0] * inputOverColor[3]; diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h index 2807b3b489a..24a991da17b 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_AlphaOverMixedOperation_h -#define _COM_AlphaOverMixedOperation_h +#ifndef _COM_AlphaOverMixedOperation_h_ +#define _COM_AlphaOverMixedOperation_h_ #include "COM_MixBaseOperation.h" @@ -31,7 +31,7 @@ */ class AlphaOverMixedOperation : public MixBaseOperation { private: - float x; + float m_x; public: /** * Default constructor @@ -43,6 +43,6 @@ public: */ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); - void setX(float x) { this->x = x; } + void setX(float x) { this->m_x = x; } }; #endif diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp index a6bf8b8834c..b2c40a058ba 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp @@ -33,9 +33,9 @@ void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, fl float inputOverColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); /* Zero alpha values should still permit an add of RGB data */ if (inputOverColor[3] < 0.0f) { diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp index 458d11f2616..46fa07893e8 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp @@ -32,33 +32,33 @@ AntiAliasOperation::AntiAliasOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->valueReader = NULL; - this->buffer = NULL; + this->m_valueReader = NULL; + this->m_buffer = NULL; this->setComplex(true); } void AntiAliasOperation::initExecution() { - this->valueReader = this->getInputSocketReader(0); + this->m_valueReader = this->getInputSocketReader(0); NodeOperation::initMutex(); } void AntiAliasOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - if (y < 0 || (unsigned int)y >= this->height || x < 0 || (unsigned int)x >= this->width) { + if (y < 0 || (unsigned int)y >= this->m_height || x < 0 || (unsigned int)x >= this->m_width) { color[0] = 0.0f; } else { - int offset = y * this->width + x; - color[0] = buffer[offset] / 255.0f; + int offset = y * this->m_width + x; + color[0] = this->m_buffer[offset] / 255.0f; } } void AntiAliasOperation::deinitExecution() { - this->valueReader = NULL; - if (this->buffer) { - delete buffer; + this->m_valueReader = NULL; + if (this->m_buffer) { + delete this->m_buffer; } NodeOperation::deinitMutex(); } @@ -66,7 +66,7 @@ void AntiAliasOperation::deinitExecution() bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti imageInput; - if (this->buffer) { + if (this->m_buffer) { return false; } else { @@ -84,10 +84,10 @@ bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe void *AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->buffer) {return buffer; } + if (this->m_buffer) { return this->m_buffer; } lockMutex(); - if (this->buffer == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)valueReader->initializeTileData(rect, memoryBuffers); + if (this->m_buffer == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_valueReader->initializeTileData(rect, memoryBuffers); int size = tile->getHeight() * tile->getWidth(); float *input = tile->getBuffer(); char *valuebuffer = new char[size]; @@ -98,8 +98,8 @@ void *AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu valuebuffer[i] = in * 255; } antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer); - this->buffer = valuebuffer; + this->m_buffer = valuebuffer; } unlockMutex(); - return this->buffer; + return this->m_buffer; } diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h index 906da598da1..3d9bcf6d90a 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.h +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h @@ -35,8 +35,8 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *valueReader; - char *buffer; + SocketReader *m_valueReader; + char *m_buffer; public: AntiAliasOperation(); diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp index 3628c399581..4f7f5eea8a0 100644 --- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp @@ -34,15 +34,15 @@ BilateralBlurOperation::BilateralBlurOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputColorProgram = NULL; - this->inputDeterminatorProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputDeterminatorProgram = NULL; } void BilateralBlurOperation::initExecution() { - this->inputColorProgram = getInputSocketReader(0); - this->inputDeterminatorProgram = getInputSocketReader(1); - this->space = this->data->sigma_space + this->data->iter; + this->m_inputColorProgram = getInputSocketReader(0); + this->m_inputDeterminatorProgram = getInputSocketReader(1); + this->m_space = this->m_data->sigma_space + this->m_data->iter; QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -54,27 +54,27 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff float tempColor[4]; float blurColor[4]; float blurDivider; - float space = this->space; - float sigmacolor = this->data->sigma_color; + float space = this->m_space; + float sigmacolor = this->m_data->sigma_color; int minx = floor(x - space); int maxx = ceil(x + space); int miny = floor(y - space); int maxy = ceil(y + space); float deltaColor; - this->inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data); + this->m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data); zero_v4(blurColor); blurDivider = 0.0f; for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) { for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) { // read determinator - this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data); + this->m_inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data); deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) + fabsf(determinatorReferenceColor[1] - determinator[1]) + fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account if (deltaColor < sigmacolor) { // add this to the blur - this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data); + this->m_inputColorProgram->read(tempColor, xi, yi, inputBuffers, data); add_v4_v4(blurColor, tempColor); blurDivider += 1.0f; } @@ -94,14 +94,14 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff void BilateralBlurOperation::deinitExecution() { - this->inputColorProgram = NULL; - this->inputDeterminatorProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputDeterminatorProgram = NULL; } bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - int add = ceil(this->space) + 1; + int add = ceil(this->m_space) + 1; newInput.xmax = input->xmax + (add); newInput.xmin = input->xmin - (add); diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h index 08b379dc4ea..be6ce7a221e 100644 --- a/source/blender/compositor/operations/COM_BilateralBlurOperation.h +++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h @@ -27,10 +27,10 @@ class BilateralBlurOperation : public NodeOperation, public QualityStepHelper { private: - SocketReader *inputColorProgram; - SocketReader *inputDeterminatorProgram; - NodeBilateralBlurData *data; - float space; + SocketReader *m_inputColorProgram; + SocketReader *m_inputDeterminatorProgram; + NodeBilateralBlurData *m_data; + float m_space; public: BilateralBlurOperation(); @@ -52,6 +52,6 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setData(NodeBilateralBlurData *data) { this->data = data; } + void setData(NodeBilateralBlurData *data) { this->m_data = data; } }; #endif diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index df64b7c8ddc..696c0748d69 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -27,37 +27,38 @@ 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); this->setComplex(true); - this->inputProgram = NULL; - this->data = NULL; - this->size = 1.0f; - this->deleteData = false; - this->sizeavailable = false; + this->m_inputProgram = NULL; + this->m_data = NULL; + this->m_size = 1.0f; + this->m_deleteData = false; + this->m_sizeavailable = false; } void BlurBaseOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->inputSize = this->getInputSocketReader(1); - this->data->image_in_width = this->getWidth(); - this->data->image_in_height = this->getHeight(); - if (this->data->relative) { - switch (this->data->aspect) { + this->m_inputProgram = this->getInputSocketReader(0); + this->m_inputSize = this->getInputSocketReader(1); + this->m_data->image_in_width = this->getWidth(); + this->m_data->image_in_height = this->getHeight(); + if (this->m_data->relative) { + switch (this->m_data->aspect) { case CMP_NODE_BLUR_ASPECT_NONE: - this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width); - this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height); + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height); break; case CMP_NODE_BLUR_ASPECT_Y: - this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width); - this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_width); + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_width); break; case CMP_NODE_BLUR_ASPECT_X: - this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_height); - this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height); + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_height); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height); break; } } @@ -77,7 +78,7 @@ float *BlurBaseOperation::make_gausstab(int rad) sum = 0.0f; for (i = -rad; i <= rad; i++) { - val = RE_filter_value(this->data->filtertype, (float)i / (float)rad); + val = RE_filter_value(this->m_data->filtertype, (float)i / (float)rad); sum += val; gausstab[i + rad] = val; } @@ -131,20 +132,20 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff) void BlurBaseOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputSize = NULL; - if (this->deleteData) { - delete this->data; + this->m_inputProgram = NULL; + this->m_inputSize = NULL; + if (this->m_deleteData) { + delete this->m_data; } - this->data = NULL; + this->m_data = NULL; } void BlurBaseOperation::updateSize(MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + if (!this->m_sizeavailable) { float result[4]; this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers); - this->size = result[0]; - this->sizeavailable = true; + this->m_size = result[0]; + this->m_sizeavailable = true; } } diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h index 8f7208274db..6d60abf09bf 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.h +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h @@ -29,19 +29,24 @@ class BlurBaseOperation : public NodeOperation, public QualityStepHelper { private: protected: - /** - * Cached reference to the inputProgram - */ - SocketReader *inputProgram; - SocketReader *inputSize; - NodeBlurData *data; + BlurBaseOperation(DataType data_type); float *make_gausstab(int rad); float *make_dist_fac_inverse(int rad, int falloff); - float size; - bool deleteData; - bool sizeavailable; + void updateSize(MemoryBuffer **memoryBuffers); + + /** + * Cached reference to the inputProgram + */ + SocketReader *m_inputProgram; + SocketReader *m_inputSize; + NodeBlurData *m_data; + + float m_size; + bool m_deleteData; + bool m_sizeavailable; + public: /** * Initialize the execution @@ -53,10 +58,10 @@ public: */ void deinitExecution(); - void setData(NodeBlurData *data) { this->data = data; } + void setData(NodeBlurData *data) { this->m_data = data; } - void deleteDataWhenFinished() { this->deleteData = true; } + void deleteDataWhenFinished() { this->m_deleteData = true; } - void setSize(float size) { this->size = size; sizeavailable = true; } + void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; } }; #endif diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index 9fe5abcb075..fb06f6d3761 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -37,11 +37,11 @@ BokehBlurOperation::BokehBlurOperation() : NodeOperation() this->setComplex(true); this->setOpenCL(true); - this->size = 1.0f; + this->m_size = 1.0f; - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputBoundingBoxReader = NULL; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputBoundingBoxReader = NULL; } void *BokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -52,12 +52,12 @@ void *BokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu void BokehBlurOperation::initExecution() { - this->inputProgram = getInputSocketReader(0); - this->inputBokehProgram = getInputSocketReader(1); - this->inputBoundingBoxReader = getInputSocketReader(2); + this->m_inputProgram = getInputSocketReader(0); + this->m_inputBokehProgram = getInputSocketReader(1); + this->m_inputBoundingBoxReader = getInputSocketReader(2); - int width = inputBokehProgram->getWidth(); - int height = inputBokehProgram->getHeight(); + int width = this->m_inputBokehProgram->getWidth(); + int height = this->m_inputBokehProgram->getHeight(); float dimension; if (width < height) { @@ -66,9 +66,9 @@ void BokehBlurOperation::initExecution() else { dimension = height; } - this->bokehMidX = width / 2.0f; - this->bokehMidY = height / 2.0f; - this->bokehDimension = dimension / 2.0f; + this->m_bokehMidX = width / 2.0f; + this->m_bokehMidY = height / 2.0f; + this->m_bokehDimension = dimension / 2.0f; QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -78,7 +78,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * float tempBoundingBox[4]; float bokeh[4]; - inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers); if (tempBoundingBox[0] > 0.0f) { float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; @@ -86,7 +86,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int pixelSize = this->size * this->getWidth() / 100.0f; + int pixelSize = this->m_size * this->getWidth() / 100.0f; int miny = y - pixelSize; int maxy = y + pixelSize; @@ -102,13 +102,13 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * int step = getStep(); int offsetadd = getOffsetAdd(); - float m = this->bokehDimension / pixelSize; + float m = this->m_bokehDimension / pixelSize; for (int ny = miny; ny < maxy; ny += step) { int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - float u = this->bokehMidX - (nx - x) * m; - float v = this->bokehMidY - (ny - y) * m; - inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + float u = this->m_bokehMidX - (nx - x) * m; + float v = this->m_bokehMidY - (ny - y) * m; + this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]); add_v4_v4(multiplier_accum, bokeh); bufferindex += offsetadd; @@ -120,15 +120,15 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } else { - inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); } } void BokehBlurOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputBoundingBoxReader = NULL; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputBoundingBoxReader = NULL; } bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -136,10 +136,10 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe rcti newInput; rcti bokehInput; - newInput.xmax = input->xmax + (size * this->getWidth() / 100.0f); - newInput.xmin = input->xmin - (size * this->getWidth() / 100.0f); - newInput.ymax = input->ymax + (size * this->getWidth() / 100.0f); - newInput.ymin = input->ymin - (size * this->getWidth() / 100.0f); + newInput.xmax = input->xmax + (this->m_size * this->getWidth() / 100.0f); + newInput.xmin = input->xmin - (this->m_size * this->getWidth() / 100.0f); + newInput.ymax = input->ymax + (this->m_size * this->getWidth() / 100.0f); + newInput.ymin = input->ymin - (this->m_size * this->getWidth() / 100.0f); NodeOperation *operation = getInputOperation(1); bokehInput.xmax = operation->getWidth(); @@ -169,12 +169,12 @@ void BokehBlurOperation::executeOpenCL(OpenCLDevice* device, if (!kernel) { kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); } - cl_int radius = this->getWidth() * this->size / 100.0f; + cl_int radius = this->getWidth() * this->m_size / 100.0f; cl_int step = this->getStep(); - device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader); - device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBokehProgram); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBoundingBoxReader); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram); device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer); device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer); clSetKernelArg(kernel, 6, sizeof(cl_int), &radius); diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h index 853855d5c34..0433a4156a8 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h @@ -27,13 +27,13 @@ class BokehBlurOperation : public NodeOperation, public QualityStepHelper { private: - SocketReader *inputProgram; - SocketReader *inputBokehProgram; - SocketReader *inputBoundingBoxReader; - float size; - float bokehMidX; - float bokehMidY; - float bokehDimension; + SocketReader *m_inputProgram; + SocketReader *m_inputBokehProgram; + SocketReader *m_inputBoundingBoxReader; + float m_size; + float m_bokehMidX; + float m_bokehMidY; + float m_bokehDimension; public: BokehBlurOperation(); @@ -55,7 +55,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setSize(float size) { this->size = size; } + void setSize(float size) { this->m_size = size; } void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); }; diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp index abb378e2adb..90e272438d6 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp @@ -26,35 +26,35 @@ BokehImageOperation::BokehImageOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->deleteData = false; + this->m_deleteData = false; } void BokehImageOperation::initExecution() { - this->centerX = getWidth() / 2; - this->centerY = getHeight() / 2; - this->center[0] = this->centerX; - this->center[1] = this->centerY; - this->inverseRounding = 1.0f - this->data->rounding; - this->circularDistance = getWidth() / 2; - this->flapRad = (float)(M_PI * 2) / this->data->flaps; - this->flapRadAdd = (this->data->angle / 360.0f) * (float)(M_PI * 2.0); - while (this->flapRadAdd < 0.0f) { - this->flapRadAdd += (float)(M_PI * 2.0); + this->m_centerX = getWidth() / 2; + this->m_centerY = getHeight() / 2; + this->m_center[0] = this->m_centerX; + this->m_center[1] = this->m_centerY; + this->m_inverseRounding = 1.0f - this->m_data->rounding; + this->m_circularDistance = getWidth() / 2; + this->m_flapRad = (float)(M_PI * 2) / this->m_data->flaps; + this->m_flapRadAdd = (this->m_data->angle / 360.0f) * (float)(M_PI * 2.0); + while (this->m_flapRadAdd < 0.0f) { + this->m_flapRadAdd += (float)(M_PI * 2.0); } - while (this->flapRadAdd > (float)M_PI) { - this->flapRadAdd -= (float)(M_PI * 2.0); + while (this->m_flapRadAdd > (float)M_PI) { + this->m_flapRadAdd -= (float)(M_PI * 2.0); } } void BokehImageOperation::detemineStartPointOfFlap(float r[2], int flapNumber, float distance) { - r[0] = sinf(flapRad * flapNumber + flapRadAdd) * distance + centerX; - r[1] = cosf(flapRad * flapNumber + flapRadAdd) * distance + centerY; + r[0] = sinf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_centerX; + r[1] = cosf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_centerY; } float BokehImageOperation::isInsideBokeh(float distance, float x, float y) { float insideBokeh = 0.0f; - const float deltaX = x - centerX; - const float deltaY = y - centerY; + const float deltaX = x - this->m_centerX; + const float deltaY = y - this->m_centerY; float closestPoint[2]; float lineP1[2]; float lineP2[2]; @@ -62,23 +62,23 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y) point[0] = x; point[1] = y; - const float distanceToCenter = len_v2v2(point, center); + const float distanceToCenter = len_v2v2(point, this->m_center); const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0)); - int flapNumber = (int)((bearing - flapRadAdd) / flapRad); + int flapNumber = (int)((bearing - this->m_flapRadAdd) / this->m_flapRad); detemineStartPointOfFlap(lineP1, flapNumber, distance); detemineStartPointOfFlap(lineP2, flapNumber + 1, distance); closest_to_line_v2(closestPoint, point, lineP1, lineP2); - const float distanceLineToCenter = len_v2v2(center, closestPoint); - const float distanceRoundingToCenter = inverseRounding * distanceLineToCenter + this->data->rounding * distance; + const float distanceLineToCenter = len_v2v2(this->m_center, closestPoint); + const float distanceRoundingToCenter = this->m_inverseRounding * distanceLineToCenter + this->m_data->rounding * distance; - const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->data->catadioptric; + const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->m_data->catadioptric; if (distanceRoundingToCenter >= distanceToCenter && catadioptricDistanceToCenter <= distanceToCenter) { if (distanceRoundingToCenter - distanceToCenter < 1.0f) { insideBokeh = (distanceRoundingToCenter - distanceToCenter); } - else if (this->data->catadioptric != 0.0f && distanceToCenter - catadioptricDistanceToCenter < 1.0f) { + else if (this->m_data->catadioptric != 0.0f && distanceToCenter - catadioptricDistanceToCenter < 1.0f) { insideBokeh = (distanceToCenter - catadioptricDistanceToCenter); } else { @@ -89,9 +89,9 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y) } void BokehImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - float shift = this->data->lensshift; + float shift = this->m_data->lensshift; float shift2 = shift / 2.0f; - float distance = this->circularDistance; + float distance = this->m_circularDistance; float insideBokehMax = isInsideBokeh(distance, x, y); float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), x, y); float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), x, y); @@ -110,10 +110,10 @@ void BokehImageOperation::executePixel(float *color, float x, float y, PixelSamp void BokehImageOperation::deinitExecution() { - if (deleteData) { - if (data) { - delete data; - data = NULL; + if (this->m_deleteData) { + if (this->m_data) { + delete this->m_data; + this->m_data = NULL; } } } diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h index 8edd32a4f77..085aaa471f0 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.h +++ b/source/blender/compositor/operations/COM_BokehImageOperation.h @@ -27,17 +27,17 @@ class BokehImageOperation : public NodeOperation { private: - NodeBokehImage *data; + NodeBokehImage *m_data; - float center[2]; - float centerX; - float centerY; - float inverseRounding; - float circularDistance; - float flapRad; - float flapRadAdd; + float m_center[2]; + float m_centerX; + float m_centerY; + float m_inverseRounding; + float m_circularDistance; + float m_flapRad; + float m_flapRadAdd; - bool deleteData; + bool m_deleteData; void detemineStartPointOfFlap(float r[2], int flapNumber, float distance); float isInsideBokeh(float distance, float x, float y); @@ -61,7 +61,7 @@ public: void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setData(NodeBokehImage *data) { this->data = data; } - void deleteDataOnFinish() { this->deleteData = true; } + void setData(NodeBokehImage *data) { this->m_data = data; } + void deleteDataOnFinish() { this->m_deleteData = true; } }; #endif diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp index 3b99fc9a2a0..96738a2920a 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp @@ -29,19 +29,19 @@ BoxMaskOperation::BoxMaskOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputMask = NULL; - this->inputValue = NULL; - this->cosine = 0.0f; - this->sine = 0.0f; + this->m_inputMask = NULL; + this->m_inputValue = NULL; + this->m_cosine = 0.0f; + this->m_sine = 0.0f; } void BoxMaskOperation::initExecution() { - this->inputMask = this->getInputSocketReader(0); - this->inputValue = this->getInputSocketReader(1); - const double rad = DEG2RAD((double)this->data->rotation); - this->cosine = cos(rad); - this->sine = sin(rad); - this->aspectRatio = ((float)this->getWidth()) / this->getHeight(); + this->m_inputMask = this->getInputSocketReader(0); + this->m_inputValue = this->getInputSocketReader(1); + const double rad = DEG2RAD((double)this->m_data->rotation); + this->m_cosine = cos(rad); + this->m_sine = sin(rad); + this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -52,22 +52,22 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler float rx = x / this->getWidth(); float ry = y / this->getHeight(); - const float dy = (ry - this->data->y) / this->aspectRatio; - const float dx = rx - this->data->x; - rx = this->data->x + (this->cosine * dx + this->sine * dy); - ry = this->data->y + (-this->sine * dx + this->cosine * dy); + const float dy = (ry - this->m_data->y) / this->m_aspectRatio; + const float dx = rx - this->m_data->x; + rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); + ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->inputMask->read(inputMask, x, y, sampler, inputBuffers); - this->inputValue->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); + this->m_inputValue->read(inputValue, x, y, sampler, inputBuffers); - float halfHeight = this->data->height / 2.0f; - float halfWidth = this->data->width / 2.0f; - bool inside = (rx > this->data->x - halfWidth && - rx < this->data->x + halfWidth && - ry > this->data->y - halfHeight && - ry < this->data->y + halfHeight); + float halfHeight = this->m_data->height / 2.0f; + float halfWidth = this->m_data->width / 2.0f; + bool inside = (rx > this->m_data->x - halfWidth && + rx < this->m_data->x + halfWidth && + ry > this->m_data->y - halfHeight && + ry < this->m_data->y + halfHeight); - switch (this->maskType) { + switch (this->m_maskType) { case CMP_NODE_MASKTYPE_ADD: if (inside) { color[0] = max(inputMask[0], inputValue[0]); @@ -113,7 +113,7 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler void BoxMaskOperation::deinitExecution() { - this->inputMask = NULL; - this->inputValue = NULL; + this->m_inputMask = NULL; + this->m_inputValue = NULL; } diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h index 65327abc9a6..cec680ef6c3 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.h +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h @@ -30,15 +30,15 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputMask; - SocketReader *inputValue; + SocketReader *m_inputMask; + SocketReader *m_inputValue; - float sine; - float cosine; - float aspectRatio; - int maskType; + float m_sine; + float m_cosine; + float m_aspectRatio; + int m_maskType; - NodeBoxMask *data; + NodeBoxMask *m_data; public: BoxMaskOperation(); @@ -57,9 +57,9 @@ public: */ void deinitExecution(); - void setData(NodeBoxMask *data) { this->data = data; } + void setData(NodeBoxMask *data) { this->m_data = data; } - void setMaskType(int maskType) { this->maskType = maskType; } + void setMaskType(int maskType) { this->m_maskType = maskType; } }; #endif diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp index 95862a1fd83..8c9fb6394a7 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp +++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp @@ -28,13 +28,13 @@ BrightnessOperation::BrightnessOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void BrightnessOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->inputBrightnessProgram = this->getInputSocketReader(1); - this->inputContrastProgram = this->getInputSocketReader(2); + this->m_inputProgram = this->getInputSocketReader(0); + this->m_inputBrightnessProgram = this->getInputSocketReader(1); + this->m_inputContrastProgram = this->getInputSocketReader(2); } void BrightnessOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -43,9 +43,9 @@ void BrightnessOperation::executePixel(float *color, float x, float y, PixelSamp float a, b; float inputBrightness[4]; float inputContrast[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); - this->inputBrightnessProgram->read(inputBrightness, x, y, sampler, inputBuffers); - this->inputContrastProgram->read(inputContrast, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputBrightnessProgram->read(inputBrightness, x, y, sampler, inputBuffers); + this->m_inputContrastProgram->read(inputContrast, x, y, sampler, inputBuffers); float brightness = inputBrightness[0]; float contrast = inputContrast[0]; brightness /= 100.0f; @@ -73,8 +73,8 @@ void BrightnessOperation::executePixel(float *color, float x, float y, PixelSamp void BrightnessOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputBrightnessProgram = NULL; - this->inputContrastProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputBrightnessProgram = NULL; + this->m_inputContrastProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h index 74c648fd8fb..61f667aa1be 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.h +++ b/source/blender/compositor/operations/COM_BrightnessOperation.h @@ -30,9 +30,9 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - SocketReader *inputBrightnessProgram; - SocketReader *inputContrastProgram; + SocketReader *m_inputProgram; + SocketReader *m_inputBrightnessProgram; + SocketReader *m_inputContrastProgram; public: BrightnessOperation(); diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp index fe6be55e237..a1c679b3e15 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp @@ -30,33 +30,33 @@ CalculateMeanOperation::CalculateMeanOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_VALUE); - this->imageReader = NULL; - this->iscalculated = false; - this->setting = 1; + this->m_imageReader = NULL; + this->m_iscalculated = false; + this->m_setting = 1; this->setComplex(true); } void CalculateMeanOperation::initExecution() { - this->imageReader = this->getInputSocketReader(0); - this->iscalculated = false; + this->m_imageReader = this->getInputSocketReader(0); + this->m_iscalculated = false; NodeOperation::initMutex(); } void CalculateMeanOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - color[0] = this->result; + color[0] = this->m_result; } void CalculateMeanOperation::deinitExecution() { - this->imageReader = NULL; + this->m_imageReader = NULL; NodeOperation::deinitMutex(); } bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti imageInput; - if (iscalculated) { + if (this->m_iscalculated) { return false; } NodeOperation *operation = getInputOperation(0); @@ -73,10 +73,10 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti *input, ReadB void *CalculateMeanOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (!this->iscalculated) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (!this->m_iscalculated) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); calculateMean(tile); - this->iscalculated = true; + this->m_iscalculated = true; } unlockMutex(); return NULL; @@ -84,7 +84,7 @@ void *CalculateMeanOperation::initializeTileData(rcti *rect, MemoryBuffer **memo void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) { - this->result = 0.0f; + this->m_result = 0.0f; float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; @@ -93,8 +93,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) if (buffer[offset + 3] > 0) { pixels++; - switch (this->setting) - { + switch (this->m_setting) { case 1: { sum += rgb_to_bw(&buffer[offset]); @@ -125,5 +124,5 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) } } } - this->result = sum / pixels; + this->m_result = sum / pixels; } diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h index 7a28eb3774a..2bd723c40a3 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h @@ -34,11 +34,11 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *imageReader; + SocketReader *m_imageReader; - bool iscalculated; - float result; - int setting; + bool m_iscalculated; + float m_result; + int m_setting; public: CalculateMeanOperation(); @@ -61,7 +61,7 @@ public: void deinitExecution(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setSetting(int setting) { this->setting = setting; } + void setSetting(int setting) { this->m_setting = setting; } protected: void calculateMean(MemoryBuffer *tile); diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp index 811975c5e13..2d860df449c 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp @@ -33,27 +33,26 @@ CalculateStandardDeviationOperation::CalculateStandardDeviationOperation() : Cal void CalculateStandardDeviationOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - color[0] = this->standardDeviation; + color[0] = this->m_standardDeviation; } void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (!this->iscalculated) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (!this->m_iscalculated) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); CalculateMeanOperation::calculateMean(tile); - this->standardDeviation = 0.0f; + this->m_standardDeviation = 0.0f; float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; float sum = 0.0f; - float mean = this->result; + float mean = this->m_result; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { pixels++; - switch (this->setting) - { + switch (this->m_setting) { case 1: { float value = rgb_to_bw(&buffer[offset]); @@ -90,8 +89,8 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, Memory } } } - this->standardDeviation = sqrt(sum / (float)(pixels - 1)); - this->iscalculated = true; + this->m_standardDeviation = sqrt(sum / (float)(pixels - 1)); + this->m_iscalculated = true; } unlockMutex(); return NULL; diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h index d3163d4cc32..506c5d6fe3a 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h @@ -31,7 +31,7 @@ */ class CalculateStandardDeviationOperation : public CalculateMeanOperation { protected: - float standardDeviation; + float m_standardDeviation; public: CalculateStandardDeviationOperation(); diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp index 487c1869782..0812dd45bf6 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp @@ -26,30 +26,30 @@ ChangeHSVOperation::ChangeHSVOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ChangeHSVOperation::initExecution() { - this->inputOperation = getInputSocketReader(0); + this->m_inputOperation = getInputSocketReader(0); } void ChangeHSVOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ChangeHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor1[4]; - inputOperation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor1, x, y, sampler, inputBuffers); - outputValue[0] = inputColor1[0] + (this->hue - 0.5f); + outputValue[0] = inputColor1[0] + (this->m_hue - 0.5f); if (outputValue[0] > 1.0f) outputValue[0] -= 1.0f; else if (outputValue[0] < 0.0f) outputValue[0] += 1.0f; - outputValue[1] = inputColor1[1] * this->saturation; - outputValue[2] = inputColor1[2] * this->value; + outputValue[1] = inputColor1[1] * this->m_saturation; + outputValue[2] = inputColor1[2] * this->m_value; outputValue[3] = inputColor1[3]; } diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h index a2a6c034a82..9c343db9c3c 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h @@ -31,11 +31,11 @@ */ class ChangeHSVOperation : public NodeOperation { private: - SocketReader *inputOperation; + SocketReader *m_inputOperation; - float hue; - float saturation; - float value; + float m_hue; + float m_saturation; + float m_value; public: /** @@ -51,9 +51,9 @@ public: */ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); - void setHue(float hue) { this->hue = hue; } - void setSaturation(float saturation) { this->saturation = saturation; } - void setValue(float value) { this->value = value; } + void setHue(float hue) { this->m_hue = hue; } + void setSaturation(float saturation) { this->m_saturation = saturation; } + void setValue(float value) { this->m_value = value; } }; #endif diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp index 24af1a3aa53..b2de934e6d8 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp @@ -27,45 +27,45 @@ ChannelMatteOperation::ChannelMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void ChannelMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(0); - this->limit_range = this->limit_max - this->limit_min; + this->m_limit_range = this->m_limit_max - this->m_limit_min; - switch (this->limit_method) { + switch (this->m_limit_method) { /* SINGLE */ case 0: { /* 123 / RGB / HSV / YUV / YCC */ - const int matte_channel = this->matte_channel - 1; - const int limit_channel = this->limit_channel - 1; - this->ids[0] = matte_channel; - this->ids[1] = limit_channel; - this->ids[2] = limit_channel; + const int matte_channel = this->m_matte_channel - 1; + const int limit_channel = this->m_limit_channel - 1; + this->m_ids[0] = matte_channel; + this->m_ids[1] = limit_channel; + this->m_ids[2] = limit_channel; break; } /* MAX */ case 1: { - switch (this->matte_channel) { + switch (this->m_matte_channel) { case 1: { - this->ids[0] = 0; - this->ids[1] = 1; - this->ids[2] = 2; + this->m_ids[0] = 0; + this->m_ids[1] = 1; + this->m_ids[2] = 2; break; } case 2: { - this->ids[0] = 1; - this->ids[1] = 0; - this->ids[2] = 2; + this->m_ids[0] = 1; + this->m_ids[1] = 0; + this->m_ids[2] = 2; break; } case 3: { - this->ids[0] = 2; - this->ids[1] = 0; - this->ids[2] = 1; + this->m_ids[0] = 2; + this->m_ids[1] = 0; + this->m_ids[2] = 1; break; } default: @@ -80,7 +80,7 @@ void ChannelMatteOperation::initExecution() void ChannelMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -88,17 +88,17 @@ void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, P float inColor[4]; float alpha; - const float limit_max = this->limit_max; - const float limit_min = this->limit_min; - const float limit_range = this->limit_range; + const float limit_max = this->m_limit_max; + const float limit_min = this->m_limit_min; + const float limit_range = this->m_limit_range; - this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); /* matte operation */ - alpha = inColor[this->ids[0]] - max(inColor[this->ids[1]], inColor[this->ids[2]]); + alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]); /* flip because 0.0 is transparent, not 1.0 */ - alpha = 1.f - alpha; + alpha = 1.0f - alpha; /* test range*/ if (alpha > limit_max) { diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h index 17db0f9ffe2..5bc13736dda 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h @@ -30,16 +30,16 @@ */ class ChannelMatteOperation : public NodeOperation { private: - SocketReader *inputImageProgram; + SocketReader *m_inputImageProgram; - int color_space; /* node->custom1 */ - int matte_channel; /* node->custom2 */ - int limit_method; /* node->algorithm */ - int limit_channel; /* node->channel */ - float limit_max; /* node->storage->t1 */ - float limit_min; /* node->storage->t2 */ + /* 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 */ + float m_limit_max; /* node->storage->t1 */ + float m_limit_min; /* node->storage->t2 */ - float limit_range; + float m_limit_range; /** ids to use for the operations (max and simple) * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]]) @@ -49,7 +49,7 @@ private: * ids[2] = ids[1] * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]]) */ - int ids[3]; + int m_ids[3]; public: /** * Default constructor @@ -66,11 +66,11 @@ public: void setSettings(NodeChroma *nodeChroma, const int custom2) { - this->limit_max = nodeChroma->t1; - this->limit_min = nodeChroma->t2; - this->limit_method = nodeChroma->algorithm; - this->limit_channel = nodeChroma->channel; - this->matte_channel = custom2; + this->m_limit_max = nodeChroma->t1; + this->m_limit_min = nodeChroma->t2; + this->m_limit_method = nodeChroma->algorithm; + this->m_limit_channel = nodeChroma->channel; + this->m_matte_channel = custom2; } }; #endif diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp index 0ce1a585598..e88feb6db9c 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp @@ -28,20 +28,20 @@ ChromaMatteOperation::ChromaMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; - inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ChromaMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); - this->inputKeyProgram = this->getInputSocketReader(1); + this->m_inputImageProgram = this->getInputSocketReader(0); + this->m_inputKeyProgram = this->getInputSocketReader(1); } void ChromaMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; - this->inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,16 +49,16 @@ void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, Pi float inKey[4]; float inImage[4]; - const float acceptance = this->settings->t1; /* in radians */ - const float cutoff = this->settings->t2; /* in radians */ - const float gain = this->settings->fstrength; + const float acceptance = this->m_settings->t1; /* in radians */ + const float cutoff = this->m_settings->t2; /* in radians */ + const float gain = this->m_settings->fstrength; float x_angle, z_angle, alpha; float theta, beta; float kfg; - this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); - this->inputImageProgram->read(inImage, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inImage, x, y, sampler, inputBuffers); /* store matte(alpha) value in [0] to go with * COM_SetAlphaOperation and the Value output diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h index a09203f29b3..472a797fa28 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h @@ -30,9 +30,9 @@ */ class ChromaMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; - SocketReader *inputKeyProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; + SocketReader *m_inputKeyProgram; public: /** * Default constructor @@ -47,6 +47,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index a48fe169fd7..66ce86234b7 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -38,15 +38,15 @@ ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; this->setResolutionInputSocketIndex(1); } void ColorBalanceASCCDLOperation::initExecution() { - this->inputValueOperation = this->getInputSocketReader(0); - this->inputColorOperation = this->getInputSocketReader(1); + this->m_inputValueOperation = this->getInputSocketReader(0); + this->m_inputColorOperation = this->getInputSocketReader(1); } void ColorBalanceASCCDLOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -54,22 +54,22 @@ void ColorBalanceASCCDLOperation::executePixel(float *outputColor, float x, floa float inputColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); float fac = value[0]; fac = min(1.0f, fac); const float mfac = 1.0f - fac; - outputColor[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->lift[0], this->gamma[0], this->gain[0]); - outputColor[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->lift[1], this->gamma[1], this->gain[1]); - outputColor[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->lift[2], this->gamma[2], this->gain[2]); + outputColor[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); + outputColor[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); + outputColor[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); outputColor[3] = inputColor[3]; } void ColorBalanceASCCDLOperation::deinitExecution() { - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index 9e7db59d99d..479927d30d1 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -33,12 +33,12 @@ protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValueOperation; - SocketReader *inputColorOperation; + SocketReader *m_inputValueOperation; + SocketReader *m_inputColorOperation; - float gain[3]; - float lift[3]; - float gamma[3]; + float m_gain[3]; + float m_lift[3]; + float m_gamma[3]; public: /** @@ -61,8 +61,8 @@ public: */ void deinitExecution(); - void setGain(float gain[3]) { copy_v3_v3(this->gain, gain); } - void setLift(float lift[3]) { copy_v3_v3(this->lift, lift); } - void setGamma(float gamma[3]) { copy_v3_v3(this->gamma, gamma); } + void setGain(float gain[3]) { copy_v3_v3(this->m_gain, gain); } + void setLift(float lift[3]) { copy_v3_v3(this->m_lift, lift); } + void setGamma(float gamma[3]) { copy_v3_v3(this->m_gamma, gamma); } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp index 7a8d62dfe21..13863a9ec5a 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp @@ -43,15 +43,15 @@ ColorBalanceLGGOperation::ColorBalanceLGGOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; this->setResolutionInputSocketIndex(1); } void ColorBalanceLGGOperation::initExecution() { - this->inputValueOperation = this->getInputSocketReader(0); - this->inputColorOperation = this->getInputSocketReader(1); + this->m_inputValueOperation = this->getInputSocketReader(0); + this->m_inputColorOperation = this->getInputSocketReader(1); } void ColorBalanceLGGOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -59,22 +59,22 @@ void ColorBalanceLGGOperation::executePixel(float *outputColor, float x, float y float inputColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); float fac = value[0]; fac = min(1.0f, fac); const float mfac = 1.0f - fac; - outputColor[0] = mfac * inputColor[0] + fac *colorbalance_lgg(inputColor[0], this->lift[0], this->gamma_inv[0], this->gain[0]); - outputColor[1] = mfac * inputColor[1] + fac *colorbalance_lgg(inputColor[1], this->lift[1], this->gamma_inv[1], this->gain[1]); - outputColor[2] = mfac * inputColor[2] + fac *colorbalance_lgg(inputColor[2], this->lift[2], this->gamma_inv[2], this->gain[2]); + outputColor[0] = mfac * inputColor[0] + fac *colorbalance_lgg(inputColor[0], this->m_lift[0], this->m_gamma_inv[0], this->m_gain[0]); + outputColor[1] = mfac * inputColor[1] + fac *colorbalance_lgg(inputColor[1], this->m_lift[1], this->m_gamma_inv[1], this->m_gain[1]); + outputColor[2] = mfac * inputColor[2] + fac *colorbalance_lgg(inputColor[2], this->m_lift[2], this->m_gamma_inv[2], this->m_gain[2]); outputColor[3] = inputColor[3]; } void ColorBalanceLGGOperation::deinitExecution() { - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h index 54cfb49327f..ec3652da09e 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h @@ -34,12 +34,12 @@ protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValueOperation; - SocketReader *inputColorOperation; + SocketReader *m_inputValueOperation; + SocketReader *m_inputColorOperation; - float gain[3]; - float lift[3]; - float gamma_inv[3]; + float m_gain[3]; + float m_lift[3]; + float m_gamma_inv[3]; public: /** @@ -62,20 +62,8 @@ public: */ void deinitExecution(); - void setGain(float gain[3]) { - this->gain[0] = gain[0]; - this->gain[1] = gain[1]; - this->gain[2] = gain[2]; - } - void setLift(float lift[3]) { - this->lift[0] = lift[0]; - this->lift[1] = lift[1]; - this->lift[2] = lift[2]; - } - void setGammaInv(float gamma_inv[3]) { - this->gamma_inv[0] = gamma_inv[0]; - this->gamma_inv[1] = gamma_inv[1]; - this->gamma_inv[2] = gamma_inv[2]; - } + void setGain(const float gain[3]) { copy_v3_v3(this->m_gain, gain); } + void setLift(const float lift[3]) { copy_v3_v3(this->m_lift, lift); } + void setGammaInv(const float gamma_inv[3]) { copy_v3_v3(this->m_gamma_inv, gamma_inv); } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp index 5f62f9ec403..8008866752f 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp @@ -28,31 +28,31 @@ ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputImage = NULL; - this->inputMask = NULL; - this->redChannelEnabled = true; - this->greenChannelEnabled = true; - this->blueChannelEnabled = true; + this->m_inputImage = NULL; + this->m_inputMask = NULL; + this->m_redChannelEnabled = true; + this->m_greenChannelEnabled = true; + this->m_blueChannelEnabled = true; } void ColorCorrectionOperation::initExecution() { - this->inputImage = this->getInputSocketReader(0); - this->inputMask = this->getInputSocketReader(1); + this->m_inputImage = this->getInputSocketReader(0); + this->m_inputMask = this->getInputSocketReader(1); } void ColorCorrectionOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputImageColor[4]; float inputMask[4]; - this->inputImage->read(inputImageColor, x, y, sampler, inputBuffers); - this->inputMask->read(inputMask, x, y, sampler, inputBuffers); + this->m_inputImage->read(inputImageColor, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f; - float contrast = this->data->master.contrast; - float saturation = this->data->master.saturation; - float gamma = this->data->master.gamma; - float gain = this->data->master.gain; - float lift = this->data->master.lift; + float contrast = this->m_data->master.contrast; + float saturation = this->m_data->master.saturation; + float gamma = this->m_data->master.gamma; + float gain = this->m_data->master.gain; + float lift = this->m_data->master.lift; float r, g, b; float value = inputMask[0]; @@ -64,18 +64,18 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix float levelHighlights = 0.0; #define MARGIN 0.10f #define MARGIN_DIV (0.5f / MARGIN) - if (level < this->data->startmidtones - MARGIN) { + if (level < this->m_data->startmidtones - MARGIN) { levelShadows = 1.0f; } - else if (level < this->data->startmidtones + MARGIN) { - levelMidtones = ((level - this->data->startmidtones) * MARGIN_DIV) + 0.5f; + else if (level < this->m_data->startmidtones + MARGIN) { + levelMidtones = ((level - this->m_data->startmidtones) * MARGIN_DIV) + 0.5f; levelShadows = 1.0f - levelMidtones; } - else if (level < this->data->endmidtones - MARGIN) { + else if (level < this->m_data->endmidtones - MARGIN) { levelMidtones = 1.0f; } - else if (level < this->data->endmidtones + MARGIN) { - levelHighlights = ((level - this->data->endmidtones) * MARGIN_DIV) + 0.5f; + else if (level < this->m_data->endmidtones + MARGIN) { + levelHighlights = ((level - this->m_data->endmidtones) * MARGIN_DIV) + 0.5f; levelMidtones = 1.0f - levelHighlights; } else { @@ -83,11 +83,11 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix } #undef MARGIN #undef MARGIN_DIV - contrast *= (levelShadows * this->data->shadows.contrast) + (levelMidtones * this->data->midtones.contrast) + (levelHighlights * this->data->highlights.contrast); - saturation *= (levelShadows * this->data->shadows.saturation) + (levelMidtones * this->data->midtones.saturation) + (levelHighlights * this->data->highlights.saturation); - gamma *= (levelShadows * this->data->shadows.gamma) + (levelMidtones * this->data->midtones.gamma) + (levelHighlights * this->data->highlights.gamma); - gain *= (levelShadows * this->data->shadows.gain) + (levelMidtones * this->data->midtones.gain) + (levelHighlights * this->data->highlights.gain); - lift += (levelShadows * this->data->shadows.lift) + (levelMidtones * this->data->midtones.lift) + (levelHighlights * this->data->highlights.lift); + contrast *= (levelShadows * this->m_data->shadows.contrast) + (levelMidtones * this->m_data->midtones.contrast) + (levelHighlights * this->m_data->highlights.contrast); + saturation *= (levelShadows * this->m_data->shadows.saturation) + (levelMidtones * this->m_data->midtones.saturation) + (levelHighlights * this->m_data->highlights.saturation); + gamma *= (levelShadows * this->m_data->shadows.gamma) + (levelMidtones * this->m_data->midtones.gamma) + (levelHighlights * this->m_data->highlights.gamma); + gain *= (levelShadows * this->m_data->shadows.gain) + (levelMidtones * this->m_data->midtones.gain) + (levelHighlights * this->m_data->highlights.gain); + lift += (levelShadows * this->m_data->shadows.lift) + (levelMidtones * this->m_data->midtones.lift) + (levelHighlights * this->m_data->highlights.lift); float invgamma = 1.0f / gamma; float luma = rgb_to_luma_y(inputImageColor); @@ -114,19 +114,19 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix g = mvalue * inputImageColor[1] + value * g; b = mvalue * inputImageColor[2] + value * b; - if (this->redChannelEnabled) { + if (this->m_redChannelEnabled) { output[0] = r; } else { output[0] = inputImageColor[0]; } - if (this->greenChannelEnabled) { + if (this->m_greenChannelEnabled) { output[1] = g; } else { output[1] = inputImageColor[1]; } - if (this->blueChannelEnabled) { + if (this->m_blueChannelEnabled) { output[2] = b; } else { @@ -137,7 +137,7 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix void ColorCorrectionOperation::deinitExecution() { - this->inputImage = NULL; - this->inputMask = NULL; + this->m_inputImage = NULL; + this->m_inputMask = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h index c0c33f7f2fa..8db3870709e 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h @@ -30,13 +30,13 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputImage; - SocketReader *inputMask; - NodeColorCorrection *data; + SocketReader *m_inputImage; + SocketReader *m_inputMask; + NodeColorCorrection *m_data; - bool redChannelEnabled; - bool greenChannelEnabled; - bool blueChannelEnabled; + bool m_redChannelEnabled; + bool m_greenChannelEnabled; + bool m_blueChannelEnabled; public: ColorCorrectionOperation(); @@ -56,9 +56,9 @@ public: */ void deinitExecution(); - void setData(NodeColorCorrection *data) { this->data = data; } - void setRedChannelEnabled(bool enabled) { this->redChannelEnabled = enabled; } - void setGreenChannelEnabled(bool enabled) { this->greenChannelEnabled = enabled; } - void setBlueChannelEnabled(bool enabled) { this->blueChannelEnabled = enabled; } + void setData(NodeColorCorrection *data) { this->m_data = data; } + void setRedChannelEnabled(bool enabled) { this->m_redChannelEnabled = enabled; } + void setGreenChannelEnabled(bool enabled) { this->m_greenChannelEnabled = enabled; } + void setBlueChannelEnabled(bool enabled) { this->m_blueChannelEnabled = enabled; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 4feac3e7273..9848d191c04 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -39,28 +39,28 @@ ColorCurveOperation::ColorCurveOperation() : CurveBaseOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; - this->inputBlackProgram = NULL; - this->inputWhiteProgram = NULL; + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputBlackProgram = NULL; + this->m_inputWhiteProgram = NULL; this->setResolutionInputSocketIndex(1); } void ColorCurveOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputFacProgram = this->getInputSocketReader(0); - this->inputImageProgram = this->getInputSocketReader(1); - this->inputBlackProgram = this->getInputSocketReader(2); - this->inputWhiteProgram = this->getInputSocketReader(3); + this->m_inputFacProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(1); + this->m_inputBlackProgram = this->getInputSocketReader(2); + this->m_inputWhiteProgram = this->getInputSocketReader(3); - curvemapping_premultiply(this->curveMapping, 0); + curvemapping_premultiply(this->m_curveMapping, 0); } void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - CurveMapping *cumap = this->curveMapping; + CurveMapping *cumap = this->m_curveMapping; CurveMapping *workingCopy = (CurveMapping *)MEM_dupallocN(cumap); float black[4]; @@ -68,13 +68,13 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp float fac[4]; float image[4]; - this->inputBlackProgram->read(black, x, y, sampler, inputBuffers); - this->inputWhiteProgram->read(white, x, y, sampler, inputBuffers); + this->m_inputBlackProgram->read(black, x, y, sampler, inputBuffers); + this->m_inputWhiteProgram->read(white, x, y, sampler, inputBuffers); curvemapping_set_black_white(workingCopy, black, white); - this->inputFacProgram->read(fac, x, y, sampler, inputBuffers); - this->inputImageProgram->read(image, x, y, sampler, inputBuffers); + this->m_inputFacProgram->read(fac, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(image, x, y, sampler, inputBuffers); if (*fac >= 1.0f) curvemapping_evaluate_premulRGBF(workingCopy, color, image); @@ -94,11 +94,11 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp void ColorCurveOperation::deinitExecution() { - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; - this->inputBlackProgram = NULL; - this->inputWhiteProgram = NULL; - curvemapping_premultiply(this->curveMapping, 1); + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputBlackProgram = NULL; + this->m_inputWhiteProgram = NULL; + curvemapping_premultiply(this->m_curveMapping, 1); } @@ -110,20 +110,20 @@ ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() : CurveBase this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; this->setResolutionInputSocketIndex(1); } void ConstantLevelColorCurveOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputFacProgram = this->getInputSocketReader(0); - this->inputImageProgram = this->getInputSocketReader(1); + this->m_inputFacProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(1); - curvemapping_premultiply(this->curveMapping, 0); + curvemapping_premultiply(this->m_curveMapping, 0); - curvemapping_set_black_white(this->curveMapping, this->black, this->white); + curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); } void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -132,17 +132,17 @@ void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float float image[4]; - this->inputFacProgram->read(fac, x, y, sampler, inputBuffers); - this->inputImageProgram->read(image, x, y, sampler, inputBuffers); + this->m_inputFacProgram->read(fac, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(image, x, y, sampler, inputBuffers); if (*fac >= 1.0f) - curvemapping_evaluate_premulRGBF(this->curveMapping, color, image); + curvemapping_evaluate_premulRGBF(this->m_curveMapping, color, image); else if (*fac <= 0.0f) { copy_v3_v3(color, image); } else { float col[4], mfac = 1.0f - *fac; - curvemapping_evaluate_premulRGBF(this->curveMapping, col, image); + curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); color[0] = mfac * image[0] + *fac * col[0]; color[1] = mfac * image[1] + *fac * col[1]; color[2] = mfac * image[2] + *fac * col[2]; @@ -152,7 +152,7 @@ void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float void ConstantLevelColorCurveOperation::deinitExecution() { - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; - curvemapping_premultiply(this->curveMapping, 1); + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; + curvemapping_premultiply(this->m_curveMapping, 1); } diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h index fcd78be8372..3bcbc31650c 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.h +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h @@ -31,10 +31,10 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputFacProgram; - SocketReader *inputImageProgram; - SocketReader *inputBlackProgram; - SocketReader *inputWhiteProgram; + SocketReader *m_inputFacProgram; + SocketReader *m_inputImageProgram; + SocketReader *m_inputBlackProgram; + SocketReader *m_inputWhiteProgram; public: ColorCurveOperation(); @@ -59,10 +59,10 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputFacProgram; - SocketReader *inputImageProgram; - float black[3]; - float white[3]; + SocketReader *m_inputFacProgram; + SocketReader *m_inputImageProgram; + float m_black[3]; + float m_white[3]; public: ConstantLevelColorCurveOperation(); @@ -82,8 +82,8 @@ public: */ void deinitExecution(); - void setBlackLevel(float black[3]) { this->black[0] = black[0]; this->black[1] = black[1]; this->black[2] = black[2]; } - void setWhiteLevel(float white[3]) { this->white[0] = white[0]; this->white[1] = white[1]; this->white[2] = white[2]; } + void setBlackLevel(float black[3]) { this->m_black[0] = black[0]; this->m_black[1] = black[1]; this->m_black[2] = black[2]; } + void setWhiteLevel(float white[3]) { this->m_white[0] = white[0]; this->m_white[1] = white[1]; this->m_white[2] = white[2]; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp index afb362dbdcd..4a01499b060 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp @@ -28,20 +28,20 @@ ColorMatteOperation::ColorMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; - inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ColorMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); - this->inputKeyProgram = this->getInputSocketReader(1); + this->m_inputImageProgram = this->getInputSocketReader(0); + this->m_inputKeyProgram = this->getInputSocketReader(1); } void ColorMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; - this->inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ColorMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,14 +49,14 @@ void ColorMatteOperation::executePixel(float *outputValue, float x, float y, Pix float inColor[4]; float inKey[4]; - const float hue = this->settings->t1; - const float sat = this->settings->t2; - const float val = this->settings->t3; + const float hue = this->m_settings->t1; + const float sat = this->m_settings->t2; + const float val = this->m_settings->t3; float h_wrap; - this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers); - this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); /* store matte(alpha) value in [0] to go with diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h index e5dd9efd820..ae904f8f938 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.h +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h @@ -30,9 +30,9 @@ */ class ColorMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; - SocketReader *inputKeyProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; + SocketReader *m_inputKeyProgram; public: /** * Default constructor @@ -47,6 +47,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp index 9af70ddc5a7..95dca0dc410 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp @@ -35,23 +35,23 @@ ColorRampOperation::ColorRampOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; - this->colorBand = NULL; + this->m_inputProgram = NULL; + this->m_colorBand = NULL; } void ColorRampOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void ColorRampOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float values[4]; - this->inputProgram->read(values, x, y, sampler, inputBuffers); - do_colorband(this->colorBand, values[0], color); + this->m_inputProgram->read(values, x, y, sampler, inputBuffers); + do_colorband(this->m_colorBand, values[0], color); } void ColorRampOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h index eef5321eb19..42bc6b943b7 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.h +++ b/source/blender/compositor/operations/COM_ColorRampOperation.h @@ -30,8 +30,8 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - ColorBand *colorBand; + SocketReader *m_inputProgram; + ColorBand *m_colorBand; public: ColorRampOperation(); @@ -51,7 +51,7 @@ public: void deinitExecution(); void setColorBand(ColorBand *colorBand) { - this->colorBand = colorBand; + this->m_colorBand = colorBand; } diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp index 1a534d778c0..e2773f3a6b4 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp @@ -30,72 +30,72 @@ ColorSpillOperation::ColorSpillOperation() : NodeOperation() addInputSocket(COM_DT_VALUE); addOutputSocket(COM_DT_COLOR); - inputImageReader = NULL; - inputFacReader = NULL; - this->spillChannel = 1; // GREEN + this->m_inputImageReader = NULL; + this->m_inputFacReader = NULL; + this->m_spillChannel = 1; // GREEN } void ColorSpillOperation::initExecution() { - this->inputImageReader = this->getInputSocketReader(0); - this->inputFacReader = this->getInputSocketReader(1); - if (spillChannel == 0) { - this->rmut = -1.0f; - this->gmut = 1.0f; - this->bmut = 1.0f; - this->channel2 = 1; - this->channel3 = 2; - if (this->settings->unspill == 0) { - this->settings->uspillr = 1.0f; - this->settings->uspillg = 0.0f; - this->settings->uspillb = 0.0f; + this->m_inputImageReader = this->getInputSocketReader(0); + this->m_inputFacReader = this->getInputSocketReader(1); + if (this->m_spillChannel == 0) { + this->m_rmut = -1.0f; + this->m_gmut = 1.0f; + this->m_bmut = 1.0f; + this->m_channel2 = 1; + this->m_channel3 = 2; + if (this->m_settings->unspill == 0) { + this->m_settings->uspillr = 1.0f; + this->m_settings->uspillg = 0.0f; + this->m_settings->uspillb = 0.0f; } } - else if (spillChannel == 1) { - this->rmut = 1.0f; - this->gmut = -1.0f; - this->bmut = 1.0f; - this->channel2 = 0; - this->channel3 = 2; - if (this->settings->unspill == 0) { - this->settings->uspillr = 0.0f; - this->settings->uspillg = 1.0f; - this->settings->uspillb = 0.0f; + else if (this->m_spillChannel == 1) { + this->m_rmut = 1.0f; + this->m_gmut = -1.0f; + this->m_bmut = 1.0f; + this->m_channel2 = 0; + this->m_channel3 = 2; + if (this->m_settings->unspill == 0) { + this->m_settings->uspillr = 0.0f; + this->m_settings->uspillg = 1.0f; + this->m_settings->uspillb = 0.0f; } } else { - this->rmut = 1.0f; - this->gmut = 1.0f; - this->bmut = -1.0f; + this->m_rmut = 1.0f; + this->m_gmut = 1.0f; + this->m_bmut = -1.0f; - this->channel2 = 0; - this->channel3 = 1; - if (this->settings->unspill == 0) { - this->settings->uspillr = 0.0f; - this->settings->uspillg = 0.0f; - this->settings->uspillb = 1.0f; + this->m_channel2 = 0; + this->m_channel3 = 1; + if (this->m_settings->unspill == 0) { + this->m_settings->uspillr = 0.0f; + this->m_settings->uspillg = 0.0f; + this->m_settings->uspillb = 1.0f; } } } void ColorSpillOperation::deinitExecution() { - this->inputImageReader = NULL; - this->inputFacReader = NULL; + this->m_inputImageReader = NULL; + this->m_inputFacReader = NULL; } void ColorSpillOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float fac[4]; float input[4]; - this->inputFacReader->read(fac, x, y, sampler, inputBuffers); - this->inputImageReader->read(input, x, y, sampler, inputBuffers); + this->m_inputFacReader->read(fac, x, y, sampler, inputBuffers); + this->m_inputImageReader->read(input, x, y, sampler, inputBuffers); float rfac = min(1.0f, fac[0]); float map = calculateMapValue(rfac, input); if (map > 0.0f) { - outputValue[0] = input[0] + this->rmut * (this->settings->uspillr * map); - outputValue[1] = input[1] + this->gmut * (this->settings->uspillg * map); - outputValue[2] = input[2] + this->bmut * (this->settings->uspillb * map); + outputValue[0] = input[0] + this->m_rmut * (this->m_settings->uspillr * map); + outputValue[1] = input[1] + this->m_gmut * (this->m_settings->uspillg * map); + outputValue[2] = input[2] + this->m_bmut * (this->m_settings->uspillb * map); outputValue[3] = input[3]; } else { @@ -104,11 +104,11 @@ void ColorSpillOperation::executePixel(float *outputValue, float x, float y, Pix } float ColorSpillOperation::calculateMapValue(float fac, float *input) { - return fac * (input[this->spillChannel] - (this->settings->limscale * input[this->settings->limchan])); + return fac * (input[this->m_spillChannel] - (this->m_settings->limscale * input[this->m_settings->limchan])); } float ColorSpillAverageOperation::calculateMapValue(float fac, float *input) { - return fac * (input[this->spillChannel] - (this->settings->limscale * AVG(input[this->channel2], input[this->channel3]))); + return fac * (input[this->m_spillChannel] - (this->m_settings->limscale * AVG(input[this->m_channel2], input[this->m_channel3]))); } diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index e890a1e1564..6e3156819b2 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -30,13 +30,13 @@ */ class ColorSpillOperation : public NodeOperation { protected: - NodeColorspill *settings; - SocketReader *inputImageReader; - SocketReader *inputFacReader; - int spillChannel; - int channel2; - int channel3; - float rmut, gmut, bmut; + NodeColorspill *m_settings; + SocketReader *m_inputImageReader; + SocketReader *m_inputFacReader; + int m_spillChannel; + int m_channel2; + int m_channel3; + float m_rmut, m_gmut, m_bmut; public: /** * Default constructor @@ -51,8 +51,8 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeColorspill *nodeColorSpill) { this->settings = nodeColorSpill; } - void setSpillChannel(int channel) { this->spillChannel = channel; } + void setSettings(NodeColorspill *nodeColorSpill) { this->m_settings = nodeColorSpill; } + void setSpillChannel(int channel) { this->m_spillChannel = channel; } float calculateMapValue(float fac, float *input); }; diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp index fb4e6f03e76..9f175a381a4 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp @@ -31,10 +31,10 @@ CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputChannel1Operation = NULL; - this->inputChannel2Operation = NULL; - this->inputChannel3Operation = NULL; - this->inputChannel4Operation = NULL; + this->m_inputChannel1Operation = NULL; + this->m_inputChannel2Operation = NULL; + this->m_inputChannel3Operation = NULL; + this->m_inputChannel4Operation = NULL; } bool CombineChannelsOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -63,18 +63,18 @@ bool CombineChannelsOperation::determineDependingAreaOfInterest(rcti *input, Rea void CombineChannelsOperation::initExecution() { - this->inputChannel1Operation = this->getInputSocketReader(0); - this->inputChannel2Operation = this->getInputSocketReader(1); - this->inputChannel3Operation = this->getInputSocketReader(2); - this->inputChannel4Operation = this->getInputSocketReader(3); + this->m_inputChannel1Operation = this->getInputSocketReader(0); + this->m_inputChannel2Operation = this->getInputSocketReader(1); + this->m_inputChannel3Operation = this->getInputSocketReader(2); + this->m_inputChannel4Operation = this->getInputSocketReader(3); } void CombineChannelsOperation::deinitExecution() { - this->inputChannel1Operation = NULL; - this->inputChannel2Operation = NULL; - this->inputChannel3Operation = NULL; - this->inputChannel4Operation = NULL; + this->m_inputChannel1Operation = NULL; + this->m_inputChannel2Operation = NULL; + this->m_inputChannel3Operation = NULL; + this->m_inputChannel4Operation = NULL; } @@ -82,20 +82,20 @@ void CombineChannelsOperation::executePixel(float *color, float x, float y, Pixe { float input[4]; /// @todo: remove if statements - if (this->inputChannel1Operation) { - this->inputChannel1Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel1Operation) { + this->m_inputChannel1Operation->read(input, x, y, sampler, inputBuffers); color[0] = input[0]; } - if (this->inputChannel2Operation) { - this->inputChannel2Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel2Operation) { + this->m_inputChannel2Operation->read(input, x, y, sampler, inputBuffers); color[1] = input[0]; } - if (this->inputChannel3Operation) { - this->inputChannel3Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel3Operation) { + this->m_inputChannel3Operation->read(input, x, y, sampler, inputBuffers); color[2] = input[0]; } - if (this->inputChannel4Operation) { - this->inputChannel4Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel4Operation) { + this->m_inputChannel4Operation->read(input, x, y, sampler, inputBuffers); color[3] = input[0]; } } diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.h b/source/blender/compositor/operations/COM_CombineChannelsOperation.h index cc71f44b4f5..8e4c2120614 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.h +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.h @@ -27,10 +27,10 @@ class CombineChannelsOperation : public NodeOperation { private: - SocketReader *inputChannel1Operation; - SocketReader *inputChannel2Operation; - SocketReader *inputChannel3Operation; - SocketReader *inputChannel4Operation; + SocketReader *m_inputChannel1Operation; + SocketReader *m_inputChannel2Operation; + SocketReader *m_inputChannel3Operation; + SocketReader *m_inputChannel4Operation; public: CombineChannelsOperation(); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 936cbaadd84..717b6ce76cc 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -42,36 +42,36 @@ CompositorOperation::CompositorOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->setRenderData(NULL); - this->outputBuffer = NULL; - this->imageInput = NULL; - this->alphaInput = NULL; + this->m_outputBuffer = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; } void CompositorOperation::initExecution() { // When initializing the tree during initial load the width and height can be zero. - this->imageInput = getInputSocketReader(0); - this->alphaInput = getInputSocketReader(1); + this->m_imageInput = getInputSocketReader(0); + this->m_alphaInput = getInputSocketReader(1); if (this->getWidth() * this->getHeight() != 0) { - this->outputBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation"); + this->m_outputBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation"); } } void CompositorOperation::deinitExecution() { if (!isBreaked()) { - const RenderData *rd = this->rd; + const RenderData *rd = this->m_rd; Render *re = RE_GetRender_FromData(rd); RenderResult *rr = RE_AcquireResultWrite(re); if (rr) { if (rr->rectf != NULL) { MEM_freeN(rr->rectf); } - rr->rectf = outputBuffer; + rr->rectf = this->m_outputBuffer; } else { - if (this->outputBuffer) { - MEM_freeN(this->outputBuffer); + if (this->m_outputBuffer) { + MEM_freeN(this->m_outputBuffer); } } @@ -83,21 +83,21 @@ void CompositorOperation::deinitExecution() } } else { - if (this->outputBuffer) { - MEM_freeN(this->outputBuffer); + if (this->m_outputBuffer) { + MEM_freeN(this->m_outputBuffer); } } - this->outputBuffer = NULL; - this->imageInput = NULL; - this->alphaInput = NULL; + this->m_outputBuffer = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; } void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { float color[8]; // 7 is enough - float *buffer = this->outputBuffer; + float *buffer = this->m_outputBuffer; if (!buffer) return; int x1 = rect->xmin; @@ -111,9 +111,9 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { - imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers); - if (alphaInput != NULL) { - alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers); + if (this->m_alphaInput != NULL) { + this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers); } copy_v4_v4(buffer + offset, color); offset += COM_NUMBER_OF_CHANNELS; @@ -127,12 +127,12 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem void CompositorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - int width = this->rd->xsch * this->rd->size / 100; - int height = this->rd->ysch * this->rd->size / 100; + int width = this->m_rd->xsch * this->m_rd->size / 100; + int height = this->m_rd->ysch * this->m_rd->size / 100; // check actual render resolution with cropping it may differ with cropped border.rendering // FIX for: [31777] Border Crop gives black (easy) - Render *re = RE_GetRender_FromData(this->rd); + Render *re = RE_GetRender_FromData(this->m_rd); if (re) { RenderResult *rr = RE_AcquireResultRead(re); if (rr) { diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index 280f39b7729..2719d376339 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -34,26 +34,26 @@ private: /** * @brief local reference to the scene */ - const RenderData *rd; + const RenderData *m_rd; /** * @brief reference to the output float buffer */ - float *outputBuffer; + float *m_outputBuffer; /** * @brief local reference to the input image operation */ - SocketReader *imageInput; + SocketReader *m_imageInput; /** * @brief local reference to the input alpha operation */ - SocketReader *alphaInput; + SocketReader *m_alphaInput; public: CompositorOperation(); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); - void setRenderData(const RenderData *rd) { this->rd = rd; } + void setRenderData(const RenderData *rd) { this->m_rd = rd; } bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp index 2e8fc9005b8..4d829eae7a0 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp @@ -29,23 +29,23 @@ ConvertColorProfileOperation::ConvertColorProfileOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; - this->predivided = false; + this->m_inputOperation = NULL; + this->m_predivided = false; } void ConvertColorProfileOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertColorProfileOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float color[4]; - inputOperation->read(color, x, y, sampler, inputBuffers); - IMB_buffer_float_from_float(outputValue, color, 4, this->toProfile, this->fromProfile, this->predivided, 1, 1, 0, 0); + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); + IMB_buffer_float_from_float(outputValue, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0); } void ConvertColorProfileOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h index b11a06f7749..0b9a07a57ca 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h @@ -34,22 +34,22 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; /** * @brief color profile where to convert from */ - int fromProfile; + int m_fromProfile; /** * @brief color profile where to convert to */ - int toProfile; + int m_toProfile; /** * @brief is color predivided */ - bool predivided; + bool m_predivided; public: /** * Default constructor @@ -71,8 +71,8 @@ public: */ void deinitExecution(); - void setFromColorProfile(int colorProfile) { this->fromProfile = colorProfile; } - void setToColorProfile(int colorProfile) { this->toProfile = colorProfile; } - void setPredivided(bool predivided) { this->predivided = predivided; } + void setFromColorProfile(int colorProfile) { this->m_fromProfile = colorProfile; } + void setToColorProfile(int colorProfile) { this->m_toProfile = colorProfile; } + void setPredivided(bool predivided) { this->m_predivided = predivided; } }; #endif diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp index 0e2c1e29a1d..a8c57449a2e 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp @@ -26,22 +26,22 @@ ConvertColorToBWOperation::ConvertColorToBWOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertColorToBWOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); + this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); outputValue[0] = rgb_to_bw(inputColor); } void ConvertColorToBWOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h index 814c0c2e808..2a57c997196 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp index 613bfe68fbb..6c79c4ea6a3 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp @@ -26,20 +26,20 @@ ConvertColorToVectorOperation::ConvertColorToVectorOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VECTOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertColorToVectorOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertColorToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - inputOperation->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(outputValue, x, y, sampler, inputBuffers); } void ConvertColorToVectorOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h index 1167b565a8e..f9170dfc7aa 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp b/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp index 2c8caec6f61..c872f3e85bb 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp @@ -26,22 +26,22 @@ ConvertColourToValueProg::ConvertColourToValueProg() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertColourToValueProg::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertColourToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); + this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f; } void ConvertColourToValueProg::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h b/source/blender/compositor/operations/COM_ConvertColourToValueProg.h index 9c43ec47604..ebd4bcbd59b 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h +++ b/source/blender/compositor/operations/COM_ConvertColourToValueProg.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index 1746afea713..91b68a90126 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -28,27 +28,27 @@ ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; - this->fStop = 128.0f; - this->cameraObject = NULL; - this->maxRadius = 32.0f; + this->m_inputOperation = NULL; + this->m_fStop = 128.0f; + this->m_cameraObject = NULL; + this->m_maxRadius = 32.0f; } float ConvertDepthToRadiusOperation::determineFocalDistance() { - if (cameraObject == NULL || cameraObject->type != OB_CAMERA) { + if (this->m_cameraObject == NULL || this->m_cameraObject->type != OB_CAMERA) { return 10.0f; } else { - Camera *camera = (Camera *)this->cameraObject->data; - cam_lens = camera->lens; + Camera *camera = (Camera *)this->m_cameraObject->data; + this->m_cam_lens = camera->lens; if (camera->dof_ob) { /* too simple, better to return the distance on the view axis only * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */ float mat[4][4], imat[4][4], obmat[4][4]; - copy_m4_m4(obmat, cameraObject->obmat); + copy_m4_m4(obmat, this->m_cameraObject->obmat); normalize_m4(obmat); invert_m4_m4(imat, obmat); mult_m4_m4m4(mat, imat, camera->dof_ob->obmat); @@ -60,14 +60,14 @@ float ConvertDepthToRadiusOperation::determineFocalDistance() void ConvertDepthToRadiusOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); float focalDistance = determineFocalDistance(); if (focalDistance == 0.0f) focalDistance = 1e10f; /* if the dof is 0.0 then set it be be far away */ - inverseFocalDistance = 1.f / focalDistance; - this->aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight()); - this->aperture = 0.5f * (this->cam_lens / (this->aspect * 32.f)) / this->fStop; + this->m_inverseFocalDistance = 1.f / focalDistance; + this->m_aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight()); + this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * 32.0f)) / this->m_fStop; float minsz = MIN2(getWidth(), getHeight()); - this->dof_sp = (float)minsz / (16.f / cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); + this->m_dof_sp = (float)minsz / (16.f / this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); } void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -75,7 +75,7 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl float inputValue[4]; float z; float radius; - inputOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputValue, x, y, sampler, inputBuffers); z = inputValue[0]; if (z != 0.f) { float iZ = (1.f / z); @@ -86,11 +86,11 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl // scale crad back to original maximum and blend crad->rect[px] = bcrad + wts->rect[px]*(scf*crad->rect[px] - bcrad); #endif - radius = 0.5f * fabsf(this->aperture * (dof_sp * (inverseFocalDistance - iZ) - 1.f)); + radius = 0.5f * fabsf(this->m_aperture * (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.f)); // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem if (radius < 0.5f) radius = 0.5f; - if (radius > maxRadius) { - radius = maxRadius; + if (radius > this->m_maxRadius) { + radius = this->m_maxRadius; } outputValue[0] = radius; } @@ -99,5 +99,5 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl void ConvertDepthToRadiusOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h index c6da6bc94a9..966a74c04ad 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h @@ -34,15 +34,15 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; - float fStop; - float aspect; - float maxRadius; - float inverseFocalDistance; - float aperture; - float cam_lens; - float dof_sp; - Object *cameraObject; + SocketReader *m_inputOperation; + float m_fStop; + float m_aspect; + float m_maxRadius; + float m_inverseFocalDistance; + float m_aperture; + float m_cam_lens; + float m_dof_sp; + Object *m_cameraObject; public: /** * Default constructor @@ -64,9 +64,9 @@ public: */ void deinitExecution(); - void setfStop(float fStop) { this->fStop = fStop; } - void setMaxRadius(float maxRadius) { this->maxRadius = maxRadius; } - void setCameraObject(Object *camera) { this->cameraObject = camera; } + void setfStop(float fStop) { this->m_fStop = fStop; } + void setMaxRadius(float maxRadius) { this->m_maxRadius = maxRadius; } + void setCameraObject(Object *camera) { this->m_cameraObject = camera; } float determineFocalDistance(); }; #endif diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp index e8c0061319c..5149e370208 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp @@ -27,24 +27,24 @@ ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertHSVToRGBOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertHSVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); hsv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertHSVToRGBOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h index 29c82361d12..f8b6a4c11fa 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp index 842546a2755..b7db0a6a2c7 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp @@ -27,12 +27,12 @@ ConvertKeyToPremulOperation::ConvertKeyToPremulOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputColor = NULL; + this->m_inputColor = NULL; } void ConvertKeyToPremulOperation::initExecution() { - this->inputColor = getInputSocketReader(0); + this->m_inputColor = getInputSocketReader(0); } void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -40,7 +40,7 @@ void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, floa float inputValue[4]; float alpha; - this->inputColor->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor->read(inputValue, x, y, sampler, inputBuffers); alpha = inputValue[3]; mul_v3_v3fl(outputValue, inputValue, alpha); @@ -51,5 +51,5 @@ void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, floa void ConvertKeyToPremulOperation::deinitExecution() { - this->inputColor = NULL; + this->m_inputColor = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h index fe0586f7a88..2b5e1871972 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h @@ -30,7 +30,7 @@ */ class ConvertKeyToPremulOperation : public NodeOperation { private: - SocketReader *inputColor; + SocketReader *m_inputColor; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp index 3554be53e3f..0ba23b2ec2e 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp @@ -27,12 +27,12 @@ ConvertPremulToKeyOperation::ConvertPremulToKeyOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputColor = NULL; + this->m_inputColor = NULL; } void ConvertPremulToKeyOperation::initExecution() { - this->inputColor = getInputSocketReader(0); + this->m_inputColor = getInputSocketReader(0); } void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -40,7 +40,7 @@ void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, floa float inputValue[4]; float alpha; - this->inputColor->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor->read(inputValue, x, y, sampler, inputBuffers); alpha = inputValue[3]; if (fabsf(alpha) < 1e-5f) { @@ -56,5 +56,5 @@ void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, floa void ConvertPremulToKeyOperation::deinitExecution() { - this->inputColor = NULL; + this->m_inputColor = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h index 093f28df3e5..05c6b26b171 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h @@ -30,7 +30,7 @@ */ class ConvertPremulToKeyOperation : public NodeOperation { private: - SocketReader *inputColor; + SocketReader *m_inputColor; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp index 051d9d2b8f9..dd5e9907642 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp @@ -27,23 +27,23 @@ ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertRGBToHSVOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertRGBToHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); rgb_to_hsv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertRGBToHSVOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h index 61270539e70..af8a7f78a61 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp index d984a1ab943..7f41a79b7f4 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp @@ -26,27 +26,26 @@ ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertRGBToYCCOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertRGBToYCCOperation::setMode(int mode) { - switch (mode) - { + switch (mode) { case 1: - this->mode = BLI_YCC_ITU_BT709; + this->m_mode = BLI_YCC_ITU_BT709; break; case 2: - this->mode = BLI_YCC_JFIF_0_255; + this->m_mode = BLI_YCC_JFIF_0_255; break; case 0: default: - this->mode = BLI_YCC_ITU_BT601; + this->m_mode = BLI_YCC_ITU_BT601; break; } } @@ -56,8 +55,8 @@ void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y float inputColor[4]; float color[3]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); - rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->mode); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode); /* divided by 255 to normalize for viewing in */ /* R,G,B --> Y,Cb,Cr */ @@ -67,5 +66,5 @@ void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y void ConvertRGBToYCCOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h index 33075cda509..97fbdb29874 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h @@ -33,12 +33,12 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; /** * YCbCr mode (Jpeg, ITU601, ITU709) */ - int mode; + int m_mode; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp index e5a8e7de1bb..e87a765f2eb 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp @@ -26,23 +26,23 @@ ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertRGBToYUVOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertRGBToYUVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertRGBToYUVOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h index 4fc525456f8..89998897782 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h @@ -33,7 +33,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp b/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp index 9d95c51a546..a29a381938f 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp @@ -26,17 +26,17 @@ ConvertValueToColourProg::ConvertValueToColourProg() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void ConvertValueToColourProg::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void ConvertValueToColourProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); color[0] = inputValue[0]; color[1] = inputValue[0]; color[2] = inputValue[0]; @@ -45,5 +45,5 @@ void ConvertValueToColourProg::executePixel(float *color, float x, float y, Pixe void ConvertValueToColourProg::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h b/source/blender/compositor/operations/COM_ConvertValueToColourProg.h index ff1d1aaeae7..69ce7e9afea 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h +++ b/source/blender/compositor/operations/COM_ConvertValueToColourProg.h @@ -30,7 +30,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: ConvertValueToColourProg(); diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp index 5ba3f6ef4a9..37760fe26d7 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp @@ -26,18 +26,18 @@ ConvertValueToVectorOperation::ConvertValueToVectorOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VECTOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertValueToVectorOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertValueToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float input[4]; - inputOperation->read(input, x, y, sampler, inputBuffers); + this->m_inputOperation->read(input, x, y, sampler, inputBuffers); outputValue[0] = input[0]; outputValue[1] = input[0]; outputValue[2] = input[0]; @@ -46,5 +46,5 @@ void ConvertValueToVectorOperation::executePixel(float *outputValue, float x, fl void ConvertValueToVectorOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h index fbb294d6a26..781b31f7fce 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp index f6a2072932c..395b96e8b25 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp @@ -26,21 +26,21 @@ ConvertVectorToColorOperation::ConvertVectorToColorOperation() : NodeOperation() { this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertVectorToColorOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertVectorToColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - inputOperation->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(outputValue, x, y, sampler, inputBuffers); outputValue[3] = 1.0f; } void ConvertVectorToColorOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h index c26adc5a6b1..2f1173ba4e8 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp index ef2d45eea03..68842c5a055 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp @@ -26,22 +26,22 @@ ConvertVectorToValueOperation::ConvertVectorToValueOperation() : NodeOperation() { this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertVectorToValueOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertVectorToValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float input[4]; - inputOperation->read(input, x, y, sampler, inputBuffers); + this->m_inputOperation->read(input, x, y, sampler, inputBuffers); outputValue[0] = (input[0] + input[1] + input[2]) / 3.0f; } void ConvertVectorToValueOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h index dd29d1bb9a9..8770992c69c 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h @@ -34,7 +34,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp index 373de25a276..78b7a7af60d 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp @@ -26,27 +26,26 @@ ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertYCCToRGBOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertYCCToRGBOperation::setMode(int mode) { - switch (mode) - { + switch (mode) { case 1: - this->mode = BLI_YCC_ITU_BT709; + this->m_mode = BLI_YCC_ITU_BT709; break; case 2: - this->mode = BLI_YCC_JFIF_0_255; + this->m_mode = BLI_YCC_JFIF_0_255; break; case 0: default: - this->mode = BLI_YCC_ITU_BT601; + this->m_mode = BLI_YCC_ITU_BT601; break; } } @@ -54,18 +53,18 @@ void ConvertYCCToRGBOperation::setMode(int mode) void ConvertYCCToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); /* need to un-normalize the data */ /* R,G,B --> Y,Cb,Cr */ mul_v3_fl(inputColor, 255.0f); - ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->mode); + ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->m_mode); outputValue[3] = inputColor[3]; } void ConvertYCCToRGBOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h index d7ddd910ed7..a595fc19bc7 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h @@ -33,12 +33,12 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; /** * YCbCr mode (Jpeg, ITU601, ITU709) */ - int mode; + int m_mode; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp index a77806d16d0..b4393c53b92 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp @@ -26,24 +26,24 @@ ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertYUVToRGBOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertYUVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertYUVToRGBOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h index f77954606cf..e89f1500d69 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h @@ -33,7 +33,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp index 5ac8c2254dc..cf3ffe6d8f4 100644 --- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp @@ -46,7 +46,7 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, Me CLAMP(y3, 0, getHeight() - 1); float value[4]; - this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL); + this->m_inputValueOperation->read(value, x2, y2, inputBuffers, NULL); float mval = 1.0f - value[0]; res1[0] = 0.0f; @@ -58,41 +58,41 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, Me res2[2] = 0.0f; res2[3] = 0.0f; - this->inputOperation->read(in1, x1, y1, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[0]); - madd_v3_v3fl(res2, in1, this->filter[0]); + this->m_inputOperation->read(in1, x1, y1, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[0]); + madd_v3_v3fl(res2, in1, this->m_filter[0]); - this->inputOperation->read(in1, x2, y1, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[1]); - madd_v3_v3fl(res2, in1, this->filter[3]); + this->m_inputOperation->read(in1, x2, y1, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[1]); + madd_v3_v3fl(res2, in1, this->m_filter[3]); - this->inputOperation->read(in1, x3, y1, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[2]); - madd_v3_v3fl(res2, in1, this->filter[6]); + this->m_inputOperation->read(in1, x3, y1, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[2]); + madd_v3_v3fl(res2, in1, this->m_filter[6]); - this->inputOperation->read(in1, x1, y2, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[3]); - madd_v3_v3fl(res2, in1, this->filter[1]); + this->m_inputOperation->read(in1, x1, y2, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[3]); + madd_v3_v3fl(res2, in1, this->m_filter[1]); - this->inputOperation->read(in2, x2, y2, inputBuffers, NULL); - madd_v3_v3fl(res1, in2, this->filter[4]); - madd_v3_v3fl(res2, in2, this->filter[4]); + this->m_inputOperation->read(in2, x2, y2, inputBuffers, NULL); + madd_v3_v3fl(res1, in2, this->m_filter[4]); + madd_v3_v3fl(res2, in2, this->m_filter[4]); - this->inputOperation->read(in1, x3, y2, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[5]); - madd_v3_v3fl(res2, in1, this->filter[7]); + this->m_inputOperation->read(in1, x3, y2, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[5]); + madd_v3_v3fl(res2, in1, this->m_filter[7]); - this->inputOperation->read(in1, x1, y3, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[6]); - madd_v3_v3fl(res2, in1, this->filter[2]); + this->m_inputOperation->read(in1, x1, y3, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[6]); + madd_v3_v3fl(res2, in1, this->m_filter[2]); - this->inputOperation->read(in1, x2, y3, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[7]); - madd_v3_v3fl(res2, in1, this->filter[5]); + this->m_inputOperation->read(in1, x2, y3, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[7]); + madd_v3_v3fl(res2, in1, this->m_filter[5]); - this->inputOperation->read(in1, x3, y3, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[8]); - madd_v3_v3fl(res2, in1, this->filter[8]); + this->m_inputOperation->read(in1, x3, y3, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[8]); + madd_v3_v3fl(res2, in1, this->m_filter[8]); color[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]); color[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]); diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp index b4f2714360e..3840e775fe3 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp @@ -30,39 +30,39 @@ ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->filter = NULL; + this->m_inputOperation = NULL; + this->m_filter = NULL; this->setComplex(true); } void ConvolutionFilterOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputValueOperation = this->getInputSocketReader(1); + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputValueOperation = this->getInputSocketReader(1); } void ConvolutionFilterOperation::set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9) { - this->filter = new float[9]; - this->filter[0] = f1; - this->filter[1] = f2; - this->filter[2] = f3; - this->filter[3] = f4; - this->filter[4] = f5; - this->filter[5] = f6; - this->filter[6] = f7; - this->filter[7] = f8; - this->filter[8] = f9; - this->filterHeight = 3; - this->filterWidth = 3; + this->m_filter = new float[9]; + this->m_filter[0] = f1; + this->m_filter[1] = f2; + this->m_filter[2] = f3; + this->m_filter[3] = f4; + this->m_filter[4] = f5; + this->m_filter[5] = f6; + this->m_filter[6] = f7; + this->m_filter[7] = f8; + this->m_filter[8] = f9; + this->m_filterHeight = 3; + this->m_filterWidth = 3; } void ConvolutionFilterOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputValueOperation = NULL; - if (this->filter) { - delete[] this->filter; - this->filter = NULL; + this->m_inputOperation = NULL; + this->m_inputValueOperation = NULL; + if (this->m_filter) { + delete[] this->m_filter; + this->m_filter = NULL; } } @@ -84,28 +84,28 @@ void ConvolutionFilterOperation::executePixel(float *color, int x, int y, Memory CLAMP(y2, 0, getHeight() - 1); CLAMP(y3, 0, getHeight() - 1); float value[4]; - this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL); + this->m_inputValueOperation->read(value, x2, y2, inputBuffers, NULL); const float mval = 1.0f - value[0]; zero_v4(color); - this->inputOperation->read(in1, x1, y1, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[0]); - this->inputOperation->read(in1, x2, y1, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[1]); - this->inputOperation->read(in1, x3, y1, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[2]); - this->inputOperation->read(in1, x1, y2, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[3]); - this->inputOperation->read(in2, x2, y2, inputBuffers, NULL); - madd_v4_v4fl(color, in2, this->filter[4]); - this->inputOperation->read(in1, x3, y2, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[5]); - this->inputOperation->read(in1, x1, y3, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[6]); - this->inputOperation->read(in1, x2, y3, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[7]); - this->inputOperation->read(in1, x3, y3, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[8]); + this->m_inputOperation->read(in1, x1, y1, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[0]); + this->m_inputOperation->read(in1, x2, y1, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[1]); + this->m_inputOperation->read(in1, x3, y1, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[2]); + this->m_inputOperation->read(in1, x1, y2, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[3]); + this->m_inputOperation->read(in2, x2, y2, inputBuffers, NULL); + madd_v4_v4fl(color, in2, this->m_filter[4]); + this->m_inputOperation->read(in1, x3, y2, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[5]); + this->m_inputOperation->read(in1, x1, y3, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[6]); + this->m_inputOperation->read(in1, x2, y3, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[7]); + this->m_inputOperation->read(in1, x3, y3, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[8]); color[0] = color[0] * value[0] + in2[0] * mval; color[1] = color[1] * value[0] + in2[1] * mval; @@ -116,8 +116,8 @@ void ConvolutionFilterOperation::executePixel(float *color, int x, int y, Memory bool ConvolutionFilterOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - int addx = (this->filterWidth - 1) / 2 + 1; - int addy = (this->filterHeight - 1) / 2 + 1; + int addx = (this->m_filterWidth - 1) / 2 + 1; + int addy = (this->m_filterHeight - 1) / 2 + 1; newInput.xmax = input->xmax + addx; newInput.xmin = input->xmin - addx; newInput.ymax = input->ymax + addy; diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h index f3347eb583a..0b5dfb4d75a 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h @@ -27,13 +27,13 @@ class ConvolutionFilterOperation : public NodeOperation { private: - int filterWidth; - int filterHeight; + int m_filterWidth; + int m_filterHeight; protected: - SocketReader *inputOperation; - SocketReader *inputValueOperation; - float *filter; + SocketReader *m_inputOperation; + SocketReader *m_inputValueOperation; + float *m_filter; public: ConvolutionFilterOperation(); diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp index 0bdd2cfcb51..0a40f2370c8 100644 --- a/source/blender/compositor/operations/COM_CropOperation.cpp +++ b/source/blender/compositor/operations/COM_CropOperation.cpp @@ -27,8 +27,8 @@ CropBaseOperation::CropBaseOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; - this->settings = NULL; + this->m_inputOperation = NULL; + this->m_settings = NULL; } void CropBaseOperation::updateArea() @@ -36,36 +36,36 @@ void CropBaseOperation::updateArea() SocketReader *inputReference = this->getInputSocketReader(0); float width = inputReference->getWidth(); float height = inputReference->getHeight(); - if (this->relative) { - settings->x1 = width * settings->fac_x1; - settings->x2 = width * settings->fac_x2; - settings->y1 = height * settings->fac_y1; - settings->y2 = height * settings->fac_y2; + if (this->m_relative) { + this->m_settings->x1 = width * this->m_settings->fac_x1; + this->m_settings->x2 = width * this->m_settings->fac_x2; + this->m_settings->y1 = height * this->m_settings->fac_y1; + this->m_settings->y2 = height * this->m_settings->fac_y2; } - if (width <= settings->x1 + 1) - settings->x1 = width - 1; - if (height <= settings->y1 + 1) - settings->y1 = height - 1; - if (width <= settings->x2 + 1) - settings->x2 = width - 1; - if (height <= settings->y2 + 1) - settings->y2 = height - 1; + if (width <= this->m_settings->x1 + 1) + this->m_settings->x1 = width - 1; + if (height <= this->m_settings->y1 + 1) + this->m_settings->y1 = height - 1; + if (width <= this->m_settings->x2 + 1) + this->m_settings->x2 = width - 1; + if (height <= this->m_settings->y2 + 1) + this->m_settings->y2 = height - 1; - this->xmax = MAX2(settings->x1, settings->x2) + 1; - this->xmin = MIN2(settings->x1, settings->x2); - this->ymax = MAX2(settings->y1, settings->y2) + 1; - this->ymin = MIN2(settings->y1, settings->y2); + this->m_xmax = MAX2(this->m_settings->x1, this->m_settings->x2) + 1; + this->m_xmin = MIN2(this->m_settings->x1, this->m_settings->x2); + this->m_ymax = MAX2(this->m_settings->y1, this->m_settings->y2) + 1; + this->m_ymin = MIN2(this->m_settings->y1, this->m_settings->y2); } void CropBaseOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); updateArea(); } void CropBaseOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } CropOperation::CropOperation() : CropBaseOperation() @@ -75,14 +75,11 @@ CropOperation::CropOperation() : CropBaseOperation() void CropOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if ((x < this->xmax && x >= xmin) && (y < ymax && y >= ymin)) { - inputOperation->read(color, x, y, sampler, inputBuffers); + if ((x < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) { + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); } else { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + zero_v4(color); } } @@ -95,10 +92,10 @@ bool CropImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe { rcti newInput; - newInput.xmax = input->xmax + this->xmin; - newInput.xmin = input->xmin + this->xmin; - newInput.ymax = input->ymax + this->ymin; - newInput.ymin = input->ymin + this->ymin; + newInput.xmax = input->xmax + this->m_xmin; + newInput.xmin = input->xmin + this->m_xmin; + newInput.ymax = input->ymax + this->m_ymin; + newInput.ymin = input->ymin + this->m_ymin; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -107,11 +104,11 @@ void CropImageOperation::determineResolution(unsigned int resolution[], unsigned { NodeOperation::determineResolution(resolution, preferedResolution); updateArea(); - resolution[0] = this->xmax - this->xmin; - resolution[1] = this->ymax - this->ymin; + resolution[0] = this->m_xmax - this->m_xmin; + resolution[1] = this->m_ymax - this->m_ymin; } void CropImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - this->inputOperation->read(color, (x + this->xmin), (y + this->ymin), sampler, inputBuffers); + this->m_inputOperation->read(color, (x + this->m_xmin), (y + this->m_ymin), sampler, inputBuffers); } diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h index 48e5ab7f75b..39dbb8aa873 100644 --- a/source/blender/compositor/operations/COM_CropOperation.h +++ b/source/blender/compositor/operations/COM_CropOperation.h @@ -27,21 +27,21 @@ class CropBaseOperation : public NodeOperation { protected: - SocketReader *inputOperation; - NodeTwoXYs *settings; - bool relative; - int xmax; - int xmin; - int ymax; - int ymin; + SocketReader *m_inputOperation; + NodeTwoXYs *m_settings; + bool m_relative; + int m_xmax; + int m_xmin; + int m_ymax; + int m_ymin; void updateArea(); public: CropBaseOperation(); void initExecution(); void deinitExecution(); - void setCropSettings(NodeTwoXYs *settings) { this->settings = settings; } - void setRelative(bool rel) { this->relative = rel; } + void setCropSettings(NodeTwoXYs *settings) { this->m_settings = settings; } + void setRelative(bool rel) { this->m_relative = rel; } }; class CropOperation : public CropBaseOperation { diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp index 6aa8bc2a0df..48d2bcd0ef9 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp @@ -32,9 +32,9 @@ extern "C" { CurveBaseOperation::CurveBaseOperation() : NodeOperation() { - this->curveMapping = NULL; + this->m_curveMapping = NULL; } void CurveBaseOperation::initExecution() { - curvemapping_initialize(this->curveMapping); + curvemapping_initialize(this->m_curveMapping); } diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h index 9cddb3be46b..1636c13a571 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.h +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h @@ -30,7 +30,7 @@ protected: /** * Cached reference to the inputProgram */ - CurveMapping *curveMapping; + CurveMapping *m_curveMapping; public: CurveBaseOperation(); @@ -39,6 +39,6 @@ public: */ void initExecution(); - void setCurveMapping(CurveMapping *mapping) { this->curveMapping = mapping; } + void setCurveMapping(CurveMapping *mapping) { this->m_curveMapping = mapping; } }; #endif diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp index c27e699f627..75f909e2198 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp @@ -29,19 +29,19 @@ DifferenceMatteOperation::DifferenceMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImage1Program = NULL; - inputImage2Program = NULL; + this->m_inputImage1Program = NULL; + this->m_inputImage2Program = NULL; } void DifferenceMatteOperation::initExecution() { - this->inputImage1Program = this->getInputSocketReader(0); - this->inputImage2Program = this->getInputSocketReader(1); + this->m_inputImage1Program = this->getInputSocketReader(0); + this->m_inputImage2Program = this->getInputSocketReader(1); } void DifferenceMatteOperation::deinitExecution() { - this->inputImage1Program = NULL; - this->inputImage2Program = NULL; + this->m_inputImage1Program = NULL; + this->m_inputImage2Program = NULL; } void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,13 +49,13 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y float inColor1[4]; float inColor2[4]; - const float tolerence = this->settings->t1; - const float falloff = this->settings->t2; + const float tolerence = this->m_settings->t1; + const float falloff = this->m_settings->t2; float difference; float alpha; - this->inputImage1Program->read(inColor1, x, y, sampler, inputBuffers); - this->inputImage2Program->read(inColor2, x, y, sampler, inputBuffers); + this->m_inputImage1Program->read(inColor1, x, y, sampler, inputBuffers); + this->m_inputImage2Program->read(inColor2, x, y, sampler, inputBuffers); difference = (fabsf(inColor2[0] - inColor1[0]) + fabsf(inColor2[1] - inColor1[1]) + diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h index 3bdc3384556..48eb2626f02 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h @@ -31,9 +31,9 @@ */ class DifferenceMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImage1Program; - SocketReader *inputImage2Program; + NodeChroma *m_settings; + SocketReader *m_inputImage1Program; + SocketReader *m_inputImage2Program; public: /** * Default constructor @@ -48,6 +48,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 80d1c6444eb..338a3a0b59b 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -30,57 +30,57 @@ DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); this->setComplex(true); - this->inputProgram = NULL; - this->inset = 0.0f; - this->_switch = 0.5f; - this->distance = 0.0f; + this->m_inputProgram = NULL; + this->m_inset = 0.0f; + this->m__switch = 0.5f; + this->m_distance = 0.0f; } void DilateErodeThresholdOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - if (this->distance < 0.0f) { - this->scope = -this->distance + this->inset; + this->m_inputProgram = this->getInputSocketReader(0); + if (this->m_distance < 0.0f) { + this->m_scope = -this->m_distance + this->m_inset; } else { - if (this->inset * 2 > this->distance) { - this->scope = max(this->inset * 2 - this->distance, this->distance); + if (this->m_inset * 2 > this->m_distance) { + this->m_scope = max(this->m_inset * 2 - this->m_distance, this->m_distance); } else { - this->scope = distance; + this->m_scope = this->m_distance; } } - if (scope < 3) { - scope = 3; + if (this->m_scope < 3) { + this->m_scope = 3; } } void *DilateErodeThresholdOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { float inputValue[4]; - const float sw = this->_switch; - const float distance = this->distance; + const float sw = this->m__switch; + const float distance = this->m_distance; float pixelvalue; - const float rd = scope * scope; - const float inset = this->inset; + const float rd = this->m_scope * this->m_scope; + const float inset = this->m_inset; float mindist = rd * 2; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); - const int minx = max(x - scope, rect->xmin); - const int miny = max(y - scope, rect->ymin); - const int maxx = min(x + scope, rect->xmax); - const int maxy = min(y + scope, rect->ymax); + const int minx = max(x - this->m_scope, rect->xmin); + const int miny = max(y - this->m_scope, rect->ymin); + const int maxx = min(x + this->m_scope, rect->xmax); + const int maxy = min(y + this->m_scope, rect->ymax); const int bufferWidth = rect->xmax - rect->xmin; int offset; - this->inputProgram->read(inputValue, x, y, inputBuffers, NULL); + this->m_inputProgram->read(inputValue, x, y, inputBuffers, NULL); if (inputValue[0] > sw) { for (int yi = miny; yi < maxy; yi++) { const float dy = yi - y; @@ -145,17 +145,17 @@ void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, Mem void DilateErodeThresholdOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - newInput.xmax = input->xmax + scope; - newInput.xmin = input->xmin - scope; - newInput.ymax = input->ymax + scope; - newInput.ymin = input->ymin - scope; + newInput.xmax = input->xmax + this->m_scope; + newInput.xmin = input->xmin - this->m_scope; + newInput.ymax = input->ymax + this->m_scope; + newInput.ymin = input->ymin - this->m_scope; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -166,37 +166,37 @@ DilateDistanceOperation::DilateDistanceOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); this->setComplex(true); - this->inputProgram = NULL; - this->distance = 0.0f; + this->m_inputProgram = NULL; + this->m_distance = 0.0f; this->setOpenCL(true); } void DilateDistanceOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->scope = distance; - if (scope < 3) { - scope = 3; + this->m_inputProgram = this->getInputSocketReader(0); + this->m_scope = this->m_distance; + if (this->m_scope < 3) { + this->m_scope = 3; } } void *DilateDistanceOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const float distance = this->distance; + const float distance = this->m_distance; const float mindist = distance * distance; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); - const int minx = max(x - scope, rect->xmin); - const int miny = max(y - scope, rect->ymin); - const int maxx = min(x + scope, rect->xmax); - const int maxy = min(y + scope, rect->ymax); + const int minx = max(x - this->m_scope, rect->xmin); + const int miny = max(y - this->m_scope, rect->ymin); + const int maxx = min(x + this->m_scope, rect->xmax); + const int maxy = min(y + this->m_scope, rect->ymax); const int bufferWidth = rect->xmax - rect->xmin; int offset; @@ -219,17 +219,17 @@ void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuf void DilateDistanceOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - newInput.xmax = input->xmax + scope; - newInput.xmin = input->xmin - scope; - newInput.ymax = input->ymax + scope; - newInput.ymin = input->ymin - scope; + newInput.xmax = input->xmax + this->m_scope; + newInput.xmin = input->xmin - this->m_scope; + newInput.ymax = input->ymax + this->m_scope; + newInput.ymin = input->ymin - this->m_scope; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -243,10 +243,10 @@ void DilateDistanceOperation::executeOpenCL(OpenCLDevice* device, if (!dilateKernel) { dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); } - cl_int distanceSquared = this->distance * this->distance; - cl_int scope = this->scope; + cl_int distanceSquared = this->m_distance * this->m_distance; + cl_int scope = this->m_scope; - device->COM_clAttachMemoryBufferToKernelParameter(dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachMemoryBufferToKernelParameter(dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer); device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer); clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope); @@ -263,16 +263,16 @@ ErodeDistanceOperation::ErodeDistanceOperation() : DilateDistanceOperation() void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const float distance = this->distance; + const float distance = this->m_distance; const float mindist = distance * distance; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); - const int minx = max(x - scope, rect->xmin); - const int miny = max(y - scope, rect->ymin); - const int maxx = min(x + scope, rect->xmax); - const int maxy = min(y + scope, rect->ymax); + const int minx = max(x - this->m_scope, rect->xmin); + const int miny = max(y - this->m_scope, rect->ymin); + const int maxx = min(x + this->m_scope, rect->xmax); + const int maxy = min(y + this->m_scope, rect->ymax); const int bufferWidth = rect->xmax - rect->xmin; int offset; @@ -302,10 +302,10 @@ void ErodeDistanceOperation::executeOpenCL(OpenCLDevice* device, if (!erodeKernel) { erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); } - cl_int distanceSquared = this->distance * this->distance; - cl_int scope = this->scope; + cl_int distanceSquared = this->m_distance * this->m_distance; + cl_int scope = this->m_scope; - device->COM_clAttachMemoryBufferToKernelParameter(erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachMemoryBufferToKernelParameter(erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer); device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer); clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope); @@ -320,29 +320,29 @@ DilateStepOperation::DilateStepOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); this->setComplex(true); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void DilateStepOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->cached_buffer = NULL; + this->m_inputProgram = this->getInputSocketReader(0); + this->m_cached_buffer = NULL; this->initMutex(); } void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cached_buffer != NULL) { - return this->cached_buffer; + if (this->m_cached_buffer != NULL) { + return this->m_cached_buffer; } lockMutex(); - if (this->cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers); + if (this->m_cached_buffer == NULL) { + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL, memoryBuffers); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; int bwidth = buffer->getWidth(); int bheight = buffer->getHeight(); - for (i = 0; i < this->iterations; i++) { + for (i = 0; i < this->m_iterations; i++) { for (y = 0; y < bheight; y++) { for (x = 0; x < bwidth - 1; x++) { p = rectf + (bwidth * y + x); @@ -371,31 +371,31 @@ void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB } } } - this->cached_buffer = rectf; + this->m_cached_buffer = rectf; } unlockMutex(); - return this->cached_buffer; + return this->m_cached_buffer; } void DilateStepOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - color[0] = this->cached_buffer[y * this->getWidth() + x]; + color[0] = this->m_cached_buffer[y * this->getWidth() + x]; } void DilateStepOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; this->deinitMutex(); - if (this->cached_buffer) { - delete cached_buffer; - this->cached_buffer = NULL; + if (this->m_cached_buffer) { + delete this->m_cached_buffer; + this->m_cached_buffer = NULL; } } bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { - if (this->cached_buffer) { + if (this->m_cached_buffer) { return false; } else { @@ -418,18 +418,18 @@ ErodeStepOperation::ErodeStepOperation() : DilateStepOperation() void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cached_buffer != NULL) { - return this->cached_buffer; + if (this->m_cached_buffer != NULL) { + return this->m_cached_buffer; } lockMutex(); - if (this->cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers); + if (this->m_cached_buffer == NULL) { + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL, memoryBuffers); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; int bwidth = buffer->getWidth(); int bheight = buffer->getHeight(); - for (i = 0; i < this->iterations; i++) { + for (i = 0; i < this->m_iterations; i++) { for (y = 0; y < bheight; y++) { for (x = 0; x < bwidth - 1; x++) { p = rectf + (bwidth * y + x); @@ -458,8 +458,8 @@ void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu } } } - this->cached_buffer = rectf; + this->m_cached_buffer = rectf; } unlockMutex(); - return this->cached_buffer; + return this->m_cached_buffer; } diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h index 4d0bf9de0ec..bc6049bf992 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.h +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h @@ -30,17 +30,17 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - float distance; - float _switch; - float inset; + float m_distance; + float m__switch; + float m_inset; /** * determines the area of interest to track pixels * keep this one as small as possible for speed gain. */ - int scope; + int m_scope; public: DilateErodeThresholdOperation(); @@ -60,9 +60,9 @@ public: */ void deinitExecution(); - void setDistance(float distance) { this->distance = distance; } - void setSwitch(float sw) { this->_switch = sw; } - void setInset(float inset) { this->inset = inset; } + void setDistance(float distance) { this->m_distance = distance; } + void setSwitch(float sw) { this->m__switch = sw; } + void setInset(float inset) { this->m_inset = inset; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -74,9 +74,9 @@ protected: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - float distance; - int scope; + SocketReader *m_inputProgram; + float m_distance; + int m_scope; public: DilateDistanceOperation(); @@ -96,7 +96,7 @@ public: */ void deinitExecution(); - void setDistance(float distance) { this->distance = distance; } + void setDistance(float distance) { this->m_distance = distance; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void executeOpenCL(OpenCLDevice* device, @@ -124,11 +124,11 @@ protected: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - int iterations; + int m_iterations; - float *cached_buffer; + float *m_cached_buffer; public: DilateStepOperation(); @@ -148,7 +148,7 @@ public: */ void deinitExecution(); - void setIterations(int iterations) { this->iterations = iterations; } + void setIterations(int iterations) { this->m_iterations = iterations; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp index 271a165f0ff..da7336afc07 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp @@ -33,20 +33,20 @@ DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void DirectionalBlurOperation::initExecution() { - this->inputProgram = getInputSocketReader(0); + this->m_inputProgram = getInputSocketReader(0); QualityStepHelper::initExecution(COM_QH_INCREASE); - const float angle = this->data->angle; - const float zoom = this->data->zoom; - const float spin = this->data->spin; - const float iterations = this->data->iter; - const float distance = this->data->distance; - const float center_x = this->data->center_x; - const float center_y = this->data->center_y; + const float angle = this->m_data->angle; + const float zoom = this->m_data->zoom; + const float spin = this->m_data->spin; + const float iterations = this->m_data->iter; + const float distance = this->m_data->distance; + const float center_x = this->m_data->center_x; + const float center_y = this->m_data->center_y; const float width = getWidth(); const float height = getHeight(); @@ -55,43 +55,46 @@ void DirectionalBlurOperation::initExecution() float D; D = distance * sqrtf(width * width + height * height); - center_x_pix = center_x * width; - center_y_pix = center_y * height; + this->m_center_x_pix = center_x * width; + this->m_center_y_pix = center_y * height; - tx = itsc * D * cosf(a); - ty = -itsc *D *sinf(a); - sc = itsc * zoom; - rot = itsc * spin; + this->m_tx = itsc * D * cosf(a); + this->m_ty = -itsc *D *sinf(a); + this->m_sc = itsc * zoom; + this->m_rot = itsc * spin; } void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const int iterations = pow(2.f, this->data->iter); + const int iterations = pow(2.0f, this->m_data->iter); float col[4] = {0, 0, 0, 0}; float col2[4] = {0, 0, 0, 0}; - this->inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers); - float ltx = tx; - float lty = ty; - float lsc = sc; - float lrot = rot; + this->m_inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers); + float ltx = this->m_tx; + float lty = this->m_ty; + float lsc = this->m_sc; + float lrot = this->m_rot; /* blur the image */ for (int i = 0; i < iterations; ++i) { const float cs = cos(lrot), ss = sin(lrot); - const float isc = 1.f / (1.f + lsc); + const float isc = 1.0f / (1.0f + lsc); - const float v = isc * (y - center_y_pix) + lty; - const float u = isc * (x - center_x_pix) + ltx; + const float v = isc * (y - this->m_center_y_pix) + lty; + const float u = isc * (x - this->m_center_x_pix) + ltx; - this->inputProgram->read(col, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(col, + cs * u + ss * v + this->m_center_x_pix, + cs * v - ss * u + this->m_center_y_pix, + COM_PS_NEAREST, inputBuffers); add_v4_v4(col2, col); /* double transformations */ - ltx += tx; - lty += ty; - lrot += rot; - lsc += sc; + ltx += this->m_tx; + lty += this->m_ty; + lrot += this->m_rot; + lsc += this->m_sc; } mul_v4_v4fl(color, col2, 1.0f / iterations); @@ -99,7 +102,7 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu void DirectionalBlurOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h index 9cc0a4361f1..329f855871e 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h @@ -27,12 +27,12 @@ class DirectionalBlurOperation : public NodeOperation, public QualityStepHelper { private: - SocketReader *inputProgram; - NodeDBlurData *data; + SocketReader *m_inputProgram; + NodeDBlurData *m_data; - float center_x_pix, center_y_pix; - float tx, ty; - float sc, rot; + float m_center_x_pix, m_center_y_pix; + float m_tx, m_ty; + float m_sc, m_rot; public: DirectionalBlurOperation(); @@ -54,6 +54,6 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setData(NodeDBlurData *data) { this->data = data; } + void setData(NodeDBlurData *data) { this->m_data = data; } }; #endif diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp index be50641a125..c7df53770c5 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp @@ -32,21 +32,21 @@ DisplaceOperation::DisplaceOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } void DisplaceOperation::initExecution() { - this->inputColorProgram = this->getInputSocketReader(0); - this->inputVectorProgram = this->getInputSocketReader(1); - this->inputScaleXProgram = this->getInputSocketReader(2); - this->inputScaleYProgram = this->getInputSocketReader(3); + this->m_inputColorProgram = this->getInputSocketReader(0); + this->m_inputVectorProgram = this->getInputSocketReader(1); + this->m_inputScaleXProgram = this->getInputSocketReader(2); + this->m_inputScaleYProgram = this->getInputSocketReader(3); - width_x4 = this->getWidth() * 4; - height_x4 = this->getHeight() * 4; + this->m_width_x4 = this->getWidth() * 4; + this->m_height_x4 = this->getHeight() * 4; } @@ -64,17 +64,17 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i float dxt, dyt; float u, v; - this->inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); float xs = inScale[0]; - this->inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - * to prevent hangs from huge values mistakenly plugged in eg. z buffers */ - CLAMP(xs, -width_x4, width_x4); - CLAMP(ys, -height_x4, height_x4); + CLAMP(xs, -this->m_width_x4, this->m_width_x4); + CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST, inputBuffers); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -83,9 +83,9 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i v = y - p_dy + 0.5f; /* calc derivatives */ - this->inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST, inputBuffers); d_dx = inVector[0] * xs; - this->inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST, inputBuffers); d_dy = inVector[0] * ys; /* clamp derivatives to minimum displacement distance in UV space */ @@ -96,15 +96,15 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i dyt = signf(dyt) * maxf(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight(); /* EWA filtering */ - this->inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers); + this->m_inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers); } void DisplaceOperation::deinitExecution() { - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.h b/source/blender/compositor/operations/COM_DisplaceOperation.h index 82788e37e3a..e01c9190396 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.h +++ b/source/blender/compositor/operations/COM_DisplaceOperation.h @@ -29,13 +29,13 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputColorProgram; - SocketReader *inputVectorProgram; - SocketReader *inputScaleXProgram; - SocketReader *inputScaleYProgram; + SocketReader *m_inputColorProgram; + SocketReader *m_inputVectorProgram; + SocketReader *m_inputScaleXProgram; + SocketReader *m_inputScaleYProgram; - float width_x4; - float height_x4; + float m_width_x4; + float m_height_x4; public: DisplaceOperation(); diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp index 716646e9c36..d21fc62abd7 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp @@ -31,21 +31,21 @@ DisplaceSimpleOperation::DisplaceSimpleOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } void DisplaceSimpleOperation::initExecution() { - this->inputColorProgram = this->getInputSocketReader(0); - this->inputVectorProgram = this->getInputSocketReader(1); - this->inputScaleXProgram = this->getInputSocketReader(2); - this->inputScaleYProgram = this->getInputSocketReader(3); + this->m_inputColorProgram = this->getInputSocketReader(0); + this->m_inputVectorProgram = this->getInputSocketReader(1); + this->m_inputScaleXProgram = this->getInputSocketReader(2); + this->m_inputScaleYProgram = this->getInputSocketReader(3); - width_x4 = this->getWidth() * 4; - height_x4 = this->getHeight() * 4; + this->m_width_x4 = this->getWidth() * 4; + this->m_height_x4 = this->getHeight() * 4; } @@ -61,17 +61,17 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel float p_dx, p_dy; /* main displacement in pixel space */ float u, v; - this->inputScaleXProgram->read(inScale, x, y, sampler, inputBuffers); + this->m_inputScaleXProgram->read(inScale, x, y, sampler, inputBuffers); float xs = inScale[0]; - this->inputScaleYProgram->read(inScale, x, y, sampler, inputBuffers); + this->m_inputScaleYProgram->read(inScale, x, y, sampler, inputBuffers); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - * to prevent hangs from huge values mistakenly plugged in eg. z buffers */ - CLAMP(xs, -width_x4, width_x4); - CLAMP(ys, -height_x4, height_x4); + CLAMP(xs, -this->m_width_x4, this->m_width_x4); + CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->inputVectorProgram->read(inVector, x, y, sampler, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y, sampler, inputBuffers); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -82,15 +82,15 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel CLAMP(u, 0.f, this->getWidth() - 1.f); CLAMP(v, 0.f, this->getHeight() - 1.f); - this->inputColorProgram->read(color, u, v, sampler, inputBuffers); + this->m_inputColorProgram->read(color, u, v, sampler, inputBuffers); } void DisplaceSimpleOperation::deinitExecution() { - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h index 1ebb238855b..25afbafe335 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h @@ -29,13 +29,13 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputColorProgram; - SocketReader *inputVectorProgram; - SocketReader *inputScaleXProgram; - SocketReader *inputScaleYProgram; + SocketReader *m_inputColorProgram; + SocketReader *m_inputVectorProgram; + SocketReader *m_inputScaleXProgram; + SocketReader *m_inputScaleYProgram; - float width_x4; - float height_x4; + float m_width_x4; + float m_height_x4; public: DisplaceSimpleOperation(); diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp index ec01ba922b5..19cca3d25bb 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp @@ -28,20 +28,20 @@ DistanceMatteOperation::DistanceMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; - inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void DistanceMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); - this->inputKeyProgram = this->getInputSocketReader(1); + this->m_inputImageProgram = this->getInputSocketReader(0); + this->m_inputKeyProgram = this->getInputSocketReader(1); } void DistanceMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; - this->inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,14 +49,14 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, float inKey[4]; float inImage[4]; - const float tolerence = this->settings->t1; - const float falloff = this->settings->t2; + const float tolerence = this->m_settings->t1; + const float falloff = this->m_settings->t2; float distance; float alpha; - this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); - this->inputImageProgram->read(inImage, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inImage, x, y, sampler, inputBuffers); distance = sqrt(pow((inKey[0] - inImage[0]), 2) + pow((inKey[1] - inImage[1]), 2) + diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceMatteOperation.h index cf1172a8c11..51e139d179e 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.h @@ -30,9 +30,9 @@ */ class DistanceMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; - SocketReader *inputKeyProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; + SocketReader *m_inputKeyProgram; public: /** * Default constructor @@ -47,6 +47,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp index e225a677989..53ab5f97518 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.cpp +++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp @@ -28,19 +28,19 @@ DotproductOperation::DotproductOperation() : NodeOperation() this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_VALUE); this->setResolutionInputSocketIndex(0); - this->input1Operation = NULL; - this->input2Operation = NULL; + this->m_input1Operation = NULL; + this->m_input2Operation = NULL; } void DotproductOperation::initExecution() { - this->input1Operation = this->getInputSocketReader(0); - this->input2Operation = this->getInputSocketReader(1); + this->m_input1Operation = this->getInputSocketReader(0); + this->m_input2Operation = this->getInputSocketReader(1); } void DotproductOperation::deinitExecution() { - this->input1Operation = NULL; - this->input2Operation = NULL; + this->m_input1Operation = NULL; + this->m_input2Operation = NULL; } /** @todo: current implementation is the inverse of a dotproduct. not 'logically' correct @@ -49,7 +49,7 @@ void DotproductOperation::executePixel(float *color, float x, float y, PixelSamp { float input1[4]; float input2[4]; - this->input1Operation->read(input1, x, y, sampler, inputBuffers); - this->input2Operation->read(input2, x, y, sampler, inputBuffers); + this->m_input1Operation->read(input1, x, y, sampler, inputBuffers); + this->m_input2Operation->read(input2, x, y, sampler, inputBuffers); color[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]); } diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h index 849dc83a9cd..7ca540983d9 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.h +++ b/source/blender/compositor/operations/COM_DotproductOperation.h @@ -27,8 +27,8 @@ class DotproductOperation : public NodeOperation { private: - SocketReader *input1Operation; - SocketReader *input2Operation; + SocketReader *m_input1Operation; + SocketReader *m_input2Operation; public: DotproductOperation(); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index 8344a4d248b..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. */ @@ -1184,8 +1184,8 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float * * Each version has slightly different criteria for detecting an edge pixel. */ - if (this->adjecentOnly) { // if "adjacent only" inner edge mode is turned on - if (this->keepInside) { // if "keep inside" buffer edge mode is turned on + if (this->m_adjecentOnly) { // if "adjacent only" inner edge mode is turned on + if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize); } else { // "bleed out" buffer edge mode is turned on @@ -1198,7 +1198,7 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz); } else { // "all" inner edge mode is turned on - if (this->keepInside) { // if "keep inside" buffer edge mode is turned on + if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize); } else { // "bleed out" buffer edge mode is turned on @@ -1230,16 +1230,16 @@ DoubleEdgeMaskOperation::DoubleEdgeMaskOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputInnerMask = NULL; - this->inputOuterMask = NULL; - this->adjecentOnly = false; - this->keepInside = false; + this->m_inputInnerMask = NULL; + this->m_inputOuterMask = NULL; + this->m_adjecentOnly = false; + this->m_keepInside = false; this->setComplex(true); } bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { - if (this->cachedInstance == NULL) { + if (this->m_cachedInstance == NULL) { rcti newInput; newInput.xmax = this->getWidth(); newInput.xmin = 0; @@ -1254,30 +1254,31 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti *input, Read void DoubleEdgeMaskOperation::initExecution() { - this->inputInnerMask = this->getInputSocketReader(0); - this->inputOuterMask = this->getInputSocketReader(1); + this->m_inputInnerMask = this->getInputSocketReader(0); + this->m_inputOuterMask = this->getInputSocketReader(1); initMutex(); - this->cachedInstance = NULL; + this->m_cachedInstance = NULL; } void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cachedInstance) return this->cachedInstance; + if (this->m_cachedInstance) + return this->m_cachedInstance; lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *innerMask = (MemoryBuffer *)inputInnerMask->initializeTileData(rect, memoryBuffers); - MemoryBuffer *outerMask = (MemoryBuffer *)inputOuterMask->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect, memoryBuffers); + MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect, memoryBuffers); float *data = new float[this->getWidth() * this->getHeight()]; float *imask = innerMask->convertToValueBuffer(); float *omask = outerMask->convertToValueBuffer(); doDoubleEdgeMask(imask, omask, data); delete imask; delete omask; - this->cachedInstance = data; + this->m_cachedInstance = data; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } void DoubleEdgeMaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { @@ -1291,12 +1292,12 @@ void DoubleEdgeMaskOperation::executePixel(float *color, int x, int y, MemoryBuf void DoubleEdgeMaskOperation::deinitExecution() { - this->inputInnerMask = NULL; - this->inputOuterMask = NULL; + this->m_inputInnerMask = NULL; + this->m_inputOuterMask = NULL; deinitMutex(); - if (this->cachedInstance) { - delete cachedInstance; - this->cachedInstance = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; + this->m_cachedInstance = NULL; } } diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h index a18d59ae5a2..442680e320e 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h @@ -30,11 +30,11 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOuterMask; - SocketReader *inputInnerMask; - bool adjecentOnly; - bool keepInside; - float *cachedInstance; + SocketReader *m_inputOuterMask; + SocketReader *m_inputInnerMask; + bool m_adjecentOnly; + bool m_keepInside; + float *m_cachedInstance; public: DoubleEdgeMaskOperation(); @@ -58,7 +58,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setAdjecentOnly(bool adjecentOnly) { this->adjecentOnly = adjecentOnly; } - void setKeepInside(bool keepInside) { this->keepInside = keepInside; } + void setAdjecentOnly(bool adjecentOnly) { this->m_adjecentOnly = adjecentOnly; } + void setKeepInside(bool keepInside) { this->m_keepInside = keepInside; } }; #endif diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp index 0beacd02738..1aa1b89ee76 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp @@ -29,19 +29,19 @@ EllipseMaskOperation::EllipseMaskOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputMask = NULL; - this->inputValue = NULL; - this->cosine = 0.0f; - this->sine = 0.0f; + this->m_inputMask = NULL; + this->m_inputValue = NULL; + this->m_cosine = 0.0f; + this->m_sine = 0.0f; } void EllipseMaskOperation::initExecution() { - this->inputMask = this->getInputSocketReader(0); - this->inputValue = this->getInputSocketReader(1); - const double rad = DEG2RAD((double)this->data->rotation); - this->cosine = cos(rad); - this->sine = sin(rad); - this->aspectRatio = ((float)this->getWidth()) / this->getHeight(); + this->m_inputMask = this->getInputSocketReader(0); + this->m_inputValue = this->getInputSocketReader(1); + const double rad = DEG2RAD((double)this->m_data->rotation); + this->m_cosine = cos(rad); + this->m_sine = sin(rad); + this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -52,26 +52,26 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam float rx = x / this->getWidth(); float ry = y / this->getHeight(); - const float dy = (ry - this->data->y) / this->aspectRatio; - const float dx = rx - this->data->x; - rx = this->data->x + (this->cosine * dx + this->sine * dy); - ry = this->data->y + (-this->sine * dx + this->cosine * dy); + const float dy = (ry - this->m_data->y) / this->m_aspectRatio; + const float dx = rx - this->m_data->x; + rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); + ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->inputMask->read(inputMask, x, y, sampler, inputBuffers); - this->inputValue->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); + this->m_inputValue->read(inputValue, x, y, sampler, inputBuffers); - const float halfHeight = (this->data->height) / 2.0f; - const float halfWidth = this->data->width / 2.0f; - float sx = rx - this->data->x; + const float halfHeight = (this->m_data->height) / 2.0f; + const float halfWidth = this->m_data->width / 2.0f; + float sx = rx - this->m_data->x; sx *= sx; const float tx = halfWidth * halfWidth; - float sy = ry - this->data->y; + float sy = ry - this->m_data->y; sy *= sy; const float ty = halfHeight * halfHeight; bool inside = ((sx / tx) + (sy / ty)) < 1.0f; - switch (this->maskType) { + switch (this->m_maskType) { case CMP_NODE_MASKTYPE_ADD: if (inside) { color[0] = max(inputMask[0], inputValue[0]); @@ -117,7 +117,7 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam void EllipseMaskOperation::deinitExecution() { - this->inputMask = NULL; - this->inputValue = NULL; + this->m_inputMask = NULL; + this->m_inputValue = NULL; } diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h index 61d724c2f15..0b0ffa023cb 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h @@ -30,15 +30,15 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputMask; - SocketReader *inputValue; + SocketReader *m_inputMask; + SocketReader *m_inputValue; - float sine; - float cosine; - float aspectRatio; - int maskType; + float m_sine; + float m_cosine; + float m_aspectRatio; + int m_maskType; - NodeEllipseMask *data; + NodeEllipseMask *m_data; public: EllipseMaskOperation(); @@ -57,9 +57,9 @@ public: */ void deinitExecution(); - void setData(NodeEllipseMask *data) { this->data = data; } + void setData(NodeEllipseMask *data) { this->m_data = data; } - void setMaskType(int maskType) { this->maskType = maskType; } + void setMaskType(int maskType) { this->m_maskType = maskType; } }; #endif diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 7491b0f30dd..8f0ebd9b8d2 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -28,7 +28,7 @@ FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->iirgaus = NULL; + this->m_iirgaus = NULL; } void FastGaussianBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) @@ -51,7 +51,7 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re return true; } else { - if (this->iirgaus) { + if (this->m_iirgaus) { return false; } else { @@ -72,9 +72,9 @@ void FastGaussianBlurOperation::initExecution() void FastGaussianBlurOperation::deinitExecution() { - if (this->iirgaus) { - delete this->iirgaus; - this->iirgaus = NULL; + if (this->m_iirgaus) { + delete this->m_iirgaus; + this->m_iirgaus = NULL; } BlurBaseOperation::deinitMutex(); } @@ -82,33 +82,33 @@ void FastGaussianBlurOperation::deinitExecution() void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (!iirgaus) { - MemoryBuffer *newBuf = (MemoryBuffer *)this->inputProgram->initializeTileData(rect, memoryBuffers); + if (!this->m_iirgaus) { + MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect, memoryBuffers); MemoryBuffer *copy = newBuf->duplicate(); updateSize(memoryBuffers); int c; - sx = data->sizex * this->size / 2.0f; - sy = data->sizey * this->size / 2.0f; + this->m_sx = this->m_data->sizex * this->m_size / 2.0f; + this->m_sy = this->m_data->sizey * this->m_size / 2.0f; - if ((sx == sy) && (sx > 0.f)) { + if ((this->m_sx == this->m_sy) && (this->m_sx > 0.f)) { for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sx, c, 3); + IIR_gauss(copy, this->m_sx, c, 3); } else { - if (sx > 0.f) { + if (this->m_sx > 0.0f) { for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sx, c, 1); + IIR_gauss(copy, this->m_sx, c, 1); } - if (sy > 0.f) { + if (this->m_sy > 0.0f) { for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sy, c, 2); + IIR_gauss(copy, this->m_sy, c, 2); } } - this->iirgaus = copy; + this->m_iirgaus = copy; } unlockMutex(); - return iirgaus; + return this->m_iirgaus; } void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy) diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index 0f3929f052c..1e303b23869 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -28,9 +28,9 @@ class FastGaussianBlurOperation : public BlurBaseOperation { private: - float sx; - float sy; - MemoryBuffer *iirgaus; + float m_sx; + float m_sy; + MemoryBuffer *m_iirgaus; public: FastGaussianBlurOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp index 5023473f4aa..60dabb86bb5 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.cpp +++ b/source/blender/compositor/operations/COM_FlipOperation.cpp @@ -27,34 +27,34 @@ FlipOperation::FlipOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->flipX = true; - this->flipY = false; + this->m_inputOperation = NULL; + this->m_flipX = true; + this->m_flipY = false; } void FlipOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void FlipOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void FlipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - float nx = this->flipX ? this->getWidth() - 1 - x : x; - float ny = this->flipY ? this->getHeight() - 1 - y : y; + float nx = this->m_flipX ? this->getWidth() - 1 - x : x; + float ny = this->m_flipY ? this->getHeight() - 1 - y : y; - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - if (this->flipX) { + if (this->m_flipX) { newInput.xmax = (this->getWidth() - 1 - input->xmin) + 1; newInput.xmin = (this->getWidth() - 1 - input->xmax) - 1; } @@ -62,7 +62,7 @@ bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper newInput.xmin = input->xmin; newInput.xmax = input->xmax; } - if (this->flipY) { + if (this->m_flipY) { newInput.ymax = (this->getHeight() - 1 - input->ymin) + 1; newInput.ymin = (this->getHeight() - 1 - input->ymax) - 1; } diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h index f83fa6ac3a8..5442774c94c 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.h +++ b/source/blender/compositor/operations/COM_FlipOperation.h @@ -27,9 +27,9 @@ class FlipOperation : public NodeOperation { private: - SocketReader *inputOperation; - bool flipX; - bool flipY; + SocketReader *m_inputOperation; + bool m_flipX; + bool m_flipY; public: FlipOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -37,8 +37,8 @@ public: void initExecution(); void deinitExecution(); - void setFlipX(bool flipX) { this->flipX = flipX; } - void setFlipY(bool flipY) { this->flipY = flipY; } + void setFlipX(bool flipX) { this->m_flipX = flipX; } + void setFlipY(bool flipY) { this->m_flipY = flipY; } }; #endif diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp index 3e90b643604..db8d54a2f3c 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp @@ -27,17 +27,17 @@ GammaCorrectOperation::GammaCorrectOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void GammaCorrectOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void GammaCorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - this->inputProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputColor, x, y, sampler, inputBuffers); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; inputColor[1] /= inputColor[3]; @@ -61,24 +61,24 @@ void GammaCorrectOperation::executePixel(float *color, float x, float y, PixelSa void GammaCorrectOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } GammaUncorrectOperation::GammaUncorrectOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void GammaUncorrectOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void GammaUncorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - this->inputProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputColor, x, y, sampler, inputBuffers); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; @@ -102,5 +102,5 @@ void GammaUncorrectOperation::executePixel(float *color, float x, float y, Pixel void GammaUncorrectOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h index 4bf03eac0a1..4db911bb9b5 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h @@ -30,7 +30,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: GammaCorrectOperation(); @@ -56,7 +56,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: GammaUncorrectOperation(); diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp index 2c3e78840ee..9ccc76f4392 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaOperation.cpp @@ -28,13 +28,13 @@ GammaOperation::GammaOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; - this->inputGammaProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputGammaProgram = NULL; } void GammaOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->inputGammaProgram = this->getInputSocketReader(1); + this->m_inputProgram = this->getInputSocketReader(0); + this->m_inputGammaProgram = this->getInputSocketReader(1); } void GammaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -42,8 +42,8 @@ void GammaOperation::executePixel(float *color, float x, float y, PixelSampler s float inputValue[4]; float inputGamma[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); - this->inputGammaProgram->read(inputGamma, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputGammaProgram->read(inputGamma, x, y, sampler, inputBuffers); const float gamma = inputGamma[0]; /* check for negative to avoid nan's */ color[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0]; @@ -55,6 +55,6 @@ void GammaOperation::executePixel(float *color, float x, float y, PixelSampler s void GammaOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputGammaProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputGammaProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h index 8c007d27843..758f7bda04d 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.h +++ b/source/blender/compositor/operations/COM_GammaOperation.h @@ -30,8 +30,8 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - SocketReader *inputGammaProgram; + SocketReader *m_inputProgram; + SocketReader *m_inputGammaProgram; public: GammaOperation(); diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp index 954aef7b916..a138d4be1d9 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp @@ -30,16 +30,18 @@ extern "C" { GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(COM_DT_VALUE) { - this->gausstab = NULL; - this->rad = 0; + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianAlphaXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -47,37 +49,39 @@ void GaussianAlphaXBlurOperation::initExecution() { /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ - if (this->sizeavailable) { - float rad = size * this->data->sizex; + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } - if (this->distbuf_inv == NULL) { + if (this->m_distbuf_inv == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + this->m_rad = rad; + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } @@ -88,7 +92,7 @@ BLI_INLINE float finv_test(const float f, const bool test) void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const bool do_invert = this->do_subtract; + const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -97,8 +101,8 @@ void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, Memor int miny = y; int maxy = y; - int minx = x - this->rad; - int maxx = x + this->rad; + int minx = x - this->m_rad; + int maxx = x + this->m_rad; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); @@ -118,20 +122,20 @@ void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, Memor float distfacinv_max = 1.0f; /* 0 to 1 */ for (int nx = minx; nx < maxx; nx += step) { - const int index = (nx - x) + this->rad; + const int index = (nx - x) + this->m_rad; float value = finv_test(buffer[bufferindex], do_invert); float multiplier; /* gauss */ { - multiplier = gausstab[index]; + multiplier = this->m_gausstab[index]; alpha_accum += value * multiplier; multiplier_accum += multiplier; } /* dilate - find most extreme color */ if (value > value_max) { - multiplier = distbuf_inv[index]; + multiplier = this->m_distbuf_inv[index]; value *= multiplier; if (value > value_max) { value_max = value; @@ -150,10 +154,12 @@ void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, Memor void GaussianAlphaXBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; - delete [] this->distbuf_inv; - this->distbuf_inv = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + delete [] this->m_distbuf_inv; + this->m_distbuf_inv = NULL; + + deinitMutex(); } bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -173,9 +179,9 @@ bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(rcti *input, else #endif { - if (this->sizeavailable && this->gausstab != NULL) { - newInput.xmax = input->xmax + rad; - newInput.xmin = input->xmin - rad; + if (this->m_sizeavailable && this->m_gausstab != NULL) { + newInput.xmax = input->xmax + this->m_rad; + newInput.xmin = input->xmin - this->m_rad; newInput.ymax = input->ymax; newInput.ymin = input->ymin; } diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h index 38817ebef1d..59797c27952 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h @@ -28,11 +28,11 @@ class GaussianAlphaXBlurOperation : public BlurBaseOperation { private: - float *gausstab; - float *distbuf_inv; - int falloff; /* falloff for distbuf_inv */ - bool do_subtract; - int rad; + float *m_gausstab; + float *m_distbuf_inv; + int m_falloff; /* falloff for distbuf_inv */ + bool m_do_subtract; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianAlphaXBlurOperation(); @@ -58,7 +58,7 @@ public: /** * Set subtract for Dilate/Erode functionality */ - void setSubtract(bool subtract) { this->do_subtract = subtract; } - void setFalloff(int falloff) { this->falloff = falloff; } + void setSubtract(bool subtract) { this->m_do_subtract = subtract; } + void setFalloff(int falloff) { this->m_falloff = falloff; } }; #endif diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp index e1105cf94b1..ab5f8d33850 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -30,16 +30,18 @@ extern "C" { GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE) { - this->gausstab = NULL; - this->rad = 0; + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -47,37 +49,39 @@ void GaussianAlphaYBlurOperation::initExecution() { /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ - if (this->sizeavailable) { - float rad = size * this->data->sizey; + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizey; + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } - if (this->distbuf_inv == NULL) { + if (this->m_distbuf_inv == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + this->m_rad = rad; + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } @@ -88,15 +92,15 @@ BLI_INLINE float finv_test(const float f, const bool test) void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const bool do_invert = this->do_subtract; + const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int miny = y - this->rad; - int maxy = y + this->rad; + int miny = y - this->m_rad; + int maxy = y + this->m_rad; int minx = x; int maxx = x; miny = max(miny, inputBuffer->getRect()->ymin); @@ -118,20 +122,20 @@ void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, Memor for (int ny = miny; ny < maxy; ny += step) { int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); - const int index = (ny - y) + this->rad; + const int index = (ny - y) + this->m_rad; float value = finv_test(buffer[bufferindex], do_invert); float multiplier; /* gauss */ { - multiplier = gausstab[index]; + multiplier = this->m_gausstab[index]; alpha_accum += value * multiplier; multiplier_accum += multiplier; } /* dilate - find most extreme color */ if (value > value_max) { - multiplier = distbuf_inv[index]; + multiplier = this->m_distbuf_inv[index]; value *= multiplier; if (value > value_max) { value_max = value; @@ -150,10 +154,12 @@ void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, Memor void GaussianAlphaYBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; - delete [] this->distbuf_inv; - this->distbuf_inv = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + delete [] this->m_distbuf_inv; + this->m_distbuf_inv = NULL; + + deinitMutex(); } bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -173,11 +179,11 @@ bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, else #endif { - if (this->sizeavailable && this->gausstab != NULL) { + if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmax = input->xmax; newInput.xmin = input->xmin; - newInput.ymax = input->ymax + rad; - newInput.ymin = input->ymin - rad; + newInput.ymax = input->ymax + this->m_rad; + newInput.ymin = input->ymin - this->m_rad; } else { newInput.xmax = this->getWidth(); diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h index 67166be8241..e0789db7815 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h @@ -28,11 +28,11 @@ class GaussianAlphaYBlurOperation : public BlurBaseOperation { private: - float *gausstab; - float *distbuf_inv; - bool do_subtract; - int falloff; - int rad; + float *m_gausstab; + float *m_distbuf_inv; + bool m_do_subtract; + int m_falloff; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianAlphaYBlurOperation(); @@ -58,7 +58,7 @@ public: /** * Set subtract for Dilate/Erode functionality */ - void setSubtract(bool subtract) { this->do_subtract = subtract; } - void setFalloff(int falloff) { this->falloff = falloff; } + void setSubtract(bool subtract) { this->m_do_subtract = subtract; } + void setFalloff(int falloff) { this->m_falloff = falloff; } }; #endif diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index dc9e354b124..ac91d3336e2 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -29,15 +29,17 @@ extern "C" { GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->gausstab = NULL; + this->m_gausstab = NULL; } void *GaussianBokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -45,14 +47,16 @@ void GaussianBokehBlurOperation::initExecution() { BlurBaseOperation::initExecution(); - if (this->sizeavailable) { + initMutex(); + + if (this->m_sizeavailable) { updateGauss(NULL); } } void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { float radxf; float radyf; int n; @@ -62,37 +66,37 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) int j, i; const float width = this->getWidth(); const float height = this->getHeight(); - if (!sizeavailable) { + if (!this->m_sizeavailable) { updateSize(memoryBuffers); } - radxf = size * (float)this->data->sizex; + radxf = this->m_size * (float)this->m_data->sizex; if (radxf > width / 2.0f) radxf = width / 2.0f; else if (radxf < 1.0f) radxf = 1.0f; /* vertical */ - radyf = size * (float)this->data->sizey; + radyf = this->m_size * (float)this->m_data->sizey; if (radyf > height / 2.0f) radyf = height / 2.0f; else if (radyf < 1.0f) radyf = 1.0f; - radx = ceil(radxf); - rady = ceil(radyf); + this->m_radx = ceil(radxf); + this->m_rady = ceil(radyf); - n = (2 * radx + 1) * (2 * rady + 1); + n = (2 * this->m_radx + 1) * (2 * this->m_rady + 1); /* create a full filter image */ ddgauss = new float[n]; dgauss = ddgauss; val = 0.0f; - for (j = -rady; j <= rady; j++) { - for (i = -radx; i <= radx; i++, dgauss++) { + for (j = -this->m_rady; j <= this->m_rady; j++) { + for (i = -this->m_radx; i <= this->m_radx; i++, dgauss++) { float fj = (float)j / radyf; float fi = (float)i / radxf; float dist = sqrt(fj * fj + fi * fi); - *dgauss = RE_filter_value(this->data->filtertype, dist); + *dgauss = RE_filter_value(this->m_data->filtertype, dist); val += *dgauss; } @@ -104,7 +108,7 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } else ddgauss[4] = 1.0f; - gausstab = ddgauss; + this->m_gausstab = ddgauss; } } @@ -122,10 +126,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int miny = y - this->rady; - int maxy = y + this->rady; - int minx = x - this->radx; - int maxx = x + this->radx; + int miny = y - this->m_rady; + int maxy = y + this->m_rady; + int minx = x - this->m_radx; + int maxx = x + this->m_radx; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); @@ -135,10 +139,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory int step = QualityStepHelper::getStep(); int offsetadd = QualityStepHelper::getOffsetAdd(); for (int ny = miny; ny < maxy; ny += step) { - index = ((ny - y) + this->rady) * (this->radx * 2 + 1) + (minx - x + this->radx); + index = ((ny - y) + this->m_rady) * (this->m_radx * 2 + 1) + (minx - x + this->m_radx); int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - const float multiplier = gausstab[index]; + const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; index += step; @@ -152,8 +156,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory void GaussianBokehBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + + deinitMutex(); } bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -170,15 +176,15 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, R return true; } else { - if (this->sizeavailable && this->gausstab != NULL) { + if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmin = 0; newInput.ymin = 0; newInput.xmax = this->getWidth(); newInput.ymax = this->getHeight(); } else { - int addx = radx; - int addy = rady; + int addx = this->m_radx; + int addy = this->m_rady; newInput.xmax = input->xmax + addx; newInput.xmin = input->xmin - addx; newInput.ymax = input->ymax + addy; diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h index 616a6539ad4..54dc8caed53 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h @@ -28,8 +28,8 @@ class GaussianBokehBlurOperation : public BlurBaseOperation { private: - float *gausstab; - int radx, rady; + float *m_gausstab; + int m_radx, m_rady; void updateGauss(MemoryBuffer **memoryBuffers); public: diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 7a1964a4a63..d18dd17528d 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -29,17 +29,18 @@ extern "C" { GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->gausstab = NULL; - this->rad = 0; - + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -47,27 +48,29 @@ void GaussianXBlurOperation::initExecution() { BlurBaseOperation::initExecution(); - if (this->sizeavailable) { - float rad = size * this->data->sizex; + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } } void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); - } + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); + } } void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) @@ -82,8 +85,8 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int miny = y; int maxy = y; - int minx = x - this->rad; - int maxx = x + this->rad; + int minx = x - this->m_rad; + int maxx = x + this->m_rad; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); @@ -94,8 +97,8 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int offsetadd = getOffsetAdd(); int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - index = (nx - x) + this->rad; - const float multiplier = gausstab[index]; + index = (nx - x) + this->m_rad; + const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; bufferindex += offsetadd; @@ -106,8 +109,10 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff void GaussianXBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + + deinitMutex(); } bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -124,9 +129,9 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB return true; } else { - if (this->sizeavailable && this->gausstab != NULL) { - newInput.xmax = input->xmax + rad; - newInput.xmin = input->xmin - rad; + if (this->m_sizeavailable && this->m_gausstab != NULL) { + newInput.xmax = input->xmax + this->m_rad; + newInput.xmin = input->xmin - this->m_rad; newInput.ymax = input->ymax; newInput.ymin = input->ymin; } diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h index 10a8a538391..9b5c2131b74 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h @@ -27,8 +27,8 @@ class GaussianXBlurOperation : public BlurBaseOperation { private: - float *gausstab; - int rad; + float *m_gausstab; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianXBlurOperation(); diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index 06c1c78d85a..d2d30da8ddf 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -29,41 +29,47 @@ extern "C" { GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->gausstab = NULL; - this->rad = 0; + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } void GaussianYBlurOperation::initExecution() { - if (this->sizeavailable) { - float rad = size * this->data->sizey; + BlurBaseOperation::initExecution(); + + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } } void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizey; + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } } @@ -77,8 +83,8 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int miny = y - this->rad; - int maxy = y + this->rad; + int miny = y - this->m_rad; + int maxy = y + this->m_rad; int minx = x; int maxx = x; miny = max(miny, inputBuffer->getRect()->ymin); @@ -86,12 +92,12 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - int step = getStep(); int index; + int step = getStep(); for (int ny = miny; ny < maxy; ny += step) { - index = (ny - y) + this->rad; + index = (ny - y) + this->m_rad; int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); - const float multiplier = gausstab[index]; + const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; } @@ -101,8 +107,10 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff void GaussianYBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + + deinitMutex(); } bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -119,11 +127,11 @@ bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB return true; } else { - if (this->sizeavailable && this->gausstab != NULL) { + if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmax = input->xmax; newInput.xmin = input->xmin; - newInput.ymax = input->ymax + rad; - newInput.ymin = input->ymin - rad; + newInput.ymax = input->ymax + this->m_rad; + newInput.ymin = input->ymin - this->m_rad; } else { newInput.xmax = this->getWidth(); diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h index e8d362e4c32..f4d40c231dc 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h @@ -27,8 +27,8 @@ class GaussianYBlurOperation : public BlurBaseOperation { private: - float *gausstab; - int rad; + float *m_gausstab; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianYBlurOperation(); diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp index 90bdd705a7c..a6678fdecef 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp @@ -27,23 +27,23 @@ GlareBaseOperation::GlareBaseOperation() : SingleThreadedNodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->settings = NULL; + this->m_settings = NULL; } void GlareBaseOperation::initExecution() { SingleThreadedNodeOperation::initExecution(); - this->inputProgram = getInputSocketReader(0); + this->m_inputProgram = getInputSocketReader(0); } void GlareBaseOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; SingleThreadedNodeOperation::deinitExecution(); } MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2, MemoryBuffer **memoryBuffers) { - MemoryBuffer *tile = (MemoryBuffer *)inputProgram->initializeTileData(rect2, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect2, memoryBuffers); rcti rect; rect.xmin = 0; rect.ymin = 0; @@ -51,7 +51,7 @@ MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2, MemoryBuffer * rect.ymax = getHeight(); MemoryBuffer *result = new MemoryBuffer(NULL, &rect); float *data = result->getBuffer(); - this->generateGlare(data, tile, this->settings); + this->generateGlare(data, tile, this->m_settings); return result; } diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h index ac67ac055e9..6104ec7a81e 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.h +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h @@ -41,12 +41,12 @@ private: /** * @brief Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; /** * @brief settings of the glare node. */ - NodeGlare *settings; + NodeGlare *m_settings; public: /** * Initialize the execution @@ -59,7 +59,7 @@ public: void deinitExecution(); void setGlareSettings(NodeGlare *settings) { - this->settings = settings; + this->m_settings = settings; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); 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_GlareFogGlowOperation.h b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h index 5737a6a1ff0..1231185a21a 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h @@ -28,8 +28,7 @@ class GlareFogGlowOperation : public GlareBaseOperation { public: - GlareFogGlowOperation() : GlareBaseOperation() { - } + GlareFogGlowOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.h b/source/blender/compositor/operations/COM_GlareGhostOperation.h index 2ee85cc4543..7ce1048efe9 100644 --- a/source/blender/compositor/operations/COM_GlareGhostOperation.h +++ b/source/blender/compositor/operations/COM_GlareGhostOperation.h @@ -28,8 +28,7 @@ class GlareGhostOperation : public GlareBaseOperation { public: - GlareGhostOperation() : GlareBaseOperation() { - } + GlareGhostOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h index a12d1191a1a..440f3ba147a 100644 --- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h +++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h @@ -28,8 +28,7 @@ class GlareSimpleStarOperation : public GlareBaseOperation { public: - GlareSimpleStarOperation() : GlareBaseOperation() { - } + GlareSimpleStarOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.h b/source/blender/compositor/operations/COM_GlareStreaksOperation.h index 6520a05b44f..e629ac11623 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.h +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.h @@ -28,8 +28,7 @@ class GlareStreaksOperation : public GlareBaseOperation { public: - GlareStreaksOperation() : GlareBaseOperation() { - } + GlareStreaksOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp index f9b2ec2b32d..6d8c567c1b5 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp @@ -27,26 +27,26 @@ GlareThresholdOperation::GlareThresholdOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_FIT); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void GlareThresholdOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { NodeOperation::determineResolution(resolution, preferredResolution); - resolution[0] = resolution[0] / (1 << settings->quality); - resolution[1] = resolution[1] / (1 << settings->quality); + resolution[0] = resolution[0] / (1 << this->m_settings->quality); + resolution[1] = resolution[1] / (1 << this->m_settings->quality); } void GlareThresholdOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void GlareThresholdOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - const float threshold = settings->threshold; + const float threshold = this->m_settings->threshold; - this->inputProgram->read(color, x, y, sampler, inputBuffers); + this->m_inputProgram->read(color, x, y, sampler, inputBuffers); if (rgb_to_luma_y(color) >= threshold) { color[0] -= threshold, color[1] -= threshold, color[2] -= threshold; color[0] = MAX2(color[0], 0.0f); @@ -60,5 +60,5 @@ void GlareThresholdOperation::executePixel(float *color, float x, float y, Pixel void GlareThresholdOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h index 70692565e27..d89f3a0f29d 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h @@ -30,12 +30,12 @@ private: /** * @brief Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; /** * @brief settings of the glare node. */ - NodeGlare *settings; + NodeGlare *m_settings; public: GlareThresholdOperation(); @@ -55,7 +55,7 @@ public: void deinitExecution(); void setGlareSettings(NodeGlare *settings) { - this->settings = settings; + this->m_settings = settings; } void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index b8e46e2d0be..02914487072 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -37,30 +37,30 @@ HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation() : Curve this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void HueSaturationValueCorrectOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void HueSaturationValueCorrectOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float hsv[4], f; - this->inputProgram->read(hsv, x, y, sampler, inputBuffers); + this->m_inputProgram->read(hsv, x, y, sampler, inputBuffers); /* adjust hue, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->curveMapping, 0, hsv[0]); + f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]); hsv[0] += f - 0.5f; /* adjust saturation, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->curveMapping, 1, hsv[0]); + f = curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]); hsv[1] *= (f * 2.f); /* adjust value, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->curveMapping, 2, hsv[0]); + f = curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]); hsv[2] *= (f * 2.f); hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */ @@ -74,5 +74,5 @@ void HueSaturationValueCorrectOperation::executePixel(float *output, float x, fl void HueSaturationValueCorrectOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h index 5ede0491773..7ae5f53e370 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h @@ -30,7 +30,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: HueSaturationValueCorrectOperation(); diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp index d02367088d7..c84124368be 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp @@ -26,24 +26,24 @@ IDMaskOperation::IDMaskOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void IDMaskOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void IDMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); - const float a = (inputValue[0] == this->objectIndex) ? 1.0f : 0.0f; + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + const float a = (inputValue[0] == this->m_objectIndex) ? 1.0f : 0.0f; color[0] = a; } void IDMaskOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h index 229e1b2dd82..23e8ec704e8 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.h +++ b/source/blender/compositor/operations/COM_IDMaskOperation.h @@ -30,9 +30,9 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - float objectIndex; + float m_objectIndex; public: IDMaskOperation(); @@ -51,7 +51,7 @@ public: */ void deinitExecution(); - void setObjectIndex(float objectIndex) { this->objectIndex = objectIndex; } + void setObjectIndex(float objectIndex) { this->m_objectIndex = objectIndex; } }; #endif diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index 9dbe8419daa..eb2eaa8167a 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -38,15 +38,15 @@ extern "C" { BaseImageOperation::BaseImageOperation() : NodeOperation() { - this->image = NULL; - this->buffer = NULL; - this->imageBuffer = NULL; - this->imageUser = NULL; - this->imagewidth = 0; - this->imageheight = 0; - this->framenumber = 0; - this->depthBuffer = NULL; - this->numberOfChannels = 0; + this->m_image = NULL; + this->m_buffer = NULL; + this->m_imageBuffer = NULL; + this->m_imageUser = NULL; + this->m_imagewidth = 0; + this->m_imageheight = 0; + this->m_framenumber = 0; + this->m_depthBuffer = NULL; + this->m_numberOfChannels = 0; } ImageOperation::ImageOperation() : BaseImageOperation() { @@ -65,7 +65,7 @@ ImBuf *BaseImageOperation::getImBuf() { ImBuf *ibuf; - ibuf = BKE_image_get_ibuf(this->image, this->imageUser); + ibuf = BKE_image_get_ibuf(this->m_image, this->m_imageUser); if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) { return NULL; } @@ -80,19 +80,19 @@ ImBuf *BaseImageOperation::getImBuf() void BaseImageOperation::initExecution() { ImBuf *stackbuf = getImBuf(); - this->buffer = stackbuf; + this->m_buffer = stackbuf; if (stackbuf) { - this->imageBuffer = stackbuf->rect_float; - this->depthBuffer = stackbuf->zbuf_float; - this->imagewidth = stackbuf->x; - this->imageheight = stackbuf->y; - this->numberOfChannels = stackbuf->channels; + this->m_imageBuffer = stackbuf->rect_float; + this->m_depthBuffer = stackbuf->zbuf_float; + this->m_imagewidth = stackbuf->x; + this->m_imageheight = stackbuf->y; + this->m_numberOfChannels = stackbuf->channels; } } void BaseImageOperation::deinitExecution() { - this->imageBuffer = NULL; + this->m_imageBuffer = NULL; } void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -110,22 +110,19 @@ void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned void ImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + if (this->m_imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + zero_v4(color); } else { switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->buffer, NULL, color, x, y); + neareast_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->buffer, NULL, color, x, y); + bilinear_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->buffer, NULL, color, x, y); + bicubic_interpolation_color(this->m_buffer, NULL, color, x, y); break; } } @@ -135,20 +132,20 @@ void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSamp { float tempcolor[4]; - if (this->imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { color[0] = 0.0f; } else { tempcolor[3] = 1.0f; switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->buffer, NULL, tempcolor, x, y); + neareast_interpolation_color(this->m_buffer, NULL, tempcolor, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->buffer, NULL, tempcolor, x, y); + bilinear_interpolation_color(this->m_buffer, NULL, tempcolor, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->buffer, NULL, tempcolor, x, y); + bicubic_interpolation_color(this->m_buffer, NULL, tempcolor, x, y); break; } color[0] = tempcolor[3]; @@ -157,11 +154,11 @@ void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSamp void ImageDepthOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + if (this->m_depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { color[0] = 0.0f; } else { - int offset = y * width + x; - color[0] = this->depthBuffer[offset]; + int offset = y * this->m_width + x; + color[0] = this->m_depthBuffer[offset]; } } diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h index a4645c9d504..c87b06b9c4d 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.h +++ b/source/blender/compositor/operations/COM_ImageOperation.h @@ -40,15 +40,15 @@ extern "C" { */ class BaseImageOperation : public NodeOperation { protected: - ImBuf *buffer; - Image *image; - ImageUser *imageUser; - float *imageBuffer; - float *depthBuffer; - int imageheight; - int imagewidth; - int framenumber; - int numberOfChannels; + ImBuf *m_buffer; + Image *m_image; + ImageUser *m_imageUser; + float *m_imageBuffer; + float *m_depthBuffer; + int m_imageheight; + int m_imagewidth; + int m_framenumber; + int m_numberOfChannels; BaseImageOperation(); /** @@ -62,10 +62,10 @@ public: void initExecution(); void deinitExecution(); - void setImage(Image *image) { this->image = image; } - void setImageUser(ImageUser *imageuser) { this->imageUser = imageuser; } + void setImage(Image *image) { this->m_image = image; } + void setImageUser(ImageUser *imageuser) { this->m_imageUser = imageuser; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } }; class ImageOperation : public BaseImageOperation { public: diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp index 6142959a12e..9e9c2522d66 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.cpp +++ b/source/blender/compositor/operations/COM_InvertOperation.cpp @@ -27,29 +27,29 @@ InvertOperation::InvertOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueProgram = NULL; - this->inputColorProgram = NULL; - this->color = true; - this->alpha = false; + this->m_inputValueProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_color = true; + this->m_alpha = false; setResolutionInputSocketIndex(1); } void InvertOperation::initExecution() { - this->inputValueProgram = this->getInputSocketReader(0); - this->inputColorProgram = this->getInputSocketReader(1); + this->m_inputValueProgram = this->getInputSocketReader(0); + this->m_inputColorProgram = this->getInputSocketReader(1); } void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; float inputColor[4]; - this->inputValueProgram->read(inputValue, x, y, sampler, inputBuffers); - this->inputColorProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColorProgram->read(inputColor, x, y, sampler, inputBuffers); const float value = inputValue[0]; const float invertedValue = 1.0f - value; - if (color) { + if (this->m_color) { out[0] = (1.0f - inputColor[0]) * value + inputColor[0] * invertedValue; out[1] = (1.0f - inputColor[1]) * value + inputColor[1] * invertedValue; out[2] = (1.0f - inputColor[2]) * value + inputColor[2] * invertedValue; @@ -58,7 +58,7 @@ void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sa copy_v3_v3(out, inputColor); } - if (alpha) + if (this->m_alpha) out[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue; else out[3] = inputColor[3]; @@ -67,7 +67,7 @@ void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sa void InvertOperation::deinitExecution() { - this->inputValueProgram = NULL; - this->inputColorProgram = NULL; + this->m_inputValueProgram = NULL; + this->m_inputColorProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h index 48432aecdd0..f00a3fb739d 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.h +++ b/source/blender/compositor/operations/COM_InvertOperation.h @@ -30,11 +30,11 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputValueProgram; - SocketReader *inputColorProgram; + SocketReader *m_inputValueProgram; + SocketReader *m_inputColorProgram; - bool alpha; - bool color; + bool m_alpha; + bool m_color; public: InvertOperation(); @@ -54,7 +54,7 @@ public: */ void deinitExecution(); - void setColor(bool color) { this->color = color; } - void setAlpha(bool alpha) { this->alpha = alpha; } + void setColor(bool color) { this->m_color = color; } + void setAlpha(bool alpha) { this->m_alpha = alpha; } }; #endif diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp index 9c7a33c1327..3285bd32039 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp @@ -33,7 +33,8 @@ KeyingBlurOperation::KeyingBlurOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->size = 0.0f; + this->m_size = 0; + this->m_axis = BLUR_AXIS_X; this->setComplex(true); } @@ -53,16 +54,28 @@ void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer int bufferWidth = inputBuffer->getWidth(); int bufferHeight = inputBuffer->getHeight(); - int i, j, count = 0; + int i, count = 0; float average = 0.0f; - for (i = -this->size + 1; i < this->size; i++) { - for (j = -this->size + 1; j < this->size; j++) { - int cx = x + j, cy = y + i; + if (this->m_axis == 0) { + for (i = -this->m_size + 1; i < this->m_size; i++) { + int cx = x + i; - if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) { - int bufferIndex = (cy * bufferWidth + cx) * 4; + if (cx >= 0 && cx < bufferWidth) { + int bufferIndex = (y * bufferWidth + cx) * 4; + + average += buffer[bufferIndex]; + count++; + } + } + } + else { + for (i = -this->m_size + 1; i < this->m_size; i++) { + int cy = y + i; + + if (cy >= 0 && cy < bufferHeight) { + int bufferIndex = (cy * bufferWidth + x) * 4; average += buffer[bufferIndex]; count++; @@ -79,10 +92,18 @@ bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff { rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); + if (this->m_axis == BLUR_AXIS_X) { + newInput.xmin = input->xmin - this->m_size; + newInput.ymin = input->ymin; + newInput.xmax = input->xmax + this->m_size; + newInput.ymax = input->ymax; + } + else { + newInput.xmin = input->xmin; + newInput.ymin = input->ymin - this->m_size; + newInput.xmax = input->xmax; + newInput.ymax = input->ymax + this->m_size; + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h index 2848f260cbd..6e08712bf39 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.h +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h @@ -31,12 +31,19 @@ */ class KeyingBlurOperation : public NodeOperation { protected: - int size; + int m_size; + int m_axis; public: + enum BlurAxis { + BLUR_AXIS_X = 0, + BLUR_AXIS_Y = 1 + }; + KeyingBlurOperation(); - void setSize(float value) {this->size = value;} + void setSize(int value) {this->m_size = value;} + void setAxis(int value) {this->m_axis = value;} void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp index 2c9949f2b4b..8f7d7fbf625 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp @@ -33,13 +33,13 @@ KeyingClipOperation::KeyingClipOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->kernelRadius = 3; - this->kernelTolerance = 0.1f; + this->m_kernelRadius = 3; + this->m_kernelTolerance = 0.1f; - this->clipBlack = 0.0f; - this->clipWhite = 1.0f; + this->m_clipBlack = 0.0f; + this->m_clipWhite = 1.0f; - this->isEdgeMatte = false; + this->m_isEdgeMatte = false; this->setComplex(true); } @@ -53,8 +53,8 @@ void *KeyingClipOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const int delta = this->kernelRadius; - const float tolerance = this->kernelTolerance; + const int delta = this->m_kernelRadius; + const float tolerance = this->m_kernelTolerance; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); @@ -90,7 +90,7 @@ void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer ok = count >= (float) totalCount * 0.9f; - if (this->isEdgeMatte) { + if (this->m_isEdgeMatte) { if (ok) color[0] = 0.0f; else @@ -100,12 +100,12 @@ void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer color[0] = value; if (ok) { - if (color[0] < this->clipBlack) + if (color[0] < this->m_clipBlack) color[0] = 0.0f; - else if (color[0] >= this->clipWhite) + else if (color[0] >= this->m_clipWhite) color[0] = 1.0f; else - color[0] = (color[0] - this->clipBlack) / (this->clipWhite - this->clipBlack); + color[0] = (color[0] - this->m_clipBlack) / (this->m_clipWhite - this->m_clipBlack); } } } @@ -114,10 +114,10 @@ bool KeyingClipOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff { rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); + newInput.xmin = input->xmin - this->m_kernelRadius; + newInput.ymin = input->ymin - this->m_kernelRadius; + newInput.xmax = input->xmax + this->m_kernelRadius; + newInput.ymax = input->ymax + this->m_kernelRadius; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h index 9c7b23b0160..1a8e71a306b 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.h +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h @@ -27,27 +27,27 @@ #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 clipBlack; - float clipWhite; + float m_clipBlack; + float m_clipWhite; - int kernelRadius; - float kernelTolerance; + int m_kernelRadius; + float m_kernelTolerance; - bool isEdgeMatte; + bool m_isEdgeMatte; public: KeyingClipOperation(); - void setClipBlack(float value) {this->clipBlack = value;} - void setClipWhite(float value) {this->clipWhite = value;} + void setClipBlack(float value) {this->m_clipBlack = value;} + void setClipWhite(float value) {this->m_clipWhite = value;} - void setKernelRadius(int value) {this->kernelRadius = value;} - void setKernelTolerance(float value) {this->kernelTolerance = value;} + void setKernelRadius(int value) {this->m_kernelRadius = value;} + void setKernelTolerance(float value) {this->m_kernelTolerance = value;} - void setIsEdgeMatte(bool value) {this->isEdgeMatte = value;} + void setIsEdgeMatte(bool value) {this->m_isEdgeMatte = value;} void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp index 04523384653..081d9f723e8 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp @@ -46,22 +46,22 @@ KeyingDespillOperation::KeyingDespillOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->despillFactor = 0.5f; + this->m_despillFactor = 0.5f; - this->pixelReader = NULL; - this->screenReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; } void KeyingDespillOperation::initExecution() { - this->pixelReader = this->getInputSocketReader(0); - this->screenReader = this->getInputSocketReader(1); + this->m_pixelReader = this->getInputSocketReader(0); + this->m_screenReader = this->getInputSocketReader(1); } void KeyingDespillOperation::deinitExecution() { - this->pixelReader = NULL; - this->screenReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; } void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -69,8 +69,8 @@ void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelS float pixelColor[4]; float screenColor[4]; - this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers); - this->screenReader->read(screenColor, x, y, sampler, inputBuffers); + this->m_pixelReader->read(pixelColor, x, y, sampler, inputBuffers); + this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers); int screen_primary_channel = get_pixel_primary_channel(screenColor); float average_value, amount; @@ -83,7 +83,7 @@ void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelS color[2] = pixelColor[2]; color[3] = pixelColor[3]; - if (this->despillFactor * amount > 0) { - color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->despillFactor * amount; + if (this->m_despillFactor * amount > 0) { + color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount; } } diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h index 92a1415a1f0..4fea9b578a1 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h @@ -27,13 +27,13 @@ #include "COM_NodeOperation.h" /** - * Class with implementation of keying despill node - */ + * Class with implementation of keying despill node + */ class KeyingDespillOperation : public NodeOperation { protected: - SocketReader *pixelReader; - SocketReader *screenReader; - float despillFactor; + SocketReader *m_pixelReader; + SocketReader *m_screenReader; + float m_despillFactor; public: KeyingDespillOperation(); @@ -41,7 +41,7 @@ public: void initExecution(); void deinitExecution(); - void setDespillFactor(float value) {this->despillFactor = value;} + void setDespillFactor(float value) {this->m_despillFactor = value;} void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); }; diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index ae2913350f9..e92e5c84c2d 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -60,28 +60,28 @@ KeyingOperation::KeyingOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->screenBalance = 0.5f; + this->m_screenBalance = 0.5f; - this->pixelReader = NULL; - this->screenReader = NULL; - this->garbageReader = NULL; - this->coreReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; + this->m_garbageReader = NULL; + this->m_coreReader = NULL; } void KeyingOperation::initExecution() { - this->pixelReader = this->getInputSocketReader(0); - this->screenReader = this->getInputSocketReader(1); - this->garbageReader = this->getInputSocketReader(2); - this->coreReader = this->getInputSocketReader(3); + this->m_pixelReader = this->getInputSocketReader(0); + this->m_screenReader = this->getInputSocketReader(1); + this->m_garbageReader = this->getInputSocketReader(2); + this->m_coreReader = this->getInputSocketReader(3); } void KeyingOperation::deinitExecution() { - this->pixelReader = NULL; - this->screenReader = NULL; - this->garbageReader = NULL; - this->coreReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; + this->m_garbageReader = NULL; + this->m_coreReader = NULL; } void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -91,10 +91,10 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler float garbageValue[4]; float coreValue[4]; - this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers); - this->screenReader->read(screenColor, x, y, sampler, inputBuffers); - this->garbageReader->read(garbageValue, x, y, sampler, inputBuffers); - this->coreReader->read(coreValue, x, y, sampler, inputBuffers); + this->m_pixelReader->read(pixelColor, x, y, sampler, inputBuffers); + this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers); + this->m_garbageReader->read(garbageValue, x, y, sampler, inputBuffers); + this->m_coreReader->read(coreValue, x, y, sampler, inputBuffers); int primary_channel = get_pixel_primary_channel(screenColor); @@ -107,8 +107,8 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler color[0] = 1.0f; } else { - float saturation = get_pixel_saturation(pixelColor, this->screenBalance, primary_channel); - float screen_saturation = get_pixel_saturation(screenColor, this->screenBalance, primary_channel); + float saturation = get_pixel_saturation(pixelColor, this->m_screenBalance, primary_channel); + float screen_saturation = get_pixel_saturation(screenColor, this->m_screenBalance, primary_channel); if (saturation < 0) { /* means main channel of pixel is different from screen, @@ -136,15 +136,3 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler /* apply core matte */ color[0] = MAX2(color[0], coreValue[0]); } - -bool KeyingOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) -{ - rcti newInput; - - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); - - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); -} diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h index 8d0e7851ee5..736db54850a 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.h +++ b/source/blender/compositor/operations/COM_KeyingOperation.h @@ -32,16 +32,16 @@ #include "BLI_listbase.h" /** - * Class with implementation of keying node - */ + * Class with implementation of keying node + */ class KeyingOperation : public NodeOperation { protected: - SocketReader *pixelReader; - SocketReader *screenReader; - SocketReader *garbageReader; - SocketReader *coreReader; + SocketReader *m_pixelReader; + SocketReader *m_screenReader; + SocketReader *m_garbageReader; + SocketReader *m_coreReader; - float screenBalance; + float m_screenBalance; public: KeyingOperation(); @@ -49,11 +49,9 @@ public: void initExecution(); void deinitExecution(); - void setScreenBalance(float value) {this->screenBalance = value;} + void setScreenBalance(float value) {this->m_screenBalance = value;} void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); - - bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; #endif diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index 9f7b69636ab..53572162b9e 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -42,22 +42,22 @@ extern "C" { KeyingScreenOperation::KeyingScreenOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->movieClip = NULL; - this->framenumber = 0; - this->trackingObject[0] = 0; + this->m_movieClip = NULL; + this->m_framenumber = 0; + this->m_trackingObject[0] = 0; setComplex(true); } void KeyingScreenOperation::initExecution() { initMutex(); - this->cachedTriangulation = NULL; + this->m_cachedTriangulation = NULL; } void KeyingScreenOperation::deinitExecution() { - if (this->cachedTriangulation) { - TriangulationData *triangulation = cachedTriangulation; + if (this->m_cachedTriangulation) { + TriangulationData *triangulation = this->m_cachedTriangulation; if (triangulation->triangulated_points) MEM_freeN(triangulation->triangulated_points); @@ -65,9 +65,12 @@ void KeyingScreenOperation::deinitExecution() if (triangulation->triangles) MEM_freeN(triangulation->triangles); - MEM_freeN(this->cachedTriangulation); + if (triangulation->triangles_AABB) + MEM_freeN(triangulation->triangles_AABB); - this->cachedTriangulation = NULL; + MEM_freeN(this->m_cachedTriangulation); + + this->m_cachedTriangulation = NULL; } } @@ -75,7 +78,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri { MovieClipUser user = {0}; TriangulationData *triangulation; - MovieTracking *tracking = &movieClip->tracking; + MovieTracking *tracking = &this->m_movieClip->tracking; MovieTrackingTrack *track; VoronoiSite *sites; ImBuf *ibuf; @@ -85,10 +88,10 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri int i; int width = this->getWidth(); int height = this->getHeight(); - int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber); - if (this->trackingObject[0]) { - MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->trackingObject); + if (this->m_trackingObject[0]) { + MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject); if (!object) return NULL; @@ -98,13 +101,20 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri else tracksbase = BKE_tracking_get_active_tracks(tracking); - sites_total = BLI_countlist(tracksbase); + /* count sites */ + for (track = (MovieTrackingTrack *) tracksbase->first, sites_total = 0; track; track = track->next) { + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); + + if ((marker->flag & MARKER_DISABLED) == 0) { + sites_total++; + } + } if (!sites_total) return NULL; BKE_movieclip_user_set_frame(&user, clip_frame); - ibuf = BKE_movieclip_get_ibuf(movieClip, &user); + ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user); if (!ibuf) return NULL; @@ -113,13 +123,19 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri sites = (VoronoiSite *) MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites"); track = (MovieTrackingTrack *) tracksbase->first; - i = 0; - while (track) { - VoronoiSite *site = &sites[i]; + for (track = (MovieTrackingTrack *) tracksbase->first, i = 0; track; track = track->next, i++) { MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); - ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); + VoronoiSite *site; + ImBuf *pattern_ibuf; int j; + if (marker->flag & MARKER_DISABLED) + continue; + + site = &sites[i]; + + pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); + zero_v3(site->color); for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) { if (pattern_ibuf->rect_float) { @@ -139,9 +155,6 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri site->co[0] = marker->pos[0] * width; site->co[1] = marker->pos[1] * height; - - track = track->next; - i++; } IMB_freeImBuf(ibuf); @@ -155,24 +168,100 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri MEM_freeN(sites); BLI_freelistN(&edges); + if (triangulation->triangles_total) { + rctf *rect; + rect = triangulation->triangles_AABB = + (rctf *) MEM_callocN(sizeof(rctf) * triangulation->triangles_total, "voronoi triangulation AABB"); + + for (i = 0; i < triangulation->triangles_total; i++, rect++) { + int *triangle = triangulation->triangles[i]; + VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]], + *b = &triangulation->triangulated_points[triangle[1]], + *c = &triangulation->triangulated_points[triangle[2]]; + + float min[2], max[2]; + + INIT_MINMAX2(min, max); + + DO_MINMAX2(a->co, min, max); + DO_MINMAX2(b->co, min, max); + DO_MINMAX2(c->co, min, max); + + rect->xmin = min[0]; + rect->ymin = min[1]; + + rect->xmax = max[0]; + rect->ymax = max[1]; + } + } + return triangulation; } void *KeyingScreenOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->movieClip == NULL) + TileData *tile_data; + TriangulationData *triangulation; + int triangles_allocated = 0; + int chunk_size = 20; + int i; + rctf rect_float; + + if (this->m_movieClip == NULL) return NULL; - if (this->cachedTriangulation) - return this->cachedTriangulation; + if (!this->m_cachedTriangulation) { + lockMutex(); + if (this->m_cachedTriangulation == NULL) { + this->m_cachedTriangulation = buildVoronoiTriangulation(); + } + unlockMutex(); + } + + triangulation = this->m_cachedTriangulation; + + if (!triangulation) + return NULL; + + BLI_init_rctf(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + + tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data"); + + for (i = 0; i < triangulation->triangles_total; i++) { + bool ok = BLI_isect_rctf(&rect_float, &triangulation->triangles_AABB[i], NULL); + + if (ok) { + tile_data->triangles_total++; + + if (tile_data->triangles_total > triangles_allocated) { + if (!tile_data->triangles) { + tile_data->triangles = (int *) MEM_mallocN(sizeof(int) * chunk_size, + "keying screen tile triangles chunk"); + } + else { + tile_data->triangles = (int *) MEM_reallocN(tile_data->triangles, + sizeof(int) * (triangles_allocated + chunk_size)); + } - lockMutex(); - if (this->cachedTriangulation == NULL) { - this->cachedTriangulation = buildVoronoiTriangulation(); + triangles_allocated += chunk_size; + } + + tile_data->triangles[tile_data->triangles_total - 1] = i; + } } - unlockMutex(); - return this->cachedTriangulation; + return tile_data; +} + +void KeyingScreenOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +{ + TileData *tile_data = (TileData *) data; + + if (tile_data->triangles) { + MEM_freeN(tile_data->triangles); + } + + MEM_freeN(tile_data); } void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -180,13 +269,13 @@ void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsig resolution[0] = 0; resolution[1] = 0; - if (this->movieClip) { + if (this->m_movieClip) { MovieClipUser user = {0}; int width, height; - int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber); BKE_movieclip_user_set_frame(&user, clip_frame); - BKE_movieclip_get_size(this->movieClip, &user, &width, &height); + BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height); resolution[0] = width; resolution[1] = height; @@ -200,21 +289,29 @@ void KeyingScreenOperation::executePixel(float *color, int x, int y, MemoryBuffe color[2] = 0.0f; color[3] = 1.0f; - if (this->movieClip && data) { - TriangulationData *triangulation = (TriangulationData *) data; + if (this->m_movieClip && data) { + TriangulationData *triangulation = this->m_cachedTriangulation; + TileData *tile_data = (TileData *) data; int i; - for (i = 0; i < triangulation->triangles_total; i++) { - int *triangle = triangulation->triangles[i]; - VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]], - *b = &triangulation->triangulated_points[triangle[1]], - *c = &triangulation->triangulated_points[triangle[2]]; - float co[2] = {(float) x, (float) y}, w[3]; - - if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) { - if (barycentric_inside_triangle_v2(w)) { - color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; - color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; - color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + float co[2] = {(float) x, (float) y}; + + for (i = 0; i < tile_data->triangles_total; i++) { + int triangle_idx = tile_data->triangles[i]; + rctf *rect = &triangulation->triangles_AABB[triangle_idx]; + + if (IN_RANGE_INCL(x, rect->xmin, rect->xmax) && IN_RANGE_INCL(y, rect->ymin, rect->ymax)) { + int *triangle = triangulation->triangles[triangle_idx]; + VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]], + *b = &triangulation->triangulated_points[triangle[1]], + *c = &triangulation->triangulated_points[triangle[2]]; + float w[3]; + + if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) { + if (barycentric_inside_triangle_v2(w)) { + color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; + color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; + color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + } } } } diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.h b/source/blender/compositor/operations/COM_KeyingScreenOperation.h index 9d3f44f6be2..95815cd3930 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.h +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.h @@ -39,39 +39,46 @@ extern "C" { } /** - * Class with implementation of green screen gradient rasterization - */ + * Class with implementation of green screen gradient rasterization + */ class KeyingScreenOperation : public NodeOperation { protected: typedef struct TriangulationData { VoronoiTriangulationPoint *triangulated_points; int (*triangles)[3]; int triangulated_points_total, triangles_total; + rctf *triangles_AABB; } TriangulationData; - MovieClip *movieClip; - int framenumber; - TriangulationData *cachedTriangulation; - char trackingObject[64]; + typedef struct TileData { + int *triangles; + int triangles_total; + } TileData; + + MovieClip *m_movieClip; + int m_framenumber; + TriangulationData *m_cachedTriangulation; + char m_trackingObject[64]; /** - * Determine the output resolution. The resolution is retrieved from the Renderer - */ + * Determine the output resolution. The resolution is retrieved from the Renderer + */ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); TriangulationData *buildVoronoiTriangulation(); - public: +public: KeyingScreenOperation(); void initExecution(); void deinitExecution(); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); - void setMovieClip(MovieClip *clip) {this->movieClip = clip;} - void setTrackingObject(char *object) {strncpy(this->trackingObject, object, sizeof(this->trackingObject));} - void setFramenumber(int framenumber) {this->framenumber = framenumber;} + void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;} + void setTrackingObject(const char *object) {strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));} + void setFramenumber(int framenumber) {this->m_framenumber = framenumber;} void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); }; diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp index 6e8aa9461e6..233f903c3e3 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp @@ -27,29 +27,29 @@ LuminanceMatteOperation::LuminanceMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void LuminanceMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(0); } void LuminanceMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void LuminanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inColor[4]; - const float high = this->settings->t1; - const float low = this->settings->t2; + const float high = this->m_settings->t1; + const float low = this->m_settings->t2; float alpha; - this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); /* one line thread-friend algorithm: * outputValue[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low)))) diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h index f44e32396a3..7da56465cd8 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h @@ -30,8 +30,8 @@ */ class LuminanceMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; public: /** * Default constructor @@ -46,6 +46,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp index b29dcfab194..dec2d0849c9 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.cpp +++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp @@ -27,17 +27,17 @@ MapUVOperation::MapUVOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_COLOR); - this->alpha = 0.f; + this->m_alpha = 0.0f; this->setComplex(true); - this->inputUVProgram = NULL; - this->inputColorProgram = NULL; + this->m_inputUVProgram = NULL; + this->m_inputColorProgram = NULL; } void MapUVOperation::initExecution() { - this->inputColorProgram = this->getInputSocketReader(0); - this->inputUVProgram = this->getInputSocketReader(1); + this->m_inputColorProgram = this->getInputSocketReader(0); + this->m_inputUVProgram = this->getInputSocketReader(1); } void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -50,30 +50,30 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s float uv_l, uv_r; float uv_u, uv_d; - this->inputUVProgram->read(inputUV, x, y, sampler, inputBuffers); + this->m_inputUVProgram->read(inputUV, x, y, sampler, inputBuffers); if (inputUV[2] == 0.f) { zero_v4(color); return; } /* adaptive sampling, red (U) channel */ - this->inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST, inputBuffers); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; dx = 0.5f * (uv_l + uv_r); /* adaptive sampling, green (V) channel */ - this->inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST, inputBuffers); uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; uv_d = uv_b[2] != 0.f ? fabsf(inputUV[1] - uv_b[1]) : 0.f; dy = 0.5f * (uv_u + uv_d); /* more adaptive sampling, red and green (UV) channels */ - this->inputUVProgram->read(uv_a, x - 1, y - 1, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x - 1, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x - 1, y - 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x - 1, y + 1, COM_PS_NEAREST, inputBuffers); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; @@ -82,8 +82,8 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s dx += 0.25f * (uv_l + uv_r); dy += 0.25f * (uv_u + uv_d); - this->inputUVProgram->read(uv_a, x + 1, y - 1, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x + 1, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x + 1, y - 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x + 1, y + 1, COM_PS_NEAREST, inputBuffers); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; @@ -93,7 +93,7 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s dy += 0.25f * (uv_u + uv_d); /* UV to alpha threshold */ - const float threshold = this->alpha * 0.05f; + const float threshold = this->m_alpha * 0.05f; float alpha = 1.0f - threshold * (dx + dy); if (alpha < 0.f) alpha = 0.f; else alpha *= inputUV[2]; @@ -104,10 +104,10 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s /* EWA filtering */ - u = inputUV[0] * inputColorProgram->getWidth(); - v = inputUV[1] * inputColorProgram->getHeight(); + u = inputUV[0] * this->m_inputColorProgram->getWidth(); + v = inputUV[1] * this->m_inputColorProgram->getHeight(); - this->inputColorProgram->read(color, u, v, dx, dy, inputBuffers); + this->m_inputColorProgram->read(color, u, v, dx, dy, inputBuffers); /* "premul" */ if (alpha < 1.0f) { @@ -117,8 +117,8 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s void MapUVOperation::deinitExecution() { - this->inputUVProgram = NULL; - this->inputColorProgram = NULL; + this->m_inputUVProgram = NULL; + this->m_inputColorProgram = NULL; } bool MapUVOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h index 22e3531e838..c14640da61c 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.h +++ b/source/blender/compositor/operations/COM_MapUVOperation.h @@ -29,10 +29,10 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputUVProgram; - SocketReader *inputColorProgram; + SocketReader *m_inputUVProgram; + SocketReader *m_inputColorProgram; - float alpha; + float m_alpha; public: MapUVOperation(); @@ -57,6 +57,6 @@ public: */ void deinitExecution(); - void setAlpha(float alpha) { this->alpha = alpha; } + void setAlpha(float alpha) { this->m_alpha = alpha; } }; #endif diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp index 6d7804dd6e3..17d82e85723 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.cpp +++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp @@ -26,19 +26,19 @@ MapValueOperation::MapValueOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void MapValueOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void MapValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float src[4]; - inputOperation->read(src, x, y, sampler, inputBuffers); - TexMapping *texmap = this->settings; + this->m_inputOperation->read(src, x, y, sampler, inputBuffers); + TexMapping *texmap = this->m_settings; float value = (src[0] + texmap->loc[0]) * texmap->size[0]; if (texmap->flag & TEXMAP_CLIP_MIN) if (value < texmap->min[0]) @@ -52,5 +52,5 @@ void MapValueOperation::executePixel(float *outputValue, float x, float y, Pixel void MapValueOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h index 5fae74e0a6a..53157c39938 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.h +++ b/source/blender/compositor/operations/COM_MapValueOperation.h @@ -34,8 +34,8 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; - TexMapping *settings; + SocketReader *m_inputOperation; + TexMapping *m_settings; public: /** * Default constructor @@ -60,7 +60,7 @@ public: /** * @brief set the TexMapping settings */ - void setSettings(TexMapping *settings) { this->settings = settings; } + void setSettings(TexMapping *settings) { this->m_settings = settings; } }; #endif diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 3b7e98433e4..aa16ecf5d09 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -38,69 +38,69 @@ extern "C" { MaskOperation::MaskOperation() : NodeOperation() { this->addOutputSocket(COM_DT_VALUE); - this->mask = NULL; - this->maskWidth = 0; - this->maskHeight = 0; - this->framenumber = 0; - this->rasterizedMask = NULL; + this->m_mask = NULL; + this->m_maskWidth = 0; + this->m_maskHeight = 0; + this->m_framenumber = 0; + this->m_rasterizedMask = NULL; setComplex(true); } void MaskOperation::initExecution() { initMutex(); - this->rasterizedMask = NULL; + this->m_rasterizedMask = NULL; } void MaskOperation::deinitExecution() { - if (this->rasterizedMask) { - MEM_freeN(rasterizedMask); - this->rasterizedMask = NULL; + if (this->m_rasterizedMask) { + MEM_freeN(this->m_rasterizedMask); + this->m_rasterizedMask = NULL; } } void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->rasterizedMask) - return this->rasterizedMask; + if (this->m_rasterizedMask) + return this->m_rasterizedMask; - if (!this->mask) + if (!this->m_mask) return NULL; lockMutex(); - if (this->rasterizedMask == NULL) { + if (this->m_rasterizedMask == NULL) { int width = this->getWidth(); int height = this->getHeight(); float *buffer; buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask"); - BKE_mask_rasterize(mask, width, height, buffer, TRUE, this->do_smooth, this->do_feather); - if (this->do_smooth) { + BKE_mask_rasterize(this->m_mask, width, height, buffer, TRUE, this->m_do_smooth, this->m_do_feather); + if (this->m_do_smooth) { PLX_antialias_buffer(buffer, width, height); } - this->rasterizedMask = buffer; + this->m_rasterizedMask = buffer; } unlockMutex(); - return this->rasterizedMask; + return this->m_rasterizedMask; } void MaskOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - if (maskWidth == 0 || maskHeight == 0) { + if (this->m_maskWidth == 0 || this->m_maskHeight == 0) { NodeOperation::determineResolution(resolution, preferredResolution); } else { unsigned int nr[2]; - nr[0] = maskWidth; - nr[1] = maskHeight; + nr[0] = this->m_maskWidth; + nr[1] = this->m_maskHeight; NodeOperation::determineResolution(resolution, nr); - resolution[0] = maskWidth; - resolution[1] = maskHeight; + resolution[0] = this->m_maskWidth; + resolution[1] = this->m_maskHeight; } } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 6b6d9aa9eeb..d50f5c619bb 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -36,13 +36,13 @@ */ class MaskOperation : public NodeOperation { protected: - Mask *mask; - int maskWidth; - int maskHeight; - int framenumber; - bool do_smooth; - bool do_feather; - float *rasterizedMask; + Mask *m_mask; + int m_maskWidth; + int m_maskHeight; + int m_framenumber; + bool m_do_smooth; + bool m_do_feather; + float *m_rasterizedMask; /** * Determine the output resolution. The resolution is retrieved from the Renderer @@ -57,12 +57,12 @@ public: void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void setMask(Mask *mask) { this->mask = mask; } - void setMaskWidth(int width) { this->maskWidth = width; } - void setMaskHeight(int height) { this->maskHeight = height; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } - void setSmooth(bool smooth) { this->do_smooth = smooth; } - void setFeather(bool feather) { this->do_feather = feather; } + void setMask(Mask *mask) { this->m_mask = mask; } + void setMaskWidth(int width) { this->m_maskWidth = width; } + void setMaskHeight(int height) { this->m_maskHeight = height; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } + void setSmooth(bool smooth) { this->m_do_smooth = smooth; } + void setFeather(bool feather) { this->m_do_feather = feather; } void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); }; diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp index 5e9fb70b206..1bf89be57b5 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp @@ -30,21 +30,21 @@ MathBaseOperation::MathBaseOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputValue1Operation = NULL; - this->inputValue2Operation = NULL; + this->m_inputValue1Operation = NULL; + this->m_inputValue2Operation = NULL; } void MathBaseOperation::initExecution() { - this->inputValue1Operation = this->getInputSocketReader(0); - this->inputValue2Operation = this->getInputSocketReader(1); + this->m_inputValue1Operation = this->getInputSocketReader(0); + this->m_inputValue2Operation = this->getInputSocketReader(1); } void MathBaseOperation::deinitExecution() { - this->inputValue1Operation = NULL; - this->inputValue2Operation = NULL; + this->m_inputValue1Operation = NULL; + this->m_inputValue2Operation = NULL; } void MathBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -69,8 +69,8 @@ void MathAddOperation::executePixel(float *outputValue, float x, float y, PixelS float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] + inputValue2[0]; } @@ -80,8 +80,8 @@ void MathSubtractOperation::executePixel(float *outputValue, float x, float y, P float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] - inputValue2[0]; } @@ -91,8 +91,8 @@ void MathMultiplyOperation::executePixel(float *outputValue, float x, float y, P float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] * inputValue2[0]; } @@ -102,8 +102,8 @@ void MathDivideOperation::executePixel(float *outputValue, float x, float y, Pix float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue2[0] == 0) /* We don't want to divide by zero. */ outputValue[0] = 0.0; @@ -116,8 +116,8 @@ void MathSineOperation::executePixel(float *outputValue, float x, float y, Pixel float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = sin(inputValue1[0]); } @@ -127,8 +127,8 @@ void MathCosineOperation::executePixel(float *outputValue, float x, float y, Pix float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = cos(inputValue1[0]); } @@ -138,8 +138,8 @@ void MathTangentOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = tan(inputValue1[0]); } @@ -149,8 +149,8 @@ void MathArcSineOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) outputValue[0] = asin(inputValue1[0]); @@ -163,8 +163,8 @@ void MathArcCosineOperation::executePixel(float *outputValue, float x, float y, float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) outputValue[0] = acos(inputValue1[0]); @@ -177,8 +177,8 @@ void MathArcTangentOperation::executePixel(float *outputValue, float x, float y, float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = atan(inputValue1[0]); } @@ -188,8 +188,8 @@ void MathPowerOperation::executePixel(float *outputValue, float x, float y, Pixe float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] >= 0) { outputValue[0] = pow(inputValue1[0], inputValue2[0]); @@ -211,8 +211,8 @@ void MathLogarithmOperation::executePixel(float *outputValue, float x, float y, float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] > 0 && inputValue2[0] > 0) outputValue[0] = log(inputValue1[0]) / log(inputValue2[0]); @@ -225,8 +225,8 @@ void MathMinimumOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = min(inputValue1[0], inputValue2[0]); } @@ -236,8 +236,8 @@ void MathMaximumOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = max(inputValue1[0], inputValue2[0]); } @@ -247,8 +247,8 @@ void MathRoundOperation::executePixel(float *outputValue, float x, float y, Pixe float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = round(inputValue1[0]); } @@ -258,8 +258,8 @@ void MathLessThanOperation::executePixel(float *outputValue, float x, float y, P float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f; } @@ -269,8 +269,8 @@ void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f; } diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index 12dc5fa36c7..bf77223e26f 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -34,8 +34,8 @@ protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValue1Operation; - SocketReader *inputValue2Operation; + SocketReader *m_inputValue1Operation; + SocketReader *m_inputValue2Operation; protected: /** diff --git a/source/blender/compositor/operations/COM_MixAddOperation.cpp b/source/blender/compositor/operations/COM_MixAddOperation.cpp index bd9538a5600..7f7315fb3ff 100644 --- a/source/blender/compositor/operations/COM_MixAddOperation.cpp +++ b/source/blender/compositor/operations/COM_MixAddOperation.cpp @@ -33,9 +33,9 @@ void MixAddOperation::executePixel(float *outputValue, float x, float y, PixelSa float inputColor2[4]; float inputValue[4]; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); float value = inputValue[0]; diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.cpp b/source/blender/compositor/operations/COM_MixBaseOperation.cpp index 0efab2942b0..fbe92f54aa8 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBaseOperation.cpp @@ -28,17 +28,17 @@ MixBaseOperation::MixBaseOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueOperation = NULL; - this->inputColor1Operation = NULL; - this->inputColor2Operation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColor1Operation = NULL; + this->m_inputColor2Operation = NULL; this->setUseValueAlphaMultiply(false); } void MixBaseOperation::initExecution() { - this->inputValueOperation = this->getInputSocketReader(0); - this->inputColor1Operation = this->getInputSocketReader(1); - this->inputColor2Operation = this->getInputSocketReader(2); + this->m_inputValueOperation = this->getInputSocketReader(0); + this->m_inputColor1Operation = this->getInputSocketReader(1); + this->m_inputColor2Operation = this->getInputSocketReader(2); } void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -47,9 +47,9 @@ void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelS float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -63,9 +63,9 @@ void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelS void MixBaseOperation::deinitExecution() { - this->inputValueOperation = NULL; - this->inputColor1Operation = NULL; - this->inputColor2Operation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColor1Operation = NULL; + this->m_inputColor2Operation = NULL; } void MixBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h index 3637cc9eacf..8e9bb283533 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.h +++ b/source/blender/compositor/operations/COM_MixBaseOperation.h @@ -34,10 +34,10 @@ protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValueOperation; - SocketReader *inputColor1Operation; - SocketReader *inputColor2Operation; - bool valueAlphaMultiply; + SocketReader *m_inputValueOperation; + SocketReader *m_inputColor1Operation; + SocketReader *m_inputColor2Operation; + bool m_valueAlphaMultiply; public: /** * Default constructor @@ -61,7 +61,7 @@ public: void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setUseValueAlphaMultiply(const bool value) { this->valueAlphaMultiply = value; } - bool useValueAlphaMultiply() { return this->valueAlphaMultiply; } + void setUseValueAlphaMultiply(const bool value) { this->m_valueAlphaMultiply = value; } + bool useValueAlphaMultiply() { return this->m_valueAlphaMultiply; } }; #endif diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.cpp b/source/blender/compositor/operations/COM_MixBlendOperation.cpp index f010d23ce60..341aba0e7fc 100644 --- a/source/blender/compositor/operations/COM_MixBlendOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBlendOperation.cpp @@ -34,9 +34,9 @@ void MixBlendOperation::executePixel(float *outputValue, float x, float y, Pixel float inputValue[4]; float value; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); value = inputValue[0]; if (this->useValueAlphaMultiply()) { diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.cpp b/source/blender/compositor/operations/COM_MixBurnOperation.cpp index e94834148e8..039915ab66a 100644 --- a/source/blender/compositor/operations/COM_MixBurnOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBurnOperation.cpp @@ -34,9 +34,9 @@ void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelS float value; float tmp; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixColorOperation.cpp b/source/blender/compositor/operations/COM_MixColorOperation.cpp index f3e893bc18f..cb5791c02bb 100644 --- a/source/blender/compositor/operations/COM_MixColorOperation.cpp +++ b/source/blender/compositor/operations/COM_MixColorOperation.cpp @@ -37,9 +37,9 @@ void MixColorOperation::executePixel(float *outputValue, float x, float y, Pixel float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp index a36c663ddda..db243cf4a87 100644 --- a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp @@ -33,9 +33,9 @@ void MixDarkenOperation::executePixel(float *outputValue, float x, float y, Pixe float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp index 69886753480..9fe1a3cb94b 100644 --- a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp @@ -34,9 +34,9 @@ void MixDifferenceOperation::executePixel(float *outputValue, float x, float y, float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.cpp b/source/blender/compositor/operations/COM_MixDivideOperation.cpp index 8b6586c5336..0e1bd408b89 100644 --- a/source/blender/compositor/operations/COM_MixDivideOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDivideOperation.cpp @@ -33,9 +33,9 @@ void MixDivideOperation::executePixel(float *outputValue, float x, float y, Pixe float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp index 971ddd5b736..ea01806267b 100644 --- a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp @@ -34,9 +34,9 @@ void MixDodgeOperation::executePixel(float *outputValue, float x, float y, Pixel float value; float tmp; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.cpp b/source/blender/compositor/operations/COM_MixGlareOperation.cpp index bfb0efe692f..7cd24b3bf06 100644 --- a/source/blender/compositor/operations/COM_MixGlareOperation.cpp +++ b/source/blender/compositor/operations/COM_MixGlareOperation.cpp @@ -34,9 +34,9 @@ void MixGlareOperation::executePixel(float *outputValue, float x, float y, Pixel float inputValue[4]; float value; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); value = inputValue[0]; float mf = 2.f - 2.f * fabsf(value - 0.5f); diff --git a/source/blender/compositor/operations/COM_MixHueOperation.cpp b/source/blender/compositor/operations/COM_MixHueOperation.cpp index 05d02805ebc..e7b444616f4 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.cpp +++ b/source/blender/compositor/operations/COM_MixHueOperation.cpp @@ -37,9 +37,9 @@ void MixHueOperation::executePixel(float *outputValue, float x, float y, PixelSa float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.cpp b/source/blender/compositor/operations/COM_MixLightenOperation.cpp index 6e1af7a3c44..89166637f9f 100644 --- a/source/blender/compositor/operations/COM_MixLightenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixLightenOperation.cpp @@ -33,9 +33,9 @@ void MixLightenOperation::executePixel(float *outputValue, float x, float y, Pix float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp index bf1c181b566..5406a3cbcc1 100644 --- a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp +++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp @@ -33,9 +33,9 @@ void MixLinearLightOperation::executePixel(float *outputValue, float x, float y, float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp index 62018ed5698..978e96eb2f6 100644 --- a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp +++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp @@ -33,9 +33,9 @@ void MixMultiplyOperation::executePixel(float *outputValue, float x, float y, Pi float inputColor2[4]; float inputValue[4]; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp index a269045c598..f4f96747acd 100644 --- a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp +++ b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp @@ -33,9 +33,9 @@ void MixOverlayOperation::executePixel(float *outputValue, float x, float y, Pix float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp index 863a17a7f80..c9c6f691fdb 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp @@ -37,9 +37,9 @@ void MixSaturationOperation::executePixel(float *outputValue, float x, float y, float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.cpp b/source/blender/compositor/operations/COM_MixScreenOperation.cpp index 6fb7befeba4..9bc9144f4ff 100644 --- a/source/blender/compositor/operations/COM_MixScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixScreenOperation.cpp @@ -33,9 +33,9 @@ void MixScreenOperation::executePixel(float *outputValue, float x, float y, Pixe float inputColor2[4]; float valuev[4]; - inputValueOperation->read(valuev, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(valuev, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); float value = valuev[0]; if (this->useValueAlphaMultiply()) { diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp index 9f7d0823473..52c2e8829dc 100644 --- a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp @@ -33,9 +33,9 @@ void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, P float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp index 80086053872..60f54ab478d 100644 --- a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp @@ -33,9 +33,9 @@ void MixSubtractOperation::executePixel(float *outputValue, float x, float y, Pi float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixValueOperation.cpp b/source/blender/compositor/operations/COM_MixValueOperation.cpp index cd79c54318d..2651b0d7dee 100644 --- a/source/blender/compositor/operations/COM_MixValueOperation.cpp +++ b/source/blender/compositor/operations/COM_MixValueOperation.cpp @@ -37,9 +37,9 @@ void MixValueOperation::executePixel(float *outputValue, float x, float y, Pixel float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp index 662212567de..1af206920c5 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp @@ -28,40 +28,40 @@ extern "C" { MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation() { this->addOutputSocket(COM_DT_VALUE); - this->valueSet = false; - this->framenumber = 0; - this->attribute = MCA_X; + this->m_valueSet = false; + this->m_framenumber = 0; + this->m_attribute = MCA_X; } void MovieClipAttributeOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (!valueSet) { + if (!this->m_valueSet) { float loc[2], scale, angle; loc[0] = 0.0f; loc[1] = 0.0f; scale = 1.0f; angle = 0.0f; - if (clip) { - int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenumber); - BKE_tracking_stabilization_data_get(&clip->tracking, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle); + if (this->m_clip) { + int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber); + BKE_tracking_stabilization_data_get(&this->m_clip->tracking, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle); } - switch (this->attribute) { + switch (this->m_attribute) { case MCA_SCALE: - this->value = scale; + this->m_value = scale; break; case MCA_ANGLE: - this->value = angle; + this->m_value = angle; break; case MCA_X: - this->value = loc[0]; + this->m_value = loc[0]; break; case MCA_Y: - this->value = loc[1]; + this->m_value = loc[1]; break; } - valueSet = true; + this->m_valueSet = true; } - outputValue[0] = this->value; + outputValue[0] = this->m_value; } void MovieClipAttributeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h index b6e89fa345c..ba104d07572 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h @@ -37,11 +37,11 @@ typedef enum MovieClipAttribute { */ class MovieClipAttributeOperation : public NodeOperation { private: - MovieClip *clip; - float value; - bool valueSet; - int framenumber; - MovieClipAttribute attribute; + MovieClip *m_clip; + float m_value; + bool m_valueSet; + int m_framenumber; + MovieClipAttribute m_attribute; public: /** * Default constructor @@ -54,8 +54,8 @@ public: void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setMovieClip(MovieClip *clip) { this->clip = clip; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } - void setAttribute(MovieClipAttribute attribute) { this->attribute = attribute; } + void setMovieClip(MovieClip *clip) { this->m_clip = clip; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } + void setAttribute(MovieClipAttribute attribute) { this->m_attribute = attribute; } }; #endif diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp index b8bda12c626..f53bb66d478 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp @@ -34,23 +34,23 @@ extern "C" { MovieClipOperation::MovieClipOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->movieClip = NULL; - this->movieClipBuffer = NULL; - this->movieClipUser = NULL; - this->movieClipwidth = 0; - this->movieClipheight = 0; - this->framenumber = 0; + this->m_movieClip = NULL; + this->m_movieClipBuffer = NULL; + this->m_movieClipUser = NULL; + this->m_movieClipwidth = 0; + this->m_movieClipheight = 0; + this->m_framenumber = 0; } void MovieClipOperation::initExecution() { - if (this->movieClip) { - BKE_movieclip_user_set_frame(this->movieClipUser, this->framenumber); + if (this->m_movieClip) { + BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber); ImBuf *ibuf; - ibuf = BKE_movieclip_get_ibuf(this->movieClip, this->movieClipUser); + ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser); if (ibuf) { - this->movieClipBuffer = ibuf; + this->m_movieClipBuffer = ibuf; if (ibuf->rect_float == NULL || ibuf->userflags & IB_RECT_INVALID) { IMB_float_from_rect(ibuf); ibuf->userflags &= ~IB_RECT_INVALID; @@ -61,10 +61,10 @@ void MovieClipOperation::initExecution() void MovieClipOperation::deinitExecution() { - if (this->movieClipBuffer) { - IMB_freeImBuf(this->movieClipBuffer); + if (this->m_movieClipBuffer) { + IMB_freeImBuf(this->m_movieClipBuffer); - this->movieClipBuffer = NULL; + this->m_movieClipBuffer = NULL; } } @@ -73,10 +73,10 @@ void MovieClipOperation::determineResolution(unsigned int resolution[], unsigned resolution[0] = 0; resolution[1] = 0; - if (this->movieClip) { + if (this->m_movieClip) { int width, height; - BKE_movieclip_get_size(this->movieClip, this->movieClipUser, &width, &height); + BKE_movieclip_get_size(this->m_movieClip, this->m_movieClipUser, &width, &height); resolution[0] = width; resolution[1] = height; @@ -85,22 +85,19 @@ void MovieClipOperation::determineResolution(unsigned int resolution[], unsigned void MovieClipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->movieClipBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + if (this->m_movieClipBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + zero_v4(color); } else { switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->movieClipBuffer, NULL, color, x, y); + neareast_interpolation_color(this->m_movieClipBuffer, NULL, color, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->movieClipBuffer, NULL, color, x, y); + bilinear_interpolation_color(this->m_movieClipBuffer, NULL, color, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->movieClipBuffer, NULL, color, x, y); + bicubic_interpolation_color(this->m_movieClipBuffer, NULL, color, x, y); break; } } diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h index 454c442a167..2e824009ab6 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipOperation.h @@ -37,12 +37,12 @@ */ class MovieClipOperation : public NodeOperation { protected: - MovieClip *movieClip; - MovieClipUser *movieClipUser; - ImBuf *movieClipBuffer; - int movieClipheight; - int movieClipwidth; - int framenumber; + MovieClip *m_movieClip; + MovieClipUser *m_movieClipUser; + ImBuf *m_movieClipBuffer; + int m_movieClipheight; + int m_movieClipwidth; + int m_framenumber; /** * Determine the output resolution. The resolution is retrieved from the Renderer @@ -54,10 +54,10 @@ public: void initExecution(); void deinitExecution(); - void setMovieClip(MovieClip *image) { this->movieClip = image; } - void setMovieClipUser(MovieClipUser *imageuser) { this->movieClipUser = imageuser; } + void setMovieClip(MovieClip *image) { this->m_movieClip = image; } + void setMovieClipUser(MovieClipUser *imageuser) { this->m_movieClipUser = imageuser; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); }; diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index 5320f901747..6b423cadcc6 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -37,57 +37,57 @@ MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperat this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->movieClip = NULL; - this->cache = NULL; - this->distortion = distortion; + this->m_inputOperation = NULL; + this->m_movieClip = NULL; + this->m_cache = NULL; + this->m_distortion = distortion; } void MovieDistortionOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - if (this->movieClip) { + this->m_inputOperation = this->getInputSocketReader(0); + if (this->m_movieClip) { MovieClipUser clipUser = {0}; int calibration_width, calibration_height; - BKE_movieclip_user_set_frame(&clipUser, this->framenumber); - BKE_movieclip_get_size(this->movieClip, &clipUser, &calibration_width, &calibration_height); + BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber); + BKE_movieclip_get_size(this->m_movieClip, &clipUser, &calibration_width, &calibration_height); for (unsigned int i = 0; i < s_cache.size(); i++) { DistortionCache *c = (DistortionCache *)s_cache[i]; - if (c->isCacheFor(this->movieClip, this->width, this->height, - calibration_width, calibration_height, this->distortion)) + if (c->isCacheFor(this->m_movieClip, this->m_width, this->m_height, + calibration_width, calibration_height, this->m_distortion)) { - this->cache = c; + this->m_cache = c; return; } } - DistortionCache *newC = new DistortionCache(this->movieClip, this->width, this->height, - calibration_width, calibration_height, this->distortion); + DistortionCache *newC = new DistortionCache(this->m_movieClip, this->m_width, this->m_height, + calibration_width, calibration_height, this->m_distortion); s_cache.push_back(newC); - this->cache = newC; + this->m_cache = newC; } else { - this->cache = NULL; + this->m_cache = NULL; } } void MovieDistortionOperation::deinitExecution() { - this->inputOperation = NULL; - this->movieClip = NULL; + this->m_inputOperation = NULL; + this->m_movieClip = NULL; } void MovieDistortionOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->cache != NULL) { + if (this->m_cache != NULL) { float u, v; - this->cache->getUV(&this->movieClip->tracking, x, y, &u, &v); - this->inputOperation->read(color, u, v, sampler, inputBuffers); + this->m_cache->getUV(&this->m_movieClip->tracking, x, y, &u, &v); + this->m_inputOperation->read(color, u, v, sampler, inputBuffers); } else { - this->inputOperation->read(color, x, y, sampler, inputBuffers); + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); } } diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h index c2ce04a78e1..ab81ae44597 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h @@ -31,100 +31,101 @@ extern "C" { class DistortionCache { private: - float k1; - float k2; - float k3; - float principal_x; - float principal_y; - float pixel_aspect; - int width; - int height; - int calibration_width; - int calibration_height; - bool inverted; - float *buffer; - int *bufferCalculated; + float m_k1; + float m_k2; + float m_k3; + float m_principal_x; + float m_principal_y; + float m_pixel_aspect; + int m_width; + int m_height; + int m_calibration_width; + int m_calibration_height; + bool m_inverted; + float *m_buffer; + int *m_bufferCalculated; public: DistortionCache(MovieClip *movieclip, int width, int height, int calibration_width, int calibration_height, bool inverted) { - this->k1 = movieclip->tracking.camera.k1; - this->k2 = movieclip->tracking.camera.k2; - this->k3 = movieclip->tracking.camera.k3; - this->principal_x = movieclip->tracking.camera.principal[0]; - this->principal_y = movieclip->tracking.camera.principal[1]; - this->pixel_aspect = movieclip->tracking.camera.pixel_aspect; - this->width = width; - this->height = height; - this->calibration_width = calibration_width; - this->calibration_height = calibration_height; - this->inverted = inverted; - this->bufferCalculated = new int[this->width * this->height]; - this->buffer = new float[this->width * this->height * 2]; - for (int i = 0; i < this->width * this->height; i++) { - this->bufferCalculated[i] = 0; + this->m_k1 = movieclip->tracking.camera.k1; + this->m_k2 = movieclip->tracking.camera.k2; + this->m_k3 = movieclip->tracking.camera.k3; + this->m_principal_x = movieclip->tracking.camera.principal[0]; + this->m_principal_y = movieclip->tracking.camera.principal[1]; + this->m_pixel_aspect = movieclip->tracking.camera.pixel_aspect; + this->m_width = width; + this->m_height = height; + this->m_calibration_width = calibration_width; + this->m_calibration_height = calibration_height; + this->m_inverted = inverted; + this->m_bufferCalculated = new int[this->m_width * this->m_height]; + this->m_buffer = new float[this->m_width * this->m_height * 2]; + for (int i = 0; i < this->m_width * this->m_height; i++) { + this->m_bufferCalculated[i] = 0; } } bool isCacheFor(MovieClip *movieclip, int width, int height, int calibration_width, int claibration_height, bool inverted) { - return this->k1 == movieclip->tracking.camera.k1 && - this->k2 == movieclip->tracking.camera.k2 && - this->k3 == movieclip->tracking.camera.k3 && - this->principal_x == movieclip->tracking.camera.principal[0] && - this->principal_y == movieclip->tracking.camera.principal[1] && - this->pixel_aspect == movieclip->tracking.camera.pixel_aspect && - this->inverted == inverted && - this->width == width && - this->height == height && - this->calibration_width == calibration_width && - this->calibration_height == calibration_height; + return this->m_k1 == movieclip->tracking.camera.k1 && + this->m_k2 == movieclip->tracking.camera.k2 && + this->m_k3 == movieclip->tracking.camera.k3 && + this->m_principal_x == movieclip->tracking.camera.principal[0] && + this->m_principal_y == movieclip->tracking.camera.principal[1] && + this->m_pixel_aspect == movieclip->tracking.camera.pixel_aspect && + this->m_inverted == inverted && + this->m_width == width && + this->m_height == height && + this->m_calibration_width == this->m_calibration_width && + this->m_calibration_height == this->m_calibration_height; } - void getUV(MovieTracking *trackingData, int x, int y, float *u, float *v) { - if (x < 0 || x >= this->width || y < 0 || y >= this->height) { + void getUV(MovieTracking *trackingData, int x, int y, float *u, float *v) + { + if (x < 0 || x >= this->m_width || y < 0 || y >= this->m_height) { *u = x; *v = y; } else { - int offset = y * this->width + x; + int offset = y * this->m_width + x; int offset2 = offset * 2; - if (!bufferCalculated[offset]) { + if (!this->m_bufferCalculated[offset]) { //float overscan = 0.0f; - float w = (float)this->width /* / (1 + overscan) */; - float h = (float)this->height /* / (1 + overscan) */; - float aspx = (float)w / this->calibration_width; - float aspy = (float)h / this->calibration_height; + float w = (float)this->m_width /* / (1 + overscan) */; + float h = (float)this->m_height /* / (1 + overscan) */; + float aspx = (float)w / this->m_calibration_width; + float aspy = (float)h / this->m_calibration_height; float in[2]; float out[2]; in[0] = (x /* - 0.5 * overscan * w */) / aspx; - in[1] = (y /* - 0.5 * overscan * h */) / aspy / this->pixel_aspect; + in[1] = (y /* - 0.5 * overscan * h */) / aspy / this->m_pixel_aspect; - if (inverted) { + if (this->m_inverted) { BKE_tracking_undistort_v2(trackingData, in, out); } else { BKE_tracking_distort_v2(trackingData, in, out); } - buffer[offset2] = out[0] * aspx /* + 0.5 * overscan * w */; - buffer[offset2 + 1] = (out[1] * aspy /* + 0.5 * overscan * h */) * this->pixel_aspect; + this->m_buffer[offset2] = out[0] * aspx /* + 0.5 * overscan * w */; + this->m_buffer[offset2 + 1] = (out[1] * aspy /* + 0.5 * overscan * h */) * this->m_pixel_aspect; - bufferCalculated[offset] = 1; + this->m_bufferCalculated[offset] = 1; } - *u = buffer[offset2]; - *v = buffer[offset2 + 1]; + *u = this->m_buffer[offset2]; + *v = this->m_buffer[offset2 + 1]; } } }; class MovieDistortionOperation : public NodeOperation { private: - DistortionCache *cache; - SocketReader *inputOperation; - MovieClip *movieClip; + DistortionCache *m_cache; + SocketReader *m_inputOperation; + MovieClip *m_movieClip; protected: - bool distortion; - int framenumber; + bool m_distortion; + int m_framenumber; public: MovieDistortionOperation(bool distortion); @@ -134,8 +135,8 @@ public: void initExecution(); void deinitExecution(); - void setMovieClip(MovieClip *clip) { this->movieClip = clip; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } + void setMovieClip(MovieClip *clip) { this->m_movieClip = clip; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } }; #endif diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp index 1bd21f6e712..363c0379770 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp @@ -29,15 +29,15 @@ extern "C" { MultilayerBaseOperation::MultilayerBaseOperation(int pass) : BaseImageOperation() { - this->passId = pass; + this->m_passId = pass; } ImBuf *MultilayerBaseOperation::getImBuf() { RenderPass *rpass; - rpass = (RenderPass *)BLI_findlink(&this->renderlayer->passes, this->passId); + rpass = (RenderPass *)BLI_findlink(&this->m_renderlayer->passes, this->m_passId); if (rpass) { - this->imageUser->pass = this->passId; - BKE_image_multilayer_index(image->rr, this->imageUser); + this->m_imageUser->pass = this->m_passId; + BKE_image_multilayer_index(this->m_image->rr, this->m_imageUser); return BaseImageOperation::getImBuf(); } return NULL; @@ -47,31 +47,29 @@ void MultilayerColorOperation::executePixel(float *color, float x, float y, Pixe { int yi = y; int xi = x; - if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { color[0] = 0.0f; color[1] = 0.0f; color[2] = 0.0f; color[3] = 0.0f; } else { - if (this->numberOfChannels == 4) { + if (this->m_numberOfChannels == 4) { switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->buffer, NULL, color, x, y); + neareast_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->buffer, NULL, color, x, y); + bilinear_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->buffer, NULL, color, x, y); + bicubic_interpolation_color(this->m_buffer, NULL, color, x, y); break; } } else { int offset = (yi * this->getWidth() + xi) * 3; - color[0] = this->imageBuffer[offset]; - color[1] = this->imageBuffer[offset + 1]; - color[2] = this->imageBuffer[offset + 2]; + copy_v3_v3(color, &this->m_imageBuffer[offset]); } } } @@ -80,11 +78,11 @@ void MultilayerValueOperation::executePixel(float *color, float x, float y, Pixe { int yi = y; int xi = x; - if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { color[0] = 0.0f; } else { - float result = this->imageBuffer[yi * this->getWidth() + xi]; + float result = this->m_imageBuffer[yi * this->getWidth() + xi]; color[0] = result; } } @@ -93,13 +91,11 @@ void MultilayerVectorOperation::executePixel(float *color, float x, float y, Pix { int yi = y; int xi = x; - if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { color[0] = 0.0f; } else { int offset = (yi * this->getWidth() + xi) * 3; - color[0] = this->imageBuffer[offset]; - color[1] = this->imageBuffer[offset + 1]; - color[2] = this->imageBuffer[offset + 2]; + copy_v3_v3(color, &this->m_imageBuffer[offset]); } } diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h index c33e65fc55b..f946c44dd35 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h @@ -29,8 +29,8 @@ class MultilayerBaseOperation : public BaseImageOperation { private: - int passId; - RenderLayer *renderlayer; + int m_passId; + RenderLayer *m_renderlayer; protected: ImBuf *getImBuf(); public: @@ -38,7 +38,7 @@ public: * Constructor */ MultilayerBaseOperation(int pass); - void setRenderLayer(RenderLayer *renderlayer) { this->renderlayer = renderlayer; } + void setRenderLayer(RenderLayer *renderlayer) { this->m_renderlayer = renderlayer; } }; class MultilayerColorOperation : public MultilayerBaseOperation { diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp index 6d12141a455..8a83ef7f3ae 100644 --- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp +++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp @@ -25,13 +25,13 @@ NormalizeOperation::NormalizeOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->imageReader = NULL; - this->cachedInstance = NULL; + this->m_imageReader = NULL; + this->m_cachedInstance = NULL; this->setComplex(true); } void NormalizeOperation::initExecution() { - this->imageReader = this->getInputSocketReader(0); + this->m_imageReader = this->getInputSocketReader(0); NodeOperation::initMutex(); } @@ -41,16 +41,16 @@ void NormalizeOperation::executePixel(float *color, int x, int y, MemoryBuffer * NodeTwoFloats *minmult = (NodeTwoFloats *)data; float output[4]; - this->imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, inputBuffers, NULL); color[0] = (output[0] - minmult->x) * minmult->y; } void NormalizeOperation::deinitExecution() { - this->imageReader = NULL; - if (this->cachedInstance) { - delete cachedInstance; + this->m_imageReader = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; } NodeOperation::deinitMutex(); } @@ -58,7 +58,8 @@ void NormalizeOperation::deinitExecution() bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti imageInput; - + if (this->m_cachedInstance) return false; + NodeOperation *operation = getInputOperation(0); imageInput.xmax = operation->getWidth(); imageInput.xmin = 0; @@ -77,8 +78,8 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); /* using generic two floats struct to store x: min y: mult */ NodeTwoFloats *minmult = new NodeTwoFloats(); @@ -92,8 +93,12 @@ void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu float value; while (p--) { value = bc[0]; - maxv = max(value, maxv); - minv = min(value, minv); + if ((value > maxv) && (value <= BLENDER_ZMAX)) { + maxv = value; + } + if ((value < minv) && (value >= -BLENDER_ZMAX)) { + minv = value; + } bc += 4; } @@ -101,11 +106,11 @@ void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu /* The rare case of flat buffer would cause a divide by 0 */ minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.f); - this->cachedInstance = minmult; + this->m_cachedInstance = minmult; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } void NormalizeOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.h b/source/blender/compositor/operations/COM_NormalizeOperation.h index de1c4d67bba..1f4a403434e 100644 --- a/source/blender/compositor/operations/COM_NormalizeOperation.h +++ b/source/blender/compositor/operations/COM_NormalizeOperation.h @@ -33,13 +33,13 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *imageReader; + SocketReader *m_imageReader; /** * @brief temporarily cache of the execution storage * it stores x->min and y->mult */ - NodeTwoFloats *cachedInstance; + NodeTwoFloats *m_cachedInstance; public: NormalizeOperation(); diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index c0aa139b032..087e7a15e39 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -94,66 +94,66 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bN OutputSingleLayerOperation::OutputSingleLayerOperation( const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) { - this->rd = rd; - this->tree = tree; + this->m_rd = rd; + this->m_tree = tree; this->addInputSocket(datatype); - this->outputBuffer = NULL; - this->datatype = datatype; - this->imageInput = NULL; + this->m_outputBuffer = NULL; + this->m_datatype = datatype; + this->m_imageInput = NULL; - this->format = format; - BLI_strncpy(this->path, path, sizeof(this->path)); + this->m_format = format; + BLI_strncpy(this->m_path, path, sizeof(this->m_path)); } void OutputSingleLayerOperation::initExecution() { - this->imageInput = getInputSocketReader(0); - this->outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->datatype); + this->m_imageInput = getInputSocketReader(0); + this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype); } void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - write_buffer_rect(rect, memoryBuffers, this->tree, imageInput, this->outputBuffer, this->getWidth(), this->datatype); + write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_imageInput, this->m_outputBuffer, this->getWidth(), this->m_datatype); } void OutputSingleLayerOperation::deinitExecution() { if (this->getWidth() * this->getHeight() != 0) { - int size = get_datatype_size(this->datatype); + int size = get_datatype_size(this->m_datatype); ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), size * 8, 0); Main *bmain = G.main; /* TODO, have this passed along */ char filename[FILE_MAX]; ibuf->channels = size; - ibuf->rect_float = this->outputBuffer; + ibuf->rect_float = this->m_outputBuffer; ibuf->mall |= IB_rectfloat; - ibuf->dither = this->rd->dither_intensity; + ibuf->dither = this->m_rd->dither_intensity; - if (this->rd->color_mgt_flag & R_COLOR_MANAGEMENT) + if (this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT) ibuf->profile = IB_PROFILE_LINEAR_RGB; - BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, this->format->imtype, - (this->rd->scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format->imtype, + (this->m_rd->scemode & R_EXTENSION), true); - if (0 == BKE_imbuf_write(ibuf, filename, this->format)) + if (0 == BKE_imbuf_write(ibuf, filename, this->m_format)) printf("Cannot save Node File Output to %s\n", filename); else printf("Saved: %s\n", filename); IMB_freeImBuf(ibuf); } - this->outputBuffer = NULL; - this->imageInput = NULL; + this->m_outputBuffer = NULL; + this->m_imageInput = NULL; } -OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype) +OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_) { - BLI_strncpy(this->name, name, sizeof(this->name)); - this->datatype = datatype; + BLI_strncpy(this->name, name_, sizeof(this->name)); + this->datatype = datatype_; /* these are created in initExecution */ this->outputBuffer = 0; this->imageInput = 0; @@ -162,31 +162,31 @@ OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype) OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation( const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec) { - this->rd = rd; - this->tree = tree; + this->m_rd = rd; + this->m_tree = tree; - BLI_strncpy(this->path, path, sizeof(this->path)); - this->exr_codec = exr_codec; + BLI_strncpy(this->m_path, path, sizeof(this->m_path)); + this->m_exr_codec = exr_codec; } void OutputOpenExrMultiLayerOperation::add_layer(const char *name, DataType datatype) { this->addInputSocket(datatype); - layers.push_back(OutputOpenExrLayer(name, datatype)); + this->m_layers.push_back(OutputOpenExrLayer(name, datatype)); } void OutputOpenExrMultiLayerOperation::initExecution() { - for (unsigned int i = 0; i < layers.size(); ++i) { - layers[i].imageInput = getInputSocketReader(i); - layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), layers[i].datatype); + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { + this->m_layers[i].imageInput = getInputSocketReader(i); + this->m_layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_layers[i].datatype); } } void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - for (unsigned int i = 0; i < layers.size(); ++i) { - write_buffer_rect(rect, memoryBuffers, this->tree, layers[i].imageInput, layers[i].outputBuffer, this->getWidth(), layers[i].datatype); + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { + write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_layers[i].imageInput, this->m_layers[i].outputBuffer, this->getWidth(), this->m_layers[i].datatype); } } @@ -199,19 +199,19 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() char filename[FILE_MAX]; void *exrhandle = IMB_exr_get_handle(); - BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, R_IMF_IMTYPE_MULTILAYER, - (this->rd->scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER, + (this->m_rd->scemode & R_EXTENSION), true); BLI_make_existing_file(filename); - for (unsigned int i = 0; i < layers.size(); ++i) { + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { char channelname[EXR_TOT_MAXNAME]; - BLI_strncpy(channelname, layers[i].name, sizeof(channelname) - 2); + BLI_strncpy(channelname, this->m_layers[i].name, sizeof(channelname) - 2); char *channelname_ext = channelname + strlen(channelname); - float *buf = layers[i].outputBuffer; + float *buf = this->m_layers[i].outputBuffer; /* create channels */ - switch (layers[i].datatype) { + switch (this->m_layers[i].datatype) { case COM_DT_VALUE: strcpy(channelname_ext, ".V"); IMB_exr_add_channel(exrhandle, 0, channelname, 1, width, buf); @@ -241,7 +241,7 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() } /* when the filename has no permissions, this can fail */ - if (IMB_exr_begin_write(exrhandle, filename, width, height, this->exr_codec)) { + if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec)) { IMB_exr_write_channels(exrhandle); } else { @@ -251,13 +251,13 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() } IMB_exr_close(exrhandle); - for (unsigned int i = 0; i < layers.size(); ++i) { - if (layers[i].outputBuffer) { - MEM_freeN(layers[i].outputBuffer); - layers[i].outputBuffer = NULL; + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { + if (this->m_layers[i].outputBuffer) { + MEM_freeN(this->m_layers[i].outputBuffer); + this->m_layers[i].outputBuffer = NULL; } - layers[i].imageInput = NULL; + this->m_layers[i].imageInput = NULL; } } } diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h index 25ee5b31ec0..60244a8bf72 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileOperation.h @@ -32,15 +32,15 @@ /* Writes the image to a single-layer file. */ class OutputSingleLayerOperation : public NodeOperation { private: - const RenderData *rd; - const bNodeTree *tree; + const RenderData *m_rd; + const bNodeTree *m_tree; - ImageFormatData *format; - char path[FILE_MAX]; + ImageFormatData *m_format; + char m_path[FILE_MAX]; - float *outputBuffer; - DataType datatype; - SocketReader *imageInput; + float *m_outputBuffer; + DataType m_datatype; + SocketReader *m_imageInput; public: OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); @@ -67,12 +67,12 @@ class OutputOpenExrMultiLayerOperation : public NodeOperation { private: typedef std::vector<OutputOpenExrLayer> LayerList; - const RenderData *rd; - const bNodeTree *tree; + const RenderData *m_rd; + const bNodeTree *m_tree; - char path[FILE_MAX]; - char exr_codec; - LayerList layers; + char m_path[FILE_MAX]; + char m_exr_codec; + LayerList m_layers; public: OutputOpenExrMultiLayerOperation(const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec); diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 54a95af33b9..55e94568688 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -42,39 +42,41 @@ extern "C" { PreviewOperation::PreviewOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); - this->outputBuffer = NULL; - this->input = NULL; - this->divider = 1.0f; - this->node = NULL; + this->m_outputBuffer = NULL; + this->m_input = NULL; + this->m_divider = 1.0f; + this->m_node = NULL; } void PreviewOperation::initExecution() { - this->input = getInputSocketReader(0); - if (!this->node->preview) { - this->node->preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview"); + this->m_input = getInputSocketReader(0); + if (!this->m_node->preview) { + this->m_node->preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview"); } else { - if (this->getWidth() == (unsigned int)this->node->preview->xsize && this->getHeight() == (unsigned int)this->node->preview->ysize) { - this->outputBuffer = this->node->preview->rect; + if (this->getWidth() == (unsigned int)this->m_node->preview->xsize && + this->getHeight() == (unsigned int)this->m_node->preview->ysize) + { + this->m_outputBuffer = this->m_node->preview->rect; } } - if (this->outputBuffer == NULL) { - this->outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation"); - if (this->node->preview->rect) { - MEM_freeN(this->node->preview->rect); + if (this->m_outputBuffer == NULL) { + this->m_outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation"); + if (this->m_node->preview->rect) { + MEM_freeN(this->m_node->preview->rect); } - this->node->preview->xsize = getWidth(); - this->node->preview->ysize = getHeight(); - this->node->preview->rect = outputBuffer; + this->m_node->preview->xsize = getWidth(); + this->m_node->preview->ysize = getHeight(); + this->m_node->preview->rect = this->m_outputBuffer; } } void PreviewOperation::deinitExecution() { - this->outputBuffer = NULL; - this->input = NULL; + this->m_outputBuffer = NULL; + this->m_input = NULL; } void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) @@ -84,16 +86,16 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, Memory for (int y = rect->ymin; y < rect->ymax; y++) { offset = (y * getWidth() + rect->xmin) * 4; for (int x = rect->xmin; x < rect->xmax; x++) { - float rx = floor(x / divider); - float ry = floor(y / divider); + float rx = floor(x / this->m_divider); + float ry = floor(y / this->m_divider); color[0] = 0.0f; color[1] = 0.0f; color[2] = 0.0f; color[3] = 1.0f; - input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers); linearrgb_to_srgb_v4(color, color); - F4TOCHAR4(color, outputBuffer + offset); + F4TOCHAR4(color, this->m_outputBuffer + offset); offset += 4; } } @@ -102,10 +104,10 @@ bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferO { rcti newInput; - newInput.xmin = input->xmin / divider; - newInput.xmax = input->xmax / divider; - newInput.ymin = input->ymin / divider; - newInput.ymax = input->ymax / divider; + newInput.xmin = input->xmin / this->m_divider; + newInput.xmax = input->xmax / this->m_divider; + newInput.ymin = input->ymin / this->m_divider; + newInput.ymax = input->ymax / this->m_divider; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -114,15 +116,15 @@ void PreviewOperation::determineResolution(unsigned int resolution[], unsigned i NodeOperation::determineResolution(resolution, preferredResolution); int width = resolution[0]; int height = resolution[1]; - this->divider = 0.0f; + this->m_divider = 0.0f; if (width > height) { - divider = COM_PREVIEW_SIZE / (width - 1); + this->m_divider = COM_PREVIEW_SIZE / (width - 1); } else { - divider = COM_PREVIEW_SIZE / (height - 1); + this->m_divider = COM_PREVIEW_SIZE / (height - 1); } - width = width * divider; - height = height * divider; + width = width * this->m_divider; + height = height * this->m_divider; resolution[0] = width; resolution[1] = height; diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index f9ce0c644a1..e7b8ba55ae0 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -28,14 +28,14 @@ class PreviewOperation : public NodeOperation { protected: - unsigned char *outputBuffer; + unsigned char *m_outputBuffer; /** * @brief holds reference to the SDNA bNode, where this nodes will render the preview image for */ - bNode *node; - SocketReader *input; - float divider; + bNode *m_node; + SocketReader *m_input; + float m_divider; public: PreviewOperation(); @@ -46,7 +46,7 @@ public: void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setbNode(bNode *node) { this->node = node; } + void setbNode(bNode *node) { this->m_node = node; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); bool isPreviewOperation() { return true; } diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index b337e435df4..74145c52a5d 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -30,19 +30,20 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOpera this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; - this->dispersionAvailable = false; - this->dispersion = 0.0f; + this->m_inputProgram = NULL; + this->m_dispersionAvailable = false; + this->m_dispersion = 0.0f; } void ProjectorLensDistortionOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->initMutex(); + this->m_inputProgram = this->getInputSocketReader(0); } void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { updateDispersion(memoryBuffers); - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } @@ -54,45 +55,49 @@ void ProjectorLensDistortionOperation::executePixel(float *color, int x, int y, const float v = (y + 0.5f) / height; const float u = (x + 0.5f) / width; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; - inputBuffer->readCubic(inputValue, (u * width + kr2) - 0.5f, v * height - 0.5f); + inputBuffer->readCubic(inputValue, (u * width + this->m_kr2) - 0.5f, v * height - 0.5f); color[0] = inputValue[0]; inputBuffer->read(inputValue, x, y); color[1] = inputValue[1]; - inputBuffer->readCubic(inputValue, (u * width - kr2) - 0.5f, v * height - 0.5f); + inputBuffer->readCubic(inputValue, (u * width - this->m_kr2) - 0.5f, v * height - 0.5f); color[2] = inputValue[2]; color[3] = 1.0f; } void ProjectorLensDistortionOperation::deinitExecution() { - this->inputProgram = NULL; + this->deinitMutex(); + this->m_inputProgram = NULL; } bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - if (dispersionAvailable) { + if (this->m_dispersionAvailable) { newInput.ymax = input->ymax; newInput.ymin = input->ymin; - newInput.xmin = input->xmin - kr2 - 2; - newInput.xmax = input->xmax + kr2 + 2; + 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 = 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 (!dispersionAvailable) { + 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); - dispersion = result[0]; - kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr2 = kr * 20; - dispersionAvailable = true; + this->m_dispersion = result[0]; + this->m_kr = 0.25f * MAX2(MIN2(this->m_dispersion, 1.f), 0.f); + 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 5023a5df507..c658d66429a 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h @@ -30,14 +30,14 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - NodeLensDist *data; + NodeLensDist *m_data; - float dispersion; - bool dispersionAvailable; + float m_dispersion; + bool m_dispersionAvailable; - float kr, kr2; + float m_kr, m_kr2; public: ProjectorLensDistortionOperation(); @@ -57,11 +57,11 @@ public: */ void deinitExecution(); - void setData(NodeLensDist *data) { this->data = data; } + void setData(NodeLensDist *data) { this->m_data = data; } 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_QualityStepHelper.cpp b/source/blender/compositor/operations/COM_QualityStepHelper.cpp index 18b3b106138..d99d6f28eff 100644 --- a/source/blender/compositor/operations/COM_QualityStepHelper.cpp +++ b/source/blender/compositor/operations/COM_QualityStepHelper.cpp @@ -24,45 +24,45 @@ QualityStepHelper::QualityStepHelper() { - this->quality = COM_QUALITY_HIGH; - this->step = 1; - this->offsetadd = 4; + this->m_quality = COM_QUALITY_HIGH; + this->m_step = 1; + this->m_offsetadd = 4; } void QualityStepHelper::initExecution(QualityHelper helper) { switch (helper) { case COM_QH_INCREASE: - switch (this->quality) { + switch (this->m_quality) { case COM_QUALITY_HIGH: default: - this->step = 1; - this->offsetadd = 4; + this->m_step = 1; + this->m_offsetadd = 4; break; case COM_QUALITY_MEDIUM: - this->step = 2; - this->offsetadd = 8; + this->m_step = 2; + this->m_offsetadd = 8; break; case COM_QUALITY_LOW: - this->step = 3; - this->offsetadd = 12; + this->m_step = 3; + this->m_offsetadd = 12; break; } break; case COM_QH_MULTIPLY: - switch (this->quality) { + switch (this->m_quality) { case COM_QUALITY_HIGH: default: - this->step = 1; - this->offsetadd = 4; + this->m_step = 1; + this->m_offsetadd = 4; break; case COM_QUALITY_MEDIUM: - this->step = 2; - this->offsetadd = 8; + this->m_step = 2; + this->m_offsetadd = 8; break; case COM_QUALITY_LOW: - this->step = 4; - this->offsetadd = 16; + this->m_step = 4; + this->m_offsetadd = 16; break; } break; diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.h b/source/blender/compositor/operations/COM_QualityStepHelper.h index aef80e22e38..34e2ba1b47c 100644 --- a/source/blender/compositor/operations/COM_QualityStepHelper.h +++ b/source/blender/compositor/operations/COM_QualityStepHelper.h @@ -31,9 +31,9 @@ typedef enum QualityHelper { class QualityStepHelper { private: - CompositorQuality quality; - int step; - int offsetadd; + CompositorQuality m_quality; + int m_step; + int m_offsetadd; protected: /** @@ -41,13 +41,13 @@ protected: */ void initExecution(QualityHelper helper); - inline int getStep() const { return this->step; } - inline int getOffsetAdd() const { return this->offsetadd; } + inline int getStep() const { return this->m_step; } + inline int getOffsetAdd() const { return this->m_offsetadd; } public: QualityStepHelper(); - void setQuality(CompositorQuality quality) { this->quality = quality; } + void setQuality(CompositorQuality quality) { this->m_quality = quality; } }; #endif diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 857131950dd..76e6921503e 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -27,7 +27,7 @@ ReadBufferOperation::ReadBufferOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->offset = 0; + this->m_offset = 0; } void *ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -37,19 +37,21 @@ void *ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - if (this->memoryProxy != NULL) { - WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation(); + if (this->m_memoryProxy != NULL) { + WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation(); operation->determineResolution(resolution, preferredResolution); operation->setResolution(resolution); /// @todo: may not occur!, but does with blur node - if (memoryProxy->getExecutor()) memoryProxy->getExecutor()->setResolution(resolution); + if (this->m_memoryProxy->getExecutor()) { + this->m_memoryProxy->getExecutor()->setResolution(resolution); + } } } void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { if (inputBuffers) { - MemoryBuffer *inputBuffer = inputBuffers[this->offset]; + MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; if (inputBuffer) { if (sampler == COM_PS_NEAREST) { inputBuffer->read(color, x, y); @@ -68,7 +70,7 @@ void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSamp void ReadBufferOperation::executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) { - MemoryBuffer *inputBuffer = inputBuffers[this->offset]; + MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; if (inputBuffer) { inputBuffer->readEWA(color, x, y, dx, dy); } @@ -85,8 +87,8 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff void ReadBufferOperation::readResolutionFromWriteBuffer() { - if (this->memoryProxy != NULL) { - WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation(); + if (this->m_memoryProxy != NULL) { + WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation(); this->setWidth(operation->getWidth()); this->setHeight(operation->getHeight()); } diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h index 576aa194bc5..de0c69c0ecc 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.h +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h @@ -28,23 +28,23 @@ class ReadBufferOperation : public NodeOperation { private: - MemoryProxy *memoryProxy; - unsigned int offset; + MemoryProxy *m_memoryProxy; + unsigned int m_offset; public: ReadBufferOperation(); int isBufferOperation() { return true; } - void setMemoryProxy(MemoryProxy *memoryProxy) { this->memoryProxy = memoryProxy; } - MemoryProxy *getMemoryProxy() { return this->memoryProxy; } + void setMemoryProxy(MemoryProxy *memoryProxy) { this->m_memoryProxy = memoryProxy; } + MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; } void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); void executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer * inputBuffers[]); const bool isReadBufferOperation() const { return true; } - void setOffset(unsigned int offset) { this->offset = offset; } - unsigned int getOffset() { return this->offset; } + void setOffset(unsigned int offset) { this->m_offset = offset; } + unsigned int getOffset() { return this->m_offset; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[offset]; } + MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[this->m_offset]; } void readResolutionFromWriteBuffer(); }; diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp index f27af3c25f5..e4543c06d9b 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp @@ -33,10 +33,10 @@ extern "C" { RenderLayersBaseProg::RenderLayersBaseProg(int renderpass, int elementsize) : NodeOperation() { - this->renderpass = renderpass; + this->m_renderpass = renderpass; this->setScene(NULL); - this->inputBuffer = NULL; - this->elementsize = elementsize; + this->m_inputBuffer = NULL; + this->m_elementsize = elementsize; } @@ -55,10 +55,10 @@ void RenderLayersBaseProg::initExecution() RenderLayer *rl = RE_GetRenderLayer(rr, srl->name); if (rl && rl->rectf) { - this->inputBuffer = RE_RenderLayerGetPass(rl, renderpass); + this->m_inputBuffer = RE_RenderLayerGetPass(rl, this->m_renderpass); - if (this->inputBuffer == NULL || renderpass == SCE_PASS_COMBINED) { - this->inputBuffer = rl->rectf; + if (this->m_inputBuffer == NULL || this->m_renderpass == SCE_PASS_COMBINED) { + this->m_inputBuffer = rl->rectf; } } } @@ -74,38 +74,30 @@ void RenderLayersBaseProg::executePixel(float *output, float x, float y, PixelSa int ix = x; int iy = y; - if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) { - output[0] = 0.0f; - output[1] = 0.0f; - output[2] = 0.0f; - output[3] = 0.0f; + if (this->m_inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) { + zero_v4(output); } else { - unsigned int offset = (iy * this->getWidth() + ix) * elementsize; - if (elementsize == 1) { - output[0] = inputBuffer[offset]; + unsigned int offset = (iy * this->getWidth() + ix) * this->m_elementsize; + if (this->m_elementsize == 1) { + output[0] = this->m_inputBuffer[offset]; output[1] = 0.0f; output[2] = 0.0f; output[3] = 0.0f; } - else if (elementsize == 3) { - output[0] = inputBuffer[offset]; - output[1] = inputBuffer[offset + 1]; - output[2] = inputBuffer[offset + 2]; + else if (this->m_elementsize == 3) { + copy_v3_v3(output, &this->m_inputBuffer[offset]); output[3] = 1.0f; } else { - output[0] = inputBuffer[offset]; - output[1] = inputBuffer[offset + 1]; - output[2] = inputBuffer[offset + 2]; - output[3] = inputBuffer[offset + 3]; + copy_v4_v4(output, &this->m_inputBuffer[offset]); } } } void RenderLayersBaseProg::deinitExecution() { - this->inputBuffer = NULL; + this->m_inputBuffer = NULL; } void RenderLayersBaseProg::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h index ce2b8f767b6..a18b515bd7b 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h @@ -45,24 +45,24 @@ private: /** * Reference to the scene object. */ - Scene *scene; + Scene *m_scene; /** * layerId of the layer where this operation needs to get its data from */ - short layerId; + short m_layerId; /** * cached instance to the float buffer inside the layer */ - float *inputBuffer; + float *m_inputBuffer; /** * renderpass where this operation needs to get its data from */ - int renderpass; + int m_renderpass; - int elementsize; + int m_elementsize; protected: /** @@ -78,7 +78,7 @@ protected: /** * retrieve the reference to the float buffer of the renderer. */ - inline float *getInputBuffer() { return this->inputBuffer; } + inline float *getInputBuffer() { return this->m_inputBuffer; } public: /** @@ -86,10 +86,10 @@ public: * @see RenderLayerNode to set the actual scene where * the data will be retrieved from. */ - void setScene(Scene *scene) { this->scene = scene; } - Scene *getScene() { return this->scene; } - void setLayerId(short layerId) { this->layerId = layerId; } - short getLayerId() { return this->layerId; } + void setScene(Scene *scene) { this->m_scene = scene; } + Scene *getScene() { return this->m_scene; } + void setLayerId(short layerId) { this->m_layerId = layerId; } + short getLayerId() { return this->m_layerId; } void initExecution(); void deinitExecution(); void executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); diff --git a/source/blender/compositor/operations/COM_RenderLayersMistOperation.h b/source/blender/compositor/operations/COM_RenderLayersMistOperation.h index 8c0ee9bfcab..ad838c9e340 100644 --- a/source/blender/compositor/operations/COM_RenderLayersMistOperation.h +++ b/source/blender/compositor/operations/COM_RenderLayersMistOperation.h @@ -1,3 +1,25 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + #ifndef _COM_RenderLayersMistOperation_h #define _COM_RenderLayersMistOperation_h diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp index 456dc5d1d0f..086ce917e7e 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cpp +++ b/source/blender/compositor/operations/COM_RotateOperation.cpp @@ -29,41 +29,41 @@ RotateOperation::RotateOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->imageSocket = NULL; - this->degreeSocket = NULL; - this->doDegree2RadConversion = false; - this->isDegreeSet = false; + this->m_imageSocket = NULL; + this->m_degreeSocket = NULL; + this->m_doDegree2RadConversion = false; + this->m_isDegreeSet = false; } void RotateOperation::initExecution() { - this->imageSocket = this->getInputSocketReader(0); - this->degreeSocket = this->getInputSocketReader(1); - this->centerX = this->getWidth() / 2.0; - this->centerY = this->getHeight() / 2.0; + this->m_imageSocket = this->getInputSocketReader(0); + this->m_degreeSocket = this->getInputSocketReader(1); + this->m_centerX = this->getWidth() / 2.0; + this->m_centerY = this->getHeight() / 2.0; } void RotateOperation::deinitExecution() { - this->imageSocket = NULL; - this->degreeSocket = NULL; + this->m_imageSocket = NULL; + this->m_degreeSocket = NULL; } inline void RotateOperation::ensureDegree() { - if (!isDegreeSet) { + if (!this->m_isDegreeSet) { float degree[4]; - this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); + this->m_degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); double rad; - if (this->doDegree2RadConversion) { + if (this->m_doDegree2RadConversion) { rad = DEG2RAD((double)degree[0]); } else { rad = degree[0]; } - this->cosine = cos(rad); - this->sine = sin(rad); + this->m_cosine = cos(rad); + this->m_sine = sin(rad); - isDegreeSet = true; + this->m_isDegreeSet = true; } } @@ -71,11 +71,11 @@ inline void RotateOperation::ensureDegree() void RotateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { ensureDegree(); - const float dy = y - this->centerY; - const float dx = x - this->centerX; - const float nx = this->centerX + (this->cosine * dx + this->sine * dy); - const float ny = this->centerY + (-this->sine * dx + this->cosine * dy); - this->imageSocket->read(color, nx, ny, sampler, inputBuffers); + const float dy = y - this->m_centerY; + const float dx = x - this->m_centerX; + const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy); + const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy); + this->m_imageSocket->read(color, nx, ny, sampler, inputBuffers); } bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -83,19 +83,19 @@ bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOp ensureDegree(); rcti newInput; - const float dxmin = input->xmin - this->centerX; - const float dymin = input->ymin - this->centerY; - const float dxmax = input->xmax - this->centerX; - const float dymax = input->ymax - this->centerY; + const float dxmin = input->xmin - this->m_centerX; + const float dymin = input->ymin - this->m_centerY; + const float dxmax = input->xmax - this->m_centerX; + const float dymax = input->ymax - this->m_centerY; - const float x1 = this->centerX + (this->cosine * dxmin + this->sine * dymin); - const float x2 = this->centerX + (this->cosine * dxmax + this->sine * dymin); - const float x3 = this->centerX + (this->cosine * dxmin + this->sine * dymax); - const float x4 = this->centerX + (this->cosine * dxmax + this->sine * dymax); - const float y1 = this->centerY + (-this->sine * dxmin + this->cosine * dymin); - const float y2 = this->centerY + (-this->sine * dxmax + this->cosine * dymin); - const float y3 = this->centerY + (-this->sine * dxmin + this->cosine * dymax); - const float y4 = this->centerY + (-this->sine * dxmax + this->cosine * dymax); + const float x1 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymin); + const float x2 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymin); + const float x3 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymax); + const float x4 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymax); + const float y1 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymin); + const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin); + const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax); + const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax); const float minx = min(x1, min(x2, min(x3, x4))); const float maxx = max(x1, max(x2, max(x3, x4))); const float miny = min(y1, min(y2, min(y3, y4))); diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h index bf7355da80e..9e6dd3987d1 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.h +++ b/source/blender/compositor/operations/COM_RotateOperation.h @@ -27,21 +27,21 @@ class RotateOperation : public NodeOperation { private: - SocketReader *imageSocket; - SocketReader *degreeSocket; - float centerX; - float centerY; - float cosine; - float sine; - bool doDegree2RadConversion; - bool isDegreeSet; + SocketReader *m_imageSocket; + SocketReader *m_degreeSocket; + float m_centerX; + float m_centerY; + float m_cosine; + float m_sine; + bool m_doDegree2RadConversion; + bool m_isDegreeSet; public: RotateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); void initExecution(); void deinitExecution(); - void setDoDegree2RadConversion(bool abool) { this->doDegree2RadConversion = abool; } + void setDoDegree2RadConversion(bool abool) { this->m_doDegree2RadConversion = abool; } void ensureDegree(); }; diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp index 2e23df73b67..6a1f7b62203 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cpp +++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp @@ -33,24 +33,24 @@ ScaleOperation::ScaleOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } void ScaleOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputXOperation = this->getInputSocketReader(1); - this->inputYOperation = this->getInputSocketReader(2); - this->centerX = this->getWidth() / 2.0; - this->centerY = this->getHeight() / 2.0; + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputXOperation = this->getInputSocketReader(1); + this->m_inputYOperation = this->getInputSocketReader(2); + this->m_centerX = this->getWidth() / 2.0; + this->m_centerY = this->getHeight() / 2.0; } void ScaleOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } @@ -63,15 +63,15 @@ void ScaleOperation::executePixel(float *color, float x, float y, PixelSampler s float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, x, y, sampler, inputBuffers); - this->inputYOperation->read(scaleY, x, y, sampler, inputBuffers); + this->m_inputXOperation->read(scaleX, x, y, sampler, inputBuffers); + this->m_inputYOperation->read(scaleY, x, y, sampler, inputBuffers); const float scx = scaleX[0]; const float scy = scaleY[0]; - float nx = this->centerX + (x - this->centerX) / scx; - float ny = this->centerY + (y - this->centerY) / scy; - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + float nx = this->m_centerX + (x - this->m_centerX) / scx; + float ny = this->m_centerY + (y - this->m_centerY) / scy; + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -80,16 +80,16 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); - this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); const float scx = scaleX[0]; const float scy = scaleY[0]; - newInput.xmax = this->centerX + (input->xmax - this->centerX) / scx; - newInput.xmin = this->centerX + (input->xmin - this->centerX) / scx; - newInput.ymax = this->centerY + (input->ymax - this->centerY) / scy; - newInput.ymin = this->centerY + (input->ymin - this->centerY) / scy; + newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / scx; + newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / scx; + newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / scy; + newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / scy; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -103,24 +103,24 @@ ScaleAbsoluteOperation::ScaleAbsoluteOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } void ScaleAbsoluteOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputXOperation = this->getInputSocketReader(1); - this->inputYOperation = this->getInputSocketReader(2); - this->centerX = this->getWidth() / 2.0; - this->centerY = this->getHeight() / 2.0; + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputXOperation = this->getInputSocketReader(1); + this->m_inputYOperation = this->getInputSocketReader(2); + this->m_centerX = this->getWidth() / 2.0; + this->m_centerY = this->getHeight() / 2.0; } void ScaleAbsoluteOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } @@ -133,8 +133,8 @@ void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelS float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, x, y, sampler, inputBuffers); - this->inputYOperation->read(scaleY, x, y, sampler, inputBuffers); + this->m_inputXOperation->read(scaleX, x, y, sampler, inputBuffers); + this->m_inputYOperation->read(scaleY, x, y, sampler, inputBuffers); const float scx = scaleX[0]; // target absolute scale const float scy = scaleY[0]; // target absolute scale @@ -145,10 +145,10 @@ void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelS float relativeXScale = scx / width; float relativeYScale = scy / height; - float nx = this->centerX + (x - this->centerX) / relativeXScale; - float ny = this->centerY + (y - this->centerY) / relativeYScale; + float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale; + float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale; - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -157,8 +157,8 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); - this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); const float scx = scaleX[0]; const float scy = scaleY[0]; @@ -168,10 +168,10 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB float relateveXScale = scx / width; float relateveYScale = scy / height; - newInput.xmax = this->centerX + (input->xmax - this->centerX) / relateveXScale; - newInput.xmin = this->centerX + (input->xmin - this->centerX) / relateveXScale; - newInput.ymax = this->centerY + (input->ymax - this->centerY) / relateveYScale; - newInput.ymin = this->centerY + (input->ymin - this->centerY) / relateveYScale; + newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / relateveXScale; + newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / relateveXScale; + newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / relateveYScale; + newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / relateveYScale; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -180,59 +180,59 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB // Absolute fixed siez ScaleFixedSizeOperation::ScaleFixedSizeOperation() : NodeOperation() { - this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ScaleFixedSizeOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->relX = inputOperation->getWidth() / (float)this->newWidth; - this->relY = inputOperation->getHeight() / (float)this->newHeight; + this->m_inputOperation = this->getInputSocketReader(0); + this->m_relX = this->m_inputOperation->getWidth() / (float)this->m_newWidth; + this->m_relY = this->m_inputOperation->getHeight() / (float)this->m_newHeight; /* *** all the options below are for a fairly special case - camera framing *** */ - if (this->offsetX != 0.0f || this->offsetY != 0.0f) { - this->is_offset = true; + if (this->m_offsetX != 0.0f || this->m_offsetY != 0.0f) { + this->m_is_offset = true; - if (this->newWidth > this->newHeight) { - this->offsetX *= this->newWidth; - this->offsetY *= this->newWidth; + if (this->m_newWidth > this->m_newHeight) { + this->m_offsetX *= this->m_newWidth; + this->m_offsetY *= this->m_newWidth; } else { - this->offsetX *= this->newHeight; - this->offsetY *= this->newHeight; + this->m_offsetX *= this->m_newHeight; + this->m_offsetY *= this->m_newHeight; } } - if (this->is_aspect) { + if (this->m_is_aspect) { /* apply aspect from clip */ - const float w_src = inputOperation->getWidth(); - const float h_src = inputOperation->getHeight(); + const float w_src = this->m_inputOperation->getWidth(); + const float h_src = this->m_inputOperation->getHeight(); /* destination aspect is already applied from the camera frame */ - const float w_dst = this->newWidth; - const float h_dst = this->newHeight; + const float w_dst = this->m_newWidth; + const float h_dst = this->m_newHeight; const float asp_src = w_src / h_src; const float asp_dst = w_dst / h_dst; if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) { - if ((asp_src > asp_dst) == (this->is_crop == true)) { + if ((asp_src > asp_dst) == (this->m_is_crop == true)) { /* fit X */ const float div = asp_src / asp_dst; - this->relX /= div; - this->offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f; + this->m_relX /= div; + this->m_offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f; } else { /* fit Y */ const float div = asp_dst / asp_src; - this->relY /= div; - this->offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f; + this->m_relY /= div; + this->m_offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f; } - this->is_offset = true; + this->m_is_offset = true; } } /* *** end framing options *** */ @@ -240,7 +240,7 @@ void ScaleFixedSizeOperation::initExecution() void ScaleFixedSizeOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } @@ -250,13 +250,13 @@ void ScaleFixedSizeOperation::executePixel(float *color, float x, float y, Pixel sampler = COM_PS_BICUBIC; #endif - if (this->is_offset) { - float nx = ((x - this->offsetX) * relX); - float ny = ((y - this->offsetY) * relY); - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + if (this->m_is_offset) { + float nx = ((x - this->m_offsetX) * this->m_relX); + float ny = ((y - this->m_offsetY) * this->m_relY); + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } else { - this->inputOperation->read(color, x * relX, y * relY, sampler, inputBuffers); + this->m_inputOperation->read(color, x * this->m_relX, y * this->m_relY, sampler, inputBuffers); } } @@ -264,10 +264,10 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, Read { rcti newInput; - newInput.xmax = input->xmax * relX; - newInput.xmin = input->xmin * relX; - newInput.ymax = input->ymax * relY; - newInput.ymin = input->ymin * relY; + newInput.xmax = input->xmax * this->m_relX; + newInput.xmin = input->xmin * this->m_relX; + newInput.ymax = input->ymax * this->m_relY; + newInput.ymin = input->ymin * this->m_relY; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -275,9 +275,9 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, Read void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { unsigned int nr[2]; - nr[0] = newWidth; - nr[1] = newHeight; + nr[0] = this->m_newWidth; + nr[1] = this->m_newHeight; NodeOperation::determineResolution(resolution, nr); - resolution[0] = newWidth; - resolution[1] = newHeight; + resolution[0] = this->m_newWidth; + resolution[1] = this->m_newHeight; } diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h index 7089f6c10a4..8cd44810bbd 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.h +++ b/source/blender/compositor/operations/COM_ScaleOperation.h @@ -27,11 +27,11 @@ class ScaleOperation : public NodeOperation { private: - SocketReader *inputOperation; - SocketReader *inputXOperation; - SocketReader *inputYOperation; - float centerX; - float centerY; + SocketReader *m_inputOperation; + SocketReader *m_inputXOperation; + SocketReader *m_inputYOperation; + float m_centerX; + float m_centerY; public: ScaleOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -42,11 +42,11 @@ public: }; class ScaleAbsoluteOperation : public NodeOperation { - SocketReader *inputOperation; - SocketReader *inputXOperation; - SocketReader *inputYOperation; - float centerX; - float centerY; + SocketReader *m_inputOperation; + SocketReader *m_inputXOperation; + SocketReader *m_inputYOperation; + float m_centerX; + float m_centerY; public: ScaleAbsoluteOperation(); @@ -58,20 +58,20 @@ public: }; class ScaleFixedSizeOperation : public NodeOperation { - SocketReader *inputOperation; - int newWidth; - int newHeight; - float relX; - float relY; + SocketReader *m_inputOperation; + int m_newWidth; + int m_newHeight; + float m_relX; + float m_relY; /* center is only used for aspect correction */ - float offsetX; - float offsetY; - bool is_aspect; - bool is_crop; + float m_offsetX; + float m_offsetY; + bool m_is_aspect; + bool m_is_crop; /* set from other properties on initialization, * check if we need to apply offset */ - bool is_offset; + bool m_is_offset; public: ScaleFixedSizeOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -80,11 +80,11 @@ public: void initExecution(); void deinitExecution(); - void setNewWidth(int width) { this->newWidth = width; } - void setNewHeight(int height) { this->newHeight = height; } - void setIsAspect(bool is_aspect) { this->is_aspect = is_aspect; } - void setIsCrop(bool is_crop) { this->is_crop = is_crop; } - void setOffset(float x, float y) { this->offsetX = x; this->offsetY = y; } + void setNewWidth(int width) { this->m_newWidth = width; } + void setNewHeight(int height) { this->m_newHeight = height; } + void setIsAspect(bool is_aspect) { this->m_is_aspect = is_aspect; } + void setIsCrop(bool is_crop) { this->m_is_crop = is_crop; } + void setOffset(float x, float y) { this->m_offsetX = x; this->m_offsetY = y; } }; #endif diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index da3504de971..e3abf2aa70b 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -34,19 +34,19 @@ ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; - this->valuesAvailable = false; - this->dispersion = 0.0f; - this->distortion = 0.0f; + this->m_inputProgram = NULL; + this->m_valuesAvailable = false; + this->m_dispersion = 0.0f; + this->m_distortion = 0.0f; } void ScreenLensDistortionOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); updateDispersionAndDistortion(memoryBuffers); return buffer; } @@ -60,29 +60,29 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int int dr = 0, dg = 0, db = 0; float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; float tc[4] = {0, 0, 0, 0}; - const float v = sc * ((y + 0.5f) - cy) / cy; - const float u = sc * ((x + 0.5f) - cx) / cx; + 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 uv_dot = u * u + v * v; int sta = 0, mid = 0, end = 0; - if ((t = 1.f - kr4 * uv_dot) >= 0.f) { + 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; sta = 1; } - if ((t = 1.f - kg4 * uv_dot) >= 0.f) { + 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; mid = 1; } - if ((t = 1.f - kb4 * uv_dot) >= 0.f) { + 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; end = 1; } if (sta && mid && end) { - float jit = this->data->jit; + float jit = this->m_data->jit; float z; float color[4]; { @@ -94,8 +94,8 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kr4 + tz * drg) * uv_dot; - d = 1.f / (1.f + sqrtf(t)); + 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; buffer->readCubic(color, nx, ny); @@ -112,7 +112,7 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kg4 + tz * dgb) * uv_dot; + 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; @@ -122,9 +122,9 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int } } - if (dr) outputColor[0] = 2.f * tc[0] / (float)dr; - if (dg) outputColor[1] = 2.f * tc[1] / (float)dg; - if (db) outputColor[2] = 2.f * tc[2] / (float)db; + if (dr) outputColor[0] = 2.0f * tc[0] / (float)dr; + if (dg) outputColor[1] = 2.0f * tc[1] / (float)dg; + if (db) outputColor[2] = 2.0f * tc[2] / (float)db; /* set alpha */ outputColor[3] = 1.0f; @@ -139,14 +139,14 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int void ScreenLensDistortionOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void ScreenLensDistortionOperation::determineUV(float result[2], float x, float y) const { - const float v = sc * ((y + 0.5f) - cy) / cy; - const float u = sc * ((x + 0.5f) - cx) / cx; - const float t = ABS(MIN3(kr, kg, kb) * 4); + 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; @@ -157,34 +157,34 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input rcti newInput; newInput.xmin = 0; newInput.ymin = 0; - newInput.ymax = inputProgram->getHeight(); - newInput.xmax = inputProgram->getWidth(); + newInput.ymax = this->m_inputProgram->getHeight(); + newInput.xmax = this->m_inputProgram->getWidth(); return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers) { - if (!valuesAvailable) { + if (!this->m_valuesAvailable) { float result[4]; this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); - this->distortion = result[0]; + this->m_distortion = result[0]; this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); - this->dispersion = result[0]; - kg = MAX2(MIN2(this->distortion, 1.f), -0.999f); + 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->dispersion, 1.f), 0.f); - kr = MAX2(MIN2((kg + d), 1.f), -0.999f); - kb = MAX2(MIN2((kg - d), 1.f), -0.999f); - maxk = MAX3(kr, kg, kb); - sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk)); - drg = 4.f * (kg - kr); - dgb = 4.f * (kb - kg); + 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); - kr4 = kr * 4.f; - kg4 = kg * 4.f; - kb4 = kb * 4.f; - cx = 0.5f * (float)getWidth(); - cy = 0.5f * (float)getHeight(); - valuesAvailable = true; + 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(); + this->m_valuesAvailable = true; } } diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h index 21babd11295..7e4fda0f755 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h @@ -30,19 +30,19 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - NodeLensDist *data; + NodeLensDist *m_data; - float dispersion; - float distortion; - bool valuesAvailable; - float kr, kg, kb; - float kr4, kg4, kb4; - float maxk; - float drg; - float dgb; - float sc, cx, cy; + float m_dispersion; + float m_distortion; + bool m_valuesAvailable; + float m_kr, m_kg, m_kb; + float m_kr4, m_kg4, m_kb4; + float m_maxk; + float m_drg; + float m_dgb; + float m_sc, m_cx, m_cy; public: ScreenLensDistortionOperation(); @@ -62,13 +62,13 @@ public: */ void deinitExecution(); - void setData(NodeLensDist *data) { this->data = data; } + void setData(NodeLensDist *data) { this->m_data = data; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); private: void determineUV(float *result, float x, float y) const; - void updateDispersionAndDistortion(MemoryBuffer** inputBuffers); + void updateDispersionAndDistortion(MemoryBuffer **inputBuffers); }; #endif diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp index caa1387da2a..6ae4fc4cfe5 100644 --- a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp +++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp @@ -26,22 +26,22 @@ SeparateChannelOperation::SeparateChannelOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SeparateChannelOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void SeparateChannelOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SeparateChannelOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float input[4]; - this->inputOperation->read(input, x, y, sampler, inputBuffers); - color[0] = input[this->channel]; + this->m_inputOperation->read(input, x, y, sampler, inputBuffers); + color[0] = input[this->m_channel]; } diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.h b/source/blender/compositor/operations/COM_SeparateChannelOperation.h index b1a38fd8294..65a54f91252 100644 --- a/source/blender/compositor/operations/COM_SeparateChannelOperation.h +++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.h @@ -27,8 +27,8 @@ class SeparateChannelOperation : public NodeOperation { private: - SocketReader *inputOperation; - int channel; + SocketReader *m_inputOperation; + int m_channel; public: SeparateChannelOperation(); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); @@ -36,7 +36,7 @@ public: void initExecution(); void deinitExecution(); - void setChannel(int channel) { this->channel = channel; } + void setChannel(int channel) { this->m_channel = channel; } }; #endif diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp index 5924108ed86..d383fb638ae 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp @@ -28,28 +28,28 @@ SetAlphaOperation::SetAlphaOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputColor = NULL; - this->inputAlpha = NULL; + this->m_inputColor = NULL; + this->m_inputAlpha = NULL; } void SetAlphaOperation::initExecution() { - this->inputColor = getInputSocketReader(0); - this->inputAlpha = getInputSocketReader(1); + this->m_inputColor = getInputSocketReader(0); + this->m_inputAlpha = getInputSocketReader(1); } void SetAlphaOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float alphaInput[4]; - this->inputColor->read(outputValue, x, y, sampler, inputBuffers); - this->inputAlpha->read(alphaInput, x, y, sampler, inputBuffers); + this->m_inputColor->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputAlpha->read(alphaInput, x, y, sampler, inputBuffers); outputValue[3] = alphaInput[0]; } void SetAlphaOperation::deinitExecution() { - this->inputColor = NULL; - this->inputAlpha = NULL; + this->m_inputColor = NULL; + this->m_inputAlpha = NULL; } diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h index 231b41f1697..857bd08bfbf 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h @@ -31,8 +31,8 @@ */ class SetAlphaOperation : public NodeOperation { private: - SocketReader *inputColor; - SocketReader *inputAlpha; + SocketReader *m_inputColor; + SocketReader *m_inputAlpha; public: /** diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp index 5307d7abc24..55a6a3800ca 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp @@ -29,10 +29,10 @@ SetColorOperation::SetColorOperation() : NodeOperation() void SetColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - outputValue[0] = this->channel1; - outputValue[1] = this->channel2; - outputValue[2] = this->channel3; - outputValue[3] = this->channel4; + outputValue[0] = this->m_channel1; + outputValue[1] = this->m_channel2; + outputValue[2] = this->m_channel3; + outputValue[3] = this->m_channel4; } void SetColorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h index 9d28f1757db..abfa2b9538a 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.h +++ b/source/blender/compositor/operations/COM_SetColorOperation.h @@ -31,10 +31,10 @@ */ class SetColorOperation : public NodeOperation { private: - float channel1; - float channel2; - float channel3; - float channel4; + float m_channel1; + float m_channel2; + float m_channel3; + float m_channel4; public: /** @@ -42,15 +42,21 @@ public: */ SetColorOperation(); - const float getChannel1() {return this->channel1;} - void setChannel1(float value) {this->channel1 = value;} - const float getChannel2() {return this->channel2;} - void setChannel2(float value) {this->channel2 = value;} - const float getChannel3() {return this->channel3;} - void setChannel3(float value) {this->channel3 = value;} - const float getChannel4() {return this->channel4;} - void setChannel4(float value) {this->channel4 = value;} - void setChannels(float value[4]) {this->channel1 = value[0];this->channel2 = value[1];this->channel3 = value[2];this->channel4 = value[3];} + const float getChannel1() { return this->m_channel1; } + void setChannel1(float value) { this->m_channel1 = value; } + const float getChannel2() { return this->m_channel2; } + void setChannel2(float value) { this->m_channel2 = value; } + const float getChannel3() { return this->m_channel3; } + void setChannel3(float value) { this->m_channel3 = value; } + const float getChannel4() { return this->m_channel4; } + void setChannel4(float value) { this->m_channel4 = value; } + void setChannels(float value[4]) + { + this->m_channel1 = value[0]; + this->m_channel2 = value[1]; + this->m_channel3 = value[2]; + this->m_channel4 = value[3]; + } /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp index dfe7fe91bf8..c235bd81e58 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp @@ -30,14 +30,14 @@ SetSamplerOperation::SetSamplerOperation() : NodeOperation() void SetSamplerOperation::initExecution() { - this->reader = this->getInputSocketReader(0); + this->m_reader = this->getInputSocketReader(0); } void SetSamplerOperation::deinitExecution() { - this->reader = NULL; + this->m_reader = NULL; } void SetSamplerOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - reader->read(output, x, y, this->sampler, inputBuffers); + this->m_reader->read(output, x, y, this->m_sampler, inputBuffers); } diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h index 5dba0b3703f..24e0c5e2ef5 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.h +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h @@ -31,15 +31,15 @@ */ class SetSamplerOperation : public NodeOperation { private: - PixelSampler sampler; - SocketReader *reader; + PixelSampler m_sampler; + SocketReader *m_reader; public: /** * Default constructor */ SetSamplerOperation(); - void setSampler(PixelSampler sampler) { this->sampler = sampler; } + void setSampler(PixelSampler sampler) { this->m_sampler = sampler; } /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp index 483fcc97a1f..98a21112c5b 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.cpp +++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp @@ -29,7 +29,7 @@ SetValueOperation::SetValueOperation() : NodeOperation() void SetValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - outputValue[0] = this->value; + outputValue[0] = this->m_value; } void SetValueOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h index 2f4a6ec0dc8..dce0c3299ac 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.h +++ b/source/blender/compositor/operations/COM_SetValueOperation.h @@ -31,7 +31,7 @@ */ class SetValueOperation : public NodeOperation { private: - float value; + float m_value; public: /** @@ -39,8 +39,8 @@ public: */ SetValueOperation(); - const float getValue() { return this->value; } - void setValue(float value) { this->value = value; } + const float getValue() { return this->m_value; } + void setValue(float value) { this->m_value = value; } /** diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp index 3d15a184c4e..f37bc489e75 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp @@ -30,10 +30,10 @@ SetVectorOperation::SetVectorOperation() : NodeOperation() void SetVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - outputValue[0] = this->x; - outputValue[1] = this->y; - outputValue[2] = this->z; - outputValue[3] = this->w; + outputValue[0] = this->m_x; + outputValue[1] = this->m_y; + outputValue[2] = this->m_z; + outputValue[3] = this->m_w; } void SetVectorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h index 49088027762..dc2a05ceff4 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.h +++ b/source/blender/compositor/operations/COM_SetVectorOperation.h @@ -31,10 +31,10 @@ */ class SetVectorOperation : public NodeOperation { private: - float x; - float y; - float z; - float w; + float m_x; + float m_y; + float m_z; + float m_w; public: /** @@ -42,14 +42,14 @@ public: */ SetVectorOperation(); - const float getX() { return this->x; } - void setX(float value) { this->x = value; } - const float getY() { return this->y; } - void setY(float value) { this->y = value; } - const float getZ() { return this->z; } - void setZ(float value) { this->z = value; } - const float getW() { return this->w; } - void setW(float value) { this->w = value; } + const float getX() { return this->m_x; } + void setX(float value) { this->m_x = value; } + const float getY() { return this->m_y; } + void setY(float value) { this->m_y = value; } + const float getZ() { return this->m_z; } + void setZ(float value) { this->m_z = value; } + const float getW() { return this->m_w; } + void setW(float value) { this->m_w = value; } /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp index 55c4b68ee57..8b39406fd83 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp @@ -26,22 +26,22 @@ SocketProxyOperation::SocketProxyOperation(DataType type) : NodeOperation() { this->addInputSocket(type); this->addOutputSocket(type); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SocketProxyOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void SocketProxyOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SocketProxyOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->inputOperation) { - this->inputOperation->read(color, x, y, sampler, inputBuffers); + if (this->m_inputOperation) { + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); } } diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h index 5dc8f3d6f8f..a4177efbd8e 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.h +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h @@ -27,7 +27,7 @@ class SocketProxyOperation : public NodeOperation { private: - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: SocketProxyOperation(DataType type); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp index 2735f182406..00f854b2ba9 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp @@ -40,30 +40,30 @@ SplitViewerOperation::SplitViewerOperation() : ViewerBaseOperation() { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR); - this->image1Input = NULL; - this->image2Input = NULL; + this->m_image1Input = NULL; + this->m_image2Input = NULL; } void SplitViewerOperation::initExecution() { // When initializing the tree during initial load the width and height can be zero. - this->image1Input = getInputSocketReader(0); - this->image2Input = getInputSocketReader(1); + this->m_image1Input = getInputSocketReader(0); + this->m_image2Input = getInputSocketReader(1); ViewerBaseOperation::initExecution(); } void SplitViewerOperation::deinitExecution() { - this->image1Input = NULL; - this->image2Input = NULL; + this->m_image1Input = NULL; + this->m_image2Input = NULL; ViewerBaseOperation::deinitExecution(); } void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - float *buffer = this->outputBuffer; - unsigned char *bufferDisplay = this->outputBufferDisplay; + float *buffer = this->m_outputBuffer; + unsigned char *bufferDisplay = this->m_outputBufferDisplay; if (!buffer) return; int x1 = rect->xmin; @@ -73,21 +73,21 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me int offset = (y1 * this->getWidth() + x1) * 4; int x; int y; - int perc = xSplit ? this->splitPercentage *getWidth() / 100.0f : this->splitPercentage *getHeight() / 100.0f; + int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f; for (y = y1; y < y2; y++) { for (x = x1; x < x2; x++) { bool image1; float srgb[4]; - image1 = xSplit ? x > perc : y > perc; + image1 = this->m_xSplit ? x > perc : y > perc; if (image1) { - image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); } else { - image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); } /// @todo: linear conversion only when scene color management is selected, also check predivide. - if (this->doColorManagement) { - if (this->doColorPredivide) { + if (this->m_doColorManagement) { + if (this->m_doColorPredivide) { linearrgb_to_srgb_predivide_v4(srgb, buffer + offset); } else { diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.h b/source/blender/compositor/operations/COM_SplitViewerOperation.h index aba63ff190b..92275606105 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.h +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.h @@ -28,17 +28,17 @@ class SplitViewerOperation : public ViewerBaseOperation { private: - SocketReader *image1Input; - SocketReader *image2Input; + SocketReader *m_image1Input; + SocketReader *m_image2Input; - float splitPercentage; - bool xSplit; + float m_splitPercentage; + bool m_xSplit; public: SplitViewerOperation(); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); void initExecution(); void deinitExecution(); - void setSplitPercentage(float splitPercentage) { this->splitPercentage = splitPercentage; } - void setXSplit(bool xsplit) { this->xSplit = xsplit; } + void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; } + void setXSplit(bool xsplit) { this->m_xSplit = xsplit; } }; #endif diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp index dbdd17adbe4..6098cfc3e5c 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cpp +++ b/source/blender/compositor/operations/COM_TextureOperation.cpp @@ -29,10 +29,10 @@ TextureBaseOperation::TextureBaseOperation() : NodeOperation() { this->addInputSocket(COM_DT_VECTOR); //offset this->addInputSocket(COM_DT_VECTOR); //size - this->texture = NULL; - this->inputSize = NULL; - this->inputOffset = NULL; - this->rd = NULL; + this->m_texture = NULL; + this->m_inputSize = NULL; + this->m_inputOffset = NULL; + this->m_rd = NULL; } TextureOperation::TextureOperation() : TextureBaseOperation() { @@ -45,20 +45,20 @@ TextureAlphaOperation::TextureAlphaOperation() : TextureBaseOperation() void TextureBaseOperation::initExecution() { - this->inputOffset = getInputSocketReader(0); - this->inputSize = getInputSocketReader(1); + this->m_inputOffset = getInputSocketReader(0); + this->m_inputSize = getInputSocketReader(1); } void TextureBaseOperation::deinitExecution() { - this->inputSize = NULL; - this->inputOffset = NULL; + this->m_inputSize = NULL; + this->m_inputOffset = NULL; } void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { if (preferredResolution[0] == 0 || preferredResolution[1] == 0) { - int width = this->rd->xsch * this->rd->size / 100; - int height = this->rd->ysch * this->rd->size / 100; + int width = this->m_rd->xsch * this->m_rd->size / 100; + int height = this->m_rd->ysch * this->m_rd->size / 100; resolution[0] = width; resolution[1] = height; } @@ -89,14 +89,14 @@ void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSam const float u = (cx - x) / this->getWidth() * 2; const float v = (cy - y) / this->getHeight() * 2; - this->inputSize->read(textureSize, x, y, sampler, inputBuffers); - this->inputOffset->read(textureOffset, x, y, sampler, inputBuffers); + this->m_inputSize->read(textureSize, x, y, sampler, inputBuffers); + this->m_inputOffset->read(textureOffset, x, y, sampler, inputBuffers); vec[0] = textureSize[0] * (u + textureOffset[0]); vec[1] = textureSize[1] * (v + textureOffset[1]); vec[2] = textureSize[2] * textureOffset[2]; - retval = multitex_ext(this->texture, vec, NULL, NULL, 0, &texres); + retval = multitex_ext(this->m_texture, vec, NULL, NULL, 0, &texres); if (texres.talpha) color[3] = texres.ta; diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h index 14714242511..d42da697b08 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.h +++ b/source/blender/compositor/operations/COM_TextureOperation.h @@ -42,10 +42,10 @@ extern "C" { */ class TextureBaseOperation : public NodeOperation { private: - Tex *texture; - const RenderData *rd; - SocketReader *inputSize; - SocketReader *inputOffset; + Tex *m_texture; + const RenderData *m_rd; + SocketReader *m_inputSize; + SocketReader *m_inputOffset; protected: @@ -62,10 +62,10 @@ protected: public: void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); - void setTexture(Tex *texture) { this->texture = texture; } + void setTexture(Tex *texture) { this->m_texture = texture; } void initExecution(); void deinitExecution(); - void setRenderData(const RenderData *rd) { this->rd = rd; } + void setRenderData(const RenderData *rd) { this->m_rd = rd; } }; class TextureOperation : public TextureBaseOperation { diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp index 7b978e0f87c..b5daf85b390 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.cpp +++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp @@ -30,14 +30,14 @@ TonemapOperation::TonemapOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_COLOR); - this->imageReader = NULL; - this->data = NULL; - this->cachedInstance = NULL; + this->m_imageReader = NULL; + this->m_data = NULL; + this->m_cachedInstance = NULL; this->setComplex(true); } void TonemapOperation::initExecution() { - this->imageReader = this->getInputSocketReader(0); + this->m_imageReader = this->getInputSocketReader(0); NodeOperation::initMutex(); } @@ -46,11 +46,11 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in AvgLogLum *avg = (AvgLogLum *)data; float output[4]; - this->imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, inputBuffers, NULL); mul_v3_fl(output, avg->al); - float dr = output[0] + this->data->offset; - float dg = output[1] + this->data->offset; - float db = output[2] + this->data->offset; + float dr = output[0] + this->m_data->offset; + float dg = output[1] + this->m_data->offset; + float db = output[2] + this->m_data->offset; output[0] /= ((dr == 0.f) ? 1.0f : dr); output[1] /= ((dg == 0.f) ? 1.0f : dg); output[2] /= ((db == 0.f) ? 1.0f : db); @@ -66,14 +66,14 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { AvgLogLum *avg = (AvgLogLum *)data; - NodeTonemap *ntm = this->data; + NodeTonemap *ntm = this->m_data; - const float f = expf(-this->data->f); + const float f = expf(-this->m_data->f); const float m = (ntm->m > 0.0f) ? ntm->m : (0.3f + 0.7f * powf(avg->auto_key, 1.4f)); const float ic = 1.0f - ntm->c, ia = 1.0f - ntm->a; float output[4]; - this->imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, inputBuffers, NULL); const float L = rgb_to_luma_y(output); float I_l = output[0] + ic * (L - output[0]); @@ -94,9 +94,9 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem void TonemapOperation::deinitExecution() { - this->imageReader = NULL; - if (this->cachedInstance) { - delete cachedInstance; + this->m_imageReader = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; } NodeOperation::deinitMutex(); } @@ -119,8 +119,8 @@ bool TonemapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferO void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); AvgLogLum *data = new AvgLogLum(); float *buffer = tile->getBuffer(); @@ -146,12 +146,12 @@ void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuff maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5); avl = lsum * sc; data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f; float al = exp((double)avl); - data->al = (al == 0.f) ? 0.f : (this->data->key / al); - data->igm = (this->data->gamma == 0.f) ? 1 : (1.f / this->data->gamma); - this->cachedInstance = data; + data->al = (al == 0.0f) ? 0.0f : (this->m_data->key / al); + data->igm = (this->m_data->gamma == 0.f) ? 1 : (1.f / this->m_data->gamma); + this->m_cachedInstance = data; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } void TonemapOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h index 005f0862443..ed9018d0a09 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.h +++ b/source/blender/compositor/operations/COM_TonemapOperation.h @@ -46,17 +46,17 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *imageReader; + SocketReader *m_imageReader; /** * @brief settings of the Tonemap */ - NodeTonemap *data; + NodeTonemap *m_data; /** * @brief temporarily cache of the execution storage */ - AvgLogLum *cachedInstance; + AvgLogLum *m_cachedInstance; public: TonemapOperation(); @@ -79,7 +79,7 @@ public: */ void deinitExecution(); - void setData(NodeTonemap *data) { this->data = data; } + void setData(NodeTonemap *data) { this->m_data = data; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp index c41e2c7f156..e43a8e55130 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.cpp +++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp @@ -29,31 +29,31 @@ TranslateOperation::TranslateOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; - this->isDeltaSet = false; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; + this->m_isDeltaSet = false; } void TranslateOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputXOperation = this->getInputSocketReader(1); - this->inputYOperation = this->getInputSocketReader(2); + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputXOperation = this->getInputSocketReader(1); + this->m_inputYOperation = this->getInputSocketReader(2); } void TranslateOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } void TranslateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { ensureDelta(); - this->inputOperation->read(color, x - this->getDeltaX(), y - this->getDeltaY(), sampler, inputBuffers); + this->m_inputOperation->read(color, x - this->getDeltaX(), y - this->getDeltaY(), sampler, inputBuffers); } bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h index bf3121bec11..8af4ffe8967 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.h +++ b/source/blender/compositor/operations/COM_TranslateOperation.h @@ -27,12 +27,12 @@ class TranslateOperation : public NodeOperation { private: - SocketReader *inputOperation; - SocketReader *inputXOperation; - SocketReader *inputYOperation; - float deltaX; - float deltaY; - bool isDeltaSet; + SocketReader *m_inputOperation; + SocketReader *m_inputXOperation; + SocketReader *m_inputYOperation; + float m_deltaX; + float m_deltaY; + bool m_isDeltaSet; public: TranslateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -41,17 +41,17 @@ public: void initExecution(); void deinitExecution(); - float getDeltaX() { return this->deltaX; } - float getDeltaY() { return this->deltaY; } + float getDeltaX() { return this->m_deltaX; } + float getDeltaY() { return this->m_deltaY; } inline void ensureDelta() { - if (!isDeltaSet) { + if (!this->m_isDeltaSet) { float tempDelta[4]; - this->inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); - this->deltaX = tempDelta[0]; - this->inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); - this->deltaY = tempDelta[0]; - this->isDeltaSet = true; + this->m_inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->m_deltaX = tempDelta[0]; + this->m_inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->m_deltaY = tempDelta[0]; + this->m_isDeltaSet = true; } } }; diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index c17e51e6391..9eb004b3686 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -36,21 +36,21 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputSizeProgram = NULL; - this->inputDepthProgram = NULL; - this->maxBlur = 32.0f; - this->threshold = 1.0f; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputSizeProgram = NULL; + this->m_inputDepthProgram = NULL; + this->m_maxBlur = 32.0f; + this->m_threshold = 1.0f; } void VariableSizeBokehBlurOperation::initExecution() { - this->inputProgram = getInputSocketReader(0); - this->inputBokehProgram = getInputSocketReader(1); - this->inputSizeProgram = getInputSocketReader(2); - this->inputDepthProgram = getInputSocketReader(3); + this->m_inputProgram = getInputSocketReader(0); + this->m_inputBokehProgram = getInputSocketReader(1); + this->m_inputSizeProgram = getInputSocketReader(2); + this->m_inputDepthProgram = getInputSocketReader(3); QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -63,27 +63,27 @@ 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 - maxBlur; - int maxy = y + maxBlur; - int minx = x - maxBlur; - int maxx = x + maxBlur; + int miny = y - this->m_maxBlur; + int maxy = y + this->m_maxBlur; + int minx = x - this->m_maxBlur; + int maxx = x + this->m_maxBlur; { - inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); - inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); - inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); add_v4_v4(color_accum, readColor); add_v4_fl(multiplier_accum, 1.0f); float sizeCenter = tempSize[0]; - float centerDepth = tempDepth[0]+threshold; + float centerDepth = tempDepth[0] + this->m_threshold; for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { - inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); - inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); + 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) { - if ((sizeCenter > threshold && size > threshold) || size <= threshold) { + if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_threshold) { float dx = nx - x; float dy = ny - y; if (nx == x && ny == y) { @@ -91,8 +91,8 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me else if (size >= fabsf(dx) && size >= fabsf(dy)) { float u = 256 + dx * 256 / size; float v = 256 + dy * 256 / size; - inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); + this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); madd_v4_v4v4(color_accum, bokeh, readColor); add_v4_v4(multiplier_accum, bokeh); } @@ -112,9 +112,9 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me void VariableSizeBokehBlurOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputSizeProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputSizeProgram = NULL; } bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -122,10 +122,10 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu rcti newInput; rcti bokehInput; - newInput.xmax = input->xmax + maxBlur + 2; - newInput.xmin = input->xmin - maxBlur + 2; - newInput.ymax = input->ymax + maxBlur - 2; - newInput.ymin = input->ymin - maxBlur - 2; + newInput.xmax = input->xmax + this->m_maxBlur + 2; + newInput.xmin = input->xmin - this->m_maxBlur + 2; + newInput.ymax = input->ymax + this->m_maxBlur - 2; + newInput.ymin = input->ymin - this->m_maxBlur - 2; bokehInput.xmax = 512; bokehInput.xmin = 0; bokehInput.ymax = 512; diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index d04bf08405f..8e59a43fcb1 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -27,12 +27,12 @@ class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper { private: - int maxBlur; - float threshold; - SocketReader *inputProgram; - SocketReader *inputBokehProgram; - SocketReader *inputSizeProgram; - SocketReader *inputDepthProgram; + int m_maxBlur; + float m_threshold; + SocketReader *m_inputProgram; + SocketReader *m_inputBokehProgram; + SocketReader *m_inputSizeProgram; + SocketReader *m_inputDepthProgram; public: VariableSizeBokehBlurOperation(); @@ -54,9 +54,9 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; } + void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; } - void setThreshold(float threshold) { this->threshold = threshold; } + void setThreshold(float threshold) { this->m_threshold = threshold; } }; diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index 3efae2c4e3d..48be72561ba 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -34,20 +34,20 @@ VectorBlurOperation::VectorBlurOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); // ZBUF this->addInputSocket(COM_DT_COLOR); //SPEED this->addOutputSocket(COM_DT_COLOR); - this->settings = NULL; - this->cachedInstance = NULL; - this->inputImageProgram = NULL; - this->inputSpeedProgram = NULL; - this->inputZProgram = NULL; + this->m_settings = NULL; + this->m_cachedInstance = NULL; + this->m_inputImageProgram = NULL; + this->m_inputSpeedProgram = NULL; + this->m_inputZProgram = NULL; setComplex(true); } void VectorBlurOperation::initExecution() { initMutex(); - this->inputImageProgram = getInputSocketReader(0); - this->inputZProgram = getInputSocketReader(1); - this->inputSpeedProgram = getInputSocketReader(2); - this->cachedInstance = NULL; + this->m_inputImageProgram = getInputSocketReader(0); + this->m_inputZProgram = getInputSocketReader(1); + this->m_inputSpeedProgram = getInputSocketReader(2); + this->m_cachedInstance = NULL; QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -56,44 +56,43 @@ void VectorBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer { float *buffer = (float *) data; int index = (y * this->getWidth() + x) * COM_NUMBER_OF_CHANNELS; - color[0] = buffer[index]; - color[1] = buffer[index + 1]; - color[2] = buffer[index + 2]; - color[3] = buffer[index + 3]; + copy_v4_v4(color, &buffer[index]); } void VectorBlurOperation::deinitExecution() { deinitMutex(); - this->inputImageProgram = NULL; - this->inputSpeedProgram = NULL; - this->inputZProgram = NULL; - if (this->cachedInstance) { - delete cachedInstance; - this->cachedInstance = NULL; + this->m_inputImageProgram = NULL; + this->m_inputSpeedProgram = NULL; + this->m_inputZProgram = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; + this->m_cachedInstance = NULL; } } void *VectorBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cachedInstance) return this->cachedInstance; + if (this->m_cachedInstance) { + return this->m_cachedInstance; + } lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)inputImageProgram->initializeTileData(rect, memoryBuffers); - MemoryBuffer *speed = (MemoryBuffer *)inputSpeedProgram->initializeTileData(rect, memoryBuffers); - MemoryBuffer *z = (MemoryBuffer *)inputZProgram->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect, memoryBuffers); float *data = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS]; memcpy(data, tile->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float)); this->generateVectorBlur(data, tile, speed, z); - this->cachedInstance = data; + this->m_cachedInstance = data; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } bool VectorBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { - if (this->cachedInstance == NULL) { + if (this->m_cachedInstance == NULL) { rcti newInput; newInput.xmax = this->getWidth(); newInput.xmin = 0; @@ -110,11 +109,11 @@ void VectorBlurOperation::generateVectorBlur(float *data, MemoryBuffer *inputIma { float *zbuf = inputZ->convertToValueBuffer(); NodeBlurData blurdata; - blurdata.samples = this->settings->samples / QualityStepHelper::getStep(); - blurdata.maxspeed = this->settings->maxspeed; - blurdata.minspeed = this->settings->minspeed; - blurdata.curved = this->settings->curved; - blurdata.fac = this->settings->fac; + blurdata.samples = this->m_settings->samples / QualityStepHelper::getStep(); + blurdata.maxspeed = this->m_settings->maxspeed; + blurdata.minspeed = this->m_settings->minspeed; + blurdata.curved = this->m_settings->curved; + blurdata.fac = this->m_settings->fac; RE_zbuf_accumulate_vecblur(&blurdata, this->getWidth(), this->getHeight(), data, inputImage->getBuffer(), inputSpeed->getBuffer(), zbuf); delete zbuf; return; diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h index 30821cdd8b2..a2e72fa3232 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.h +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h @@ -31,16 +31,16 @@ private: /** * @brief Cached reference to the inputProgram */ - SocketReader *inputImageProgram; - SocketReader *inputSpeedProgram; - SocketReader *inputZProgram; + SocketReader *m_inputImageProgram; + SocketReader *m_inputSpeedProgram; + SocketReader *m_inputZProgram; /** * @brief settings of the glare node. */ - NodeBlurData *settings; + NodeBlurData *m_settings; - float *cachedInstance; + float *m_cachedInstance; public: VectorBlurOperation(); @@ -62,7 +62,7 @@ public: void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void setVectorBlurSettings(NodeBlurData *settings) { this->settings = settings; } + void setVectorBlurSettings(NodeBlurData *settings) { this->m_settings = settings; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); protected: diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index 3173599ece6..ee3f44d8979 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -35,12 +35,12 @@ VectorCurveOperation::VectorCurveOperation() : CurveBaseOperation() this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_VECTOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void VectorCurveOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void VectorCurveOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -48,13 +48,13 @@ void VectorCurveOperation::executePixel(float *output, float x, float y, PixelSa float input[4]; - this->inputProgram->read(input, x, y, sampler, inputBuffers); + this->m_inputProgram->read(input, x, y, sampler, inputBuffers); - curvemapping_evaluate_premulRGBF(this->curveMapping, output, input); + curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); output[3] = input[3]; } void VectorCurveOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h index 41faee7acf6..2fbaf170986 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.h +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h @@ -30,7 +30,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: VectorCurveOperation(); diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index a8aa84e84f9..446b169763c 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -42,10 +42,10 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation() { this->setImage(NULL); this->setImageUser(NULL); - this->outputBuffer = NULL; - this->outputBufferDisplay = NULL; - this->active = false; - this->doColorManagement = true; + this->m_outputBuffer = NULL; + this->m_outputBufferDisplay = NULL; + this->m_active = false; + this->m_doColorManagement = true; } void ViewerBaseOperation::initExecution() @@ -57,8 +57,8 @@ void ViewerBaseOperation::initExecution() void ViewerBaseOperation::initImage() { - Image *anImage = this->image; - ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->imageUser, &this->lock); + Image *anImage = this->m_image; + ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock); if (!ibuf) return; if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) { @@ -73,10 +73,10 @@ void ViewerBaseOperation::initImage() } /* now we combine the input with ibuf */ - this->outputBuffer = ibuf->rect_float; - this->outputBufferDisplay = (unsigned char *)ibuf->rect; + this->m_outputBuffer = ibuf->rect_float; + this->m_outputBufferDisplay = (unsigned char *)ibuf->rect; - BKE_image_release_ibuf(this->image, this->lock); + BKE_image_release_ibuf(this->m_image, this->m_lock); } void ViewerBaseOperation:: updateImage(rcti *rect) { @@ -85,7 +85,7 @@ void ViewerBaseOperation:: updateImage(rcti *rect) void ViewerBaseOperation::deinitExecution() { - this->outputBuffer = NULL; + this->m_outputBuffer = NULL; } const CompositorPriority ViewerBaseOperation::getRenderPriority() const diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h index 2aaa7d20966..f3fd1e9c9df 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h @@ -28,35 +28,35 @@ class ViewerBaseOperation : public NodeOperation { protected: - float *outputBuffer; - unsigned char *outputBufferDisplay; - Image *image; - ImageUser *imageUser; - void *lock; - bool active; - float centerX; - float centerY; - OrderOfChunks chunkOrder; - bool doColorManagement; - bool doColorPredivide; + float *m_outputBuffer; + unsigned char *m_outputBufferDisplay; + Image *m_image; + ImageUser *m_imageUser; + void *m_lock; + bool m_active; + float m_centerX; + float m_centerY; + OrderOfChunks m_chunkOrder; + bool m_doColorManagement; + bool m_doColorPredivide; public: bool isOutputOperation(bool rendering) const { return isActiveViewerOutput(); } void initExecution(); void deinitExecution(); - void setImage(Image *image) { this->image = image; } - void setImageUser(ImageUser *imageUser) { this->imageUser = imageUser; } - const bool isActiveViewerOutput() const { return active; } - void setActive(bool active) { this->active = active; } - void setCenterX(float centerX) { this->centerX = centerX;} - void setCenterY(float centerY) { this->centerY = centerY;} - void setChunkOrder(OrderOfChunks tileOrder) { this->chunkOrder = tileOrder; } - float getCenterX() { return this->centerX; } - float getCenterY() { return this->centerY; } - OrderOfChunks getChunkOrder() { return this->chunkOrder; } + void setImage(Image *image) { this->m_image = image; } + void setImageUser(ImageUser *imageUser) { this->m_imageUser = imageUser; } + const bool isActiveViewerOutput() const { return this->m_active; } + void setActive(bool active) { this->m_active = active; } + void setCenterX(float centerX) { this->m_centerX = centerX;} + void setCenterY(float centerY) { this->m_centerY = centerY;} + void setChunkOrder(OrderOfChunks tileOrder) { this->m_chunkOrder = tileOrder; } + float getCenterX() { return this->m_centerX; } + float getCenterY() { return this->m_centerY; } + OrderOfChunks getChunkOrder() { return this->m_chunkOrder; } const CompositorPriority getRenderPriority() const; - void setColorManagement(bool doColorManagement) { this->doColorManagement = doColorManagement; } - void setColorPredivide(bool doColorPredivide) { this->doColorPredivide = doColorPredivide; } + void setColorManagement(bool doColorManagement) { this->m_doColorManagement = doColorManagement; } + void setColorPredivide(bool doColorPredivide) { this->m_doColorPredivide = doColorPredivide; } bool isViewerOperation() { return true; } protected: diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index cf7bf3fdc9d..9278ddd6ead 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -44,30 +44,30 @@ ViewerOperation::ViewerOperation() : ViewerBaseOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); - this->imageInput = NULL; - this->alphaInput = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; } void ViewerOperation::initExecution() { // When initializing the tree during initial load the width and height can be zero. - this->imageInput = getInputSocketReader(0); - this->alphaInput = getInputSocketReader(1); + this->m_imageInput = getInputSocketReader(0); + this->m_alphaInput = getInputSocketReader(1); ViewerBaseOperation::initExecution(); } void ViewerOperation::deinitExecution() { - this->imageInput = NULL; - this->alphaInput = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; ViewerBaseOperation::deinitExecution(); } void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - float *buffer = this->outputBuffer; - unsigned char *bufferDisplay = this->outputBufferDisplay; + float *buffer = this->m_outputBuffer; + unsigned char *bufferDisplay = this->m_outputBufferDisplay; if (!buffer) return; const int x1 = rect->xmin; const int y1 = rect->ymin; @@ -82,14 +82,14 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryB for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2; x++) { - imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); - if (alphaInput != NULL) { - alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + if (this->m_alphaInput != NULL) { + this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers); buffer[offset + 3] = alpha[0]; } /// @todo: linear conversion only when scene color management is selected, also check predivide. - if (this->doColorManagement) { - if (this->doColorPredivide) { + if (this->m_doColorManagement) { + if (this->m_doColorPredivide) { linearrgb_to_srgb_predivide_v4(srgb, buffer + offset); } else { diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h index 49ef5ad4bb7..fd83c3957f1 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.h +++ b/source/blender/compositor/operations/COM_ViewerOperation.h @@ -29,8 +29,8 @@ class ViewerOperation : public ViewerBaseOperation { private: - SocketReader *imageInput; - SocketReader *alphaInput; + SocketReader *m_imageInput; + SocketReader *m_alphaInput; public: ViewerOperation(); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 356ba452185..7259db34134 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -28,42 +28,42 @@ WriteBufferOperation::WriteBufferOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); - this->memoryProxy = new MemoryProxy(); - this->memoryProxy->setWriteBufferOperation(this); - this->memoryProxy->setExecutor(NULL); + this->m_memoryProxy = new MemoryProxy(); + this->m_memoryProxy->setWriteBufferOperation(this); + this->m_memoryProxy->setExecutor(NULL); } WriteBufferOperation::~WriteBufferOperation() { - if (this->memoryProxy) { - delete this->memoryProxy; - this->memoryProxy = NULL; + if (this->m_memoryProxy) { + delete this->m_memoryProxy; + this->m_memoryProxy = NULL; } } void WriteBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - input->read(color, x, y, sampler, inputBuffers); + this->m_input->read(color, x, y, sampler, inputBuffers); } void WriteBufferOperation::initExecution() { - this->input = this->getInputOperation(0); - this->memoryProxy->allocate(this->width, this->height); + this->m_input = this->getInputOperation(0); + this->m_memoryProxy->allocate(this->m_width, this->m_height); } void WriteBufferOperation::deinitExecution() { - this->input = NULL; - this->memoryProxy->free(); + this->m_input = NULL; + this->m_memoryProxy->free(); } void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { //MemoryBuffer *memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber); - MemoryBuffer *memoryBuffer = this->memoryProxy->getBuffer(); + MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer(); float *buffer = memoryBuffer->getBuffer(); - if (this->input->isComplex()) { - void *data = this->input->initializeTileData(rect, memoryBuffers); + if (this->m_input->isComplex()) { + void *data = this->m_input->initializeTileData(rect, memoryBuffers); int x1 = rect->xmin; int y1 = rect->ymin; int x2 = rect->xmax; @@ -74,7 +74,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - input->read(&(buffer[offset4]), x, y, memoryBuffers, data); + this->m_input->read(&(buffer[offset4]), x, y, memoryBuffers, data); offset4 += COM_NUMBER_OF_CHANNELS; } @@ -84,7 +84,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me } if (data) { - this->input->deinitializeTileData(rect, memoryBuffers, data); + this->m_input->deinitializeTileData(rect, memoryBuffers, data); data = NULL; } } @@ -100,7 +100,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers); offset4 += COM_NUMBER_OF_CHANNELS; } if (isBreaked()) { @@ -140,7 +140,7 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, clMemToCleanUp->push_back(clOutputBuffer); list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); - this->input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); + this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); // STEP 3 diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index ccc20584186..24bfdecd124 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -31,13 +31,13 @@ * @ingroup Operation */ class WriteBufferOperation : public NodeOperation { - MemoryProxy *memoryProxy; - NodeOperation *input; + MemoryProxy *m_memoryProxy; + NodeOperation *m_input; public: WriteBufferOperation(); ~WriteBufferOperation(); int isBufferOperation() { return true; } - MemoryProxy *getMemoryProxy() { return this->memoryProxy; } + MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; } void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); const bool isWriteBufferOperation() const { return true; } diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp index eb02b150fa4..c1ea63432b9 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp +++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp @@ -31,19 +31,19 @@ ZCombineOperation::ZCombineOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->image1Reader = NULL; - this->depth1Reader = NULL; - this->image2Reader = NULL; - this->depth2Reader = NULL; + this->m_image1Reader = NULL; + this->m_depth1Reader = NULL; + this->m_image2Reader = NULL; + this->m_depth2Reader = NULL; } void ZCombineOperation::initExecution() { - this->image1Reader = this->getInputSocketReader(0); - this->depth1Reader = this->getInputSocketReader(1); - this->image2Reader = this->getInputSocketReader(2); - this->depth2Reader = this->getInputSocketReader(3); + this->m_image1Reader = this->getInputSocketReader(0); + this->m_depth1Reader = this->getInputSocketReader(1); + this->m_image2Reader = this->getInputSocketReader(2); + this->m_depth2Reader = this->getInputSocketReader(3); } void ZCombineOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -51,13 +51,13 @@ void ZCombineOperation::executePixel(float *color, float x, float y, PixelSample float depth1[4]; float depth2[4]; - this->depth1Reader->read(depth1, x, y, sampler, inputBuffers); - this->depth2Reader->read(depth2, x, y, sampler, inputBuffers); + this->m_depth1Reader->read(depth1, x, y, sampler, inputBuffers); + this->m_depth2Reader->read(depth2, x, y, sampler, inputBuffers); if (depth1[0] < depth2[0]) { - this->image1Reader->read(color, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color, x, y, sampler, inputBuffers); } else { - this->image2Reader->read(color, x, y, sampler, inputBuffers); + this->m_image2Reader->read(color, x, y, sampler, inputBuffers); } } void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -67,15 +67,15 @@ void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelS float color1[4]; float color2[4]; - this->depth1Reader->read(depth1, x, y, sampler, inputBuffers); - this->depth2Reader->read(depth2, x, y, sampler, inputBuffers); + this->m_depth1Reader->read(depth1, x, y, sampler, inputBuffers); + this->m_depth2Reader->read(depth2, x, y, sampler, inputBuffers); if (depth1[0] < depth2[0]) { - this->image1Reader->read(color1, x, y, sampler, inputBuffers); - this->image2Reader->read(color2, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color1, x, y, sampler, inputBuffers); + this->m_image2Reader->read(color2, x, y, sampler, inputBuffers); } else { - this->image1Reader->read(color2, x, y, sampler, inputBuffers); - this->image2Reader->read(color1, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color2, x, y, sampler, inputBuffers); + this->m_image2Reader->read(color1, x, y, sampler, inputBuffers); } float fac = color1[3]; float ifac = 1.0f - fac; @@ -87,8 +87,8 @@ void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelS void ZCombineOperation::deinitExecution() { - this->image1Reader = NULL; - this->depth1Reader = NULL; - this->image2Reader = NULL; - this->depth2Reader = NULL; + this->m_image1Reader = NULL; + this->m_depth1Reader = NULL; + this->m_image2Reader = NULL; + this->m_depth2Reader = NULL; } diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h index 56ad950a3aa..2ade3f599ad 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.h +++ b/source/blender/compositor/operations/COM_ZCombineOperation.h @@ -31,10 +31,10 @@ */ class ZCombineOperation : public NodeOperation { protected: - SocketReader *image1Reader; - SocketReader *depth1Reader; - SocketReader *image2Reader; - SocketReader *depth2Reader; + SocketReader *m_image1Reader; + SocketReader *m_depth1Reader; + SocketReader *m_image2Reader; + SocketReader *m_depth2Reader; public: /** * Default constructor diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index c9b0f55740a..7f957d49fa3 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2464,13 +2464,15 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo case ANIMCONT_GPENCIL: { - items = animdata_filter_gpencil(anim_data, data, filter_mode); + if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) + items = animdata_filter_gpencil(anim_data, data, filter_mode); } break; case ANIMCONT_MASK: { - items = animdata_filter_mask(anim_data, data, filter_mode); + if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) + items = animdata_filter_mask(anim_data, data, filter_mode); } break; diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index e6fc4d5a168..46a89963ad9 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -847,9 +847,17 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through each F-Curve, grabbing the keyframes */ - for (ale = anim_data.first; ale; ale = ale->next) + for (ale = anim_data.first; ale; ale = ale->next) { fcurve_to_keylist(ale->adt, ale->data, keys, blocks); - + + if (ale->datatype == ALE_MASKLAY) { + mask_to_keylist(ac->ads, ale->data, keys); + } + else if (ale->datatype == ALE_GPFRAME) { + gpl_to_keylist(ac->ads, ale->data, keys); + } + } + BLI_freelistN(&anim_data); } } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index ea3c8685525..d4755fc95cd 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -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/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 2fa7b4b2126..032b999c60f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1199,8 +1199,6 @@ void load_editNurb(Object *obedit) if (obedit == NULL) return; - set_actNurb(obedit, NULL); - if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { Curve *cu = obedit->data; Nurb *nu, *newnu; @@ -1222,8 +1220,6 @@ void load_editNurb(Object *obedit) BKE_nurbList_free(&oldnurb); } - - set_actNurb(obedit, NULL); } /* make copy in cu->editnurb */ @@ -1234,7 +1230,6 @@ void make_editNurb(Object *obedit) Nurb *nu, *newnu, *nu_act = NULL; KeyBlock *actkey; - set_actNurb(obedit, NULL); if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { @@ -3937,7 +3932,6 @@ static int make_segment_exec(bContext *C, wmOperator *op) ListBase *nubase = object_editcurve_get(obedit); Nurb *nu, *nu1 = NULL, *nu2 = NULL; BPoint *bp; - float *fp, offset; int a, ok = 0; /* first decide if this is a surface merge! */ @@ -4053,25 +4047,12 @@ static int make_segment_exec(bContext *C, wmOperator *op) /* now join the knots */ if (nu1->type == CU_NURBS) { - if (nu1->knotsu == NULL) { - BKE_nurb_knot_calc_u(nu1); - } - else { - fp = MEM_mallocN(sizeof(float) * KNOTSU(nu1), "addsegment3"); - memcpy(fp, nu1->knotsu, sizeof(float) * a); + if (nu1->knotsu != NULL) { MEM_freeN(nu1->knotsu); - nu1->knotsu = fp; - - - offset = nu1->knotsu[a - 1] + 1.0f; - fp = nu1->knotsu + a; - for (a = 0; a < nu2->pntsu; a++, fp++) { - if (nu2->knotsu) - *fp = offset + nu2->knotsu[a + 1]; - else - *fp = offset; - } + nu1->knotsu = NULL; } + + BKE_nurb_knot_calc_u(nu1); } BKE_nurb_free(nu2); nu2 = NULL; } diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index dabc0ad1081..d90ec02b0c1 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -126,7 +126,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons block = uiLayoutGetBlock(sub); icon = (gpl->flag & GP_LAYER_ACTIVE) ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF; but = uiDefIconButBitI(block, TOG, GP_LAYER_ACTIVE, 0, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, - &gpd->flag, 0.0, 0.0, 0.0, 0.0, TIP_("Set active layer")); + &gpl->flag, 0.0, 0.0, 0.0, 0.0, TIP_("Set active layer")); uiButSetFunc(but, gp_ui_activelayer_cb, gpd, gpl); /* locked */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 7afa9fe8bc5..fbddd26c959 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -178,7 +178,7 @@ typedef enum eAnim_KeyType { ALE_NONE = 0, /* no keyframe data */ ALE_FCURVE, /* F-Curve */ ALE_GPFRAME, /* Grease Pencil Frames */ - ALE_MASKLAY, /* Mask */ + ALE_MASKLAY, /* Mask */ ALE_NLASTRIP, /* NLA Strips */ ALE_ALL, /* All channels summary */ 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_object.h b/source/blender/editors/include/ED_object.h index 9c10a270ef8..9209bbb2db7 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -176,6 +176,12 @@ int ED_object_modifier_apply(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md, int mode); int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md); +int ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, int include_orig, + int (*callback)(struct Object *ob, void *callback_data), + void *callback_data); + +int ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v); + #ifdef __cplusplus } #endif 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_draw.c b/source/blender/editors/interface/interface_draw.c index c14e27562b4..f173e7ce630 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1376,9 +1376,11 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f); /* grid, hsv uses different grid */ - gl_shaded_color((unsigned char *)wcol->inner, -16); - /* TODO, grid lines does not line up with colors, need to look into this */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4ub(0, 0, 0, 48); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.1666666f); + glDisable(GL_BLEND); } else { if (cumap->flag & CUMA_DO_CLIP) { diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index e5a10dc9201..b202672a2c7 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1894,8 +1894,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..6dbf53cba72 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -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..20ac3333115 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); } 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/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 6940b05e86c..fa637b6d6ce 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -712,7 +712,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); @@ -750,7 +750,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); @@ -791,7 +791,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); @@ -1003,12 +1003,13 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) BMEdge *eed; int select = TRUE; int dist = 50; - + float mvalf[2]; + em_setup_viewcontext(C, &vc); - vc.mval[0] = mval[0]; - vc.mval[1] = mval[1]; + mvalf[0] = (float)(vc.mval[0] = mval[0]); + mvalf[1] = (float)(vc.mval[1] = mval[1]); em = vc.em; - + /* no afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad */ view3d_validate_backbuf(&vc); @@ -1043,26 +1044,59 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) } EDBM_selectmode_flush(em); -// if (EM_texFaceCheck()) - + /* sets as active, useful for other tools */ -#if 0 if (select) { if (em->selectmode & SCE_SELECT_VERTEX) { - /* TODO: would be nice if the edge vertex chosen here - * was the one closer to the selection pointer, instead - * of arbitrarily selecting the first one */ - BM_select_history_store(em->bm, eed->v1); + /* Find nearest vert from mouse. */ + float v1_co[2], v2_co[2]; + + /* We can't be sure this has already been set... */ + ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); + project_float_noclip(vc.ar, eed->v1->co, v1_co); + project_float_noclip(vc.ar, eed->v2->co, v2_co); +#if 0 + printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co), + len_squared_v2v2(mvalf, v2_co)); +#endif + if (len_squared_v2v2(mvalf, v1_co) < len_squared_v2v2(mvalf, v2_co)) + BM_select_history_store(em->bm, eed->v1); + else + BM_select_history_store(em->bm, eed->v2); } else if (em->selectmode & SCE_SELECT_EDGE) { BM_select_history_store(em->bm, eed); } - /* TODO: would be nice if the nearest face that - * belongs to the selected edge could be set to - * active here in face select mode */ + else if (em->selectmode & SCE_SELECT_FACE) { + /* Select the face of eed which is the nearest of mouse. */ + BMFace *f, *efa = NULL; + BMIter iterf; + float best_dist = MAXFLOAT; + + /* We can't be sure this has already been set... */ + ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); + + BM_ITER_ELEM(f, &iterf, eed, BM_FACES_OF_EDGE) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + float cent[3]; + float co[2], tdist; + + BM_face_calc_center_mean(f, cent); + project_float_noclip(vc.ar, cent, co); + tdist = len_squared_v2v2(mvalf, co); + if (tdist < best_dist) { +/* printf("Best face: %p (%f)\n", f, tdist);*/ + best_dist = tdist; + efa = f; + } + } + } + if (efa) { + BM_active_face_set(em->bm, efa); + BM_select_history_store(em->bm, efa); + } + } } -#endif - mouse_mesh(C, mval, select, TRUE, FALSE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit); } 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 09475db0ed2..3e68e18d956 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); @@ -4966,7 +4966,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 +5032,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 +5042,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 59a0475ebb5..cdbf5751ea1 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -45,6 +45,7 @@ #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -418,8 +419,17 @@ int join_mesh_exec(bContext *C, wmOperator *op) } if (me->totloop) { - if (base->object != ob) + if (base->object != ob) { + MultiresModifierData *mmd; + multiresModifier_prepare_join(scene, base->object, ob); + + if ((mmd = get_multires_modifier(scene, base->object, TRUE))) { + ED_object_iter_other(bmain, base->object, TRUE, + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); + } + } CustomData_merge(&me->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop); CustomData_copy_data(&me->ldata, &ldata, 0, loopofs, me->totloop); @@ -888,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; @@ -916,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; @@ -979,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/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_edit.c b/source/blender/editors/object/object_edit.c index 908c0a6f4f2..35ee641d2c1 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -106,7 +106,7 @@ /* ************* XXX **************** */ static void error(const char *UNUSED(arg)) {} static void waitcursor(int UNUSED(val)) {} -static int pupmenu(const char *UNUSED(msg)) {return 0;} +static int pupmenu(const char *UNUSED(msg)) { return 0; } /* port over here */ static void error_libdata(void) {} 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 d6b5fb9fc10..aab3d8afb22 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -173,7 +173,100 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc return new_md; } -static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgraph) +/* 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) +{ + ModifierData *md; + + for (md = ob->modifiers.first; md; md = md->next) { + if ((md != exclude) && (md->type == type)) + return TRUE; + } + + return FALSE; +} + +/* If the object data of 'orig_ob' has other users, run 'callback' on + * each of them. + * + * If include_orig is TRUE, the callback will run on 'orig_ob' too. + * + * 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) +{ + ID *ob_data_id = orig_ob->data; + int users = ob_data_id->us; + + if (ob_data_id->flag & LIB_FAKEUSER) + users--; + + /* First check that the object's data has multiple users */ + if (users > 1) { + Object *ob; + int totfound = include_orig ? 0 : 1; + + for (ob = bmain->object.first; ob && totfound < users; + ob = ob->id.next) + { + if (((ob != orig_ob) || include_orig) && + (ob->data == orig_ob->data)) + { + if (callback(ob, callback_data)) + return TRUE; + + totfound++; + } + } + } + else if (include_orig) { + return callback(orig_ob, callback_data); + } + + return FALSE; +} + +static int object_has_modifier_cb(Object *ob, void *data) +{ + ModifierType type = *((ModifierType*)data); + + return object_has_modifier(ob, NULL, type); +} + +/* 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. */ +int ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v) +{ + ModifierData *md; + int totlevel = *((int*)totlevel_v); + + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Multires) { + multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } + return FALSE; +} + +/* 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) +{ + return (!object_has_modifier(ob, exclude, 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) { ModifierData *obmd; @@ -218,33 +311,13 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr ob->dt = OB_TEXTURE; } else if (md->type == eModifierType_Multires) { - int ok = 1; - ModifierData *tmpmd; - - /* ensure MDISPS CustomData layer isn't used by another multires modifiers */ - for (tmpmd = ob->modifiers.first; tmpmd; tmpmd = tmpmd->next) - if (tmpmd != md && tmpmd->type == eModifierType_Multires) { - ok = 0; - break; - } - - if (ok) { + /* Delete MDisps layer if not used by another multires modifier */ + if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Multires)) multires_customdata_delete(ob->data); - } } else if (md->type == eModifierType_Skin) { - int ok = 1; - ModifierData *tmpmd; - - /* ensure skin CustomData layer isn't used by another skin modifier */ - for (tmpmd = ob->modifiers.first; tmpmd; tmpmd = tmpmd->next) { - if (tmpmd != md && tmpmd->type == eModifierType_Skin) { - ok = 0; - break; - } - } - - if (ok) + /* Delete MVertSkin layer if not used by another skin modifier */ + if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin)) modifier_skin_customdata_delete(ob); } @@ -265,7 +338,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob int sort_depsgraph = 0; int ok; - ok = object_modifier_remove(ob, md, &sort_depsgraph); + ok = object_modifier_remove(bmain, ob, md, &sort_depsgraph); if (!ok) { BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); @@ -294,7 +367,7 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) next_md = md->next; - object_modifier_remove(ob, md, &sort_depsgraph); + object_modifier_remove(bmain, ob, md, &sort_depsgraph); md = next_md; } @@ -771,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) @@ -843,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); } @@ -882,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); } @@ -921,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); } @@ -969,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); @@ -1012,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); } @@ -1051,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); } @@ -1071,6 +1146,10 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; multiresModifier_del_levels(mmd, ob, 1); + + ED_object_iter_other(CTX_data_main(C), ob, TRUE, + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1096,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); } @@ -1112,6 +1191,10 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) multiresModifier_subdivide(mmd, ob, 0, mmd->simple); + ED_object_iter_other(CTX_data_main(C), ob, TRUE, + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1137,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); } @@ -1201,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); } @@ -1276,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); @@ -1348,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); } @@ -1673,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; @@ -1763,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); } @@ -1858,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); } @@ -1905,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); } @@ -2120,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/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index cacd6d01291..6782cd55a8b 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); } 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/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_action/action_select.c b/source/blender/editors/space_action/action_select.c index 539a32161e5..b42c6406362 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -930,8 +930,25 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s ED_gpencil_select_frame(ale->data, selx, select_mode); else if (ale->type == ANIMTYPE_MASKLAYER) ED_mask_select_frame(ale->data, selx, select_mode); - else - ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); + else { + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK) && + (ale->type == ANIMTYPE_SUMMARY) && (ale->datatype == ALE_ALL)) + { + ListBase anim_data = {NULL, NULL}; + int filter; + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + for (ale = anim_data.first; ale; ale = ale->next) { + if (ale->type == ANIMTYPE_GPLAYER) + ED_gpencil_select_frame(ale->data, selx, select_mode); + else if (ale->type == ANIMTYPE_MASKLAYER) + ED_mask_select_frame(ale->data, selx, select_mode); + } + } + else { + ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); + } + } } /* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */ diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index b57b16707d4..224a250fe4c 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -177,6 +177,13 @@ void ED_space_clip_get_aspect_dimension_aware(SpaceClip *sc, float *aspx, float * mainly this is sued for transformation stuff */ + if (!sc->clip) { + *aspx = 1.0f; + *aspy = 1.0f; + + return; + } + ED_space_clip_get_aspect(sc, aspx, aspy); BKE_movieclip_get_size(sc->clip, &sc->user, &w, &h); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index af2847492ad..2e4ba844646 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1586,14 +1586,15 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); + MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; - ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int action = RNA_enum_get(op->ptr, "action"); int clear_active = RNA_boolean_get(op->ptr, "clear_active"); int framenr = ED_space_clip_get_clip_frame_number(sc); if (clear_active) { - track = BKE_tracking_track_get_active(&clip->tracking); + track = BKE_tracking_track_get_active(tracking); BKE_tracking_track_path_clear(track, framenr, action); } else { @@ -1606,6 +1607,7 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) } } + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; @@ -2606,6 +2608,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) IMB_freeImBuf(ibuf); + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -3329,7 +3332,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) void CLIP_OT_tracking_object_remove(wmOperatorType *ot) { /* identifiers */ - ot->name = "Movie Tracking Object"; + ot->name = "Remove Tracking Object"; ot->description = "Remove object for tracking"; ot->idname = "CLIP_OT_tracking_object_remove"; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 22017a2d8b9..a4fb4d7dfee 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; @@ -1220,18 +1220,17 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap 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) @@ -2482,6 +2484,8 @@ static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), Poi uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "clip_white", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "dilate_distance", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "feather_falloff", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "feather_distance", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE); } @@ -3316,40 +3320,62 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) do_triple = TRUE; } else { + int cycle = 0; + /* going to give issues once... */ if (link->tosock->flag & SOCK_UNAVAIL) return; if (link->fromsock->flag & SOCK_UNAVAIL) return; - /* a bit ugly... but thats how we detect the internal group links */ - if (!link->fromnode || !link->tonode) { - UI_ThemeColorBlend(TH_BACK, TH_WIRE, 0.5f); - do_shaded = FALSE; - } - else { - /* check cyclic */ - if ((link->fromnode->level >= link->tonode->level && link->tonode->level != 0xFFF) && (link->flag & NODE_LINK_VALID)) { - /* special indicated link, on drop-node */ - if (link->flag & NODE_LINKFLAG_HILITE) { - th_col1 = th_col2 = TH_ACTIVE; - } - else { - /* regular link */ - if (link->fromnode->flag & SELECT) - th_col1 = TH_EDGE_SELECT; - if (link->tonode->flag & SELECT) - th_col2 = TH_EDGE_SELECT; - } - do_shaded = TRUE; - do_triple = TRUE; - } + /* check cyclic */ + if (link->fromnode && link->tonode) + cycle = (link->fromnode->level < link->tonode->level || link->tonode->level == 0xFFF); + if (!cycle && (link->flag & NODE_LINK_VALID)) { + /* special indicated link, on drop-node */ + if (link->flag & NODE_LINKFLAG_HILITE) { + th_col1 = th_col2 = TH_ACTIVE; + } else { - th_col1 = TH_REDALERT; + /* regular link */ + if (link->fromnode && link->fromnode->flag & SELECT) + th_col1 = TH_EDGE_SELECT; + if (link->tonode && link->tonode->flag & SELECT) + th_col2 = TH_EDGE_SELECT; } + do_shaded = TRUE; + do_triple = TRUE; + } + else { + th_col1 = TH_REDALERT; } } 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..17d7530d2a7 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" @@ -1087,6 +1088,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 +1098,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 +1142,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_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..3a834ef6331 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,11 +444,11 @@ 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) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; case NC_SCENE: @@ -458,7 +458,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 +472,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 +500,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_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_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index bc8133cded6..7ed5c77ed1f 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; diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index b03edfc61b9..a55f0edc06c 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -587,14 +587,14 @@ static int select_more_less_seq__internal(Scene *scene, int sel, int linked) /* only get unselected nabours */ neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_LEFT, isel); if (neighbor) { - if (sel) {neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } + if (sel) { neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } else neighbor->flag &= ~SELECT; if (linked == 0) neighbor->tmp = (Sequence *)1; change = 1; } neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_RIGHT, isel); if (neighbor) { - if (sel) {neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } + if (sel) { neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } else neighbor->flag &= ~SELECT; if (linked == 0) neighbor->tmp = (void *)1; change = 1; 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/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3be74b2811d..7210944d3e7 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6472,7 +6472,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; @@ -7098,12 +7098,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); @@ -7138,8 +7139,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_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 709de274b8b..2d4fbb90ae1 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2795,6 +2795,14 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit); +static int view3d_main_area_do_render_draw(const bContext *C) +{ + Scene *scene = CTX_data_scene(C); + RenderEngineType *type = RE_engines_find(scene->r.engine); + + return (type && type->view_update && type->view_draw); +} + static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw_border) { Scene *scene = CTX_data_scene(C); @@ -3131,7 +3139,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) int draw_border = (rv3d->persp == RV3D_CAMOB && (scene->r.mode & R_BORDER)); /* draw viewport using opengl */ - if (v3d->drawtype != OB_RENDER || draw_border) { + if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) { view3d_main_area_draw_objects(C, ar, &grid_unit); ED_region_pixelspace(ar); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8fb012a18d6..4782b95ba1c 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1564,13 +1564,15 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) static int localview_exec(bContext *C, wmOperator *UNUSED(unused)) { + Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); if (v3d->localvd) endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); else initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); - + + DAG_id_type_tag(bmain, ID_OB); ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e97df15543f..0f5f8970190 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1652,6 +1652,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 e924ce15286..af0b33d58ae 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2819,7 +2819,7 @@ static void posttrans_mask_clean(Mask *mask) short added = 0; masklay_shape_new = masklay_shape->next; - if (masklay_shape->flag & GP_FRAME_SELECT) { + if (masklay_shape->flag & MASK_SHAPE_SELECT) { BLI_remlink(&masklay->splines_shapes, masklay_shape); /* find place to add them in buffer @@ -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) @@ -5913,9 +5918,12 @@ static void createTransTrackingData(bContext *C, TransInfo *t) t->total = 0; + if (!clip) + return; + BKE_movieclip_get_size(clip, &sc->user, &width, &height); - if (!clip || width == 0 || height == 0) + if (width == 0 || height == 0) return; if (ar->regiontype == RGN_TYPE_PREVIEW) { @@ -6321,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_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/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 4197e1a3edb..9d3463d3d19 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 */ @@ -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..93934b41f28 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,11 +805,11 @@ 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 */ @@ -820,45 +817,45 @@ static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintV 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/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/tiff.c b/source/blender/imbuf/intern/tiff.c index 556ec64e59a..30dc61544b4 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -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_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_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index dc8115b556c..d28a14a9fd6 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 bd9b0a4585e..15641d97709 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -655,6 +655,8 @@ typedef struct NodeKeyingData { float edge_kernel_tolerance; float clip_black, clip_white; int dilate_distance; + int feather_distance; + int feather_falloff; int blur_pre, blur_post; } NodeKeyingData; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 59f91869780..10939ecbdc4 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -634,7 +634,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 @@ -908,7 +908,7 @@ typedef struct ToolSettings { /* Subdivide Settings */ short cornertype; - short pad3; + short pad1; /*Triangle to Quad conversion threshold*/ float jointrilimit; /* Editmode Tools */ @@ -1004,12 +1004,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 */ @@ -1021,7 +1022,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; @@ -1384,6 +1385,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/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 7151c260942..6f024cde1d0 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 2b3df4e0e3a..285cd41158b 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; @@ -2762,7 +2769,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; @@ -2930,7 +2937,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_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index ae8b0c51544..e44d6a11136 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -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..e74d192b13f 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" @@ -845,7 +846,7 @@ static void rna_def_beztriple(BlenderRNA *brna) 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; @@ -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 } 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_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 333f6878413..144b8a7f90c 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -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_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_main.c b/source/blender/makesrna/intern/rna_main.c index 6f8545099ea..69813172de7 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 ed45b378228..62af5cbad21 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -1567,12 +1567,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 */ @@ -1584,10 +1584,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); } void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) 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_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 8b8d085b2a4..9dd58dd780e 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2389,7 +2389,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); @@ -2566,7 +2566,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); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index baf3ccf35e1..cb1a45ed971 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} }; @@ -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,55 +3575,67 @@ 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 on-scaled matte pixel which considers as fully background pixel"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + 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"); prop = RNA_def_property(srna, "clip_white", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "clip_white"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Clip White", "Value of on-scaled matte pixel which considers as fully foreground pixel"); + RNA_def_property_ui_text(prop, "Clip White", "Value of non-scaled matte pixel which considers as fully foreground pixel"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "blur_pre", PROP_INT, PROP_NONE); 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"); + RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items); + RNA_def_property_ui_text(prop, "Feather Falloff", "Falloff type the feather"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "feather_distance", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "feather_distance"); + RNA_def_property_range(prop, -100, 100); + RNA_def_property_ui_text(prop, "Feather Distance", "Distance to grow/shrink the feather"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } /* -- Texture Nodes --------------------------------------------------------- */ diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 20f58f4d16e..5ebaddda043 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -37,7 +37,7 @@ DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATER DefNode( ShaderNode, SH_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) DefNode( ShaderNode, SH_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) DefNode( ShaderNode, SH_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "MixRGB", "" ) -DefNode( ShaderNode, SH_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) +DefNode( ShaderNode, SH_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) @@ -91,13 +91,13 @@ DefNode( ShaderNode, SH_NODE_TEX_WAVE, def_sh_tex_wave, "TE DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TEX_MUSGRAVE", TexMusgrave, "Musgrave Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" ) -DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate","") +DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate","" ) DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" ) DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) DefNode( CompositorNode, CMP_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) -DefNode( CompositorNode, CMP_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) +DefNode( CompositorNode, CMP_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( CompositorNode, CMP_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) DefNode( CompositorNode, CMP_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) DefNode( CompositorNode, CMP_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", CurveVec, "Vector Curve", "" ) @@ -118,7 +118,7 @@ DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPO DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "Output File", "" ) DefNode( CompositorNode, CMP_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( CompositorNode, CMP_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) -DefNode( CompositorNode, CMP_NODE_ZCOMBINE, def_cmp_zcombine, "ZCOMBINE", Zcombine, "Z Combine", "" ) +DefNode( CompositorNode, CMP_NODE_ZCOMBINE, def_cmp_zcombine, "ZCOMBINE", Zcombine, "Z Combine", "" ) DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBRGBA", CombRGBA, "Combine RGBA", "" ) DefNode( CompositorNode, CMP_NODE_DILATEERODE, def_cmp_dilate_erode, "DILATEERODE", DilateErode, "Dilate/Erode", "" ) DefNode( CompositorNode, CMP_NODE_ROTATE, def_cmp_rotate, "ROTATE", Rotate, "Rotate", "" ) @@ -178,7 +178,7 @@ DefNode( TextureNode, TEX_NODE_BRICKS, def_tex_bricks, "BRICK DefNode( TextureNode, TEX_NODE_MATH, def_math, "MATH", Math, "Math", "" ) DefNode( TextureNode, TEX_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) DefNode( TextureNode, TEX_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) -DefNode( TextureNode, TEX_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) +DefNode( TextureNode, TEX_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( TextureNode, TEX_NODE_IMAGE, def_tex_image, "IMAGE", Image, "Image", "" ) DefNode( TextureNode, TEX_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) DefNode( TextureNode, TEX_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 0399a8ee60d..51c49cf9e53 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -174,6 +174,11 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA rna_Object_internal_update(bmain, scene, ptr); } +static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + DAG_id_type_tag(bmain, ID_OB); +} + static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob = ptr->id.data; @@ -947,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; @@ -1539,17 +1544,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"); @@ -1971,6 +1976,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update"); + prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); + RNA_def_property_array(prop, 8); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object is on"); + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); RNA_def_property_ui_text(prop, "Select", "Object selection state"); @@ -2308,7 +2319,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); @@ -2320,7 +2331,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); /* anim */ rna_def_animdata_common(srna); @@ -2579,6 +2590,12 @@ static void rna_def_object_base(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on"); RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update"); + + prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); + RNA_def_property_array(prop, 8); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on"); prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index eaf1ae09524..bb8a29f8fe4 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -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 f3454285682..550463a947a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -137,6 +137,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 @@ -739,7 +747,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) { @@ -1673,6 +1681,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"); @@ -1698,7 +1713,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); 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_space.c b/source/blender/makesrna/intern/rna_space.c index 661c7ba878c..e4af06a5012 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1699,6 +1699,12 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_layer_set"); RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible in this 3D View"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_layer_update"); + + prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); + RNA_def_property_array(prop, 8); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Local View Layers", "Local view layers visible in this 3D View"); prop = RNA_def_property(srna, "layers_used", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "lay_used", 1); 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_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 5039ffef382..ab7263a1b53 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -178,7 +178,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, return derivedData; } - /* verthash gives mapping from original vertex indicies to the new indices (including selected matches only) + /* verthash gives mapping from original vertex indices to the new indices (including selected matches only) * key=oldindex, value=newindex */ vertHash = BLI_ghash_int_new("mask vert gh"); 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 2415c7842a7..ce5ce1d87c1 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 @@ -243,4 +242,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..72112180bc8 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) { @@ -218,8 +221,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 +354,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 +591,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 +681,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..33e6de8ea6e 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" 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..f365ee58f59 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" @@ -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/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..b2fd1d3d61c 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" @@ -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.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 bb4e0c61c2b..4417bc2ce8d 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -457,6 +457,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args, py_vert_a->v, py_vert_b->v, (float (*)[3])coords, ncoords, &l_new, py_edge_example ? py_edge_example->e : NULL); + PyMem_Free(coords); } else { f_new = BM_face_split(bm, py_face->f, @@ -667,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 */ @@ -687,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/stubs.c b/source/blender/python/intern/stubs.c index ab43b518085..50d2e88f210 100644 --- a/source/blender/python/intern/stubs.c +++ b/source/blender/python/intern/stubs.c @@ -35,5 +35,5 @@ //void BPY_text_free_code(void) {} void BPY_pyconstraint_exec(void) {} void BPY_pyconstraint_target(void) {} -int BPY_is_pyconstraint(void) {return 0;} +int BPY_is_pyconstraint(void) { return 0;} void BPY_pyconstraint_update(void) {} diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 8b79301f264..c08165f9850 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -133,6 +133,7 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject * } } +/* on error, -1 is returned and no allocation is made */ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, const char *error_prefix) { int size; @@ -164,6 +165,7 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c { PyObject *value_fast = NULL; // *array = NULL; + int ret; /* non list/tuple cases */ if (!(value_fast = PySequence_Fast(value, error_prefix))) { @@ -182,7 +184,13 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c *array = PyMem_Malloc(size * sizeof(float)); - return mathutils_array_parse_fast(*array, size, value_fast, error_prefix); + ret = mathutils_array_parse_fast(*array, size, value_fast, error_prefix); + + if (ret == -1) { + PyMem_Free(*array); + } + + return ret; } } diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 8fb3a3f74d6..79285b7778d 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -54,11 +54,18 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v /* Supports 2D, 3D, and 4D vector objects both int and float values * accepted. Mixed float and int values accepted. Ints are parsed to float */ -static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds)) +static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { float *vec = NULL; int size = 3; /* default to a 3D vector */ + if (kwds && PyDict_Size(kwds)) { + PyErr_SetString(PyExc_TypeError, + "Vector(): " + "takes no keyword args"); + return NULL; + } + switch (PyTuple_GET_SIZE(args)) { case 0: vec = PyMem_Malloc(size * sizeof(float)); @@ -74,9 +81,6 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED break; case 1: if ((size = mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { - if (vec) { - PyMem_Free(vec); - } return NULL; } break; @@ -86,7 +90,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED "more then a single arg given"); return NULL; } - return Vector_CreatePyObject(vec, size, Py_NEW, type); + return Vector_CreatePyObject_alloc(vec, size, type); } static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *self) @@ -294,7 +298,6 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) if ((value_size = mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) { - PyMem_Free(iter_vec); return NULL; } @@ -308,6 +311,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { + PyMem_Free(iter_vec); PyErr_SetString(PyExc_MemoryError, "Vector.Repeat(): " "problem allocating pointer space"); @@ -891,19 +895,18 @@ PyDoc_STRVAR(Vector_dot_doc, static PyObject *Vector_dot(VectorObject *self, PyObject *value) { float *tvec; + PyObject *ret; if (BaseMath_ReadCallback(self) == -1) return NULL; if (mathutils_array_parse_alloc(&tvec, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) { - goto cleanup; + return NULL; } - return PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->size)); - -cleanup: + ret = PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->size)); PyMem_Free(tvec); - return NULL; + return ret; } PyDoc_STRVAR(Vector_angle_doc, @@ -1133,12 +1136,12 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) return NULL; - if (mathutils_array_parse_alloc(&tvec, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) { - goto cleanup; + if (BaseMath_ReadCallback(self) == -1) { + return NULL; } - if (BaseMath_ReadCallback(self) == -1) { - goto cleanup; + if (mathutils_array_parse_alloc(&tvec, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) { + return NULL; } vec = PyMem_Malloc(size * sizeof(float)); @@ -1158,10 +1161,6 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) PyMem_Free(tvec); return Vector_CreatePyObject_alloc(vec, size, Py_TYPE(self)); - -cleanup: - PyMem_Free(tvec); - return NULL; } PyDoc_STRVAR(Vector_rotate_doc, @@ -1363,7 +1362,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se size = (end - begin); if (mathutils_array_parse_alloc(&vec, size, seq, "vector[begin:end] = [...]") == -1) { - goto cleanup; + return -1; } if (vec == NULL) { @@ -1376,16 +1375,12 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se /*parsed well - now set in vector*/ memcpy(self->vec + begin, vec, size * sizeof(float)); + PyMem_Free(vec); + if (BaseMath_WriteCallback(self) == -1) return -1; - PyMem_Free(vec); - return 0; - -cleanup: - PyMem_Free(vec); - return -1; } /* Numeric Protocols */ 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 4ea9333558d..19a474df342 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -328,16 +328,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 -> + */ /* ------------------------------------------------------------------------- */ @@ -3227,12 +3227,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_texture.c b/source/blender/render/intern/source/render_texture.c index e2a4ef1dca8..39577bf8da8 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -3591,7 +3591,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const if (!mvert || !mface || !mat) return; v1=mface[face_index].v1, v2=mface[face_index].v2, v3=mface[face_index].v3; - if (hit_quad) {v2=mface[face_index].v3; v3=mface[face_index].v4;} + if (hit_quad) { v2 = mface[face_index].v3; v3 = mface[face_index].v4; } normal_tri_v3(normal, mvert[v1].co, mvert[v2].co, mvert[v3].co); /* generate shadeinput with data required */ 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_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/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); |