Cleanup: trailing space for blenkernel

This commit is contained in:
Campbell Barton 2018-06-17 17:05:51 +02:00
parent a262ea8c47
commit 6fc8a74886
115 changed files with 4964 additions and 4964 deletions

@ -301,12 +301,12 @@ struct DerivedMesh {
CustomData *(*getTessFaceDataLayout)(DerivedMesh * dm);
CustomData *(*getLoopDataLayout)(DerivedMesh * dm);
CustomData *(*getPolyDataLayout)(DerivedMesh * dm);
/** 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 */
int (*getNumGrids)(DerivedMesh *dm);
int (*getGridSize)(DerivedMesh *dm);
@ -315,7 +315,7 @@ struct DerivedMesh {
void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key);
DMFlagMat *(*getGridFlagMats)(DerivedMesh * dm);
unsigned int **(*getGridHidden)(DerivedMesh * dm);
/** Iterate over each mapped vertex in the derived mesh, calling the
* given function with the original vert and the mapped vert's new
@ -397,7 +397,7 @@ struct DerivedMesh {
* Also called for *final* editmode DerivedMeshes
*/
void (*drawEdges)(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
/** Draw all loose edges (edges w/ no adjoining faces) */
void (*drawLooseEdges)(DerivedMesh *dm);
@ -478,7 +478,7 @@ struct DerivedMesh {
*
* NOTE: This routine is optional!
*/
void (*drawMappedEdgesInterp)(DerivedMesh *dm,
void (*drawMappedEdgesInterp)(DerivedMesh *dm,
DMSetDrawOptions setDrawOptions,
DMSetDrawInterpOptions setDrawInterpOptions,
void *userData);

@ -69,7 +69,7 @@ void BKE_action_make_local(struct Main *bmain, struct bAction *act, const bool l
/* Action API ----------------- */
/* types of transforms applied to the given item
/* types of transforms applied to the given item
* - these are the return falgs for action_get_item_transforms()
*/
typedef enum eAction_TransformFlags {
@ -79,21 +79,21 @@ typedef enum eAction_TransformFlags {
ACT_TRANS_ROT = (1 << 1),
/* scaling */
ACT_TRANS_SCALE = (1 << 2),
/* bbone shape - for all the parameters, provided one is set */
ACT_TRANS_BBONE = (1 << 3),
/* strictly not a transform, but custom properties are also
* quite often used in modern rigs
*/
ACT_TRANS_PROP = (1 << 4),
/* all flags */
ACT_TRANS_ONLY = (ACT_TRANS_LOC | ACT_TRANS_ROT | ACT_TRANS_SCALE),
ACT_TRANS_ALL = (ACT_TRANS_ONLY | ACT_TRANS_PROP)
} eAction_TransformFlags;
/* Return flags indicating which transforms the given object/posechannel has
/* Return flags indicating which transforms the given object/posechannel has
* - if 'curves' is provided, a list of links to these curves are also returned
* whose nodes WILL NEED FREEING
*/
@ -132,7 +132,7 @@ struct bActionGroup *BKE_action_group_find_name(struct bAction *act, const char
/* Clear all 'temp' flags on all groups */
void action_groups_clear_tempflags(struct bAction *act);
/* Pose API ----------------- */
/* Pose API ----------------- */
void BKE_pose_channel_free(struct bPoseChannel *pchan);
void BKE_pose_channel_free_ex(struct bPoseChannel *pchan, bool do_id_user);
@ -188,7 +188,7 @@ bool BKE_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan)
// XXX to be deprecated for a more general solution in animsys...
void framechange_poses_clear_unkeyed(struct Main *bmain);
/* Bone Groups API --------------------- */
/* Bone Groups API --------------------- */
/* Adds a new bone-group */
struct bActionGroup *BKE_pose_add_group(struct bPose *pose, const char *name);
@ -198,7 +198,7 @@ void BKE_pose_remove_group(struct bPose *pose, struct bActionGroup *grp, const i
/* Remove the matching bone-group from its index */
void BKE_pose_remove_group_index(struct bPose *pose, const int index);
/* Assorted Evaluation ----------------- */
/* Assorted Evaluation ----------------- */
/* Used for the Action Constraint */
void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe);

@ -80,10 +80,10 @@ void BKE_animdata_copy_id_action(struct Main *bmain, struct ID *id, const bool s
typedef enum eAnimData_MergeCopy_Modes {
/* Keep destination action */
ADT_MERGECOPY_KEEP_DST = 0,
/* Use src action (make a new copy) */
ADT_MERGECOPY_SRC_COPY = 1,
/* Use src action (but just reference the existing version) */
ADT_MERGECOPY_SRC_REF = 2
} eAnimData_MergeCopy_Modes;

@ -53,10 +53,10 @@ typedef struct PoseTarget {
typedef struct PoseTree {
struct PoseTree *next, *prev;
int type; /* type of IK that this serves (CONSTRAINT_TYPE_KINEMATIC or ..._SPLINEIK) */
int totchannel; /* number of pose channels */
struct ListBase targets; /* list of targets of the tree */
struct bPoseChannel **pchan; /* array of pose channels */
int *parent; /* and their parents */

@ -67,7 +67,7 @@ typedef struct ClothHairData {
typedef struct ClothSolverResult {
int status;
int max_iterations, min_iterations;
float avg_iterations;
float max_error, min_error, avg_error;
@ -138,7 +138,7 @@ typedef struct ClothSpring {
int flags; /* defined in BKE_cloth.h, e.g. deactivated due to tearing */
float stiffness; /* stiffness factor from the vertex groups */
float editrestlen;
/* angular bending spring target and derivatives */
float target[3];
}
@ -203,7 +203,7 @@ struct CollPair;
typedef struct ColliderContacts {
struct Object *ob;
struct CollisionModifierData *collmd;
struct CollPair *collisions;
int totcollisions;
} ColliderContacts;

@ -51,10 +51,10 @@ typedef struct bConstraintOb {
struct Scene *scene; /* for system time, part of deglobalization, code nicer later with local time (ton) */
struct Object *ob; /* if pchan, then armature that it comes from, otherwise constraint owner */
struct bPoseChannel *pchan; /* pose channel that owns the constraints being evaluated */
float matrix[4][4]; /* matrix where constraints are accumulated + solved */
float startmat[4][4]; /* original matrix (before constraint solving) */
short type; /* type of owner */
short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_math.h) */
} bConstraintOb;
@ -83,7 +83,7 @@ typedef struct bConstraintTypeInfo {
short size; /* size in bytes of the struct */
char name[32]; /* name of constraint in interface */
char structName[32]; /* name of struct for SDNA */
/* data management function pointers - special handling */
/* free any data that is allocated separately (optional) */
void (*free_data)(struct bConstraint *con);
@ -93,13 +93,13 @@ typedef struct bConstraintTypeInfo {
void (*copy_data)(struct bConstraint *con, struct bConstraint *src);
/* set settings for data that will be used for bConstraint.data (memory already allocated using MEM_callocN) */
void (*new_data)(void *cdata);
/* target handling function pointers */
/* for multi-target constraints: return that list; otherwise make a temporary list (returns number of targets) */
int (*get_constraint_targets)(struct bConstraint *con, struct ListBase *list);
/* for single-target constraints only: flush data back to source data, and the free memory used */
void (*flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, bool no_copy);
/* evaluation */
/* set the ct->matrix for the given constraint target (at the given ctime) */
void (*get_target_matrix)(struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);

@ -304,6 +304,6 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list);
#ifdef __cplusplus
}
#endif
#endif

@ -221,8 +221,8 @@ void CustomData_copy_data_named(const struct CustomData *source,
struct CustomData *dest, int source_index,
int dest_index, int count);
void CustomData_copy_elements(int type, void *src_data_ofs, void *dst_data_ofs, int count);
void CustomData_bmesh_copy_data(const struct CustomData *source,
struct CustomData *dest, void *src_block,
void CustomData_bmesh_copy_data(const struct CustomData *source,
struct CustomData *dest, void *src_block,
void **dest_block);
/* frees data in a CustomData object
@ -348,9 +348,9 @@ void CustomData_bmesh_free_block_data(struct CustomData *data, void *block);
/* copy custom data to/from layers as in mesh/derivedmesh, to editmesh
* blocks of data. the CustomData's must not be compatible */
void CustomData_to_bmesh_block(const struct CustomData *source,
void CustomData_to_bmesh_block(const struct CustomData *source,
struct CustomData *dest, int src_index, void **dest_block, bool use_default_init);
void CustomData_from_bmesh_block(const struct CustomData *source,
void CustomData_from_bmesh_block(const struct CustomData *source,
struct CustomData *dest, void *src_block, int dest_index);
void CustomData_file_write_prepare(

@ -177,5 +177,5 @@ bool DAG_is_acyclic(struct Scene *scene);
#ifdef __cplusplus
}
#endif
#endif

@ -1,4 +1,4 @@
/*
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or

@ -54,7 +54,7 @@ typedef struct PaintPoint {
} PaintPoint;
/* heigh field waves */
typedef struct PaintWavePoint {
typedef struct PaintWavePoint {
float height;
float velocity;

@ -56,7 +56,7 @@ typedef struct BMEditMesh {
/*this is for undoing failed operations*/
struct BMEditMesh *emcopy;
int emcopyusers;
/* we store tessellations as triplets of three loops,
* which each define a triangle.*/
struct BMLoop *(*looptris)[3];

@ -97,7 +97,7 @@ typedef struct EffectorCache {
struct Object *ob;
struct ParticleSystem *psys;
struct SurfaceModifierData *surmd;
struct PartDeflect *pd;
/* precalculated for guides */
@ -167,10 +167,10 @@ unsigned int BKE_sim_debug_data_hash_combine(unsigned int kx, unsigned int ky);
typedef struct SimDebugElement {
unsigned int category_hash;
unsigned int hash;
int type;
float color[3];
float v1[3], v2[3];
char str[64];
} SimDebugElement;

@ -66,7 +66,7 @@ void bezt_add_to_cfra_elem(ListBase *lb, struct BezTriple *bezt);
/* ************** F-Curve Drivers ***************** */
/* With these iterators for convenience, the variables "tarIndex" and "dtar" can be
/* With these iterators for convenience, the variables "tarIndex" and "dtar" can be
* accessed directly from the code using them, but it is not recommended that their
* values be changed to point at other slots...
*/
@ -77,14 +77,14 @@ void bezt_add_to_cfra_elem(ListBase *lb, struct BezTriple *bezt);
DriverTarget *dtar = &dvar->targets[0]; \
int tarIndex = 0; \
for (; tarIndex < MAX_DRIVER_TARGETS; tarIndex++, dtar++)
/* convenience looper over USED driver targets only */
#define DRIVER_TARGETS_USED_LOOPER(dvar) \
{ \
DriverTarget *dtar = &dvar->targets[0]; \
int tarIndex = 0; \
for (; tarIndex < dvar->num_targets; tarIndex++, dtar++)
/* tidy up for driver targets loopers */
#define DRIVER_TARGETS_LOOPER_END \
}
@ -133,7 +133,7 @@ typedef struct FModifierTypeInfo {
short requires; /* eFMI_Requirement_Flags */
char name[64]; /* name of modifier in interface */
char structName[64]; /* name of struct for SDNA */
/* data management function pointers - special handling */
/* free any data that is allocated separately (optional) */
void (*free_data)(struct FModifier *fcm);
@ -143,7 +143,7 @@ typedef struct FModifierTypeInfo {
void (*new_data)(void *mdata);
/* verifies that the modifier settings are valid */
void (*verify_data)(struct FModifier *fcm);
/* evaluation */
/* evaluate time that the modifier requires the F-Curve to be evaluated at */
float (*evaluate_modifier_time)(struct FCurve *fcu, struct FModifier *fcm, float cvalue, float evaltime);
@ -229,7 +229,7 @@ struct FCurve *iter_step_fcurve(struct FCurve *fcu_iter, const char rna_path[]);
/* high level function to get an fcurve from C without having the rna */
struct FCurve *id_data_find_fcurve(ID *id, void *data, struct StructRNA *type, const char *prop_name, int index, bool *r_driven);
/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
* e.g. numMatches = list_find_data_fcurves(matches, &act->curves, "pose.bones[", "MyFancyBone");
*/
int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName);
@ -290,7 +290,7 @@ float calculate_fcurve(struct PathResolvedRNA *anim_rna, struct FCurve *fcu, flo
/* -------- Defines -------- */
/* Basic signature for F-Curve sample-creation function
/* Basic signature for F-Curve sample-creation function
* - fcu: the F-Curve being operated on
* - data: pointer to some specific data that may be used by one of the callbacks
*/
@ -303,7 +303,7 @@ float fcurve_samplingcb_evalcurve(struct FCurve *fcu, void *data, float evaltime
/* -------- Main Methods -------- */
/* Main API function for creating a set of sampled curve data, given some callback function
/* Main API function for creating a set of sampled curve data, given some callback function
* used to retrieve the values to store.
*/
void fcurve_store_samples(struct FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb);

@ -58,7 +58,7 @@ typedef struct EditFontSelBox {
typedef struct EditFont {
wchar_t *textbuf;
struct CharInfo *textbufinfo;
/* array of rectangles & rotation */
float textcurs[4][2];
EditFontSelBox *selboxes;
@ -68,7 +68,7 @@ typedef struct EditFont {
* a copy of these is kept in Curve, but use these in editmode */
int len, pos;
int selstart, selend;
} EditFont;
@ -76,7 +76,7 @@ bool BKE_vfont_is_builtin(struct VFont *vfont);
void BKE_vfont_builtin_register(void *mem, int size);
void BKE_vfont_free_data(struct VFont *vfont);
void BKE_vfont_free(struct VFont *sc);
void BKE_vfont_free(struct VFont *sc);
void BKE_vfont_init(struct VFont *vfont);
void BKE_vfont_copy_data(struct Main *bmain, struct VFont *vfont_dst, const struct VFont *vfont_src, const int flag);
struct VFont *BKE_vfont_builtin_get(void);

@ -50,7 +50,7 @@ typedef struct Global {
/* active pointers */
struct Main *main;
/* strings: lastsaved */
char ima[1024], lib[1024]; /* 1024 = FILE_MAX */
@ -229,5 +229,5 @@ extern Global G;
#ifdef __cplusplus
}
#endif
#endif

@ -88,7 +88,7 @@ bool gpencil_layer_is_editable(const struct bGPDlayer *gpl);
typedef enum eGP_GetFrame_Mode {
/* Use the preceeding gp-frame (i.e. don't add anything) */
GP_GETFRAME_USE_PREV = 0,
/* Add a new empty/blank frame */
GP_GETFRAME_ADD_NEW = 1,
/* Make a copy of the active frame */

@ -19,7 +19,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_IDPROP_H__
#define __BKE_IDPROP_H__

@ -216,7 +216,7 @@ void BKE_image_verify_viewer_views(const struct RenderData *rd, struct Image *im
void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr, bool *r_is_in_range);
void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, char *path);
void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, char *path);
void BKE_image_update_frame(const struct Main *bmain, int cfra);
/* sets index offset for multilayer files */

@ -115,7 +115,7 @@ void free_matcopybuf(void);
void copy_matcopybuf(struct Main *bmain, struct Material *ma);
void paste_matcopybuf(struct Main *bmain, struct Material *ma);
/* handle backward compatibility for tface/materials called from doversion */
/* handle backward compatibility for tface/materials called from doversion */
int do_version_tface(struct Main *main);
#ifdef __cplusplus

@ -197,7 +197,7 @@ typedef struct ModifierTypeInfo {
*
* The derivedData argument should always be non-NULL; the modifier
* should read the object data from the derived object instead of the
* actual object data.
* actual object data.
*
* The useRenderParams argument indicates if the modifier is being
* applied in the service of the renderer which may alter quality
@ -217,7 +217,7 @@ typedef struct ModifierTypeInfo {
/* Like applyModifier but called during editmode (for supporting
* modifiers).
*
*
* The derived object that is returned must support the operations that
* are expected from editmode objects. The same qualifications regarding
* derivedData apply as for applyModifier.
@ -232,7 +232,7 @@ typedef struct ModifierTypeInfo {
/* Initialize new instance data for this modifier type, this function
* should set modifier variables to their default values.
*
*
* This function is optional.
*/
void (*initData)(struct ModifierData *md);
@ -273,7 +273,7 @@ typedef struct ModifierTypeInfo {
bool (*isDisabled)(struct ModifierData *md, int userRenderParams);
/* Add the appropriate relations to the DEP graph depending on the
* modifier data.
* modifier data.
*
* This function is optional.
*/
@ -299,7 +299,7 @@ typedef struct ModifierTypeInfo {
/* True when a deform modifier uses normals, the requiredDataMask
* cant be used here because that refers to a normal layer where as
* in this case we need to know if the deform modifier uses normals.
*
*
* this is needed because applying 2 deform modifiers will give the
* second modifier bogus normals.
* */

@ -99,7 +99,7 @@ typedef struct bNodeSocketTemplate {
float min, max;
int subtype; /* would use PropertySubType but this is a bad level include to use RNA */
int flag;
/* after this line is used internal only */
struct bNodeSocket *sock; /* used to hold verified socket */
char identifier[64]; /* generated from name */
@ -110,21 +110,21 @@ typedef struct bNodeSocketTemplate {
*/
typedef struct bNodeSocketType {
char idname[64]; /* identifier name */
void (*draw)(struct bContext *C, struct uiLayout *layout, struct PointerRNA *ptr, struct PointerRNA *node_ptr, const char *text);
void (*draw_color)(struct bContext *C, struct PointerRNA *ptr, struct PointerRNA *node_ptr, float *r_color);
void (*interface_draw)(struct bContext *C, struct uiLayout *layout, struct PointerRNA *ptr);
void (*interface_draw_color)(struct bContext *C, struct PointerRNA *ptr, float *r_color);
void (*interface_register_properties)(struct bNodeTree *ntree, struct bNodeSocket *stemp, struct StructRNA *data_srna);
void (*interface_init_socket)(struct bNodeTree *ntree, struct bNodeSocket *stemp, struct bNode *node, struct bNodeSocket *sock, const char *data_path);
void (*interface_verify_socket)(struct bNodeTree *ntree, struct bNodeSocket *stemp, struct bNode *node, struct bNodeSocket *sock, const char *data_path);
void (*interface_from_socket)(struct bNodeTree *ntree, struct bNodeSocket *stemp, struct bNode *node, struct bNodeSocket *sock);
/* RNA integration */
ExtensionRNA ext_socket;
ExtensionRNA ext_interface;
/* for standard socket types in C */
int type, subtype;
} bNodeSocketType;
@ -141,23 +141,23 @@ typedef int (*NodeGPUExecFunction)(struct GPUMaterial *mat, struct bNode *node,
typedef struct bNodeType {
void *next, *prev;
short needs_free; /* set for allocated types that need to be freed */
char idname[64]; /* identifier name */
int type;
char ui_name[64]; /* MAX_NAME */
char ui_description[256];
int ui_icon;
float width, minwidth, maxwidth;
float height, minheight, maxheight;
short nclass, flag, compatibility;
/* templates for static sockets */
bNodeSocketTemplate *inputs, *outputs;
char storagename[64]; /* struct name for DNA */
/* Main draw function for the node */
void (*draw_nodetype)(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode,
struct bNodeTree *ntree, struct bNode *node, bNodeInstanceKey key);
@ -183,41 +183,41 @@ typedef struct bNodeType {
int (*select_area_func)(struct bNode *node, int x, int y);
/// Optional tweak area polling (for grabbing).
int (*tweak_area_func)(struct bNode *node, int x, int y);
/// Called when the node is updated in the editor.
void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node);
/// Check and update if internal ID data has changed.
void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
/// Initialize a new node instance of this type after creation.
void (*initfunc)(struct bNodeTree *ntree, struct bNode *node);
/// Free the node instance.
void (*freefunc)(struct bNode *node);
/// Make a copy of the node instance.
void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, struct bNode *src_node);
/* Registerable API callback versions, called in addition to C callbacks */
void (*initfunc_api)(const struct bContext *C, struct PointerRNA *ptr);
void (*freefunc_api)(struct PointerRNA *ptr);
void (*copyfunc_api)(struct PointerRNA *ptr, struct bNode *src_node);
/* can this node type be added to a node tree */
int (*poll)(struct bNodeType *ntype, struct bNodeTree *nodetree);
/* can this node be added to a node tree */
int (*poll_instance)(struct bNode *node, struct bNodeTree *nodetree);
/* optional handling of link insertion */
void (*insert_link)(struct bNodeTree *ntree, struct bNode *node, struct bNodeLink *link);
/* Update the internal links list, for muting and disconnect operators. */
void (*update_internal_links)(struct bNodeTree *, struct bNode *node);
/* **** execution callbacks **** */
NodeInitExecFunction initexecfunc;
NodeFreeExecFunction freeexecfunc;
NodeExecFunction execfunc;
/* gpu */
NodeGPUExecFunction gpufunc;
/* RNA integration */
ExtensionRNA ext;
} bNodeType;
@ -277,7 +277,7 @@ typedef struct bNodeTreeType {
char ui_name[64];
char ui_description[256];
int ui_icon;
/* callbacks */
void (*free_cache)(struct bNodeTree *ntree);
void (*free_node_cache)(struct bNodeTree *ntree, struct bNode *node);
@ -295,11 +295,11 @@ typedef struct bNodeTreeType {
/* Tree update. Overrides nodetype->updatetreefunc! */
void (*update)(struct bNodeTree *ntree);
int (*validate_link)(struct bNodeTree *ntree, struct bNodeLink *link);
void (*node_add_init)(struct bNodeTree *ntree, struct bNode *bnode);
/* RNA integration */
ExtensionRNA ext;
} bNodeTreeType;

@ -1,4 +1,4 @@
/*
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@ -35,7 +35,7 @@ typedef struct OceanResult {
float disp[3];
float normal[3];
float foam;
/* raw eigenvalues/vectors */
float Jminus;
float Jplus;
@ -47,25 +47,25 @@ typedef struct OceanCache {
struct ImBuf **ibufs_disp;
struct ImBuf **ibufs_foam;
struct ImBuf **ibufs_norm;
const char *bakepath;
const char *relbase;
/* precalculated for time range */
float *time;
/* constant for time range */
float wave_scale;
float chop_amount;
float foam_coverage;
float foam_fade;
int start;
int end;
int duration;
int resolution_x;
int resolution_y;
int baked;
} OceanCache;
@ -93,7 +93,7 @@ struct OceanCache *BKE_ocean_init_cache(
int start, int end, float wave_scale,
float chop_amount, float foam_coverage, float foam_fade, int resolution);
void BKE_ocean_simulate_cache(struct OceanCache *och, int frame);
void BKE_ocean_bake(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void *update_cb_data);
void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, int f, float u, float v);
void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j);

@ -181,7 +181,7 @@ typedef struct SculptSession {
int totvert, totpoly;
struct KeyBlock *kb;
float *vmask;
/* Mesh connectivity */
const struct MeshElemMap *pmap;
@ -206,7 +206,7 @@ typedef struct SculptSession {
/* Partial redraw */
bool partial_redraw;
/* Used to cache the render of the active texture */
unsigned int texcache_side, *texcache, texcache_actual;
struct ImagePool *tex_pool;

@ -60,7 +60,7 @@ struct LinkNode;
struct KDTree;
struct RNG;
struct BVHTreeRay;
struct BVHTreeRayHit;
struct BVHTreeRayHit;
struct EdgeHash;
#define PARTICLE_COLLISION_MAX_COLLISIONS 10
@ -192,7 +192,7 @@ typedef struct ParticleCollisionElement {
/* values interpolated from original data*/
float x0[3], x1[3], x2[3], p[3];
/* results for found intersection point */
float nor[3], vel[3], uv[2];

@ -49,5 +49,5 @@ void BKE_bproperty_set(struct bProperty *prop, const char *str);
void BKE_bproperty_add(struct bProperty *prop, const char *str);
/* should really be called '_get_valstr()' or '_as_string()' */
void BKE_bproperty_set_valstr(struct bProperty *prop, char str[MAX_PROPSTRING]);
#endif

@ -74,6 +74,6 @@ bool BKE_report_write_file(const char *filepath, ReportList *reports, const char
#ifdef __cplusplus
}
#endif
#endif

@ -29,7 +29,7 @@
* \ingroup blenkernel
* \brief API for Blender-side Rigid Body stuff
*/
#ifndef __BKE_RIGIDBODY_H__
#define __BKE_RIGIDBODY_H__

@ -135,38 +135,38 @@ struct SeqEffectHandle {
/* constructors & destructor */
/* init is _only_ called on first creation */
void (*init)(struct Sequence *seq);
/* number of input strips needed
/* number of input strips needed
* (called directly after construction) */
int (*num_inputs)(void);
/* load is called first time after readblenfile in
* get_sequence_effect automatically */
void (*load)(struct Sequence *seq);
/* duplicate */
void (*copy)(struct Sequence *dst, struct Sequence *src);
/* destruct */
void (*free)(struct Sequence *seq);
/* returns: -1: no input needed,
* 0: no early out,
* 1: out = ibuf1,
* 2: out = ibuf2 */
int (*early_out)(struct Sequence *seq, float facf0, float facf1);
int (*early_out)(struct Sequence *seq, float facf0, float facf1);
/* stores the y-range of the effect IPO */
void (*store_icu_yrange)(struct Sequence *seq, short adrcode, float *ymin, float *ymax);
/* stores the default facf0 and facf1 if no IPO is present */
void (*get_default_fac)(struct Sequence *seq, float cfra, float *facf0, float *facf1);
/* execute the effect
* sequence effects are only required to either support
* float-rects or byte-rects
* (mixed cases are handled one layer up...) */
struct ImBuf * (*execute)(const SeqRenderData *context, struct Sequence *seq, float cfra, float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3);
@ -273,7 +273,7 @@ void BKE_sequencer_cache_cleanup(void);
/* returned ImBuf is properly refed and has to be freed */
struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context, struct Sequence *seq, float cfra, eSeqStripElemIBuf type);
/* passed ImBuf is properly refed, so ownership is *not*
/* passed ImBuf is properly refed, so ownership is *not*
* transferred to the cache.
* you can pass the same ImBuf multiple times to the cache without problems.
*/

@ -38,7 +38,7 @@ extern "C" {
/* generic blender movie support, could move to own module */
struct RenderData;
struct RenderData;
struct ReportList;
struct Scene;

@ -36,7 +36,7 @@
extern "C" {
#endif
struct RenderData;
struct RenderData;
struct ReportList;
struct Scene;

@ -277,7 +277,7 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a
ss->fMap = ccg_ehash_new(0, &ss->allocatorIFC, ss->allocator);
ss->meshIFC = *ifc;
ss->subdivLevels = subdivLevels;
ss->numGrids = 0;
ss->allowEdgeCreation = 0;
@ -489,8 +489,8 @@ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss)
ss->currentAge++;
ss->oldVMap = ss->vMap;
ss->oldEMap = ss->eMap;
ss->oldVMap = ss->vMap;
ss->oldEMap = ss->eMap;
ss->oldFMap = ss->fMap;
ss->vMap = ccg_ehash_new(0, &ss->allocatorIFC, ss->allocator);
@ -592,7 +592,7 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
void **prevp;
CCGVert *v = NULL;
short seamflag = (seam) ? Vert_eSeam : 0;
if (ss->syncState == eSyncState_Partial) {
v = ccg_ehash_lookupWithPrev(ss->vMap, vHDL, &prevp);
if (!v) {
@ -937,7 +937,7 @@ void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces, int num
for (j = 0; j < v->numFaces; j++)
if (!(v->faces[j]->flags & Face_eEffected))
break;
if (j == v->numFaces) {
arrayV[numV++] = v;
v->flags |= Vert_eEffected;
@ -952,7 +952,7 @@ void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces, int num
for (j = 0; j < e->numFaces; j++)
if (!(e->faces[j]->flags & Face_eEffected))
break;
if (j == e->numFaces) {
e->flags |= Edge_eEffected;
arrayE[numE++] = e;
@ -1550,11 +1550,11 @@ int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss)
void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level)
{
key->level = level;
key->elem_size = ss->meshIFC.vertDataSize;
key->has_normals = ss->calcVertNormals;
key->num_layers = ss->meshIFC.numLayers;
/* if normals are present, always the last three floats of an
* element */
if (key->has_normals)

@ -137,7 +137,7 @@ static MFace *dm_getTessFaceArray(DerivedMesh *dm)
if (!mface) {
int numTessFaces = dm->getNumTessFaces(dm);
if (!numTessFaces) {
/* Do not add layer if there's no elements in it, this leads to issues later when
* this layer is needed with non-zero size, but currently CD stuff does not check
@ -145,7 +145,7 @@ static MFace *dm_getTessFaceArray(DerivedMesh *dm)
* added (sergey) */
return NULL;
}
mface = CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numTessFaces);
CustomData_set_layer_flag(&dm->faceData, CD_MFACE, CD_FLAG_TEMPORARY);
dm->copyTessFaceArray(dm, mface);
@ -347,7 +347,7 @@ void DM_init(
dm->numPolyData = numPolys;
DM_init_funcs(dm);
dm->needsFree = 1;
dm->auto_bump_scale = -1.0f;
dm->dirty = 0;
@ -758,7 +758,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool
if (CustomData_has_layer(&dm->vertData, CD_SHAPEKEY)) {
KeyBlock *kb;
int uid;
if (ob) {
kb = BLI_findlink(&me->key->block, ob->shapenr - 1);
if (kb) {
@ -784,7 +784,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool
if (ob) {
BKE_mesh_texspace_copy_from_object(&tmp, ob);
}
/* not all DerivedMeshes store their verts/edges/faces in CustomData, so
* we set them here in case they are missing */
if (!CustomData_has_layer(&tmp.vdata, CD_MVERT)) {
@ -864,18 +864,18 @@ void DM_to_meshkey(DerivedMesh *dm, Mesh *me, KeyBlock *kb)
int a, totvert = dm->getNumVerts(dm);
float *fp;
MVert *mvert;
if (totvert == 0 || me->totvert == 0 || me->totvert != totvert) {
return;
}
if (kb->data) MEM_freeN(kb->data);
kb->data = MEM_malloc_arrayN(me->key->elemsize, me->totvert, "kb->data");
kb->totelem = totvert;
fp = kb->data;
mvert = dm->getVertDataArray(dm, CD_MVERT);
for (a = 0; a < kb->totelem; a++, fp += 3, mvert++) {
copy_v3_v3(fp, mvert->co);
}
@ -1135,10 +1135,10 @@ void DM_interp_poly_data(
DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
{
DerivedMesh *dm = CDDM_from_mesh(me);
if (!dm)
return NULL;
if (vertCos) {
CDDM_apply_vert_coords(dm, vertCos);
}
@ -1156,7 +1156,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
KeyBlock *kb;
md->scene = scene;
if (!(md->mode & eModifierMode_Realtime)) {
return NULL;
}
@ -1164,11 +1164,11 @@ DerivedMesh *mesh_create_derived_for_modifier(
if (mti->isDisabled && mti->isDisabled(md, 0)) {
return NULL;
}
if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr - 1))) {
BKE_keyblock_convert_to_mesh(kb, me);
}
if (mti->type == eModifierTypeType_OnlyDeform) {
int numVerts;
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
@ -1178,7 +1178,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
if (build_shapekey_layers)
add_shapekey_layers(dm, me, ob);
MEM_freeN(deformedVerts);
}
else {
@ -1186,7 +1186,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
if (build_shapekey_layers)
add_shapekey_layers(tdm, me, ob);
dm = modwrap_applyModifier(md, ob, tdm, 0);
ASSERT_IS_VALID_DM(dm);
@ -1205,13 +1205,13 @@ static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3]
/* these may not really be the orco's, but it's only for preview.
* could be solver better once, but isn't simple */
orco = MEM_malloc_arrayN(em->bm->totvert, sizeof(float) * 3, "BMEditMesh Orco");
BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
copy_v3_v3(orco[i], eve->co);
}
return orco;
}
@ -1401,7 +1401,7 @@ static void calc_weightpaint_vert_color(
const int draw_flag)
{
float input = 0.0f;
bool show_alert_color = false;
if ((defbase_sel_tot > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
@ -1633,35 +1633,35 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
{
KeyBlock *kb;
int i, j, tot;
if (!me->key)
return;
tot = CustomData_number_of_layers(&dm->vertData, CD_SHAPEKEY);
for (i = 0; i < tot; i++) {
CustomDataLayer *layer = &dm->vertData.layers[CustomData_get_layer_index_n(&dm->vertData, CD_SHAPEKEY, i)];
float (*cos)[3], (*kbcos)[3];
for (kb = me->key->block.first; kb; kb = kb->next) {
if (kb->uid == layer->uid)
break;
}
if (!kb) {
kb = BKE_keyblock_add(me->key, layer->name);
kb->uid = layer->uid;
}
if (kb->data)
MEM_freeN(kb->data);
cos = CustomData_get_layer_n(&dm->vertData, CD_SHAPEKEY, i);
kb->totelem = dm->numVertData;
kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, 3 * sizeof(float), "kbcos DerivedMesh.c");
if (kb->uid == actshape_uid) {
MVert *mvert = dm->getVertArray(dm);
for (j = 0; j < dm->numVertData; j++, kbcos++, mvert++) {
copy_v3_v3(*kbcos, mvert->co);
}
@ -1672,12 +1672,12 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
}
}
}
for (kb = me->key->block.first; kb; kb = kb->next) {
if (kb->totelem != dm->numVertData) {
if (kb->data)
MEM_freeN(kb->data);
kb->totelem = dm->numVertData;
kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), "kb->data derivedmesh.c");
fprintf(stderr, "%s: lost a shapekey layer: '%s'! (bmesh internal error)\n", __func__, kb->name);
@ -1844,13 +1844,13 @@ static void mesh_calc_modifiers(
if (useDeform) {
if (inputVertexCos)
deformedVerts = inputVertexCos;
/* Apply all leading deforming modifiers */
for (; md; md = md->next, curr = curr->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene = scene;
if (!modifier_isEnabled(scene, md, required_mode)) {
continue;
}
@ -1868,7 +1868,7 @@ static void mesh_calc_modifiers(
else {
break;
}
/* grab modifiers until index i */
if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index))
break;
@ -1883,7 +1883,7 @@ static void mesh_calc_modifiers(
if (build_shapekey_layers)
add_shapekey_layers(dm, me, ob);
if (deformedVerts) {
CDDM_apply_vert_coords(*r_deform, deformedVerts);
}
@ -1899,7 +1899,7 @@ static void mesh_calc_modifiers(
/* Now apply all remaining modifiers. If useDeform is off then skip
* OnlyDeform ones.
* OnlyDeform ones.
*/
dm = NULL;
orcodm = NULL;
@ -2059,14 +2059,14 @@ static void mesh_calc_modifiers(
}
}
/* set the DerivedMesh to only copy needed data */
mask = curr->mask;
/* needMapping check here fixes bug [#28112], otherwise it's
* possible that it won't be copied */
mask |= append_mask;
DM_set_only_copy(dm, mask | (need_mapping ? CD_MASK_ORIGINDEX : 0));
/* add cloth rest shape key if needed */
if (mask & CD_MASK_CLOTH_ORCO)
add_orco_dm(ob, NULL, dm, clothorcodm, CD_CLOTH_ORCO);
@ -2191,11 +2191,11 @@ static void mesh_calc_modifiers(
}
else {
finaldm = CDDM_from_mesh(me);
if (build_shapekey_layers) {
add_shapekey_layers(finaldm, me, ob);
}
if (deformedVerts) {
CDDM_apply_vert_coords(finaldm, deformedVerts);
}
@ -2302,7 +2302,7 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *
modifier_setError(md, "Modifier requires original data, bad stack position");
return false;
}
return true;
}
@ -2359,7 +2359,7 @@ static void editbmesh_calc_modifiers(
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene = scene;
if (!editbmesh_modifier_is_enabled(scene, md, dm)) {
continue;
}
@ -2794,7 +2794,7 @@ DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask da
DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
NULL, &final);
@ -2839,7 +2839,7 @@ DerivedMesh *mesh_create_derived_no_deform(
CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
NULL, &final);
@ -2852,7 +2852,7 @@ DerivedMesh *mesh_create_derived_no_virtual(
CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false,
NULL, &final);
@ -2865,7 +2865,7 @@ DerivedMesh *mesh_create_derived_physics(
CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false,
NULL, &final);
@ -2991,13 +2991,13 @@ DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
Mesh *me = ob->data;
DerivedMesh *dm;
DMCoNo *vertexcosnos;
/* lets prevent crashing... */
if (ob->type != OB_MESH || me->totvert == 0)
return NULL;
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
if (dm->foreachMappedVert) {
vertexcosnos = MEM_calloc_arrayN(me->totvert, sizeof(DMCoNo), "vertexcosnos map");
dm->foreachMappedVert(dm, make_vertexcosnos__mapFunc, vertexcosnos);
@ -3010,7 +3010,7 @@ DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
dm->getVertNo(dm, a, v_co_no->no);
}
}
dm->release(dm);
return vertexcosnos;
}
@ -3703,7 +3703,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
vdata = &dm->vertData;
ldata = dm->getLoopDataLayout(dm);
/* calc auto bump scale if necessary */
if (dm->auto_bump_scale <= 0.0f)
DM_calc_auto_bump_scale(dm);

@ -32,7 +32,7 @@
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stddef.h>
#include <stddef.h>
#include "MEM_guardedalloc.h"
@ -87,11 +87,11 @@
bAction *BKE_action_add(Main *bmain, const char name[])
{
bAction *act;
act = BKE_libblock_alloc(bmain, ID_AC, name, 0);
return act;
}
}
/* .................................. */
@ -105,15 +105,15 @@ void BKE_action_make_local(Main *bmain, bAction *act, const bool lib_local)
/** Free (or release) any data used by this action (does not free the action itself). */
void BKE_action_free(bAction *act)
{
{
/* No animdata here. */
/* Free F-Curves */
free_fcurves(&act->curves);
/* Free groups */
BLI_freelistN(&act->groups);
/* Free pose-references (aka local markers) */
BLI_freelistN(&act->markers);
}
@ -178,14 +178,14 @@ bAction *BKE_action_copy(Main *bmain, const bAction *act_src)
bActionGroup *get_active_actiongroup(bAction *act)
{
bActionGroup *agrp = NULL;
if (act && act->groups.first) {
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
if (agrp->flag & AGRP_ACTIVE)
break;
}
}
return agrp;
}
@ -193,11 +193,11 @@ bActionGroup *get_active_actiongroup(bAction *act)
void set_active_action_group(bAction *act, bActionGroup *agrp, short select)
{
bActionGroup *grp;
/* sanity checks */
if (act == NULL)
return;
/* Deactive all others */
for (grp = act->groups.first; grp; grp = grp->next) {
if ((grp == agrp) && (select))
@ -216,7 +216,7 @@ void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp)
/* copy theme colors on-to group's custom color in case user tries to edit color */
bTheme *btheme = U.themes.first;
ThemeWireColor *col_set = &btheme->tarm[(grp->customCol - 1)];
memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
}
else {
@ -242,69 +242,69 @@ void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp)
bActionGroup *action_groups_add_new(bAction *act, const char name[])
{
bActionGroup *agrp;
/* sanity check: must have action and name */
if (ELEM(NULL, act, name))
return NULL;
/* allocate a new one */
agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup");
/* make it selected, with default name */
agrp->flag = AGRP_SELECTED;
BLI_strncpy(agrp->name, name[0] ? name : DATA_("Group"), sizeof(agrp->name));
/* add to action, and validate */
BLI_addtail(&act->groups, agrp);
BLI_uniquename(&act->groups, agrp, DATA_("Group"), '.', offsetof(bActionGroup, name), sizeof(agrp->name));
/* return the new group */
return agrp;
}
/* Add given channel into (active) group
/* Add given channel into (active) group
* - assumes that channel is not linked to anything anymore
* - always adds at the end of the group
*/
void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
{
{
/* sanity checks */
if (ELEM(NULL, act, agrp, fcurve))
return;
/* if no channels anywhere, just add to two lists at the same time */
if (BLI_listbase_is_empty(&act->curves)) {
fcurve->next = fcurve->prev = NULL;
agrp->channels.first = agrp->channels.last = fcurve;
act->curves.first = act->curves.last = fcurve;
}
/* if the group already has channels, the F-Curve can simply be added to the list
/* if the group already has channels, the F-Curve can simply be added to the list
* (i.e. as the last channel in the group)
*/
else if (agrp->channels.first) {
/* if the group's last F-Curve is the action's last F-Curve too,
/* if the group's last F-Curve is the action's last F-Curve too,
* then set the F-Curve as the last for the action first so that
* the lists will be in sync after linking
*/
if (agrp->channels.last == act->curves.last)
act->curves.last = fcurve;
/* link in the given F-Curve after the last F-Curve in the group,
* which means that it should be able to fit in with the rest of the
* list seamlessly
*/
BLI_insertlinkafter(&agrp->channels, agrp->channels.last, fcurve);
}
/* otherwise, need to find the nearest F-Curve in group before/after current to link with */
else {
bActionGroup *grp;
/* firstly, link this F-Curve to the group */
agrp->channels.first = agrp->channels.last = fcurve;
/* step through the groups preceding this one, finding the F-Curve there to attach this one after */
for (grp = agrp->prev; grp; grp = grp->prev) {
/* if this group has F-Curves, we want weave the given one in right after the last channel there,
@ -318,18 +318,18 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
break;
}
}
/* if grp is NULL, that means we fell through, and this F-Curve should be added as the new first
* since group is (effectively) the first group. Thus, the existing first F-Curve becomes the
* since group is (effectively) the first group. Thus, the existing first F-Curve becomes the
* second in the chain, etc. etc.
*/
if (grp == NULL)
BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve);
}
/* set the F-Curve's new group */
fcurve->grp = agrp;
}
}
/* Remove the given channel from all groups */
void action_groups_remove_channel(bAction *act, FCurve *fcu)
@ -337,11 +337,11 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu)
/* sanity checks */
if (ELEM(NULL, act, fcu))
return;
/* check if any group used this directly */
if (fcu->grp) {
bActionGroup *agrp = fcu->grp;
if (agrp->channels.first == agrp->channels.last) {
if (agrp->channels.first == fcu) {
BLI_listbase_clear(&agrp->channels);
@ -359,10 +359,10 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu)
else
agrp->channels.last = NULL;
}
fcu->grp = NULL;
}
/* now just remove from list */
BLI_remlink(&act->curves, fcu);
}
@ -373,7 +373,7 @@ bActionGroup *BKE_action_group_find_name(bAction *act, const char name[])
/* sanity checks */
if (ELEM(NULL, act, act->groups.first, name) || (name[0] == 0))
return NULL;
/* do string comparisons */
return BLI_findstring(&act->groups, name, offsetof(bActionGroup, name));
}
@ -382,11 +382,11 @@ bActionGroup *BKE_action_group_find_name(bAction *act, const char name[])
void action_groups_clear_tempflags(bAction *act)
{
bActionGroup *agrp;
/* sanity checks */
if (ELEM(NULL, act, act->groups.first))
return;
/* flag clearing loop */
for (agrp = act->groups.first; agrp; agrp = agrp->next)
agrp->flag &= ~AGRP_TEMP;
@ -402,10 +402,10 @@ bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
{
if (ELEM(NULL, pose, name) || (name[0] == '\0'))
return NULL;
if (pose->chanhash)
return BLI_ghash_lookup(pose->chanhash, (const void *)name);
return BLI_findstring(&((const bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name));
}
@ -420,10 +420,10 @@ bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
{
bPoseChannel *chan;
if (pose == NULL)
return NULL;
/* See if this channel exists */
chan = BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name));
if (chan) {
@ -432,7 +432,7 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
/* If not, create it and add it */
chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel");
BLI_strncpy(chan->name, name, sizeof(chan->name));
chan->custom_scale = 1.0f;
@ -441,20 +441,20 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
unit_qt(chan->quat);
unit_axis_angle(chan->rotAxis, &chan->rotAngle);
chan->size[0] = chan->size[1] = chan->size[2] = 1.0f;
chan->scaleIn = chan->scaleOut = 1.0f;
chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -M_PI;
chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = M_PI;
chan->stiffness[0] = chan->stiffness[1] = chan->stiffness[2] = 0.0f;
chan->ikrotweight = chan->iklinweight = 0.0f;
unit_m4(chan->constinv);
chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */
BLI_addtail(&pose->chanbase, chan);
BKE_pose_channels_hash_free(pose);
return chan;
}
@ -494,7 +494,7 @@ bPoseChannel *BKE_pose_channel_active(Object *ob)
if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer))
return pchan;
}
return NULL;
}
@ -543,11 +543,11 @@ void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const
*dst = NULL;
return;
}
outPose = MEM_callocN(sizeof(bPose), "pose");
BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
/* Rebuild ghash here too, so that name lookups below won't be too bad...
* BUT this will have the penalty that the ghash will be built twice
* if BKE_pose_rebuild() gets called after this...
@ -556,12 +556,12 @@ void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const
outPose->chanhash = NULL;
BKE_pose_channels_hash_make(outPose);
}
outPose->iksolver = src->iksolver;
outPose->ikdata = NULL;
outPose->ikparam = MEM_dupallocN(src->ikparam);
outPose->avs = src->avs;
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
id_us_plus((ID *)pchan->custom);
@ -583,7 +583,7 @@ void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const
pchan->constraints = listb;
pchan->mpath = NULL; /* motion paths should not get copied yet... */
}
if (pchan->prop) {
pchan->prop = IDP_CopyProperty_ex(pchan->prop, flag);
}
@ -593,7 +593,7 @@ void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const
if (copy_constraints) {
BLI_duplicatelist(&outPose->agroups, &src->agroups);
}
*dst = outPose;
}
@ -641,7 +641,7 @@ static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
{
bConstraint *con;
Bone *bone;
/* No need to check if constraint is active (has influence),
* since all constraints with CONSTRAINT_IK_AUTO are active */
for (con = pchan->constraints.first; con; con = con->next) {
@ -670,18 +670,18 @@ bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
* Removes the hash for quick lookup of channels, must
* be done when adding/removing channels.
*/
void BKE_pose_channels_hash_make(bPose *pose)
void BKE_pose_channels_hash_make(bPose *pose)
{
if (!pose->chanhash) {
bPoseChannel *pchan;
pose->chanhash = BLI_ghash_str_new("make_pose_chan gh");
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next)
BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
}
}
void BKE_pose_channels_hash_free(bPose *pose)
void BKE_pose_channels_hash_free(bPose *pose)
{
if (pose->chanhash) {
BLI_ghash_free(pose->chanhash, NULL, NULL);
@ -737,7 +737,7 @@ void BKE_pose_channels_remove(
cti->flush_constraint_targets(con, &targets, 0);
}
}
if (pchan->bbone_prev) {
if (filter_fn(pchan->bbone_prev->name, user_data))
pchan->bbone_prev = NULL;
@ -746,7 +746,7 @@ void BKE_pose_channels_remove(
if (filter_fn(pchan->bbone_next->name, user_data))
pchan->bbone_next = NULL;
}
if (pchan->custom_tx) {
if (filter_fn(pchan->custom_tx->name, user_data))
pchan->custom_tx = NULL;
@ -775,7 +775,7 @@ void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
}
BKE_constraints_free_ex(&pchan->constraints, do_id_user);
if (pchan->prop) {
IDP_FreeProperty(pchan->prop);
MEM_freeN(pchan->prop);
@ -794,11 +794,11 @@ void BKE_pose_channel_free(bPoseChannel *pchan)
void BKE_pose_channels_free_ex(bPose *pose, bool do_id_user)
{
bPoseChannel *pchan;
if (pose->chanbase.first) {
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next)
BKE_pose_channel_free_ex(pchan, do_id_user);
BLI_freelistN(&pose->chanbase);
}
@ -852,7 +852,7 @@ void BKE_pose_free(bPose *pose)
static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan)
{
bConstraint *pcon, *con;
copy_v3_v3(pchan->loc, chan->loc);
copy_v3_v3(pchan->size, chan->size);
copy_v3_v3(pchan->eul, chan->eul);
@ -863,7 +863,7 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat);
pchan->flag = chan->flag;
pchan->roll1 = chan->roll1;
pchan->roll2 = chan->roll2;
pchan->curveInX = chan->curveInX;
@ -874,7 +874,7 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
pchan->ease2 = chan->ease2;
pchan->scaleIn = chan->scaleIn;
pchan->scaleOut = chan->scaleOut;
con = chan->constraints.first;
for (pcon = pchan->constraints.first; pcon && con; pcon = pcon->next, con = con->next) {
pcon->enforce = con->enforce;
@ -908,7 +908,7 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
pchan->ikstretch = pchan_from->ikstretch;
pchan->ikrotweight = pchan_from->ikrotweight;
pchan->iklinweight = pchan_from->iklinweight;
/* bbone settings (typically not animated) */
pchan->bboneflag = pchan_from->bboneflag;
pchan->bbone_next = pchan_from->bbone_next;
@ -946,31 +946,31 @@ void BKE_pose_update_constraint_flags(bPose *pose)
{
bPoseChannel *pchan, *parchan;
bConstraint *con;
/* clear */
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
pchan->constflag = 0;
}
pose->flag &= ~POSE_CONSTRAINTS_TIMEDEPEND;
/* detect */
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = (bKinematicConstraint *)con->data;
pchan->constflag |= PCHAN_HAS_IK;
if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
pchan->constflag |= PCHAN_HAS_TARGET;
/* negative rootbone = recalc rootbone index. used in do_versions */
if (data->rootbone < 0) {
data->rootbone = 0;
if (data->flag & CONSTRAINT_IK_TIP) parchan = pchan;
else parchan = pchan->parent;
while (parchan) {
data->rootbone++;
if ((parchan->bone->flag & BONE_CONNECTED) == 0)
@ -981,10 +981,10 @@ void BKE_pose_update_constraint_flags(bPose *pose)
}
else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
bFollowPathConstraint *data = (bFollowPathConstraint *)con->data;
/* for drawing constraint colors when color set allows this */
pchan->constflag |= PCHAN_HAS_CONST;
/* if we have a valid target, make sure that this will get updated on frame-change
* (needed for when there is no anim-data for this pose)
*/
@ -993,7 +993,7 @@ void BKE_pose_update_constraint_flags(bPose *pose)
}
else if (con->type == CONSTRAINT_TYPE_SPLINEIK)
pchan->constflag |= PCHAN_HAS_SPLINEIK;
else
else
pchan->constflag |= PCHAN_HAS_CONST;
}
}
@ -1005,7 +1005,7 @@ void BKE_pose_tag_update_constraint_flags(bPose *pose)
pose->flag |= POSE_CONSTRAINTS_NEED_UPDATE_FLAGS;
}
/* Clears all BONE_UNKEYED flags for every pose channel in every pose
/* Clears all BONE_UNKEYED flags for every pose channel in every pose
* This should only be called on frame changing, when it is acceptable to
* do this. Otherwise, these flags should not get cleared as poses may get lost.
*/
@ -1014,14 +1014,14 @@ void framechange_poses_clear_unkeyed(Main *bmain)
Object *ob;
bPose *pose;
bPoseChannel *pchan;
/* This needs to be done for each object that has a pose */
/* TODO: proxies may/may not be correctly handled here... (this needs checking) */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* we only need to do this on objects with a pose */
if ((pose = ob->pose)) {
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone)
if (pchan->bone)
pchan->bone->flag &= ~BONE_UNKEYED;
}
}
@ -1034,18 +1034,18 @@ void framechange_poses_clear_unkeyed(Main *bmain)
bActionGroup *BKE_pose_add_group(bPose *pose, const char *name)
{
bActionGroup *grp;
if (!name) {
name = DATA_("Group");
}
grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup");
BLI_strncpy(grp->name, name, sizeof(grp->name));
BLI_addtail(&pose->agroups, grp);
BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));
pose->active_group = BLI_listbase_count(&pose->agroups);
return grp;
}
@ -1055,13 +1055,13 @@ void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
{
bPoseChannel *pchan;
int idx = index;
if (idx < 1) {
idx = BLI_findindex(&pose->agroups, grp) + 1;
}
BLI_assert(idx > 0);
/* adjust group references (the trouble of using indices!):
* - firstly, make sure nothing references it
* - also, make sure that those after this item get corrected
@ -1091,7 +1091,7 @@ void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
void BKE_pose_remove_group_index(bPose *pose, const int index)
{
bActionGroup *grp = NULL;
/* get group to remove */
grp = BLI_findlink(&pose->agroups, index - 1);
if (grp) {
@ -1105,7 +1105,7 @@ void BKE_pose_remove_group_index(bPose *pose, const int index)
bool action_has_motion(const bAction *act)
{
FCurve *fcu;
/* return on the first F-Curve that has some keyframes/samples defined */
if (act) {
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
@ -1113,7 +1113,7 @@ bool action_has_motion(const bAction *act)
return true;
}
}
/* nothing found */
return false;
}
@ -1130,7 +1130,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
/* if curve has keyframes, consider them first */
if (fcu->totvert) {
float nmin, nmax;
/* get extents for this curve
* - no "selected only", since this is often used in the backend
* - no "minimum length" (we will apply this later), otherwise
@ -1138,26 +1138,26 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
* a phantom frame (T50354)
*/
calc_fcurve_range(fcu, &nmin, &nmax, false, false);
/* compare to the running tally */
min = min_ff(min, nmin);
max = max_ff(max, nmax);
foundvert = 1;
}
/* if incl_modifiers is enabled, need to consider modifiers too
* - only really care about the last modifier
*/
if ((incl_modifiers) && (fcu->modifiers.last)) {
FModifier *fcm = fcu->modifiers.last;
/* only use the maximum sensible limits of the modifiers if they are more extreme */
switch (fcm->type) {
case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */
{
FMod_Limits *fmd = (FMod_Limits *)fcm->data;
if (fmd->flag & FCM_LIMIT_XMIN) {
min = min_ff(min, fmd->rect.xmin);
}
@ -1169,7 +1169,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */
{
FMod_Cycles *fmd = (FMod_Cycles *)fcm->data;
if (fmd->before_mode != FCM_EXTRAPOLATE_NONE)
min = MINAFRAMEF;
if (fmd->after_mode != FCM_EXTRAPOLATE_NONE)
@ -1177,22 +1177,22 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
break;
}
/* TODO: function modifier may need some special limits */
default: /* all other standard modifiers are on the infinite range... */
min = MINAFRAMEF;
max = MAXFRAMEF;
break;
}
foundmod = 1;
}
}
}
if (foundvert || foundmod) {
/* ensure that action is at least 1 frame long (for NLA strips to have a valid length) */
if (min == max) max += 1.0f;
*start = min;
*end = max;
}
@ -1202,7 +1202,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
}
}
/* Return flags indicating which transforms the given object/posechannel has
/* Return flags indicating which transforms the given object/posechannel has
* - if 'curves' is provided, a list of links to these curves are also returned
*/
short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, ListBase *curves)
@ -1211,7 +1211,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
FCurve *fcu;
char *basePath = NULL;
short flags = 0;
/* build PointerRNA from provided data to obtain the paths to use */
if (pchan)
RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
@ -1219,37 +1219,37 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
RNA_id_pointer_create((ID *)ob, &ptr);
else
return 0;
/* get the basic path to the properties of interest */
basePath = RNA_path_from_ID_to_struct(&ptr);
if (basePath == NULL)
return 0;
/* search F-Curves for the given properties
/* search F-Curves for the given properties
* - we cannot use the groups, since they may not be grouped in that way...
*/
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
const char *bPtr = NULL, *pPtr = NULL;
/* if enough flags have been found, we can stop checking unless we're also getting the curves */
if ((flags == ACT_TRANS_ALL) && (curves == NULL))
break;
/* just in case... */
if (fcu->rna_path == NULL)
continue;
/* step 1: check for matching base path */
bPtr = strstr(fcu->rna_path, basePath);
if (bPtr) {
/* we must add len(basePath) bytes to the match so that we are at the end of the
/* we must add len(basePath) bytes to the match so that we are at the end of the
* base path so that we don't get false positives with these strings in the names
*/
bPtr += strlen(basePath);
/* step 2: check for some property with transforms
* - to speed things up, only check for the ones not yet found
/* step 2: check for some property with transforms
* - to speed things up, only check for the ones not yet found
* unless we're getting the curves too
* - if we're getting the curves, the BLI_genericNodeN() creates a LinkData
* node wrapping the F-Curve, which then gets added to the list
@ -1259,53 +1259,53 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
pPtr = strstr(bPtr, "location");
if (pPtr) {
flags |= ACT_TRANS_LOC;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
}
}
if ((curves) || (flags & ACT_TRANS_SCALE) == 0) {
pPtr = strstr(bPtr, "scale");
if (pPtr) {
flags |= ACT_TRANS_SCALE;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
}
}
if ((curves) || (flags & ACT_TRANS_ROT) == 0) {
pPtr = strstr(bPtr, "rotation");
if (pPtr) {
flags |= ACT_TRANS_ROT;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
}
}
if ((curves) || (flags & ACT_TRANS_BBONE) == 0) {
/* bbone shape properties */
pPtr = strstr(bPtr, "bbone_");
if (pPtr) {
flags |= ACT_TRANS_BBONE;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
}
}
if ((curves) || (flags & ACT_TRANS_SCALE) == 0) {
pPtr = strstr(bPtr, "scale");
if (pPtr) {
flags |= ACT_TRANS_SCALE;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
}
}
if ((curves) || (flags & ACT_TRANS_ROT) == 0) {
pPtr = strstr(bPtr, "rotation");
if (pPtr) {
flags |= ACT_TRANS_ROT;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
}
}
if ((curves) || (flags & ACT_TRANS_BBONE) == 0) {
/* bbone shape properties */
pPtr = strstr(bPtr, "bbone_");
if (pPtr) {
flags |= ACT_TRANS_BBONE;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
}
}
if ((curves) || (flags & ACT_TRANS_PROP) == 0) {
/* custom properties only */
pPtr = strstr(bPtr, "[\""); /* extra '"' comment here to keep my texteditor functionlist working :) */
if (pPtr) {
flags |= ACT_TRANS_PROP;
if (curves)
BLI_addtail(curves, BLI_genericNodeN(fcu));
continue;
@ -1313,10 +1313,10 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
}
}
}
/* free basePath */
MEM_freeN(basePath);
/* return flags found */
return flags;
}
@ -1346,26 +1346,26 @@ void extract_pose_from_pose(bPose *pose, const bPose *src)
void BKE_pose_rest(bPose *pose)
{
bPoseChannel *pchan;
if (!pose)
return;
memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
zero_v3(pchan->loc);
zero_v3(pchan->eul);
unit_qt(pchan->quat);
unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
pchan->roll1 = pchan->roll2 = 0.0f;
pchan->curveInX = pchan->curveInY = 0.0f;
pchan->curveOutX = pchan->curveOutY = 0.0f;
pchan->ease1 = pchan->ease2 = 0.0f;
pchan->scaleIn = pchan->scaleOut = 1.0f;
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
}
}
@ -1374,7 +1374,7 @@ void BKE_pose_rest(bPose *pose)
bool BKE_pose_copy_result(bPose *to, bPose *from)
{
bPoseChannel *pchanto, *pchanfrom;
if (to == NULL || from == NULL) {
printf("Pose copy error, pose to:%p from:%p\n", (void *)to, (void *)from); /* debug temp */
return false;
@ -1391,16 +1391,16 @@ bool BKE_pose_copy_result(bPose *to, bPose *from)
if (pchanto) {
copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
/* used for local constraints */
copy_v3_v3(pchanto->loc, pchanfrom->loc);
copy_qt_qt(pchanto->quat, pchanfrom->quat);
copy_v3_v3(pchanto->eul, pchanfrom->eul);
copy_v3_v3(pchanto->size, pchanfrom->size);
copy_v3_v3(pchanto->pose_head, pchanfrom->pose_head);
copy_v3_v3(pchanto->pose_tail, pchanfrom->pose_tail);
pchanto->roll1 = pchanfrom->roll1;
pchanto->roll2 = pchanfrom->roll2;
pchanto->curveInX = pchanfrom->curveInX;
@ -1411,7 +1411,7 @@ bool BKE_pose_copy_result(bPose *to, bPose *from)
pchanto->ease2 = pchanfrom->ease2;
pchanto->scaleIn = pchanfrom->scaleIn;
pchanto->scaleOut = pchanfrom->scaleOut;
pchanto->rotmode = pchanfrom->rotmode;
pchanto->flag = pchanfrom->flag;
pchanto->protectflag = pchanfrom->protectflag;
@ -1431,27 +1431,27 @@ void BKE_pose_tag_recalc(Main *bmain, bPose *pose)
DAG_relations_tag_update(bmain);
}
/* For the calculation of the effects of an Action at the given frame on an object
/* For the calculation of the effects of an Action at the given frame on an object
* This is currently only used for the Action Constraint
*/
void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
{
bActionGroup *agrp = BKE_action_group_find_name(act, groupname);
/* clear workob */
BKE_object_workob_clear(workob);
/* init workob */
copy_m4_m4(workob->obmat, ob->obmat);
copy_m4_m4(workob->parentinv, ob->parentinv);
copy_m4_m4(workob->constinv, ob->constinv);
workob->parent = ob->parent;
workob->rotmode = ob->rotmode;
workob->trackflag = ob->trackflag;
workob->upflag = ob->upflag;
workob->partype = ob->partype;
workob->par1 = ob->par1;
workob->par2 = ob->par2;
@ -1459,7 +1459,7 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c
workob->constraints.first = ob->constraints.first;
workob->constraints.last = ob->constraints.last;
workob->pose = pose; /* need to set pose too, since this is used for both types of Action Constraint */
if (pose) {
/* This function is most likely to be used with a temporary pose with a single bone in there.
@ -1476,27 +1476,27 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
BLI_strncpy(workob->id.name, "OB<ConstrWorkOb>", sizeof(workob->id.name)); /* we don't use real object name, otherwise RNA screws with the real thing */
/* if we're given a group to use, it's likely to be more efficient (though a bit more dangerous) */
if (agrp) {
/* specifically evaluate this group only */
PointerRNA id_ptr;
/* get RNA-pointer for the workob's ID */
RNA_id_pointer_create(&workob->id, &id_ptr);
/* execute action for this group only */
animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe);
}
else {
AnimData adt = {NULL};
/* init animdata, and attach to workob */
workob->adt = &adt;
adt.recalc = ADT_RECALC_ANIM;
adt.action = act;
/* execute effects of Action on to workob (or it's PoseChannels) */
BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM);
}

@ -92,22 +92,22 @@ void animviz_settings_init(bAnimVizSettings *avs)
/* ------------------- */
/* Free the given motion path's cache */
void animviz_free_motionpath_cache(bMotionPath *mpath)
void animviz_free_motionpath_cache(bMotionPath *mpath)
{
/* sanity check */
if (mpath == NULL)
if (mpath == NULL)
return;
/* free the path if necessary */
if (mpath->points)
MEM_freeN(mpath->points);
/* reset the relevant parameters */
mpath->points = NULL;
mpath->length = 0;
}
/* Free the given motion path instance and its data
/* Free the given motion path instance and its data
* NOTE: this frees the motion path given!
*/
void animviz_free_motionpath(bMotionPath *mpath)
@ -115,10 +115,10 @@ void animviz_free_motionpath(bMotionPath *mpath)
/* sanity check */
if (mpath == NULL)
return;
/* free the cache first */
animviz_free_motionpath_cache(mpath);
/* now the instance itself */
MEM_freeN(mpath);
}
@ -137,11 +137,11 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
{
bAnimVizSettings *avs;
bMotionPath *mpath, **dst;
/* sanity checks */
if (ELEM(NULL, scene, ob))
return NULL;
/* get destination data */
if (pchan) {
/* paths for posechannel - assume that posechannel belongs to the object */
@ -169,9 +169,9 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
*/
if (*dst != NULL) {
int expected_length = avs->path_ef - avs->path_sf;
mpath = *dst;
/* path is "valid" if length is valid, but must also be of the same length as is being requested */
if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) {
/* outer check ensures that we have some curve data for this path */
@ -190,13 +190,13 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
mpath = MEM_callocN(sizeof(bMotionPath), "bMotionPath");
*dst = mpath;
}
/* set settings from the viz settings */
mpath->start_frame = avs->path_sf;
mpath->end_frame = avs->path_ef;
mpath->length = mpath->end_frame - mpath->start_frame;
if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS)
mpath->flag |= MOTIONPATH_FLAG_BHEAD;
else
@ -212,10 +212,10 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
/* allocate a cache */
mpath->points = MEM_callocN(sizeof(bMotionPathVert) * mpath->length, "bMotionPathVerts");
/* tag viz settings as currently having some path(s) which use it */
avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS;
/* return it */
return mpath;
}
@ -225,9 +225,9 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
/* Motion path needing to be baked (mpt) */
typedef struct MPathTarget {
struct MPathTarget *next, *prev;
bMotionPath *mpath; /* motion path in question */
Object *ob; /* source object */
bPoseChannel *pchan; /* source posechannel (if applicable) */
} MPathTarget;
@ -241,28 +241,28 @@ typedef struct MPathTarget {
void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
{
MPathTarget *mpt;
/* object itself first */
if ((ob->avs.recalc & ANIMVIZ_RECALC_PATHS) && (ob->mpath)) {
/* new target for object */
mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob");
BLI_addtail(targets, mpt);
mpt->mpath = ob->mpath;
mpt->ob = ob;
}
/* bones */
if ((ob->pose) && (ob->pose->avs.recalc & ANIMVIZ_RECALC_PATHS)) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((pchan->bone) && (arm->layer & pchan->bone->layer) && (pchan->mpath)) {
/* new target for bone */
mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone");
BLI_addtail(targets, mpt);
mpt->mpath = pchan->mpath;
mpt->ob = ob;
mpt->pchan = pchan;
@ -285,28 +285,28 @@ static void motionpaths_calc_optimise_depsgraph(Main *bmain, Scene *scene, ListB
{
Base *base, *baseNext;
MPathTarget *mpt;
/* make sure our temp-tag isn't already in use */
for (base = scene->base.first; base; base = base->next)
base->object->flag &= ~BA_TEMP_TAG;
/* for each target, dump its object to the start of the list if it wasn't moved already */
for (mpt = targets->first; mpt; mpt = mpt->next) {
for (base = scene->base.first; base; base = baseNext) {
baseNext = base->next;
if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) {
BLI_remlink(&scene->base, base);
BLI_addhead(&scene->base, base);
mpt->ob->flag |= BA_TEMP_TAG;
/* we really don't need to continue anymore once this happens, but this line might really 'break' */
break;
}
}
}
/* "brew me a list that's sorted a bit faster now depsy" */
DAG_scene_relations_rebuild(bmain, scene);
}
@ -322,11 +322,11 @@ static void motionpaths_calc_update_scene(Main *bmain, Scene *scene)
}
else { /* otherwise we can optimize by restricting updates */
Base *base, *last = NULL;
/* only stuff that moves or needs display still */
DAG_scene_update_flags(bmain, scene, scene->lay, true, false);
/* find the last object with the tag
/* find the last object with the tag
* - all those afterwards are assumed to not be relevant for our calculations
*/
/* optimize further by moving out... */
@ -334,14 +334,14 @@ static void motionpaths_calc_update_scene(Main *bmain, Scene *scene)
if (base->object->flag & BA_TEMP_TAG)
last = base;
}
/* perform updates for tagged objects */
/* XXX: this will break if rigs depend on scene or other data that
* is animated but not attached to/updatable from objects */
for (base = scene->base.first; base; base = base->next) {
/* update this object */
BKE_object_handle_update(bmain, bmain->eval_ctx, scene, base->object);
/* if this is the last one we need to update, let's stop to save some time */
if (base == last)
break;
@ -363,21 +363,21 @@ static void motionpaths_calc_update_scene(Main *bmain, Scene *scene)
static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
{
MPathTarget *mpt;
/* for each target, check if it can be baked on the current frame */
for (mpt = targets->first; mpt; mpt = mpt->next) {
bMotionPath *mpath = mpt->mpath;
bMotionPathVert *mpv;
/* current frame must be within the range the cache works for
/* current frame must be within the range the cache works for
* - is inclusive of the first frame, but not the last otherwise we get buffer overruns
*/
if ((CFRA < mpath->start_frame) || (CFRA >= mpath->end_frame))
continue;
/* get the relevant cache vert to write to */
mpv = mpath->points + (CFRA - mpath->start_frame);
/* pose-channel or object path baking? */
if (mpt->pchan) {
/* heads or tails */
@ -387,7 +387,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
else {
copy_v3_v3(mpv->co, mpt->pchan->pose_tail);
}
/* result must be in worldspace */
mul_m4_v3(mpt->ob->obmat, mpv->co);
}
@ -398,7 +398,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
}
}
/* Perform baking of the given object's and/or its bones' transforms to motion paths
/* Perform baking of the given object's and/or its bones' transforms to motion paths
* - scene: current scene
* - ob: object whose flagged motionpaths should get calculated
* - recalc: whether we need to
@ -409,15 +409,15 @@ void animviz_calc_motionpaths(Main *bmain, Scene *scene, ListBase *targets)
MPathTarget *mpt;
int sfra, efra;
int cfra;
/* sanity check */
if (ELEM(NULL, targets, targets->first))
return;
/* set frame values */
cfra = CFRA;
sfra = efra = cfra;
/* TODO: this method could be improved...
* 1) max range for standard baking
* 2) minimum range for recalc baking (i.e. between keyframes, but how?) */
@ -427,34 +427,34 @@ void animviz_calc_motionpaths(Main *bmain, Scene *scene, ListBase *targets)
efra = MAX2(efra, mpt->mpath->end_frame);
}
if (efra <= sfra) return;
/* optimize the depsgraph for faster updates */
/* TODO: whether this is used should depend on some setting for the level of optimizations used */
motionpaths_calc_optimise_depsgraph(bmain, scene, targets);
/* calculate path over requested range */
for (CFRA = sfra; CFRA <= efra; CFRA++) {
/* update relevant data for new frame */
motionpaths_calc_update_scene(bmain, scene);
/* perform baking for targets */
motionpaths_calc_bake_targets(scene, targets);
}
/* reset original environment */
CFRA = cfra;
motionpaths_calc_update_scene(bmain, scene);
/* clear recalc flags from targets */
for (mpt = targets->first; mpt; mpt = mpt->next) {
bAnimVizSettings *avs;
/* get pointer to animviz settings for each target */
if (mpt->pchan)
avs = &mpt->ob->pose->avs;
else
avs = &mpt->ob->avs;
/* clear the flag requesting recalculation of targets */
avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
}
@ -463,7 +463,7 @@ void animviz_calc_motionpaths(Main *bmain, Scene *scene, ListBase *targets)
/* ******************************************************************** */
/* Curve Paths - for curve deforms and/or curve following */
/* free curve path data
/* free curve path data
* NOTE: frees the path itself!
* NOTE: this is increasingly inaccurate with non-uniform BevPoint subdivisions [#24633]
*/
@ -473,7 +473,7 @@ void free_path(Path *path)
MEM_freeN(path);
}
/* calculate a curve-deform path for a curve
/* calculate a curve-deform path for a curve
* - only called from displist.c -> do_makeDispListCurveTypes
*/
void calc_curvepath(Object *ob, ListBase *nurbs)
@ -486,17 +486,17 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
float *fp, *dist, *maxdist, xyz[3];
float fac, d = 0, fac1, fac2;
int a, tot, cycl = 0;
/* in a path vertices are with equal differences: path->len = number of verts */
/* NOW WITH BEVELCURVE!!! */
if (ob == NULL || ob->type != OB_CURVE) {
return;
}
if (ob->curve_cache->path) free_path(ob->curve_cache->path);
ob->curve_cache->path = NULL;
/* weak! can only use first curve */
bl = ob->curve_cache->bev.first;
if (bl == NULL || !bl->nr) {
@ -506,18 +506,18 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
nu = nurbs->first;
ob->curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
/* if POLY: last vertice != first vertice */
cycl = (bl->poly != -1);
tot = cycl ? bl->nr : bl->nr - 1;
path->len = tot + 1;
/* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */
if (path->len < nu->resolu * SEGMENTSU(nu)) {
path->len = nu->resolu * SEGMENTSU(nu);
}
dist = (float *)MEM_mallocN(sizeof(float) * (tot + 1), "calcpathdist");
/* all lengths in *dist */
@ -530,13 +530,13 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
else
sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec);
*fp = *(fp - 1) + len_v3(xyz);
bevp++;
}
path->totdist = *fp;
/* the path verts in path->data */
/* now also with TILT value */
pp = path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint) * path->len, "pathdata");
@ -551,11 +551,11 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
maxdist = dist + tot;
fac = 1.0f / ((float)path->len - 1.0f);
fac = fac * path->totdist;
for (a = 0; a < path->len; a++) {
d = ((float)a) * fac;
/* we're looking for location (distance) 'd' in the array */
if (LIKELY(tot > 0)) {
while ((fp < maxdist) && (d >= *fp)) {
@ -581,10 +581,10 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight;
interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2);
normalize_qt(pp->quat);
pp++;
}
MEM_freeN(dist);
}
@ -628,7 +628,7 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
}
path = ob->curve_cache->path;
pp = path->data;
/* test for cyclic */
bl = ob->curve_cache->bev.first;
if (!bl) return 0;
@ -639,7 +639,7 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
BLI_assert(cycl || ctime >= 0.0f);
ctime *= (path->len - 1);
s1 = (int)floor(ctime);
fac = (float)(s1 + 1) - ctime;

File diff suppressed because it is too large Load Diff

@ -83,18 +83,18 @@ const char *BKE_appdir_folder_default(void)
if (uput_getenv("HOME", documentfolder, MAXPATHLEN)) {
if (BLI_is_dir(documentfolder)) return documentfolder;
}
/* add user profile support for WIN 2K / NT.
* This is %APPDATA%, which translates to either
* %USERPROFILE%\Application Data or since Vista
* to %USERPROFILE%\AppData\Roaming
*/
hResult = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, documentfolder);
if (hResult == S_OK) {
if (BLI_is_dir(documentfolder)) return documentfolder;
}
return NULL;
#endif /* WIN32 */
}
@ -120,7 +120,7 @@ static bool test_path(
const char *path_base, const char *path_sep, const char *folder_name)
{
char tmppath[FILE_MAX];
if (path_sep) {
BLI_join_dirfile(tmppath, sizeof(tmppath), path_base, path_sep);
}
@ -161,7 +161,7 @@ static bool test_env_path(char *path, const char *envvar)
{
const char *env = envvar ? getenv(envvar) : NULL;
if (!env) return false;
if (BLI_is_dir(env)) {
BLI_strncpy(path, env, FILE_MAX);
#ifdef PATH_DEBUG
@ -193,7 +193,7 @@ static bool get_path_local(
const char *folder_name, const char *subfolder_name, const int ver)
{
char relfolder[FILE_MAX];
#ifdef PATH_DEBUG
printf("%s...\n", __func__);
#endif
@ -276,11 +276,11 @@ static bool get_path_user(
if (!user_path[0])
return false;
#ifdef PATH_DEBUG
printf("%s: %s\n", __func__, user_path);
#endif
if (subfolder_name) {
return test_path(targetpath, targetpath_len, user_path, folder_name, subfolder_name);
}
@ -334,14 +334,14 @@ static bool get_path_system(
system_base_path = (const char *)GHOST_getSystemDir(ver, blender_version_decimal(ver));
if (system_base_path)
BLI_strncpy(system_path, system_base_path, FILE_MAX);
if (!system_path[0])
return false;
#ifdef PATH_DEBUG
printf("%s: %s\n", __func__, system_path);
#endif
if (subfolder_name) {
/* try $BLENDERPATH/folder_name/subfolder_name */
return test_path(targetpath, targetpath_len, system_path, folder_name, subfolder_name);
@ -371,16 +371,16 @@ const char *BKE_appdir_folder_id_ex(
if (get_path_local(path, path_len, "datafiles", subfolder, ver)) break;
if (get_path_system(path, path_len, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break;
return NULL;
case BLENDER_USER_DATAFILES:
if (get_path_user(path, path_len, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
return NULL;
case BLENDER_SYSTEM_DATAFILES:
if (get_path_local(path, path_len, "datafiles", subfolder, ver)) break;
if (get_path_system(path, path_len, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break;
return NULL;
case BLENDER_USER_AUTOSAVE:
if (get_path_user(path, path_len, "autosave", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
return NULL;
@ -388,16 +388,16 @@ const char *BKE_appdir_folder_id_ex(
case BLENDER_USER_CONFIG:
if (get_path_user(path, path_len, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break;
return NULL;
case BLENDER_USER_SCRIPTS:
if (get_path_user(path, path_len, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break;
return NULL;
case BLENDER_SYSTEM_SCRIPTS:
if (get_path_local(path, path_len, "scripts", subfolder, ver)) break;
if (get_path_system(path, path_len, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break;
return NULL;
case BLENDER_SYSTEM_PYTHON:
if (get_path_local(path, path_len, "python", subfolder, ver)) break;
if (get_path_system(path, path_len, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break;
@ -407,7 +407,7 @@ const char *BKE_appdir_folder_id_ex(
BLI_assert(0);
break;
}
return path;
}
@ -460,14 +460,14 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold
/* only for user folders */
if (!ELEM(folder_id, BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG, BLENDER_USER_SCRIPTS, BLENDER_USER_AUTOSAVE))
return NULL;
path = BKE_appdir_folder_id(folder_id, subfolder);
if (!path) {
path = BKE_appdir_folder_id_user_notest(folder_id, subfolder);
if (path) BLI_dir_create_recursive(path);
}
return path;
}
@ -739,8 +739,8 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
if (userdir && BLI_is_dir(userdir)) {
BLI_strncpy(fullname, userdir, maxlen);
}
#ifdef WIN32
if (fullname[0] == '\0') {
const char *tmp = getenv("TEMP"); /* Windows */
@ -756,7 +756,7 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
BLI_strncpy(fullname, tmp, maxlen);
}
}
if (fullname[0] == '\0') {
const char *tmp = getenv("TMPDIR");
if (tmp && BLI_is_dir(tmp)) {
@ -764,7 +764,7 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
}
}
#endif
if (fullname[0] == '\0') {
BLI_strncpy(fullname, "/tmp/", maxlen);
}

@ -641,17 +641,17 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
/* add extra rolls */
roll1 += bone->roll1 + (!rest ? pchan->roll1 : 0.0f);
roll2 += bone->roll2 + (!rest ? pchan->roll2 : 0.0f);
if (bone->flag & BONE_ADD_PARENT_END_ROLL) {
if (prev) {
if (prev->bone)
roll1 += prev->bone->roll2;
if (!rest)
roll1 += prev->roll2;
}
}
/* extra curve x / y */
/* NOTE: Scale correction factors here are to compensate for some random floating-point glitches
* when scaling up the bone or it's parent by a factor of approximately 8.15/6, which results
@ -659,14 +659,14 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
*/
const float xscale_correction = (do_scale) ? scale[0] : 1.0f;
const float yscale_correction = (do_scale) ? scale[2] : 1.0f;
h1[0] += (bone->curveInX + (!rest ? pchan->curveInX : 0.0f)) * xscale_correction;
h1[2] += (bone->curveInY + (!rest ? pchan->curveInY : 0.0f)) * yscale_correction;
h2[0] += (bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f)) * xscale_correction;
h2[2] += (bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f)) * yscale_correction;
}
/* make curve */
if (bone->segments > MAX_BBONE_SUBDIV)
bone->segments = MAX_BBONE_SUBDIV;
@ -682,39 +682,39 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
for (a = 0, fp = data[0]; a < bone->segments; a++, fp += 4) {
sub_v3_v3v3(h1, fp + 4, fp);
vec_roll_to_mat3(h1, fp[3], mat3); /* fp[3] is roll */
copy_m4_m3(result_array[a].mat, mat3);
copy_v3_v3(result_array[a].mat[3], fp);
if (do_scale) {
/* correct for scaling when this matrix is used in scaled space */
mul_m4_series(result_array[a].mat, iscalemat, result_array[a].mat, scalemat);
}
/* BBone scale... */
{
const int num_segments = bone->segments;
const float scaleIn = bone->scaleIn * (!rest ? pchan->scaleIn : 1.0f);
const float scaleFactorIn = 1.0f + (scaleIn - 1.0f) * ((float)(num_segments - a) / (float)num_segments);
const float scaleOut = bone->scaleOut * (!rest ? pchan->scaleOut : 1.0f);
const float scaleFactorOut = 1.0f + (scaleOut - 1.0f) * ((float)(a + 1) / (float)num_segments);
const float scalefac = scaleFactorIn * scaleFactorOut;
float bscalemat[4][4], bscale[3];
bscale[0] = scalefac;
bscale[1] = 1.0f;
bscale[2] = scalefac;
size_to_mat4(bscalemat, bscale);
/* Note: don't multiply by inverse scale mat here, as it causes problems with scaling shearing and breaking segment chains */
/*mul_m4_series(result_array[a].mat, ibscalemat, result_array[a].mat, bscalemat);*/
mul_m4_series(result_array[a].mat, result_array[a].mat, bscalemat);
}
}
}
@ -773,10 +773,10 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D
float (*mat)[4] = b_bone[0].mat;
float segment, y;
int a;
/* need to transform co back to bonespace, only need y */
y = mat[0][1] * co[0] + mat[1][1] * co[1] + mat[2][1] * co[2] + mat[3][1];
/* now calculate which of the b_bones are deforming this */
segment = bone->length / ((float)bone->segments);
a = (int)(y / segment);
@ -1818,7 +1818,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
pchanp = BKE_pose_channel_find_name(frompose, pchan->name);
if (UNLIKELY(pchanp == NULL)) {
/* happens for proxies that become invalid because of a missing link
* for regular cases it shouldn't happen at all */
@ -1826,7 +1826,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
else if (pchan->bone->layer & layer_protected) {
ListBase proxylocal_constraints = {NULL, NULL};
bPoseChannel pchanw;
/* copy posechannel to temp, but restore important pointers */
pchanw = *pchanp;
pchanw.bone = pchan->bone;
@ -1842,13 +1842,13 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
/* this is freed so copy a copy, else undo crashes */
if (pchanw.prop) {
pchanw.prop = IDP_CopyProperty(pchanw.prop);
/* use the values from the existing props */
if (pchan->prop) {
IDP_SyncGroupValues(pchanw.prop, pchan->prop);
}
}
/* constraints - proxy constraints are flushed... local ones are added after
* 1. extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints
* 2. copy proxy-pchan's constraints on-to new
@ -1860,29 +1860,29 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
BKE_constraints_proxylocal_extract(&proxylocal_constraints, &pchan->constraints);
BKE_constraints_copy(&pchanw.constraints, &pchanp->constraints, false);
BLI_movelisttolist(&pchanw.constraints, &proxylocal_constraints);
/* constraints - set target ob pointer to own object */
for (con = pchanw.constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == from)
ct->tar = ob;
}
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 0);
}
}
/* free stuff from current channel */
BKE_pose_channel_free(pchan);
/* copy data in temp back over to the cleaned-out (but still allocated) original channel */
*pchan = pchanw;
if (pchan->custom) {

@ -116,7 +116,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
/* only happens on reload file, but violates depsgraph still... fix! */
if (ELEM(NULL, ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
BKE_displist_make_curveTypes(scene, ikData->tar, 0);
/* path building may fail in EditMode after removing verts [#33268]*/
if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
/* BLI_assert(cu->path != NULL); */
@ -422,21 +422,21 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
{
/* improved volume preservation based on the Stretch To constraint */
float final_scale;
/* as the basis for volume preservation, we use the inverse scale factor... */
if (fabsf(scaleFac) != 0.0f) {
/* NOTE: The method here is taken wholesale from the Stretch To constraint */
float bulge = powf(1.0f / fabsf(scaleFac), ikData->bulge);
if (bulge > 1.0f) {
if (ikData->flag & CONSTRAINT_SPLINEIK_USE_BULGE_MAX) {
float bulge_max = max_ff(ikData->bulge_max, 1.0f);
float hard = min_ff(bulge, bulge_max);
float range = bulge_max - 1.0f;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / (float)M_PI_2;
bulge = interpf(soft, hard, ikData->bulge_smooth);
}
}
@ -444,15 +444,15 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
if (ikData->flag & CONSTRAINT_SPLINEIK_USE_BULGE_MIN) {
float bulge_min = CLAMPIS(ikData->bulge_min, 0.0f, 1.0f);
float hard = max_ff(bulge, bulge_min);
float range = 1.0f - bulge_min;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / (float)M_PI_2;
bulge = interpf(soft, hard, ikData->bulge_smooth);
}
}
/* compute scale factor for xz axes from this value */
final_scale = sqrtf(bulge);
}
@ -460,7 +460,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* no scaling, so scale factor is simple */
final_scale = 1.0f;
}
/* apply the scaling (assuming normalised scale) */
mul_v3_fl(poseMat[0], final_scale);
mul_v3_fl(poseMat[2], final_scale);

@ -88,20 +88,20 @@ void BKE_blender_free(void)
}
BKE_spacetypes_free(); /* after free main, it uses space callbacks */
IMB_exit();
BKE_cachefiles_exit();
BKE_images_exit();
DAG_exit();
BKE_brush_system_exit();
RE_texture_rng_exit();
RE_texture_rng_exit();
BLI_callback_global_finalize();
BKE_sequencer_cache_destruct();
IMB_moviecache_destruct();
free_nodesystem();
}
@ -120,7 +120,7 @@ void BKE_blender_version_string(char *version_str, size_t maxncpy, short version
void BKE_blender_globals_init(void)
{
memset(&G, 0, sizeof(Global));
U.savetime = 1;
G_MAIN = BKE_main_new();
@ -321,7 +321,7 @@ int BKE_blender_test_break(void)
if (blender_test_break_cb)
blender_test_break_cb();
}
return (G.is_break == true);
}

@ -71,7 +71,7 @@ void calcAlpha(ImBuf *ibuf)
{
int i;
char *rect;
if (ibuf) {
rect = (char *) ibuf->rect;
for (i = ibuf->x * ibuf->y; i > 0; i--) {
@ -86,21 +86,21 @@ void readBitmapFontVersion0(ImBuf *ibuf, unsigned char *rect, int step)
int glyphcount, bytes, i, index, linelength, ysize;
unsigned char *buffer;
bmFont * bmfont;
linelength = ibuf->x * step;
glyphcount = (rect[6 * step] << 8) | rect[7 * step];
bytes = ((glyphcount - 1) * sizeof(bmGlyph)) + sizeof(bmFont);
ysize = (bytes + (ibuf->x - 1)) / ibuf->x;
if (ysize < ibuf->y) {
/* we're first going to copy all data into a linear buffer.
* step can be 4 or 1 bytes, and the data is not sequential because
* the bitmap was flipped vertically. */
buffer = MEM_mallocN(bytes, "readBitmapFontVersion0:buffer");
index = 0;
for (i = 0; i < bytes; i++) {
buffer[i] = rect[index];
@ -111,12 +111,12 @@ void readBitmapFontVersion0(ImBuf *ibuf, unsigned char *rect, int step)
index -= linelength;
}
}
/* we're now going to endian convert the data */
bmfont = MEM_mallocN(bytes, "readBitmapFontVersion0:bmfont");
index = 0;
/* first read the header */
bmfont->magic[0] = buffer[index++];
bmfont->magic[1] = buffer[index++];
@ -126,7 +126,7 @@ void readBitmapFontVersion0(ImBuf *ibuf, unsigned char *rect, int step)
bmfont->glyphcount = (buffer[index] << 8) | buffer[index + 1]; index += 2;
bmfont->xsize = (buffer[index] << 8) | buffer[index + 1]; index += 2;
bmfont->ysize = (buffer[index] << 8) | buffer[index + 1]; index += 2;
for (i = 0; i < bmfont->glyphcount; i++) {
bmfont->glyphs[i].unicode = (buffer[index] << 8) | buffer[index + 1]; index += 2;
bmfont->glyphs[i].locx = (buffer[index] << 8) | buffer[index + 1]; index += 2;
@ -141,9 +141,9 @@ void readBitmapFontVersion0(ImBuf *ibuf, unsigned char *rect, int step)
printfGlyph(&bmfont->glyphs[i]);
}
}
MEM_freeN(buffer);
if (G.debug & G_DEBUG) {
printf("Oldy = %d Newy = %d\n", ibuf->y, ibuf->y - ysize);
printf("glyphcount = %d\n", glyphcount);
@ -173,7 +173,7 @@ void detectBitmapFont(ImBuf *ibuf)
unsigned char *rect;
unsigned short version;
int i;
if (ibuf != NULL && ibuf->rect != NULL) {
/* bitmap must have an x size that is a power of two */
if (is_power_of_two(ibuf->x)) {
@ -215,7 +215,7 @@ void detectBitmapFont(ImBuf *ibuf)
int locateGlyph(bmFont *bmfont, unsigned short unicode)
{
int min, max, current = 0;
if (bmfont) {
min = 0;
max = bmfont->glyphcount;
@ -242,7 +242,7 @@ int locateGlyph(bmFont *bmfont, unsigned short unicode)
}
}
}
return(current);
}
@ -256,19 +256,19 @@ void matrixGlyph(
{
int index;
bmFont *bmfont;
*centerx = *centery = 0.0;
*sizex = *sizey = 1.0;
*transx = *transy = 0.0;
*movex = *movey = 0.0;
*advance = 1.0;
if (ibuf) {
bmfont = ibuf->userdata;
if (bmfont && (ibuf->userflags & IB_BITMAPFONT)) {
index = locateGlyph(bmfont, unicode);
if (index) {
*sizex = (bmfont->glyphs[index].sizex) / (float) (bmfont->glyphs[0].sizex);
*sizey = (bmfont->glyphs[index].sizey) / (float) (bmfont->glyphs[0].sizey);
@ -279,10 +279,10 @@ void matrixGlyph(
*centery = (ibuf->y - bmfont->glyphs[0].locy) / (float) ibuf->y;
/* 2.0 units is the default size of an object */
*movey = 1.0f - *sizey + 2.0f * (bmfont->glyphs[index].ofsy - bmfont->glyphs[0].ofsy) / (float) bmfont->glyphs[0].sizey;
*movex = *sizex - 1.0f + 2.0f * (bmfont->glyphs[index].ofsx - bmfont->glyphs[0].ofsx) / (float) bmfont->glyphs[0].sizex;
*advance = 2.0f * bmfont->glyphs[index].advance / (float) bmfont->glyphs[0].advance;
// printfGlyph(&bmfont->glyphs[index]);

@ -276,7 +276,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
sub_v3_v3v3(loc, co1, co2);
sub_v3_v3v3(vec, vel1, vel2);
inp = dot_v3v3(vec, vec);
/* velocities not parallel */
@ -286,7 +286,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
if (t > 0.0f && t < t_min) {
madd_v3_v3fl(co1, vel1, t);
madd_v3_v3fl(co2, vel2, t);
sub_v3_v3v3(vec, co2, co1);
len = normalize_v3(vec);
@ -326,7 +326,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
sub_v3_v3v3(loc, co1, co2);
sub_v3_v3v3(vec, vel1, vel2);
inp = dot_v3v3(vec, vec);
/* velocities not parallel */
@ -336,7 +336,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
if (t > 0.0f && t < t_min) {
madd_v3_v3fl(co1, vel1, t);
madd_v3_v3fl(co2, vel2, t);
sub_v3_v3v3(vec, co2, co1);
len = normalize_v3(vec);
@ -394,7 +394,7 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
neighbors = BLI_kdtree_range_search(
epsys->tree, pa->prev_state.co,
&ptn, 2.0f * val->personal_space * pa->size);
if (neighbors > 0 && ptn[0].dist < len) {
sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co);
mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist);
@ -496,13 +496,13 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
sub_v3_v3v3(vec, flbr->loc, flbr->oloc);
mul_v3_fl(vec, 1.0f/bbd->timestep);
}
/* fac is seconds behind leader */
madd_v3_v3fl(loc, vec, -flbr->distance);
sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
else if (p % n) {
@ -559,13 +559,13 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
copy_v3_v3(vec, bbd->sim->psys->particles[p - p%n].prev_state.vel);
copy_v3_v3(loc, bbd->sim->psys->particles[p - p%n].prev_state.co);
}
/* fac is seconds behind leader */
madd_v3_v3fl(loc, vec, -flbr->distance);
sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
@ -611,7 +611,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
bbd->wanted_co[1] = 2.0f*(0.5f - BLI_rng_get_float(bbd->rng));
bbd->wanted_co[2] = 2.0f*(0.5f - BLI_rng_get_float(bbd->rng));
}
/* leveling */
if (asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->scene->physics_settings.gravity);
@ -621,7 +621,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
bbd->wanted_speed = asbr->speed * val->max_speed;
return 1;
}
static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
@ -661,7 +661,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
neighbors = BLI_kdtree_range_search(
epsys->tree, pa->prev_state.co,
&ptn, fbr->distance);
health = 0.0f;
for (n=0; n<neighbors; n++) {
@ -775,7 +775,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
if (bpa->data.mode == eBoidMode_Climbing) {
SurfaceModifierData *surmd = NULL;
float x[3], v[3];
surmd = (SurfaceModifierData *)modifiers_findByType(bpa->ground, eModifierType_Surface );
/* take surface velocity into account */
@ -868,10 +868,10 @@ static int boid_rule_applies(ParticleData *pa, BoidSettings *UNUSED(boids), Boid
if (rule==NULL)
return 0;
if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
return 1;
if (bpa->data.mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
return 1;
@ -1049,7 +1049,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
if (bpa->data.mode == eBoidMode_OnLand) {
/* fuzziness makes boids capable of misjudgement */
float mul = 1.0f + state->rule_fuzziness;
if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) {
float cvel[3], dir[3];
@ -1165,7 +1165,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* auto-leveling & landing if close to ground */
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* level = how many particle sizes above ground */
level = (pa->prev_state.co[2] - ground_co[2])/(2.0f * pa->size) - 0.5f;
@ -1226,7 +1226,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* constrain speed with maximum acceleration */
old_speed = len_v3(pa->prev_state.vel);
if (bbd->wanted_speed < old_speed)
new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc);
else
@ -1273,7 +1273,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
mul_v3_fl(force, length);
}
add_v3_v3(acc, force);
/* store smoothed acceleration for nice banking etc. */
@ -1288,7 +1288,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
copy_v3_v3(dvec, acc);
mul_v3_fl(dvec, dtime*dtime*0.5f);
copy_v3_v3(bvec, pa->prev_state.vel);
mul_v3_fl(bvec, dtime);
add_v3_v3(dvec, bvec);
@ -1467,7 +1467,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
}
negate_v3(mat[2]);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
/* apply rotation */
mat3_to_quat_is_ok(q, mat);
copy_qt_qt(pa->state.rot, q);

@ -271,7 +271,7 @@ void BKE_brush_debug_print_state(Brush *br)
/* create a fake brush and set it to the defaults */
Brush def = {{NULL}};
brush_defaults(&def);
#define BR_TEST(field, t) \
if (br->field != def.field) \
printf("br->" #field " = %" #t ";\n", br->field)
@ -281,7 +281,7 @@ void BKE_brush_debug_print_state(Brush *br)
printf("br->flag |= " #_f ";\n"); \
else if (!(br->flag & _f) && (def.flag & _f)) \
printf("br->flag &= ~" #_f ";\n")
#define BR_TEST_FLAG_OVERLAY(_f) \
if ((br->overlay_flags & _f) && !(def.overlay_flags & _f)) \
printf("br->overlay_flags |= " #_f ";\n"); \
@ -355,7 +355,7 @@ void BKE_brush_debug_print_state(Brush *br)
BR_TEST(sub_col[2], f);
printf("\n");
#undef BR_TEST
#undef BR_TEST_FLAG
}
@ -757,7 +757,7 @@ int BKE_brush_size_get(const Scene *scene, const Brush *brush)
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
int size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
return size;
}

@ -44,25 +44,25 @@
BulletSoftBody *bsbNew(void)
{
BulletSoftBody *bsb;
bsb = MEM_callocN(sizeof(BulletSoftBody), "bulletsoftbody");
bsb->flag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
bsb->linStiff = 0.5f;
bsb->angStiff = 1.0f;
bsb->volume = 1.0f;
bsb->viterations = 0;
bsb->piterations = 2;
bsb->diterations = 0;
bsb->citerations = 4;
bsb->kSRHR_CL = 0.1f;
bsb->kSKHR_CL = 1.f;
bsb->kSSHR_CL = 0.5f;
bsb->kSR_SPLT_CL = 0.5f;
bsb->kSK_SPLT_CL = 0.5f;
bsb->kSS_SPLT_CL = 0.5f;
bsb->kVCF = 1;
@ -80,7 +80,7 @@ BulletSoftBody *bsbNew(void)
bsb->kSHR = 1.0f;
bsb->kAHR = 0.7f;
bsb->collisionflags = 0;
//bsb->collisionflags = OB_BSB_COL_CL_RS + OB_BSB_COL_CL_SS;
bsb->numclusteriterations = 64;

@ -76,7 +76,7 @@ float bvhtree_sphereray_tri_intersection(
const BVHTreeRay *ray, float radius, const float m_dist,
const float v0[3], const float v1[3], const float v2[3])
{
float idist;
float p1[3];
float hit_point[3];
@ -107,7 +107,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3
t2 = vert[face->v3].co;
t3 = face->v4 ? vert[face->v4].co : NULL;
do {
float nearest_tmp[3], dist_sq;
@ -191,7 +191,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
t2 = vert[face->v3].co;
t3 = face->v4 ? vert[face->v4].co : NULL;
do {
float dist;
if (ray->radius == 0.0f)
@ -284,7 +284,7 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3
closest_to_line_segment_v3(nearest_tmp, co, t0, t1);
dist_sq = len_squared_v3v3(nearest_tmp, co);
if (dist_sq < nearest->dist_sq) {
nearest->index = index;
nearest->dist_sq = dist_sq;

@ -139,7 +139,7 @@ void BKE_camera_object_mode(RenderData *rd, Object *cam_ob)
/* get the camera's dof value, takes the dof object into account */
float BKE_camera_object_dof_distance(Object *ob)
{
Camera *cam = (Camera *)ob->data;
Camera *cam = (Camera *)ob->data;
if (ob->type != OB_CAMERA)
return 0.0f;
if (cam->dof_ob) {

@ -289,7 +289,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color);
pbvh_show_mask_set(cddm->pbvh, ob->sculpt->show_mask);
}
/* always build pbvh from original mesh, and only use it for drawing if
* this derivedmesh is just original mesh. it's the multires subsurf dm
@ -310,7 +310,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
me->mvert,
me->totloop, me->totpoly,
looptri);
BKE_pbvh_build_mesh(
cddm->pbvh,
me->mpoly, me->mloop,
@ -417,7 +417,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdg
return;
}
GPU_edge_setup(dm);
gdo = dm->drawObject;
if (gdo->edges && gdo->points) {
@ -469,7 +469,7 @@ static void cdDM_drawFacesSolid(
return;
}
}
GPU_vertex_setup(dm);
GPU_normal_setup(dm);
GPU_triangle_setup(dm);
@ -630,7 +630,7 @@ static void cdDM_drawFacesTex_common(
}
GPU_buffers_unbind();
}
static void cdDM_drawFacesTex(
@ -966,8 +966,8 @@ static void cdDM_drawMappedFacesGLSL(
if (orig == ORIGINDEX_NONE) {
/* since the material is set by setMaterial(), faces with no
* origin can be assumed to be generated by a modifier */
* origin can be assumed to be generated by a modifier */
/* continue */
}
else if (setDrawOptions(userData, orig) == DM_DRAW_OPTION_SKIP)
@ -990,7 +990,7 @@ static void cdDM_drawMappedFacesGLSL(
ln2 = lnors[ltri[1]];
ln3 = lnors[ltri[2]];
}
cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], ltri[0], 0, ln1, smoothnormal);
cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[1], ltri[1], 1, ln2, smoothnormal);
cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], ltri[2], 2, ln3, smoothnormal);
@ -1883,7 +1883,7 @@ static void cdDM_foreachMappedFaceCenter(
else {
orig = i;
}
ml = &cddm->mloop[mp->loopstart];
BKE_mesh_calc_poly_center(mp, ml, mvert, cent);
@ -2182,9 +2182,9 @@ static void loops_to_customdata_corners(
for (i = 0; i < numTex; i++) {
texface = CustomData_get_n(facedata, CD_MTFACE, cdindex, i);
texpoly = CustomData_bmesh_get_n(&bm->pdata, f->head.data, CD_MTEXPOLY, i);
ME_MTEXFACE_CPY(texface, texpoly);
for (j = 0; j < 3; j++) {
l = l3[j];
mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
@ -2194,7 +2194,7 @@ static void loops_to_customdata_corners(
for (i = 0; i < numCol; i++) {
mcol = CustomData_get_n(facedata, CD_MCOL, cdindex, i);
for (j = 0; j < 3; j++) {
l = l3[j];
mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPCOL, i);
@ -2241,18 +2241,18 @@ static DerivedMesh *cddm_from_bmesh_ex(
int *index, add_orig;
CustomDataMask mask;
unsigned int i, j;
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
dm->deformedOnly = 1;
/* don't add origindex layer if one already exists */
add_orig = !CustomData_has_layer(&bm->pdata, CD_ORIGINDEX);
mask = use_mdisps ? CD_MASK_DERIVEDMESH | CD_MASK_MDISPS : CD_MASK_DERIVEDMESH;
/* don't process shapekeys, we only feed them through the modifier stack as needed,
* e.g. for applying modifiers or the like*/
mask &= ~CD_MASK_SHAPEKEY;
@ -2343,7 +2343,7 @@ static DerivedMesh *cddm_from_bmesh_ex(
test_index_face(mf, &dm->faceData, i, 3);
}
}
index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
j = 0;
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
@ -3044,7 +3044,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
newv[i] = 0;
}
}
/* now link target vertices to destination indices */
for (i = 0; i < totvert; i++) {
if (vtargetmap[i] != -1) {
@ -3081,7 +3081,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
newe[i] = -1;
}
}
if (merge_mode == CDDM_MERGE_VERTS_DUMP_IF_EQUAL) {
/* In this mode, we need to determine, whenever a poly' vertices are all mapped */
/* if the targets already make up a poly, in which case the new poly is dropped */
@ -3122,7 +3122,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
mv = cddm->mvert;
for (i = 0; i < totpoly; i++, mp++) {
MPoly *mp_new;
ml = cddm->mloop + mp->loopstart;
/* check faces with all vertices merged */
@ -3326,7 +3326,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
mp_new->totloop = c;
BLI_assert(mp_new->totloop >= 3);
mp_new->loopstart = STACK_SIZE(mloop) - c;
STACK_PUSH(oldp, i);
} /* end of the loop that tests polys */
@ -3337,11 +3337,11 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
BLI_gset_free(poly_gset, NULL);
MEM_freeN(poly_keys);
}
/*create new cddm*/
cddm2 = (CDDerivedMesh *)CDDM_from_template(
(DerivedMesh *)cddm, STACK_SIZE(mvert), STACK_SIZE(medge), 0, STACK_SIZE(mloop), STACK_SIZE(mpoly));
/*update edge indices and copy customdata*/
med = medge;
for (i = 0; i < cddm2->dm.numEdgeData; i++, med++) {
@ -3355,7 +3355,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
CustomData_copy_data(&dm->edgeData, &cddm2->dm.edgeData, olde[i], i, 1);
}
/*update loop indices and copy customdata*/
ml = mloop;
for (i = 0; i < cddm2->dm.numLoopData; i++, ml++) {
@ -3365,19 +3365,19 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
CustomData_copy_data(&dm->loopData, &cddm2->dm.loopData, oldl[i], i, 1);
}
/*copy vertex customdata*/
mv = mvert;
for (i = 0; i < cddm2->dm.numVertData; i++, mv++) {
CustomData_copy_data(&dm->vertData, &cddm2->dm.vertData, oldv[i], i, 1);
}
/*copy poly customdata*/
mp = mpoly;
for (i = 0; i < cddm2->dm.numPolyData; i++, mp++) {
CustomData_copy_data(&dm->polyData, &cddm2->dm.polyData, oldp[i], i, 1);
}
/*copy over data. CustomData_add_layer can do this, need to look it up.*/
memcpy(cddm2->mvert, mvert, sizeof(MVert) * STACK_SIZE(mvert));
memcpy(cddm2->medge, medge, sizeof(MEdge) * STACK_SIZE(medge));
@ -3405,7 +3405,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
/*free old derivedmesh*/
dm->needsFree = 1;
dm->release(dm);
return (DerivedMesh *)cddm2;
}
#endif
@ -3425,7 +3425,7 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
for (i = 0; i < numFaces; i++, mf++) {
BLI_edgeset_add(eh, mf->v1, mf->v2);
BLI_edgeset_add(eh, mf->v2, mf->v3);
if (mf->v4) {
BLI_edgeset_add(eh, mf->v3, mf->v4);
BLI_edgeset_add(eh, mf->v4, mf->v1);
@ -3671,7 +3671,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm)
void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
if (!CustomData_has_layer(&dm->vertData, CD_MVERT))
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, mvert, dm->numVertData);

@ -75,7 +75,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm );
* 2. fill object with standard values or with the GUI settings if given
*/
void cloth_init(ClothModifierData *clmd )
{
{
/* Initialize our new data structure to reasonable values. */
clmd->sim_parms->gravity[0] = 0.0;
clmd->sim_parms->gravity[1] = 0.0;
@ -86,7 +86,7 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->bending = 0.5;
clmd->sim_parms->max_bend = 0.5;
clmd->sim_parms->bending_damping = 0.5;
clmd->sim_parms->Cdis = 5.0;
clmd->sim_parms->Cdis = 5.0;
clmd->sim_parms->Cvi = 1.0;
clmd->sim_parms->mass = 0.3f;
clmd->sim_parms->stepsPerFrame = 5;
@ -102,7 +102,7 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->time_scale = 1.0f; /* multiplies cloth speed */
clmd->sim_parms->reset = 0;
clmd->sim_parms->vel_damping = 1.0f; /* 1.0 = no damping, 0.0 = fully dampened */
clmd->coll_parms->self_friction = 5.0;
clmd->coll_parms->friction = 5.0;
clmd->coll_parms->loop_count = 2;
@ -150,27 +150,27 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps
if (!cloth)
return NULL;
verts = cloth->verts;
/* in the moment, return zero if no faces there */
if (!cloth->mvert_num)
return NULL;
/* create quadtree with k=26 */
bvhtree = BLI_bvhtree_new(cloth->mvert_num, epsilon, 4, 6);
/* fill tree */
for (i = 0; i < cloth->mvert_num; i++, verts++) {
const float *co;
co = verts->xold;
BLI_bvhtree_insert(bvhtree, i, co, 1);
}
/* balance tree */
BLI_bvhtree_balance(bvhtree);
return bvhtree;
}
@ -189,10 +189,10 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon
if (!cloth)
return NULL;
verts = cloth->verts;
vt = cloth->tri;
/* in the moment, return zero if no faces there */
if (!cloth->tri_num)
return NULL;
@ -213,23 +213,23 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon
/* balance tree */
BLI_bvhtree_balance(bvhtree);
return bvhtree;
}
void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving)
{
{
unsigned int i = 0;
Cloth *cloth = clmd->clothObject;
BVHTree *bvhtree = cloth->bvhtree;
ClothVertex *verts = cloth->verts;
const MVertTri *vt;
if (!bvhtree)
return;
vt = cloth->tri;
/* update vertex position in bvh tree */
if (verts && vt) {
for (i = 0; i < cloth->tri_num; i++, vt++) {
@ -252,25 +252,25 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving)
else {
ret = BLI_bvhtree_update_node(bvhtree, i, co[0], NULL, 3);
}
/* check if tree is already full */
if (ret == false) {
break;
}
}
BLI_bvhtree_update_tree(bvhtree);
}
}
void bvhselftree_update_from_cloth(ClothModifierData *clmd, bool moving)
{
{
unsigned int i = 0;
Cloth *cloth = clmd->clothObject;
BVHTree *bvhtree = cloth->bvhselftree;
ClothVertex *verts = cloth->verts;
const MVertTri *vt;
if (!bvhtree)
return;
@ -299,7 +299,7 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, bool moving)
break;
}
}
BLI_bvhtree_update_tree(bvhtree);
}
}
@ -307,13 +307,13 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, bool moving)
void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
{
PTCacheID pid;
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
// don't do anything as long as we're in editmode!
if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT)
return;
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
}
@ -330,13 +330,13 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
modifier_setError(&(clmd->modifier), "Can't initialize cloth");
return 0;
}
if (clmd->clothObject == NULL) {
BKE_ptcache_invalidate(cache);
modifier_setError(&(clmd->modifier), "Null cloth object");
return 0;
}
BKE_cloth_solver_set_positions(clmd);
clmd->clothObject->last_frame= MINFRAME-1;
@ -382,7 +382,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
cloth_update_spring_lengths ( clmd, result );
cloth_update_springs( clmd );
// TIMEIT_START(cloth_step)
/* call the solver. */
@ -393,7 +393,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
pdEndEffectors(&effectors);
// printf ( "%f\n", ( float ) tval() );
return ret;
}
@ -424,7 +424,7 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
cache->last_exact= 0;
cache->flag &= ~PTCACHE_REDO_NEEDED;
}
// unused in the moment, calculated separately in implicit.c
clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
@ -505,13 +505,13 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
void cloth_free_modifier(ClothModifierData *clmd )
{
Cloth *cloth = NULL;
if ( !clmd )
return;
cloth = clmd->clothObject;
if ( cloth ) {
BPH_cloth_solver_free(clmd);
@ -527,12 +527,12 @@ void cloth_free_modifier(ClothModifierData *clmd )
LinkNode *search = cloth->springs;
while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
search = search->next;
}
BLI_linklist_free(cloth->springs, NULL);
cloth->springs = NULL;
}
@ -542,7 +542,7 @@ void cloth_free_modifier(ClothModifierData *clmd )
// free BVH collision tree
if ( cloth->bvhtree )
BLI_bvhtree_free ( cloth->bvhtree );
if ( cloth->bvhselftree )
BLI_bvhtree_free ( cloth->bvhselftree );
@ -552,8 +552,8 @@ void cloth_free_modifier(ClothModifierData *clmd )
if (cloth->edgeset)
BLI_edgeset_free(cloth->edgeset);
/*
if (clmd->clothObject->facemarks)
MEM_freeN(clmd->clothObject->facemarks);
@ -569,12 +569,12 @@ void cloth_free_modifier_extern(ClothModifierData *clmd )
Cloth *cloth = NULL;
if (G.debug_value > 0)
printf("cloth_free_modifier_extern\n");
if ( !clmd )
return;
cloth = clmd->clothObject;
if ( cloth ) {
if (G.debug_value > 0)
printf("cloth_free_modifier_extern in\n");
@ -608,7 +608,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd )
// free BVH collision tree
if ( cloth->bvhtree )
BLI_bvhtree_free ( cloth->bvhtree );
if ( cloth->bvhselftree )
BLI_bvhtree_free ( cloth->bvhselftree );
@ -658,11 +658,11 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte
int cloth_uses_vgroup(ClothModifierData *clmd)
{
return (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) ||
return (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) ||
(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) ||
(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) ||
(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF)) &&
((clmd->sim_parms->vgroup_mass>0) ||
(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF)) &&
((clmd->sim_parms->vgroup_mass>0) ||
(clmd->sim_parms->vgroup_struct>0)||
(clmd->sim_parms->vgroup_bend>0) ||
(clmd->sim_parms->vgroup_shrink>0) ||
@ -691,7 +691,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
mvert_num = dm->getNumVerts(dm);
verts = clothObj->verts;
if (cloth_uses_vgroup(clmd)) {
for (i = 0; i < mvert_num; i++, verts++) {
@ -715,21 +715,21 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
verts->goal = dvert->dw [j].weight;
/* goalfac= 1.0f; */ /* UNUSED */
// Kicking goal factor to simplify things...who uses that anyway?
// ABS ( clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal );
verts->goal = pow4f(verts->goal);
if ( verts->goal >= SOFTGOALSNAP )
verts->flags |= CLOTH_VERT_FLAG_PINNED;
}
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) {
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) {
verts->struct_stiff = dvert->dw [j].weight;
verts->shear_stiff = dvert->dw [j].weight;
}
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) {
verts->bend_stiff = dvert->dw [j].weight;
}
@ -784,7 +784,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
Cloth *cloth = NULL;
float maxdist = 0;
// If we have a clothObject, free it.
// If we have a clothObject, free it.
if ( clmd->clothObject != NULL ) {
cloth_free_modifier ( clmd );
if (G.debug_value > 0)
@ -835,9 +835,9 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
else
copy_v3_v3(verts->xrest, verts->x);
}
/* no GUI interface yet */
verts->mass = clmd->sim_parms->mass;
verts->mass = clmd->sim_parms->mass;
verts->impulse_count = 0;
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
@ -857,7 +857,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
verts->impulse_count = 0;
copy_v3_v3 ( verts->impulse, tnull );
}
// apply / set vertex groups
// has to be happen before springs are build!
cloth_apply_vgroup (clmd, dm);
@ -868,19 +868,19 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
printf("cloth_free_modifier cloth_build_springs\n");
return 0;
}
// init our solver
BPH_cloth_solver_init(ob, clmd);
if (!first)
BKE_cloth_solver_set_positions(clmd);
clmd->clothObject->bvhtree = bvhtree_build_from_cloth ( clmd, MAX2(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel) );
for (i = 0; i < dm->getNumVerts(dm); i++) {
maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0f));
}
clmd->clothObject->bvhselftree = bvhselftree_build_from_cloth ( clmd, maxdist );
return 1;
@ -956,17 +956,17 @@ static void cloth_free_errorsprings(Cloth *cloth, LinkNodePair *edgelist)
LinkNode *search = cloth->springs;
while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
search = search->next;
}
BLI_linklist_free(cloth->springs, NULL);
cloth->springs = NULL;
}
cloth_free_edgelist(edgelist, cloth->mvert_num);
if (cloth->edgeset) {
BLI_edgeset_free(cloth->edgeset);
cloth->edgeset = NULL;
@ -979,10 +979,10 @@ static void cloth_hair_update_bending_targets(ClothModifierData *clmd)
LinkNode *search = NULL;
float hair_frame[3][3], dir_old[3], dir_new[3];
int prev_mn; /* to find hair chains */
if (!clmd->hairdata)
return;
/* XXX Note: we need to propagate frames from the root up,
* but structural hair springs are stored in reverse order.
* The bending springs however are then inserted in the same
@ -990,17 +990,17 @@ static void cloth_hair_update_bending_targets(ClothModifierData *clmd)
* This messy situation can be resolved when solver data is
* generated directly from a dedicated hair system.
*/
prev_mn = -1;
for (search = cloth->springs; search; search = search->next) {
ClothSpring *spring = search->link;
ClothHairData *hair_ij, *hair_kl;
bool is_root = spring->kl != prev_mn;
if (spring->type != CLOTH_SPRING_TYPE_BENDING_ANG) {
continue;
}
hair_ij = &clmd->hairdata[spring->ij];
hair_kl = &clmd->hairdata[spring->kl];
if (is_root) {
@ -1011,39 +1011,39 @@ static void cloth_hair_update_bending_targets(ClothModifierData *clmd)
*/
copy_v3_v3(dir_new, hair_frame[2]);
}
copy_v3_v3(dir_old, dir_new);
sub_v3_v3v3(dir_new, cloth->verts[spring->mn].x, cloth->verts[spring->kl].x);
normalize_v3(dir_new);
#if 0
if (clmd->debug_data && (spring->ij == 0 || spring->ij == 1)) {
float a[3], b[3];
copy_v3_v3(a, cloth->verts[spring->kl].x);
// BKE_sim_debug_data_add_dot(clmd->debug_data, cloth_vert ? cloth_vert->x : key->co, 1, 1, 0, "frames", 8246, p, k);
mul_v3_v3fl(b, hair_frame[0], clmd->sim_parms->avg_spring_len);
BKE_sim_debug_data_add_vector(clmd->debug_data, a, b, 1, 0, 0, "frames", 8247, spring->kl, spring->mn);
mul_v3_v3fl(b, hair_frame[1], clmd->sim_parms->avg_spring_len);
BKE_sim_debug_data_add_vector(clmd->debug_data, a, b, 0, 1, 0, "frames", 8248, spring->kl, spring->mn);
mul_v3_v3fl(b, hair_frame[2], clmd->sim_parms->avg_spring_len);
BKE_sim_debug_data_add_vector(clmd->debug_data, a, b, 0, 0, 1, "frames", 8249, spring->kl, spring->mn);
}
#endif
/* get local targets for kl/mn vertices by putting rest targets into the current frame,
* then multiply with the rest length to get the actual goals
*/
mul_v3_m3v3(spring->target, hair_frame, hair_kl->rest_target);
mul_v3_fl(spring->target, spring->restlen);
/* move frame to next hair segment */
cloth_parallel_transport_hair_frame(hair_frame, dir_old, dir_new);
prev_mn = spring->mn;
}
}
@ -1054,10 +1054,10 @@ static void cloth_hair_update_bending_rest_targets(ClothModifierData *clmd)
LinkNode *search = NULL;
float hair_frame[3][3], dir_old[3], dir_new[3];
int prev_mn; /* to find hair roots */
if (!clmd->hairdata)
return;
/* XXX Note: we need to propagate frames from the root up,
* but structural hair springs are stored in reverse order.
* The bending springs however are then inserted in the same
@ -1065,17 +1065,17 @@ static void cloth_hair_update_bending_rest_targets(ClothModifierData *clmd)
* This messy situation can be resolved when solver data is
* generated directly from a dedicated hair system.
*/
prev_mn = -1;
for (search = cloth->springs; search; search = search->next) {
ClothSpring *spring = search->link;
ClothHairData *hair_ij, *hair_kl;
bool is_root = spring->kl != prev_mn;
if (spring->type != CLOTH_SPRING_TYPE_BENDING_ANG) {
continue;
}
hair_ij = &clmd->hairdata[spring->ij];
hair_kl = &clmd->hairdata[spring->kl];
if (is_root) {
@ -1086,18 +1086,18 @@ static void cloth_hair_update_bending_rest_targets(ClothModifierData *clmd)
*/
copy_v3_v3(dir_new, hair_frame[2]);
}
copy_v3_v3(dir_old, dir_new);
sub_v3_v3v3(dir_new, cloth->verts[spring->mn].xrest, cloth->verts[spring->kl].xrest);
normalize_v3(dir_new);
/* dir expressed in the hair frame defines the rest target direction */
copy_v3_v3(hair_kl->rest_target, dir_new);
mul_transposed_m3_v3(hair_frame, hair_kl->rest_target);
/* move frame to next hair segment */
cloth_parallel_transport_hair_frame(hair_frame, dir_old, dir_new);
prev_mn = spring->mn;
}
}
@ -1146,10 +1146,10 @@ static void cloth_update_springs( ClothModifierData *clmd )
spring->flags |= CLOTH_SPRING_FLAG_DEACTIVATE;
}
}
search = search->next;
}
cloth_hair_update_bending_targets(clmd);
}
@ -1241,10 +1241,10 @@ BLI_INLINE void madd_m3_m3fl(float r[3][3], float m[3][3], float f)
void cloth_parallel_transport_hair_frame(float mat[3][3], const float dir_old[3], const float dir_new[3])
{
float rot[3][3];
/* rotation between segments */
rotation_between_vecs_to_mat3(rot, dir_old, dir_new);
/* rotate the frame */
mul_m3_m3m3(mat, rot, mat);
}
@ -1266,7 +1266,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
LinkNodePair *edgelist;
EdgeSet *edgeset = NULL;
LinkNode *search = NULL, *search2 = NULL;
// error handling
if ( numedges==0 )
return 0;
@ -1280,7 +1280,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
cloth->edgeset = NULL;
edgelist = MEM_callocN(sizeof(*edgelist) * mvert_num, "cloth_edgelist_alloc" );
if (!edgelist)
return 0;
@ -1312,7 +1312,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
spring->flags = 0;
struct_springs++;
BLI_linklist_prepend ( &cloth->springs, spring );
}
else {
@ -1323,7 +1323,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if (struct_springs_real > 0)
clmd->sim_parms->avg_spring_len /= struct_springs_real;
for (i = 0; i < mvert_num; i++) {
if (cloth->verts[i].spring_count > 0)
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count);
@ -1413,15 +1413,15 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
while (search && search2) {
tspring = search->link;
tspring2 = search2->link;
if (tspring->ij == tspring2->kl) {
spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
if (!spring) {
cloth_free_errorsprings(cloth, edgelist);
return 0;
}
spring->ij = tspring2->ij;
spring->kl = tspring->ij;
spring->mn = tspring->kl;
@ -1429,10 +1429,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
spring->type = CLOTH_SPRING_TYPE_BENDING_ANG;
spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f;
bend_springs++;
BLI_linklist_prepend ( &cloth->springs, spring );
}
search = search->next;
search2 = search2->next;
}
@ -1450,33 +1450,33 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
while (search && search2) {
tspring = search->link;
tspring2 = search2->link;
if (tspring->ij == tspring2->kl) {
spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
if (!spring) {
cloth_free_errorsprings(cloth, edgelist);
return 0;
}
spring->ij = tspring2->ij;
spring->kl = tspring->kl;
spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
spring->type = CLOTH_SPRING_TYPE_BENDING;
spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f;
bend_springs++;
BLI_linklist_prepend ( &cloth->springs, spring );
}
search = search->next;
search2 = search2->next;
}
}
cloth_hair_update_bending_rest_targets(clmd);
}
/* note: the edges may already exist so run reinsert */
/* insert other near springs in edgeset AFTER bending springs are calculated (for selfcolls) */
@ -1490,10 +1490,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
BLI_edgeset_add(edgeset, mloop[mpoly[i].loopstart + 1].v, mloop[mpoly[i].loopstart + 3].v);
}
}
cloth->numsprings = struct_springs + shear_springs + bend_springs;
cloth_free_edgelist(edgelist, mvert_num);
#if 0

@ -444,7 +444,7 @@ static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2,
float v1[3], v2[3], relativeVelocity[3];
// calc relative velocity
// compute barycentric coordinates for both collision points
collision_compute_barycentric ( collpair->pa,
verts1[collpair->ap1].txold,
@ -487,14 +487,14 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned
/* only get objects with collision modifier */
if (((modifier_type == eModifierType_Collision) && ob->pd && ob->pd->deflect) || (modifier_type != eModifierType_Collision))
cmd= (CollisionModifierData *)modifiers_findByType(ob, modifier_type);
if (cmd) {
/* extend array */
if (*numobj >= *maxobj) {
*maxobj *= 2;
*objs= MEM_reallocN(*objs, sizeof(Object *)*(*maxobj));
}
(*objs)[*numobj] = ob;
(*numobj)++;
}
@ -511,7 +511,7 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned
}
// return all collision objects in scene
// collision object will exclude self
// collision object will exclude self
Object **get_collisionobjects_ext(Scene *scene, Object *self, Group *group, int layer, unsigned int *numcollobj, unsigned int modifier_type, bool dupli)
{
Base *base;
@ -519,7 +519,7 @@ Object **get_collisionobjects_ext(Scene *scene, Object *self, Group *group, int
GroupObject *go;
unsigned int numobj= 0, maxobj= 100;
int level = dupli ? 0 : 1;
objs= MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray");
/* gather all collision objects */
@ -560,7 +560,7 @@ static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self,
if (ob->pd && ob->pd->deflect)
cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
if (cmd && cmd->bvhtree) {
if (*objs == NULL)
*objs = MEM_callocN(sizeof(ListBase), "ColliderCache array");
@ -588,7 +588,7 @@ ListBase *get_collider_cache(Scene *scene, Object *self, Group *group)
{
GroupObject *go;
ListBase *objs= NULL;
/* add object in same layer in scene */
if (group) {
for (go= group->gobject.first; go; go= go->next)
@ -623,7 +623,7 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis
CollPair **collisions, CollPair **collisions_index, int numresult, BVHTreeOverlap *overlap, double dt)
{
int i;
*collisions = (CollPair *) MEM_mallocN(sizeof(CollPair) * numresult * 4, "collision array" ); // * 4 since cloth_collision_static can return more than 1 collision
*collisions_index = *collisions;
@ -640,10 +640,10 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
ClothVertex *verts = NULL;
int ret = 0;
int result = 0;
mvert_num = clmd->clothObject->mvert_num;
verts = cloth->verts;
// process all collisions (calculate impulses, TODO: also repulses if distance too short)
result = 1;
for ( j = 0; j < 2; j++ ) { /* 5 is just a value that ensures convergence */
@ -689,7 +689,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ) || cloth_bvh==NULL)
return 0;
verts = cloth->verts;
/* numfaces = cloth->numfaces; */ /* UNUSED */
mvert_num = cloth->mvert_num;
@ -701,9 +701,9 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
// update cloth bvh
bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function)
bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function)
collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
if (!collobjs)
return 0;
@ -721,31 +721,31 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
do {
CollPair **collisions, **collisions_index;
ret2 = 0;
collisions = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair");
collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair");
// check all collision objects
for (i = 0; i < numcollobj; i++) {
Object *collob= collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision);
BVHTreeOverlap *overlap = NULL;
unsigned int result = 0;
if (!collmd->bvhtree)
continue;
/* search for overlapping collision pairs */
overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL);
// go to next object if no overlap is there
if ( result && overlap ) {
/* check if collisions really happen (costly near check) */
cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i],
cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i],
&collisions_index[i], result, overlap, dt/(float)clmd->coll_parms->loop_count);
// resolve nearby collisions
ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]);
ret2 += ret;
@ -755,11 +755,11 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
MEM_freeN ( overlap );
}
rounds++;
for (i = 0; i < numcollobj; i++) {
if ( collisions[i] ) MEM_freeN ( collisions[i] );
}
MEM_freeN(collisions);
MEM_freeN(collisions_index);
@ -779,8 +779,8 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
VECADD ( verts[i].tx, verts[i].txold, verts[i].tv );
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Test on *simple* selfcollisions
////////////////////////////////////////////////////////////
@ -789,15 +789,15 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
/* TODO: add coll quality rounds again */
BVHTreeOverlap *overlap = NULL;
unsigned int result = 0;
// collisions = 1;
verts = cloth->verts; // needed for openMP
/* numfaces = cloth->numfaces; */ /* UNUSED */
mvert_num = cloth->mvert_num;
verts = cloth->verts;
if ( cloth->bvhselftree ) {
// search for overlapping collision pairs
overlap = BLI_bvhtree_overlap(cloth->bvhselftree, cloth->bvhselftree, &result, NULL, NULL);
@ -807,12 +807,12 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
float temp[3];
float length = 0;
float mindistance;
i = overlap[k].indexA;
j = overlap[k].indexB;
mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len );
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) &&
( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
@ -826,20 +826,20 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
{
continue;
}
sub_v3_v3v3(temp, verts[i].tx, verts[j].tx);
if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
if (BLI_edgeset_haskey(cloth->edgeset, i, j)) {
continue;
}
length = normalize_v3(temp );
if ( length < mindistance ) {
float correction = mindistance - length;
if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
mul_v3_fl(temp, -correction);
VECADD ( verts[j].tx, verts[j].tx, temp );
@ -851,7 +851,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
else {
mul_v3_fl(temp, correction * -0.5f);
VECADD ( verts[j].tx, verts[j].tx, temp );
sub_v3_v3v3(verts[i].tx, verts[i].tx, temp);
}
ret = 1;
@ -861,10 +861,10 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
// check for approximated time collisions
}
}
if ( overlap )
MEM_freeN ( overlap );
}
}
////////////////////////////////////////////////////////////
@ -883,7 +883,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
}
}
while ( ret2 && ( clmd->coll_parms->loop_count>rounds ) );
if (collobjs)
MEM_freeN(collobjs);
@ -900,14 +900,14 @@ BLI_INLINE void max_v3_v3v3(float r[3], const float a[3], const float b[3])
void collision_get_collider_velocity(float vel_old[3], float vel_new[3], CollisionModifierData *collmd, CollPair *collpair)
{
float u1, u2, u3;
/* compute barycentric coordinates */
collision_compute_barycentric(collpair->pb,
collmd->current_x[collpair->bp1].co,
collmd->current_x[collpair->bp2].co,
collmd->current_x[collpair->bp3].co,
&u1, &u2, &u3);
collision_interpolateOnTriangle(vel_new, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3);
/* XXX assume constant velocity of the collider for now */
copy_v3_v3(vel_old, vel_new);
@ -920,7 +920,7 @@ static bool cloth_points_collision_response_static(ClothModifierData *clmd, Coll
float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - pd->pdef_sbdamp);
float inv_dt = 1.0f / dt;
Cloth *cloth1 = clmd->clothObject;
// float w1, w2;
float u1, u2, u3;
float v1[3], v2_old[3], v2_new[3], v_rel_old[3], v_rel_new[3];
@ -974,20 +974,20 @@ static bool cloth_points_collision_response_static(ClothModifierData *clmd, Coll
float v_nor_old, v_nor_new;
float v_tan_old[3], v_tan_new[3];
float bounce, repulse;
/* Collision response based on
* "Simulating Complex Hair with Robust Collision Handling" (Choe, Choi, Ko, ACM SIGGRAPH 2005)
* http://graphics.snu.ac.kr/publications/2005-choe-HairSim/Choe_2005_SCA.pdf
*/
v_nor_old = mag_v_rel;
v_nor_new = dot_v3v3(v_rel_new, collpair->normal);
madd_v3_v3v3fl(v_tan_old, v_rel_old, collpair->normal, -v_nor_old);
madd_v3_v3v3fl(v_tan_new, v_rel_new, collpair->normal, -v_nor_new);
repulse = -margin_distance * inv_dt + dot_v3v3(v1, collpair->normal);
if (margin_distance < -epsilon2) {
bounce = -v_nor_new + v_nor_old * restitution;
mul_v3_v3fl(impulse, collpair->normal, max_ff(repulse, bounce));
@ -997,10 +997,10 @@ static bool cloth_points_collision_response_static(ClothModifierData *clmd, Coll
mul_v3_v3fl(impulse, collpair->normal, repulse);
}
cloth1->verts[collpair->ap1].impulse_count++;
result = true;
}
if (result) {
int i = 0;
@ -1018,21 +1018,21 @@ BLI_INLINE bool cloth_point_face_collision_params(const float p1[3], const float
{
float edge1[3], edge2[3], p2face[3], p1p2[3], v0p2[3];
float nor_v0p2, nor_p1p2;
sub_v3_v3v3(edge1, v1, v0);
sub_v3_v3v3(edge2, v2, v0);
cross_v3_v3v3(r_nor, edge1, edge2);
normalize_v3(r_nor);
nor_v0p2 = dot_v3v3(v0p2, r_nor);
madd_v3_v3v3fl(p2face, p2, r_nor, -nor_v0p2);
interp_weights_tri_v3(r_w, v0, v1, v2, p2face);
sub_v3_v3v3(p1p2, p2, p1);
sub_v3_v3v3(v0p2, p2, v0);
nor_p1p2 = dot_v3v3(p1p2, r_nor);
*r_lambda = (nor_p1p2 != 0.0f ? nor_v0p2 / nor_p1p2 : 0.0f);
return r_w[1] >= 0.0f && r_w[2] >= 0.0f && r_w[1] + r_w[2] <= 1.0f;
#if 0 /* XXX this method uses the intersection point, but is broken and doesn't work well in general */
@ -1089,7 +1089,7 @@ static CollPair *cloth_point_collpair(
if (!cloth_point_face_collision_params(p1, p2, co1, co2, co3, facenor, &lambda, w))
return collpair;
sub_v3_v3v3(v1p1, p1, co1);
// distance1 = dot_v3v3(v1p1, facenor);
sub_v3_v3v3(v1p2, p2, co1);
@ -1097,7 +1097,7 @@ static CollPair *cloth_point_collpair(
// if (distance2 > epsilon || (distance1 < 0.0f && distance2 < 0.0f))
if (distance2 > epsilon)
return collpair;
collpair->face1 = index_cloth; /* XXX actually not a face, but equivalent index for point */
collpair->face2 = index_coll;
collpair->ap1 = index_cloth;
@ -1105,20 +1105,20 @@ static CollPair *cloth_point_collpair(
collpair->bp1 = bp1;
collpair->bp2 = bp2;
collpair->bp3 = bp3;
/* note: using the second point here, which is
* the current updated position that needs to be corrected
*/
copy_v3_v3(collpair->pa, p2);
collpair->distance = distance2;
mul_v3_v3fl(collpair->vector, facenor, -distance2);
interp_v3_v3v3v3(collpair->pb, co1, co2, co3, w);
copy_v3_v3(collpair->normal, facenor);
collpair->time = lambda;
collpair->flag = 0;
collpair++;
return collpair;
}
@ -1153,7 +1153,7 @@ static void cloth_points_objcollisions_nearcheck(
int numresult, BVHTreeOverlap *overlap, float epsilon, double dt)
{
int i;
/* can return 2 collisions in total */
*collisions = (CollPair *) MEM_mallocN(sizeof(CollPair) * numresult * 2, "collision array" );
*collisions_index = *collisions;
@ -1172,11 +1172,11 @@ static int cloth_points_objcollisions_resolve(
int i = 0, mvert_num = clmd->clothObject->mvert_num;
ClothVertex *verts = cloth->verts;
int ret = 0;
// process all collisions
if ( collmd->bvhtree ) {
bool result = cloth_points_collision_response_static(clmd, collmd, pd, collisions, collisions_index, dt);
// apply impulses in parallel
if (result) {
for (i = 0; i < mvert_num; i++) {
@ -1186,13 +1186,13 @@ static int cloth_points_objcollisions_resolve(
VECADD ( verts[i].tv, verts[i].tv, verts[i].impulse);
zero_v3(verts[i].impulse);
verts[i].impulse_count = 0;
ret++;
}
}
}
}
return ret;
}
@ -1208,32 +1208,32 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f
int ret = 0, ret2 = 0;
Object **collobjs = NULL;
unsigned int numcollobj = 0;
verts = cloth->verts;
mvert_num = cloth->mvert_num;
////////////////////////////////////////////////////////////
// static collisions
////////////////////////////////////////////////////////////
// create temporary cloth points bvh
cloth_bvh = BLI_bvhtree_new(mvert_num, max_ff(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel), 4, 6);
/* fill tree */
for (i = 0; i < mvert_num; i++) {
float co[2][3];
copy_v3_v3(co[0], verts[i].x);
copy_v3_v3(co[1], verts[i].tx);
BLI_bvhtree_insert(cloth_bvh, i, co[0], 2);
}
/* balance tree */
BLI_bvhtree_balance(cloth_bvh);
collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
if (!collobjs)
return 0;
/* move object to position (step) in time */
for (i = 0; i < numcollobj; i++) {
Object *collob= collobjs[i];
@ -1247,12 +1247,12 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f
do {
CollPair **collisions, **collisions_index;
ret2 = 0;
collisions = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair");
collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair");
// check all collision objects
for (i = 0; i < numcollobj; i++) {
Object *collob= collobjs[i];
@ -1260,35 +1260,35 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f
BVHTreeOverlap *overlap = NULL;
unsigned int result = 0;
float epsilon;
if (!collmd->bvhtree)
continue;
/* search for overlapping collision pairs */
overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL);
epsilon = BLI_bvhtree_get_epsilon(collmd->bvhtree);
// go to next object if no overlap is there
if (result && overlap) {
/* check if collisions really happen (costly near check) */
cloth_points_objcollisions_nearcheck(clmd, collmd, &collisions[i], &collisions_index[i],
result, overlap, epsilon, round_dt);
// resolve nearby collisions
ret += cloth_points_objcollisions_resolve(clmd, collmd, collob->pd, collisions[i], collisions_index[i], round_dt);
ret2 += ret;
}
if (overlap)
MEM_freeN ( overlap );
}
rounds++;
for (i = 0; i < numcollobj; i++) {
if (collisions[i])
MEM_freeN(collisions[i]);
}
MEM_freeN(collisions);
MEM_freeN(collisions_index);
@ -1310,7 +1310,7 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f
////////////////////////////////////////////////////////////
}
while ( ret2 && ( clmd->coll_parms->loop_count>rounds ) );
if (collobjs)
MEM_freeN(collobjs);
@ -1326,53 +1326,53 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step,
BVHTree *cloth_bvh;
unsigned int i = 0, mvert_num = 0;
ClothVertex *verts = NULL;
ColliderContacts *collider_contacts;
Object **collobjs = NULL;
unsigned int numcollobj = 0;
verts = cloth->verts;
mvert_num = cloth->mvert_num;
////////////////////////////////////////////////////////////
// static collisions
////////////////////////////////////////////////////////////
// create temporary cloth points bvh
cloth_bvh = BLI_bvhtree_new(mvert_num, max_ff(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel), 4, 6);
/* fill tree */
for (i = 0; i < mvert_num; i++) {
float co[6];
copy_v3_v3(&co[0*3], verts[i].x);
copy_v3_v3(&co[1*3], verts[i].tx);
BLI_bvhtree_insert(cloth_bvh, i, co, 2);
}
/* balance tree */
BLI_bvhtree_balance(cloth_bvh);
collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
if (!collobjs) {
*r_collider_contacts = NULL;
*r_totcolliders = 0;
return;
}
/* move object to position (step) in time */
for (i = 0; i < numcollobj; i++) {
Object *collob= collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision);
if (!collmd->bvhtree)
continue;
/* move object to position (step) in time */
collision_move_object ( collmd, step + dt, step );
}
collider_contacts = MEM_callocN(sizeof(ColliderContacts) * numcollobj, "CollPair");
// check all collision objects
for (i = 0; i < numcollobj; i++) {
ColliderContacts *ct = collider_contacts + i;
@ -1381,46 +1381,46 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step,
BVHTreeOverlap *overlap;
unsigned int result = 0;
float epsilon;
ct->ob = collob;
ct->collmd = collmd;
ct->collisions = NULL;
ct->totcollisions = 0;
if (!collmd->bvhtree)
continue;
/* search for overlapping collision pairs */
overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL);
epsilon = BLI_bvhtree_get_epsilon(collmd->bvhtree);
// go to next object if no overlap is there
if (result && overlap) {
CollPair *collisions_index;
/* check if collisions really happen (costly near check) */
cloth_points_objcollisions_nearcheck(clmd, collmd, &ct->collisions, &collisions_index,
result, overlap, epsilon, dt);
ct->totcollisions = (int)(collisions_index - ct->collisions);
// resolve nearby collisions
// ret += cloth_points_objcollisions_resolve(clmd, collmd, collob->pd, collisions[i], collisions_index[i], dt);
}
if (overlap)
MEM_freeN(overlap);
}
if (collobjs)
MEM_freeN(collobjs);
BLI_bvhtree_free(cloth_bvh);
////////////////////////////////////////////////////////////
// update positions
// this is needed for bvh_calc_DOP_hull_moving() [kdop.c]
////////////////////////////////////////////////////////////
// verts come from clmd
for (i = 0; i < mvert_num; i++) {
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) {
@ -1428,11 +1428,11 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step,
continue;
}
}
VECADD(verts[i].tx, verts[i].txold, verts[i].tv);
}
////////////////////////////////////////////////////////////
*r_collider_contacts = collider_contacts;
*r_totcolliders = numcollobj;
}

@ -62,21 +62,21 @@ void curvemapping_set_defaults(CurveMapping *cumap, int tot, float minx, float m
{
int a;
float clipminx, clipminy, clipmaxx, clipmaxy;
cumap->flag = CUMA_DO_CLIP;
if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */
clipminx = min_ff(minx, maxx);
clipminy = min_ff(miny, maxy);
clipmaxx = max_ff(minx, maxx);
clipmaxy = max_ff(miny, maxy);
BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy);
cumap->clipr = cumap->curr;
cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
cumap->bwmul[0] = cumap->bwmul[1] = cumap->bwmul[2] = 1.0f;
for (a = 0; a < tot; a++) {
cumap->cm[a].flag = CUMA_EXTEND_EXTRAPOLATE;
cumap->cm[a].totpoint = 2;
@ -187,7 +187,7 @@ bool curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
{
CurveMapPoint *cmp;
int a, b, removed = 0;
/* must have 2 points minimum */
if (cuma->totpoint <= 2)
return false;
@ -204,7 +204,7 @@ bool curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
removed++;
}
}
MEM_freeN(cuma->curve);
cuma->curve = cmp;
cuma->totpoint -= removed;
@ -216,7 +216,7 @@ void curvemap_remove(CurveMap *cuma, const short flag)
{
CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points");
int a, b, removed = 0;
/* well, lets keep the two outer points! */
cmp[0] = cuma->curve[0];
for (a = 1, b = 1; a < cuma->totpoint - 1; a++) {
@ -229,7 +229,7 @@ void curvemap_remove(CurveMap *cuma, const short flag)
}
}
cmp[b] = cuma->curve[a];
MEM_freeN(cuma->curve);
cuma->curve = cmp;
cuma->totpoint -= removed;
@ -359,11 +359,11 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
if (slope == CURVEMAP_SLOPE_POSITIVE) {
int i, last = cuma->totpoint - 1;
CurveMapPoint *newpoints = MEM_dupallocN(cuma->curve);
for (i = 0; i < cuma->totpoint; i++) {
newpoints[i].y = cuma->curve[last - i].y;
}
MEM_freeN(cuma->curve);
cuma->curve = newpoints;
}
@ -397,7 +397,7 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
void curvemap_handle_set(CurveMap *cuma, int type)
{
int a;
for (a = 0; a < cuma->totpoint; a++) {
if (cuma->curve[a].flag & CUMA_SELECT) {
cuma->curve[a].flag &= ~(CUMA_HANDLE_VECTOR | CUMA_HANDLE_AUTO_ANIM);
@ -435,9 +435,9 @@ static void calchandle_curvemap(
if (bezt->h1 == 0 && bezt->h2 == 0) {
return;
}
p2 = bezt->vec[1];
if (prev == NULL) {
p3 = next->vec[1];
pt[0] = 2.0f * p2[0] - p3[0];
@ -447,7 +447,7 @@ static void calchandle_curvemap(
else {
p1 = prev->vec[1];
}
if (next == NULL) {
p1 = prev->vec[1];
pt[0] = 2.0f * p2[0] - p1[0];
@ -474,7 +474,7 @@ static void calchandle_curvemap(
len = len_v2(tvec) * 2.5614f;
if (len != 0.0f) {
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) {
len_a /= len;
madd_v2_v2v2fl(p2_h1, p2, tvec, -len_a);
@ -541,7 +541,7 @@ static void calchandle_curvemap(
#undef p2_h2
}
/* in X, out Y.
/* in X, out Y.
* X is presumed to be outside first or last */
static float curvemap_calc_extend(const CurveMap *cuma, float x, const float first[2], const float last[2])
{
@ -579,16 +579,16 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
BezTriple *bezt;
float *fp, *allpoints, *lastpoint, curf, range;
int a, totpoint;
if (cuma->curve == NULL) return;
/* default rect also is table range */
cuma->mintable = clipr->xmin;
cuma->maxtable = clipr->xmax;
/* hrmf... we now rely on blender ipo beziers, these are more advanced */
bezt = MEM_callocN(cuma->totpoint * sizeof(BezTriple), "beztarr");
for (a = 0; a < cuma->totpoint; a++) {
cuma->mintable = min_ff(cuma->mintable, cmp[a].x);
cuma->maxtable = max_ff(cuma->maxtable, cmp[a].x);
@ -604,27 +604,27 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
bezt[a].h1 = bezt[a].h2 = HD_AUTO;
}
}
const BezTriple *bezt_prev = NULL;
for (a = 0; a < cuma->totpoint; a++) {
const BezTriple *bezt_next = (a != cuma->totpoint - 1) ? &bezt[a + 1] : NULL;
calchandle_curvemap(&bezt[a], bezt_prev, bezt_next);
bezt_prev = &bezt[a];
}
/* first and last handle need correction, instead of pointing to center of next/prev,
/* first and last handle need correction, instead of pointing to center of next/prev,
* we let it point to the closest handle */
if (cuma->totpoint > 2) {
float hlen, nlen, vec[3];
if (bezt[0].h2 == HD_AUTO) {
hlen = len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
/* clip handle point */
copy_v3_v3(vec, bezt[1].vec[0]);
if (vec[0] < bezt[0].vec[1][0])
vec[0] = bezt[0].vec[1][0];
sub_v3_v3(vec, bezt[0].vec[1]);
nlen = len_v3(vec);
if (nlen > FLT_EPSILON) {
@ -635,13 +635,13 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
}
a = cuma->totpoint - 1;
if (bezt[a].h2 == HD_AUTO) {
hlen = len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
/* clip handle point */
copy_v3_v3(vec, bezt[a - 1].vec[2]);
if (vec[0] > bezt[a].vec[1][0])
vec[0] = bezt[a].vec[1][0];
sub_v3_v3(vec, bezt[a].vec[1]);
nlen = len_v3(vec);
if (nlen > FLT_EPSILON) {
@ -656,13 +656,13 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
MEM_freeN(cuma->table);
totpoint = (cuma->totpoint - 1) * CM_RESOL;
fp = allpoints = MEM_callocN(totpoint * 2 * sizeof(float), "table");
for (a = 0; a < cuma->totpoint - 1; a++, fp += 2 * CM_RESOL) {
correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 1].vec[1]);
BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a + 1].vec[0][0], bezt[a + 1].vec[1][0], fp, CM_RESOL - 1, 2 * sizeof(float));
BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a + 1].vec[0][1], bezt[a + 1].vec[1][1], fp + 1, CM_RESOL - 1, 2 * sizeof(float));
}
/* store first and last handle for extrapolation, unit length */
cuma->ext_in[0] = bezt[0].vec[0][0] - bezt[0].vec[1][0];
cuma->ext_in[1] = bezt[0].vec[0][1] - bezt[0].vec[1][1];
@ -676,13 +676,13 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
range = sqrtf(cuma->ext_out[0] * cuma->ext_out[0] + cuma->ext_out[1] * cuma->ext_out[1]);
cuma->ext_out[0] /= range;
cuma->ext_out[1] /= range;
/* cleanup */
MEM_freeN(bezt);
range = CM_TABLEDIV * (cuma->maxtable - cuma->mintable);
cuma->range = 1.0f / range;
/* now make a table with CM_TABLE equal x distances */
fp = allpoints;
lastpoint = allpoints + 2 * (totpoint - 1);
@ -691,7 +691,7 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
for (a = 0; a <= CM_TABLE; a++) {
curf = cuma->mintable + range * (float)a;
cmp[a].x = curf;
/* get the first x coordinate larger than curf */
while (curf >= fp[0] && fp != lastpoint) {
fp += 2;
@ -708,7 +708,7 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
cmp[a].y = fac1 * fp[-1] + (1.0f - fac1) * fp[1];
}
}
MEM_freeN(allpoints);
cuma->table = cmp;
}
@ -718,7 +718,7 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
void curvemapping_premultiply(CurveMapping *cumap, int restore)
{
int a;
if (restore) {
if (cumap->flag & CUMA_PREMULLED) {
for (a = 0; a < 3; a++) {
@ -731,7 +731,7 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
zero_v2(cumap->cm[a].premul_ext_in);
zero_v2(cumap->cm[a].premul_ext_out);
}
cumap->flag &= ~CUMA_PREMULLED;
}
}
@ -745,10 +745,10 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
cumap->cm[a].table = MEM_mallocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "premul table");
memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE + 1) * sizeof(CurveMapPoint));
}
if (cumap->cm[3].table == NULL)
curvemap_make_table(cumap->cm + 3, &cumap->clipr);
/* premul */
for (a = 0; a < 3; a++) {
int b;
@ -761,7 +761,7 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
mul_v2_v2(cumap->cm[a].ext_in, cumap->cm[3].ext_in);
mul_v2_v2(cumap->cm[a].ext_out, cumap->cm[3].ext_out);
}
cumap->flag |= CUMA_PREMULLED;
}
}
@ -770,7 +770,7 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
static int sort_curvepoints(const void *a1, const void *a2)
{
const struct CurveMapPoint *x1 = a1, *x2 = a2;
if (x1->x > x2->x) return 1;
else if (x1->x < x2->x) return -1;
return 0;
@ -821,10 +821,10 @@ void curvemapping_changed(CurveMapping *cumap, const bool rem_doubles)
cumap->curr.ymax = cumap->clipr.ymax;
}
}
qsort(cmp, cuma->totpoint, sizeof(CurveMapPoint), sort_curvepoints);
/* remove doubles, threshold set on 1% of default range */
if (rem_doubles && cuma->totpoint > 2) {
for (a = 0; a < cuma->totpoint - 1; a++) {
@ -873,14 +873,14 @@ float curvemap_evaluateF(const CurveMap *cuma, float value)
/* index in table */
fi = (value - cuma->mintable) * cuma->range;
i = (int)fi;
/* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */
if (fi < 0.0f || fi > CM_TABLE)
return curvemap_calc_extend(cuma, value, &cuma->table[0].x, &cuma->table[CM_TABLE].x);
else {
if (i < 0) return cuma->table[0].y;
if (i >= CM_TABLE) return cuma->table[CM_TABLE].y;
fi = fi - (float)i;
return (1.0f - fi) * cuma->table[i].y + (fi) * cuma->table[i + 1].y;
}
@ -963,18 +963,18 @@ void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, unsigned char ve
int curvemapping_RGBA_does_something(const CurveMapping *cumap)
{
int a;
if (cumap->black[0] != 0.0f) return 1;
if (cumap->black[1] != 0.0f) return 1;
if (cumap->black[2] != 0.0f) return 1;
if (cumap->white[0] != 1.0f) return 1;
if (cumap->white[1] != 1.0f) return 1;
if (cumap->white[2] != 1.0f) return 1;
for (a = 0; a < CM_TOT; a++) {
if (cumap->cm[a].curve) {
if (cumap->cm[a].totpoint != 2) return 1;
if (cumap->cm[a].curve[0].x != 0.0f) return 1;
if (cumap->cm[a].curve[0].y != 0.0f) return 1;
if (cumap->cm[a].curve[1].x != 1.0f) return 1;
@ -987,9 +987,9 @@ int curvemapping_RGBA_does_something(const CurveMapping *cumap)
void curvemapping_initialize(CurveMapping *cumap)
{
int a;
if (cumap == NULL) return;
for (a = 0; a < CM_TOT; a++) {
if (cumap->cm[a].table == NULL)
curvemap_make_table(cumap->cm + a, &cumap->clipr);
@ -999,7 +999,7 @@ void curvemapping_initialize(CurveMapping *cumap)
void curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size)
{
int a;
*size = CM_TABLE + 1;
*array = MEM_callocN(sizeof(float) * (*size) * 4, "CurveMapping");
@ -1165,7 +1165,7 @@ typedef struct ScopesUpdateDataChunk {
float min[3], max[3];
} ScopesUpdateDataChunk;
static void scopes_update_cb(void *__restrict userdata,
static void scopes_update_cb(void *__restrict userdata,
const int y,
const ParallelRangeTLS *__restrict tls)
{
@ -1347,7 +1347,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
/* convert to number of lines with logarithmic scale */
scopes->sample_lines = (scopes->accuracy * 0.01f) * (scopes->accuracy * 0.01f) * ibuf->y;
CLAMP_MIN(scopes->sample_lines, 1);
if (scopes->sample_full)
scopes->sample_lines = ibuf->y;
@ -1356,9 +1356,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
scopes->minmax[a][0] = 25500.0f;
scopes->minmax[a][1] = -25500.0f;
}
scopes->waveform_tot = ibuf->x * scopes->sample_lines;
if (scopes->waveform_1)
MEM_freeN(scopes->waveform_1);
if (scopes->waveform_2)
@ -1367,12 +1367,12 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
MEM_freeN(scopes->waveform_3);
if (scopes->vecscope)
MEM_freeN(scopes->vecscope);
scopes->waveform_1 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1");
scopes->waveform_2 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2");
scopes->waveform_3 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3");
scopes->vecscope = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel");
if (ibuf->rect_float) {
cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
}
@ -1411,7 +1411,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
bin_a[a] = sqrt(bin_a[a]);
}
#endif
/* convert hist data to float (proportional to max count) */
nl = na = nr = nb = ng = 0;
for (a = 0; a < 256; a++) {
@ -1426,7 +1426,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
divr = nr ? 1.0 / (double)nr : 1.0;
divg = ng ? 1.0 / (double)ng : 1.0;
divb = nb ? 1.0 / (double)nb : 1.0;
for (a = 0; a < 256; a++) {
scopes->hist.data_luma[a] = bin_lum[a] * divl;
scopes->hist.data_r[a] = bin_r[a] * divr;
@ -1439,7 +1439,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
IMB_colormanagement_processor_free(cm_processor);
if (cache_handle)
IMB_display_buffer_release(cache_handle);
scopes->ok = 1;
}

File diff suppressed because it is too large Load Diff

@ -73,7 +73,7 @@ struct bContext {
struct bContextStore *store;
const char *operator_poll_msg; /* reason for poll failing */
} wm;
/* data context */
struct {
struct Main *main;
@ -83,7 +83,7 @@ struct bContext {
int py_init; /* true if python is initialized */
void *py_context;
} data;
/* data evaluation */
#if 0
struct {
@ -97,7 +97,7 @@ struct bContext {
bContext *CTX_create(void)
{
bContext *C;
C = MEM_callocN(sizeof(bContext), "bContext");
return C;
@ -413,7 +413,7 @@ PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, Stru
__func__, member, RNA_struct_identifier(ptr.type), RNA_struct_identifier(type));
}
}
return PointerRNA_NULL;
}
@ -454,13 +454,13 @@ int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListB
static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
{
LinkData *link;
if ((use_all == false) && STREQ(member, "scene")) /* exception */
return;
if (BLI_findstring(lb, member, offsetof(LinkData, data)))
return;
link = MEM_callocN(sizeof(LinkData), "LinkData");
link->data = (void *)member;
BLI_addtail(lb, link);

@ -1026,7 +1026,7 @@ static void basisNurb(float t, short order, int pnts, float *knots, float *basis
/* this is for float inaccuracy */
if (t < knots[0])
t = knots[0];
else if (t > knots[opp2])
else if (t > knots[opp2])
t = knots[opp2];
/* this part is order '1' */
@ -2135,7 +2135,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
if (tilt_array == NULL || nu->tilt_interp != nu->radius_interp) {
key_curve_position_weights(fac, t, nu->radius_interp);
}
*radius_array =
*radius_array =
t[0] * pprev->radius + t[1] * prevbezt->radius +
t[2] * bezt->radius + t[3] * next->radius;
}
@ -2145,7 +2145,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
if (weight_array) {
/* basic interpolation for now, could copy tilt interp too */
*weight_array =
*weight_array =
prevbezt->weight +
(bezt->weight - prevbezt->weight) * (3.0f * fac * fac - 2.0f * fac * fac * fac);
@ -2680,10 +2680,10 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
}
for (; nu; nu = nu->next) {
if (nu->hide && is_editmode)
continue;
/* check if we will calculate tilt data */
do_tilt = CU_DO_TILT(cu, nu);
do_radius = CU_DO_RADIUS(cu, nu); /* normal display uses the radius, better just to calculate them */

@ -544,7 +544,7 @@ static void layerSwap_mdisps(void *data, const int *ci)
for (S = 0; S < corners; S++)
memcpy(d + cornersize * S, s->disps + cornersize * ci[S], cornersize * 3 * sizeof(float));
MEM_freeN(s->disps);
s->disps = d;
}
@ -649,7 +649,7 @@ static void layerCopy_grid_paint_mask(const void *source, void *dest, int count)
d[i].data = NULL;
d[i].level = 0;
}
}
}
@ -760,7 +760,7 @@ static void layerDoMinMax_mloopcol(const void *data, void *vmin, void *vmax)
if (m->g < min->g) min->g = m->g;
if (m->b < min->b) min->b = m->b;
if (m->a < min->a) min->a = m->a;
if (m->r > max->r) max->r = m->r;
if (m->g > max->g) max->g = m->g;
if (m->b > max->b) max->b = m->b;
@ -1023,7 +1023,7 @@ static void layerInterp_mcol(
const float *sub_weight;
if (count <= 0) return;
sub_weight = sub_weights;
for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
@ -1051,7 +1051,7 @@ static void layerInterp_mcol(
/* delay writing to the destination incase dest is in sources */
for (j = 0; j < 4; ++j) {
/* Subdivide smooth or fractal can cause problems without clamping
* although weights should also not cause this situation */
mc[j].a = round_fl_to_uchar_clamp(col[j].a);
@ -1096,7 +1096,7 @@ static void layerInterp_bweight(
float f;
float **in = (float **)sources;
int i;
if (count <= 0) return;
f = 0.0f;
@ -1147,7 +1147,7 @@ static void layerDefault_mvert_skin(void *data, int count)
{
MVertSkin *vs = data;
int i;
for (i = 0; i < count; i++) {
copy_v3_fl(vs[i].radius, 0.25f);
vs[i].flag = 0;
@ -1234,18 +1234,18 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, layerMaxNum_tface},
/* 16: CD_MLOOPUV */
{sizeof(MLoopUV), "MLoopUV", 1, N_("UVMap"), NULL, NULL, layerInterp_mloopuv, NULL, NULL,
layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv,
layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv,
layerAdd_mloopuv, layerDoMinMax_mloopuv, layerCopyValue_mloopuv, NULL, NULL, NULL, layerMaxNum_tface},
/* 17: CD_MLOOPCOL */
{sizeof(MLoopCol), "MLoopCol", 1, N_("Col"), NULL, NULL, layerInterp_mloopcol, NULL,
layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol, NULL, NULL, NULL, layerMaxNum_mloopcol},
/* 18: CD_TANGENT */
{sizeof(float) * 4 * 4, "", 0, N_("Tangent"), NULL, NULL, NULL, NULL, NULL},
/* 19: CD_MDISPS */
{sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps,
layerFree_mdisps, NULL, layerSwap_mdisps, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps},
/* 20: CD_PREVIEW_MCOL */
{sizeof(MCol) * 4, "MCol", 4, N_("PreviewCol"), NULL, NULL, layerInterp_mcol,
@ -1488,10 +1488,10 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
else {
newlayer = customData_add_layer__internal(dest, type, alloctype, data, totelem, layer->name);
}
if (newlayer) {
newlayer->uid = layer->uid;
newlayer->active = lastactive;
newlayer->active_rnd = lastrender;
newlayer->active_clone = lastclone;
@ -1569,7 +1569,7 @@ void CustomData_free(CustomData *data, int totelem)
if (data->layers)
MEM_freeN(data->layers);
CustomData_external_free(data);
CustomData_reset(data);
}
@ -1872,7 +1872,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, int typ
return NULL;
}
}
data->totlayer++;
/* keep layers ordered by type */
@ -1902,7 +1902,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, int typ
data->layers[index].active_clone = 0;
data->layers[index].active_mask = 0;
}
customData_update_offsets(data);
return &data->layers[index];
@ -1913,7 +1913,7 @@ void *CustomData_add_layer(CustomData *data, int type, int alloctype,
{
CustomDataLayer *layer;
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
layer = customData_add_layer__internal(data, type, alloctype, layerdata,
totelem, typeInfo->defaultname);
CustomData_update_typemap(data);
@ -1929,7 +1929,7 @@ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype,
void *layerdata, int totelem, const char *name)
{
CustomDataLayer *layer;
layer = customData_add_layer__internal(data, type, alloctype, layerdata,
totelem, name);
CustomData_update_typemap(data);
@ -2014,7 +2014,7 @@ int CustomData_number_of_layers(const CustomData *data, int type)
for (i = 0; i < data->totlayer; i++)
if (data->layers[i].type == type)
number++;
return number;
}
@ -2233,7 +2233,7 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest,
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
CustomData_copy_data_layer(source, dest, src_i, dest_i, source_index, dest_index, count);
/* if there are multiple source & dest layers of the same type,
* we don't want to copy all source layers to the same dest, so
* increment dest_i
@ -2371,7 +2371,7 @@ void CustomData_swap(struct CustomData *data, const int index_a, const int index
void *CustomData_get(const CustomData *data, int index, int type)
{
int layer_index;
BLI_assert(index >= 0);
/* get the layer index of the active layer of type */
@ -2450,9 +2450,9 @@ bool CustomData_set_layer_name(const CustomData *data, int type, int n, const ch
if ((layer_index == -1) || !name)
return false;
BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name));
return true;
}
@ -2852,7 +2852,7 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
if (*dest_block)
memset(*dest_block, 0, dest->totsize);
}
/* copies a layer at a time */
dest_i = 0;
for (src_i = 0; src_i < source->totlayer; ++src_i) {
@ -2894,7 +2894,7 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
{
int layer_index;
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
if (layer_index == -1) return NULL;
@ -2905,7 +2905,7 @@ void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int n)
{
int layer_index;
/* get the layer index of the first layer of type */
layer_index = CustomData_get_layer_index(data, type);
if (layer_index == -1) return NULL;
@ -2924,13 +2924,13 @@ void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n)
bool CustomData_layer_has_math(const struct CustomData *data, int layer_n)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type);
if (typeInfo->equal && typeInfo->add && typeInfo->multiply &&
if (typeInfo->equal && typeInfo->add && typeInfo->multiply &&
typeInfo->initminmax && typeInfo->dominmax)
{
return true;
}
return false;
}
@ -3203,7 +3203,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
if (*dest_block == NULL)
CustomData_bmesh_alloc_block(dest, dest_block);
/* copies a layer at a time */
dest_i = 0;
for (src_i = 0; src_i < source->totlayer; ++src_i) {
@ -3405,7 +3405,7 @@ static bool cd_layer_find_dupe(CustomData *data, const char *name, int type, int
for (i = 0; i < data->totlayer; i++) {
if (i != index) {
CustomDataLayer *layer = &data->layers[i];
if (CustomData_is_property_layer(type)) {
if (CustomData_is_property_layer(layer->type) && STREQ(layer->name, name)) {
return true;
@ -3418,7 +3418,7 @@ static bool cd_layer_find_dupe(CustomData *data, const char *name, int type, int
}
}
}
return false;
}
@ -3429,7 +3429,7 @@ static bool customdata_unique_check(void *arg, const char *name)
}
void CustomData_set_layer_unique_name(CustomData *data, int index)
{
{
CustomDataLayer *nlayer = &data->layers[index];
const LayerTypeInfo *typeInfo = layerType_getInfo(nlayer->type);
@ -3535,7 +3535,7 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
if (!external)
return;
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);

@ -115,7 +115,7 @@ static int cdf_data_type_size(int datatype)
{
if (datatype == CDF_DATA_FLOAT)
return sizeof(float);
return 0;
}
#endif
@ -156,7 +156,7 @@ static int cdf_read_header(CDataFile *cdf)
if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf))
return 0;
if (memcmp(header->ID, "BCDF", sizeof(header->ID)) != 0)
return 0;
if (header->version > CDF_VERSION)
@ -179,7 +179,7 @@ static int cdf_read_header(CDataFile *cdf)
if (fseek(f, offset, SEEK_SET) != 0)
return 0;
if (header->type == CDF_TYPE_IMAGE) {
image = &cdf->btype.image;
if (!fread(image, sizeof(CDataFileImageHeader), 1, f))
@ -258,7 +258,7 @@ static int cdf_write_header(CDataFile *cdf)
if (!fwrite(header, sizeof(CDataFileHeader), 1, f))
return 0;
if (header->type == CDF_TYPE_IMAGE) {
image = &cdf->btype.image;
if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f))
@ -287,7 +287,7 @@ bool cdf_read_open(CDataFile *cdf, const char *filename)
f = BLI_fopen(filename, "rb");
if (!f)
return 0;
cdf->readf = f;
if (!cdf_read_header(cdf)) {
@ -352,7 +352,7 @@ bool cdf_write_open(CDataFile *cdf, const char *filename)
f = BLI_fopen(filename, "wb");
if (!f)
return 0;
cdf->writef = f;
/* fill header */
@ -424,7 +424,7 @@ CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name)
if (layer->type == type && STREQ(layer->name, name))
return layer;
}
return NULL;
}

File diff suppressed because it is too large Load Diff

@ -1093,7 +1093,7 @@ static void emDM_drawMappedFaces(
efa = ltri[0]->f;
drawSmooth = lnors || ((flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH));
draw_option = (setDrawOptions ?
setDrawOptions(userData, BM_elem_index_get(efa)) :
DM_DRAW_OPTION_NORMAL);
@ -1120,7 +1120,7 @@ static void emDM_drawMappedFaces(
}
prev_mat_nr = efa->mat_nr;
}
if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */
if (poly_prev != GL_ZERO) glEnd();

@ -147,9 +147,9 @@ BMBVHTree *BKE_bmbvh_new_ex(
BLI_bvhtree_insert(bmtree->tree, i, (float *)cos, 3);
}
BLI_bvhtree_balance(bmtree->tree);
return bmtree;
}
@ -188,11 +188,11 @@ BMBVHTree *BKE_bmbvh_new(
void BKE_bmbvh_free(BMBVHTree *bmtree)
{
BLI_bvhtree_free(bmtree->tree);
if (bmtree->cos_cage && bmtree->cos_cage_free) {
MEM_freeN((void *)bmtree->cos_cage);
}
MEM_freeN(bmtree);
}
@ -313,7 +313,7 @@ BMFace *BKE_bmbvh_ray_cast(BMBVHTree *bmtree, const float co[3], const float dir
/* ok to leave 'uv' uninitialized */
bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->looptris;
bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage;
BLI_bvhtree_ray_cast(bmtree->tree, co, dir, radius, &hit, bmbvh_ray_cast_cb, &bmcb_data);
if (hit.index != -1 && hit.dist != dist) {
@ -547,4 +547,4 @@ BVHTreeOverlap *BKE_bmbvh_overlap(const BMBVHTree *bmtree_a, const BMBVHTree *bm
data.epsilon = max_ff(BLI_bvhtree_get_epsilon(bmtree_a->tree), BLI_bvhtree_get_epsilon(bmtree_b->tree));
return BLI_bvhtree_overlap(bmtree_a->tree, bmtree_b->tree, r_overlap_tot, bmbvh_overlap_cb, &data);
}
}

@ -212,10 +212,10 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
Base *base;
unsigned int layer= ob_src->lay;
ListBase *effectors = NULL;
if (weights->group) {
GroupObject *go;
for (go= weights->group->gobject.first; go; go= go->next) {
if ( (go->ob->lay & layer) ) {
if ( go->ob->pd && go->ob->pd->forcefield )
@ -245,10 +245,10 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
}
}
}
if (for_simulation)
pdPrecalculateEffectors(effectors);
return effectors;
}
@ -326,7 +326,7 @@ void pd_point_from_particle(ParticleSimulationData *sim, ParticleData *pa, Parti
point->index = pa - sim->psys->particles;
point->size = pa->size;
point->charge = 0.0f;
if (part->pd && part->pd->forcefield == PFIELD_CHARGE)
point->charge += part->pd->f_strength;
@ -385,7 +385,7 @@ void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, Effecte
// triangle - ray callback function
static void eff_tri_ray_hit(void *UNUSED(userData), int UNUSED(index), const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit)
{
{
/* whenever we hit a bounding box, we don't check further */
hit->dist = -1;
hit->index = 1;
@ -399,7 +399,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
ColliderCache *col;
float norm[3], len = 0.0;
float visibility = 1.0, absorption = 0.0;
if (!(eff->pd->flag & PFIELD_VISIBILITY))
return visibility;
@ -411,7 +411,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
negate_v3_v3(norm, efd->vec_to_point);
len = normalize_v3(norm);
/* check all collision objects */
for (col = colls->first; col; col = col->next) {
CollisionModifierData *collmd = col->collmd;
@ -434,7 +434,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
/* visibility is only between 0 and 1, calculated from 1-absorption */
visibility *= CLAMPIS(1.0f-absorption, 0.0f, 1.0f);
if (visibility <= 0.0f)
break;
}
@ -443,7 +443,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
if (!colliders)
free_collider_cache(&colls);
return visibility;
}
@ -454,11 +454,11 @@ static float wind_func(struct RNG *rng, float strength)
float force = BLI_rng_get_float(rng) + 1.0f;
float ret;
float sign = 0;
sign = ((float)random > 64.0f) ? 1.0f: -1.0f; // dividing by 2 is not giving equal sign distribution
ret = sign*((float)random / force)*strength/128.0f;
return ret;
}
@ -551,7 +551,7 @@ int closest_point_on_surface(SurfaceModifierData *surmd, const float co[3], floa
if (surface_vel) {
const MLoop *mloop = surmd->bvhtree->loop;
const MLoopTri *lt = &surmd->bvhtree->looptri[nearest.index];
copy_v3_v3(surface_vel, surmd->v[mloop[lt->tri[0]].v].co);
add_v3_v3(surface_vel, surmd->v[mloop[lt->tri[1]].v].co);
add_v3_v3(surface_vel, surmd->v[mloop[lt->tri[2]].v].co);
@ -632,7 +632,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
efd->nor[0] = 1.f;
efd->nor[1] = efd->nor[2] = 0.f;
mul_qt_v3(state.rot, efd->nor);
if (real_velocity)
copy_v3_v3(efd->vel, state.vel);
@ -705,9 +705,9 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin
}
else if (eff->psys) {
*tot = eff->psys->totpart;
if (eff->pd->forcefield == PFIELD_CHARGE) {
/* Only the charge of the effected particle is used for
/* Only the charge of the effected particle is used for
* interaction, not fall-offs. If the fall-offs aren't the
* same this will be unphysical, but for animation this
* could be the wanted behavior. If you want physical
@ -869,10 +869,10 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
/* new vortex force */
cross_v3_v3v3(temp, efd->nor2, efd->vec_to_point2);
mul_v3_fl(temp, strength * efd->falloff);
cross_v3_v3v3(force, efd->nor2, temp);
mul_v3_fl(force, strength * efd->falloff);
madd_v3_v3fl(temp, point->vel, -point->vel_to_sec);
add_v3_v3(force, temp);
}
@ -900,7 +900,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
break;
case PFIELD_LENNARDJ:
fac = pow((efd->size + point->size) / efd->distance, 6.0);
fac = - fac * (1.0f - fac) / efd->distance;
/* limit the repulsive term drastically to avoid huge forces */
@ -1005,7 +1005,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
/* Cycle through collected objects, get total of (1/(gravity_strength * dist^gravity_power)) */
/* Check for min distance here? (yes would be cool to add that, ton) */
if (effectors) for (eff = effectors->first; eff; eff=eff->next) {
/* object effectors were fully checked to be OK to evaluate! */
@ -1014,7 +1014,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
for (; p<tot; p+=step) {
if (get_effector_data(eff, &efd, point, 0)) {
efd.falloff= effector_falloff(eff, &efd, point, weights);
if (efd.falloff > 0.0f)
efd.falloff *= eff_calc_visibility(colliders, eff, &efd, point);
@ -1029,7 +1029,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
copy_v3_v3(temp1, force);
do_physical_effector(eff, &efd, point, force);
/* for softbody backward compatibility */
if (point->flag & PE_WIND_AS_SPEED && impulse) {
sub_v3_v3v3(temp2, force, temp1);
@ -1142,14 +1142,14 @@ void BKE_sim_debug_data_add_element(int type, const float v1[3], const float v2[
{
unsigned int category_hash = BLI_ghashutil_strhash_p(category);
SimDebugElement *elem;
if (!_sim_debug_data) {
if (G.debug & G_DEBUG_SIMDATA)
BKE_sim_debug_data_set_enabled(true);
else
return;
}
elem = MEM_callocN(sizeof(SimDebugElement), "sim debug data element");
elem->type = type;
elem->category_hash = category_hash;
@ -1169,7 +1169,7 @@ void BKE_sim_debug_data_add_element(int type, const float v1[3], const float v2[
BLI_strncpy(elem->str, str, sizeof(elem->str));
else
elem->str[0] = '\0';
debug_data_insert(_sim_debug_data, elem);
}
@ -1178,7 +1178,7 @@ void BKE_sim_debug_data_remove_element(unsigned int hash)
SimDebugElement dummy;
if (!_sim_debug_data)
return;
dummy.hash = hash;
BLI_ghash_remove(_sim_debug_data->gh, &dummy, NULL, debug_element_free);
}
@ -1187,7 +1187,7 @@ void BKE_sim_debug_data_clear(void)
{
if (!_sim_debug_data)
return;
if (_sim_debug_data->gh)
BLI_ghash_clear(_sim_debug_data->gh, NULL, debug_element_free);
}
@ -1195,17 +1195,17 @@ void BKE_sim_debug_data_clear(void)
void BKE_sim_debug_data_clear_category(const char *category)
{
int category_hash = (int)BLI_ghashutil_strhash_p(category);
if (!_sim_debug_data)
return;
if (_sim_debug_data->gh) {
GHashIterator iter;
BLI_ghashIterator_init(&iter, _sim_debug_data->gh);
while (!BLI_ghashIterator_done(&iter)) {
const SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
BLI_ghashIterator_step(&iter); /* removing invalidates the current iterator, so step before removing */
if (elem->category_hash == category_hash)
BLI_ghash_remove(_sim_debug_data->gh, elem, NULL, debug_element_free);
}

File diff suppressed because it is too large Load Diff

@ -67,7 +67,7 @@ void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm);
* times. In addition to this, each modifier should have a type-info struct, where
* its functions are attached for use.
*/
/* Template for type-info data:
* - make a copy of this when creating new modifiers, and just change the functions
* pointed to as necessary
@ -110,7 +110,7 @@ static FModifierTypeInfo FMI_MODNAME = {
static void fcm_generator_free(FModifier *fcm)
{
FMod_Generator *data = (FMod_Generator *)fcm->data;
/* free polynomial coefficients array */
if (data->coefficients)
MEM_freeN(data->coefficients);
@ -120,7 +120,7 @@ static void fcm_generator_copy(FModifier *fcm, const FModifier *src)
{
FMod_Generator *gen = (FMod_Generator *)fcm->data;
FMod_Generator *ogen = (FMod_Generator *)src->data;
/* copy coefficients array? */
if (ogen->coefficients)
gen->coefficients = MEM_dupallocN(ogen->coefficients);
@ -130,19 +130,19 @@ static void fcm_generator_new_data(void *mdata)
{
FMod_Generator *data = (FMod_Generator *)mdata;
float *cp;
/* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */
data->poly_order = 1;
data->arraysize = 2;
cp = data->coefficients = MEM_callocN(sizeof(float) * 2, "FMod_Generator_Coefs");
cp[0] = 0; // y-offset
cp[0] = 0; // y-offset
cp[1] = 1; // gradient
}
static void fcm_generator_verify(FModifier *fcm)
{
FMod_Generator *data = (FMod_Generator *)fcm->data;
/* requirements depend on mode */
switch (data->mode) {
case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
@ -173,8 +173,8 @@ static void fcm_generator_verify(FModifier *fcm)
static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
{
FMod_Generator *data = (FMod_Generator *)fcm->data;
/* behavior depends on mode
/* behavior depends on mode
* NOTE: the data in its default state is fine too
*/
switch (data->mode) {
@ -184,8 +184,8 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c
float *powers = MEM_callocN(sizeof(float) * data->arraysize, "Poly Powers");
float value = 0.0f;
unsigned int i;
/* for each x^n, precalculate value based on previous one first... this should be
/* for each x^n, precalculate value based on previous one first... this should be
* faster that calling pow() for each entry
*/
for (i = 0; i < data->arraysize; i++) {
@ -195,11 +195,11 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c
else
powers[0] = 1;
}
/* for each coefficient, add to value, which we'll write to *cvalue in one go */
for (i = 0; i < data->arraysize; i++)
value += data->coefficients[i] * powers[i];
/* only if something changed, write *cvalue in one go */
if (data->poly_order) {
if (data->flag & FCM_GENERATOR_ADDITIVE)
@ -207,9 +207,9 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c
else
*cvalue = value;
}
/* cleanup */
if (powers)
if (powers)
MEM_freeN(powers);
break;
}
@ -217,11 +217,11 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c
{
float value = 1.0f, *cp = NULL;
unsigned int i;
/* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */
for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order); cp += 2, i++)
value *= (cp[0] * evaltime + cp[1]);
/* only if something changed, write *cvalue in one go */
if (data->poly_order) {
if (data->flag & FCM_GENERATOR_ADDITIVE)
@ -266,7 +266,7 @@ static FModifierTypeInfo FMI_GENERATOR = {
static void fcm_fn_generator_new_data(void *mdata)
{
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)mdata;
/* set amplitude and phase multiplier to 1.0f so that something is generated */
data->amplitude = 1.0f;
data->phase_multiplier = 1.0f;
@ -289,9 +289,9 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
double arg = data->phase_multiplier * evaltime + data->phase_offset;
double (*fn)(double v) = NULL;
/* get function pointer to the func to use:
* WARNING: must perform special argument validation hereto guard against crashes
* WARNING: must perform special argument validation hereto guard against crashes
*/
switch (data->type) {
/* simple ones */
@ -304,7 +304,7 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
case FCM_GENERATOR_FN_SINC: /* normalized sine wave */
fn = sinc;
break;
/* validation required */
case FCM_GENERATOR_FN_TAN: /* tangent wave */
{
@ -346,11 +346,11 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
break;
}
/* execute function callback to set value if appropriate */
if (fn) {
float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset);
if (data->flag & FCM_GENERATOR_ADDITIVE)
*cvalue += value;
else
@ -380,7 +380,7 @@ static FModifierTypeInfo FMI_FN_GENERATOR = {
static void fcm_envelope_free(FModifier *fcm)
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
/* free envelope data array */
if (env->data)
MEM_freeN(env->data);
@ -390,7 +390,7 @@ static void fcm_envelope_copy(FModifier *fcm, const FModifier *src)
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
FMod_Envelope *oenv = (FMod_Envelope *)src->data;
/* copy envelope data array */
if (oenv->data)
env->data = MEM_dupallocN(oenv->data);
@ -399,7 +399,7 @@ static void fcm_envelope_copy(FModifier *fcm, const FModifier *src)
static void fcm_envelope_new_data(void *mdata)
{
FMod_Envelope *env = (FMod_Envelope *)mdata;
/* set default min/max ranges */
env->min = -1.0f;
env->max = 1.0f;
@ -408,7 +408,7 @@ static void fcm_envelope_new_data(void *mdata)
static void fcm_envelope_verify(FModifier *fcm)
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
/* if the are points, perform bubble-sort on them, as user may have changed the order */
if (env->data) {
/* XXX todo... */
@ -421,13 +421,13 @@ static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cv
FCM_EnvelopeData *fed, *prevfed, *lastfed;
float min = 0.0f, max = 0.0f, fac = 0.0f;
int a;
/* get pointers */
if (env->data == NULL) return;
prevfed = env->data;
fed = prevfed + 1;
lastfed = prevfed + (env->totvert - 1);
/* get min/max values for envelope at evaluation time (relative to mid-value) */
if (prevfed->time >= evaltime) {
/* before or on first sample, so just extend value */
@ -446,20 +446,20 @@ static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cv
/* evaltime occurs within the interval defined by these two envelope points */
if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) {
float afac, bfac, diff;
diff = fed->time - prevfed->time;
afac = (evaltime - prevfed->time) / diff;
bfac = (fed->time - evaltime) / diff;
min = bfac * prevfed->min + afac * fed->min;
max = bfac * prevfed->max + afac * fed->max;
break;
}
}
}
/* adjust *cvalue
/* adjust *cvalue
* - fac is the ratio of how the current y-value corresponds to the reference range
* - thus, the new value is found by mapping the old range to the new!
*/
@ -572,7 +572,7 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[], float frame, int array
/* Cycles F-Curve Modifier --------------------------- */
/* This modifier changes evaltime to something that exists within the curve's frame-range,
/* This modifier changes evaltime to something that exists within the curve's frame-range,
* then re-evaluates modifier stack up to this point using the new time. This re-entrant behavior
* is very likely to be more time-consuming than the original approach... (which was tightly integrated into
* the calculation code...).
@ -588,11 +588,11 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[], float frame, int array
typedef struct tFCMED_Cycles {
float cycyofs; /* y-offset to apply */
} tFCMED_Cycles;
static void fcm_cycles_new_data(void *mdata)
{
FMod_Cycles *data = (FMod_Cycles *)mdata;
/* turn on cycles by default */
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
}
@ -605,38 +605,38 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif
short side = 0, mode = 0;
int cycles = 0;
float ofs = 0;
/* check if modifier is first in stack, otherwise disable ourself... */
/* FIXME... */
if (fcm->prev) {
fcm->flag |= FMODIFIER_FLAG_DISABLED;
return evaltime;
}
/* calculate new evaltime due to cyclic interpolation */
if (fcu && fcu->bezt) {
BezTriple *prevbezt = fcu->bezt;
BezTriple *lastbezt = prevbezt + fcu->totvert - 1;
prevkey[0] = prevbezt->vec[1][0];
prevkey[1] = prevbezt->vec[1][1];
lastkey[0] = lastbezt->vec[1][0];
lastkey[1] = lastbezt->vec[1][1];
}
else if (fcu && fcu->fpt) {
FPoint *prevfpt = fcu->fpt;
FPoint *lastfpt = prevfpt + fcu->totvert - 1;
prevkey[0] = prevfpt->vec[0];
prevkey[1] = prevfpt->vec[1];
lastkey[0] = lastfpt->vec[0];
lastkey[1] = lastfpt->vec[1];
}
else
return evaltime;
/* check if modifier will do anything
* 1) if in data range, definitely don't do anything
* 2) if before first frame or after last frame, make sure some cycling is in use
@ -659,26 +659,26 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif
}
if ((ELEM(0, side, mode)))
return evaltime;
/* find relative place within a cycle */
{
float cycdx = 0, cycdy = 0;
float cycle = 0, cyct = 0;
/* calculate period and amplitude (total height) of a cycle */
cycdx = lastkey[0] - prevkey[0];
cycdy = lastkey[1] - prevkey[1];
/* check if cycle is infinitely small, to be point of being impossible to use */
if (cycdx == 0)
return evaltime;
/* calculate the 'number' of the cycle */
cycle = ((float)side * (evaltime - ofs) / cycdx);
/* calculate the time inside the cycle */
cyct = fmod(evaltime - ofs, cycdx);
/* check that cyclic is still enabled for the specified time */
if (cycles == 0) {
/* catch this case so that we don't exit when we have (cycles = 0)
@ -687,11 +687,11 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif
}
else if (cycle > cycles) {
/* we are too far away from range to evaluate
* TODO: but we should still hold last value...
* TODO: but we should still hold last value...
*/
return evaltime;
}
/* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */
if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
if (side < 0)
@ -700,17 +700,17 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif
cycyofs = (float)ceil((evaltime - ofs) / cycdx);
cycyofs *= cycdy;
}
/* special case for cycle start/end */
if (cyct == 0.0f) {
evaltime = (side == 1 ? lastkey[0] : prevkey[0]);
if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2))
evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
}
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) {
/* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse
/* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse
* - for 'before' extrapolation, we need to flip in a different way, otherwise values past
* then end of the curve get referenced (result of fmod will be negative, and with different phase)
*/
@ -725,22 +725,22 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif
}
if (evaltime < prevkey[0]) evaltime += cycdx;
}
/* store temp data if needed */
if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
tFCMED_Cycles *edata;
/* for now, this is just a float, but we could get more stuff... */
edata = MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles");
edata->cycyofs = cycyofs;
fmodifiers_storage_put(storage, fcm, edata);
}
/* return the new frame to evaluate */
return evaltime;
}
static void fcm_cycles_evaluate(FModifierStackStorage *storage, FCurve *UNUSED(fcu),
FModifier *fcm, float *cvalue, float UNUSED(evaltime))
{
@ -750,7 +750,7 @@ static void fcm_cycles_evaluate(FModifierStackStorage *storage, FCurve *UNUSED(f
if (edata) {
/* add cyclic offset - no need to check for now, otherwise the data wouldn't exist! */
*cvalue += edata->cycyofs;
/* free temp data */
MEM_freeN(edata);
fmodifiers_storage_remove(storage, fcm);
@ -779,7 +779,7 @@ static FModifierTypeInfo FMI_CYCLES = {
static void fcm_noise_new_data(void *mdata)
{
FMod_Noise *data = (FMod_Noise *)mdata;
/* defaults */
data->size = 1.0f;
data->strength = 1.0f;
@ -788,18 +788,18 @@ static void fcm_noise_new_data(void *mdata)
data->depth = 0;
data->modification = FCM_NOISE_MODIF_REPLACE;
}
static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
{
FMod_Noise *data = (FMod_Noise *)fcm->data;
float noise;
/* generate noise using good ol' Blender Noise
* - 0.1 is passed as the 'z' value, otherwise evaluation fails for size = phase = 1
* with evaltime being an integer (which happens when evaluating on frame by frame basis)
*/
noise = BLI_turbulence(data->size, evaltime - data->offset, data->phase, 0.1f, data->depth);
/* combine the noise with existing motion data */
switch (data->modification) {
case FCM_NOISE_MODIF_ADD:
@ -837,7 +837,7 @@ static FModifierTypeInfo FMI_NOISE = {
/* Filter F-Curve Modifier --------------------------- */
#if 0 // XXX not yet implemented
#if 0 // XXX not yet implemented
static FModifierTypeInfo FMI_FILTER = {
FMODIFIER_TYPE_FILTER, /* type */
sizeof(FMod_Filter), /* size */
@ -862,7 +862,7 @@ static FModifierTypeInfo FMI_FILTER = {
static void fcm_python_free(FModifier *fcm)
{
FMod_Python *data = (FMod_Python *)fcm->data;
/* id-properties */
IDP_FreeProperty(data->prop);
MEM_freeN(data->prop);
@ -871,7 +871,7 @@ static void fcm_python_free(FModifier *fcm)
static void fcm_python_new_data(void *mdata)
{
FMod_Python *data = (FMod_Python *)mdata;
/* everything should be set correctly by calloc, except for the prop->type constant.*/
data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps");
data->prop->type = IDP_GROUP;
@ -881,7 +881,7 @@ static void fcm_python_copy(FModifier *fcm, const FModifier *src)
{
FMod_Python *pymod = (FMod_Python *)fcm->data;
FMod_Python *opymod = (FMod_Python *)src->data;
pymod->prop = IDP_CopyProperty(opymod->prop);
}
@ -889,9 +889,9 @@ static void fcm_python_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), flo
{
#ifdef WITH_PYTHON
//FMod_Python *data = (FMod_Python *)fcm->data;
/* FIXME... need to implement this modifier...
* It will need it execute a script using the custom properties
* It will need it execute a script using the custom properties
*/
#endif /* WITH_PYTHON */
}
@ -919,13 +919,13 @@ static FModifierTypeInfo FMI_PYTHON = {
static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
{
FMod_Limits *data = (FMod_Limits *)fcm->data;
/* check for the time limits */
if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin))
return data->rect.xmin;
if ((data->flag & FCM_LIMIT_XMAX) && (evaltime > data->rect.xmax))
return data->rect.xmax;
/* modifier doesn't change time */
return evaltime;
}
@ -933,7 +933,7 @@ static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(c
static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
{
FMod_Limits *data = (FMod_Limits *)fcm->data;
/* value limits now */
if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin))
*cvalue = data->rect.ymin;
@ -944,7 +944,7 @@ static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cval
static FModifierTypeInfo FMI_LIMITS = {
FMODIFIER_TYPE_LIMITS, /* type */
sizeof(FMod_Limits), /* size */
FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */
FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */
FMI_REQUIRES_RUNTIME_CHECK, /* requirements */
N_("Limits"), /* name */
"FMod_Limits", /* struct name */
@ -963,7 +963,7 @@ static FModifierTypeInfo FMI_LIMITS = {
static void fcm_stepped_new_data(void *mdata)
{
FMod_Stepped *data = (FMod_Stepped *)mdata;
/* just need to set the step-size to 2-frames by default */
/* XXX: or would 5 be more normal? */
data->step_size = 2.0f;
@ -973,7 +973,7 @@ static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(
{
FMod_Stepped *data = (FMod_Stepped *)fcm->data;
int snapblock;
/* check range clamping to see if we should alter the timing to achieve the desired results */
if (data->flag & FCM_STEPPED_NO_BEFORE) {
if (evaltime < data->start_frame)
@ -983,15 +983,15 @@ static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(
if (evaltime > data->end_frame)
return evaltime;
}
/* we snap to the start of the previous closest block of 'step_size' frames
* after the start offset has been discarded
/* we snap to the start of the previous closest block of 'step_size' frames
* after the start offset has been discarded
* - i.e. round down
*/
snapblock = (int)((evaltime - data->offset) / data->step_size);
/* reapply the offset, and multiple the snapblock by the size of the steps to get
* the new time to evaluate at
/* reapply the offset, and multiple the snapblock by the size of the steps to get
* the new time to evaluate at
*/
return ((float)snapblock * data->step_size) + data->offset;
}
@ -999,7 +999,7 @@ static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(
static FModifierTypeInfo FMI_STEPPED = {
FMODIFIER_TYPE_STEPPED, /* type */
sizeof(FMod_Limits), /* size */
FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */
FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */
FMI_REQUIRES_RUNTIME_CHECK, /* requirements */
N_("Stepped"), /* name */
"FMod_Stepped", /* struct name */
@ -1047,7 +1047,7 @@ const FModifierTypeInfo *get_fmodifier_typeinfo(const int type)
fmods_init_typeinfo();
FMI_INIT = 0;
}
/* only return for valid types */
if ((type >= FMODIFIER_TYPE_NULL) &&
(type < FMODIFIER_NUM_TYPES))
@ -1058,10 +1058,10 @@ const FModifierTypeInfo *get_fmodifier_typeinfo(const int type)
else {
printf("No valid F-Curve Modifier type-info data available. Type = %i\n", type);
}
return NULL;
}
}
/* This function should always be used to get the appropriate type-info, as it
* has checks which prevent segfaults in some weird cases.
*/
@ -1081,11 +1081,11 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
{
const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
FModifier *fcm;
/* sanity checks */
if (ELEM(NULL, modifiers, fmi))
return NULL;
/* special checks for whether modifier can be added */
if ((modifiers->first) && (type == FMODIFIER_TYPE_CYCLES)) {
/* cycles modifier must be first in stack, so for now, don't add if it can't be */
@ -1093,7 +1093,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
printf("Error: Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be first in stack.\n");
return NULL;
}
/* add modifier itself */
fcm = MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
fcm->type = type;
@ -1101,14 +1101,14 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
fcm->curve = owner_fcu;
fcm->influence = 1.0f;
BLI_addtail(modifiers, fcm);
/* tag modifier as "active" if no other modifiers exist in the stack yet */
if (BLI_listbase_is_single(modifiers))
fcm->flag |= FMODIFIER_FLAG_ACTIVE;
/* add modifier's data */
fcm->data = MEM_callocN(fmi->size, fmi->structName);
/* init custom settings if necessary */
if (fmi->new_data)
fmi->new_data(fcm->data);
@ -1116,7 +1116,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
/* update the fcurve if the Cycles modifier is added */
if ((owner_fcu) && (type == FMODIFIER_TYPE_CYCLES))
calchandles_fcurve(owner_fcu);
/* return modifier for further editing */
return fcm;
}
@ -1126,23 +1126,23 @@ FModifier *copy_fmodifier(const FModifier *src)
{
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src);
FModifier *dst;
/* sanity check */
if (src == NULL)
return NULL;
/* copy the base data, clearing the links */
dst = MEM_dupallocN(src);
dst->next = dst->prev = NULL;
dst->curve = NULL;
/* make a new copy of the F-Modifier's data */
dst->data = MEM_dupallocN(src->data);
/* only do specific constraints if required */
if (fmi && fmi->copy_data)
fmi->copy_data(dst, src);
/* return the new modifier */
return dst;
}
@ -1151,20 +1151,20 @@ FModifier *copy_fmodifier(const FModifier *src)
void copy_fmodifiers(ListBase *dst, const ListBase *src)
{
FModifier *fcm, *srcfcm;
if (ELEM(NULL, dst, src))
return;
BLI_listbase_clear(dst);
BLI_duplicatelist(dst, src);
for (fcm = dst->first, srcfcm = src->first; fcm && srcfcm; srcfcm = srcfcm->next, fcm = fcm->next) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
/* make a new copy of the F-Modifier's data */
fcm->data = MEM_dupallocN(fcm->data);
fcm->curve = NULL;
/* only do specific constraints if required */
if (fmi && fmi->copy_data)
fmi->copy_data(fcm, srcfcm);
@ -1175,11 +1175,11 @@ void copy_fmodifiers(ListBase *dst, const ListBase *src)
bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
{
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
/* sanity check */
if (fcm == NULL)
return false;
/* removing the cycles modifier requires a handle update */
FCurve *update_fcu = (fcm->type == FMODIFIER_TYPE_CYCLES) ? fcm->curve : NULL;
@ -1187,11 +1187,11 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
if (fcm->data) {
if (fmi && fmi->free_data)
fmi->free_data(fcm);
/* free modifier's data (fcm->data) */
MEM_freeN(fcm->data);
}
/* remove modifier from stack */
if (modifiers) {
BLI_freelinkN(modifiers, fcm);
@ -1214,11 +1214,11 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
void free_fmodifiers(ListBase *modifiers)
{
FModifier *fcm, *fmn;
/* sanity check */
if (modifiers == NULL)
return;
/* free each modifier in order - modifier is unlinked from list and freed */
for (fcm = modifiers->first; fcm; fcm = fmn) {
fmn = fcm->next;
@ -1230,17 +1230,17 @@ void free_fmodifiers(ListBase *modifiers)
FModifier *find_active_fmodifier(ListBase *modifiers)
{
FModifier *fcm;
/* sanity checks */
if (ELEM(NULL, modifiers, modifiers->first))
return NULL;
/* loop over modifiers until 'active' one is found */
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
if (fcm->flag & FMODIFIER_FLAG_ACTIVE)
return fcm;
}
/* no modifier is active */
return NULL;
}
@ -1249,55 +1249,55 @@ FModifier *find_active_fmodifier(ListBase *modifiers)
void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
{
FModifier *fm;
/* sanity checks */
if (ELEM(NULL, modifiers, modifiers->first))
return;
/* deactivate all, and set current one active */
for (fm = modifiers->first; fm; fm = fm->next)
fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
/* make given modifier active */
if (fcm)
fcm->flag |= FMODIFIER_FLAG_ACTIVE;
}
/* Do we have any modifiers which match certain criteria
/* Do we have any modifiers which match certain criteria
* - mtype - type of modifier (if 0, doesn't matter)
* - acttype - type of action to perform (if -1, doesn't matter)
*/
bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
{
FModifier *fcm;
/* if there are no specific filtering criteria, just skip */
if ((mtype == 0) && (acttype == 0))
return (modifiers && modifiers->first);
/* sanity checks */
if (ELEM(NULL, modifiers, modifiers->first))
return false;
/* find the first mdifier fitting these criteria */
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */
/* check if applicable ones are fullfilled */
if (mtype)
mOk = (fcm->type == mtype);
if (acttype > -1)
aOk = (fmi->acttype == acttype);
/* if both are ok, we've found a hit */
if (mOk && aOk)
return true;
}
/* no matches */
return false;
}
}
/* Evaluation API --------------------------- */
@ -1359,19 +1359,19 @@ void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm)
static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
{
float influence;
/* sanity check */
if (fcm == NULL)
if (fcm == NULL)
return 0.0f;
/* should we use influence stored in modifier or not
/* should we use influence stored in modifier or not
* NOTE: this is really just a hack so that we don't need to version patch old files ;)
*/
if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE)
influence = fcm->influence;
else
influence = 1.0f;
/* restricted range or full range? */
if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) {
if ((evaltime <= fcm->sfra) || (evaltime >= fcm->efra)) {
@ -1391,7 +1391,7 @@ static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
return influence * (evaltime - a) / (b - a);
}
}
/* just return the influence of the modifier */
return influence;
}
@ -1411,7 +1411,7 @@ float evaluate_time_fmodifiers(FModifierStackStorage *storage, ListBase *modifie
FCurve *fcu, float cvalue, float evaltime)
{
FModifier *fcm;
/* sanity checks */
if (ELEM(NULL, modifiers, modifiers->last))
return evaltime;
@ -1419,22 +1419,22 @@ float evaluate_time_fmodifiers(FModifierStackStorage *storage, ListBase *modifie
if (fcu && fcu->flag & FCURVE_MOD_OFF)
return evaltime;
/* Starting from the end of the stack, calculate the time effects of various stacked modifiers
* on the time the F-Curve should be evaluated at.
/* Starting from the end of the stack, calculate the time effects of various stacked modifiers
* on the time the F-Curve should be evaluated at.
*
* This is done in reverse order to standard evaluation, as when this is done in standard
* order, each modifier would cause jumps to other points in the curve, forcing all
* previous ones to be evaluated again for them to be correct. However, if we did in the
* previous ones to be evaluated again for them to be correct. However, if we did in the
* reverse order as we have here, we can consider them a macro to micro type of waterfall
* effect, which should get us the desired effects when using layered time manipulations
* (such as multiple 'stepped' modifiers in sequence, causing different stepping rates)
*/
for (fcm = modifiers->last; fcm; fcm = fcm->prev) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
if (fmi == NULL)
if (fmi == NULL)
continue;
/* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results)
* hence we shouldn't bother seeing what it would do given the chance
*/
@ -1453,13 +1453,13 @@ float evaluate_time_fmodifiers(FModifierStackStorage *storage, ListBase *modifie
else {
nval = fmi->evaluate_modifier_time_storage(storage, fcu, fcm, cvalue, evaltime);
}
evaltime = interpf(nval, evaltime, influence);
}
}
}
}
/* return the modified evaltime */
return evaltime;
}
@ -1471,21 +1471,21 @@ void evaluate_value_fmodifiers(FModifierStackStorage *storage, ListBase *modifie
FCurve *fcu, float *cvalue, float evaltime)
{
FModifier *fcm;
/* sanity checks */
if (ELEM(NULL, modifiers, modifiers->first))
return;
if (fcu->flag & FCURVE_MOD_OFF)
return;
/* evaluate modifiers */
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
if (fmi == NULL)
if (fmi == NULL)
continue;
/* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
@ -1507,7 +1507,7 @@ void evaluate_value_fmodifiers(FModifierStackStorage *storage, ListBase *modifie
}
}
}
}
}
/* ---------- */
@ -1517,24 +1517,24 @@ void evaluate_value_fmodifiers(FModifierStackStorage *storage, ListBase *modifie
void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
{
ChannelDriver *driver;
/* sanity checks */
/* TODO: make these tests report errors using reports not printf's */
if (ELEM(NULL, fcu, fcu->modifiers.first)) {
printf("Error: No F-Curve with F-Curve Modifiers to Bake\n");
return;
}
/* temporarily, disable driver while we sample, so that they don't influence the outcome */
driver = fcu->driver;
fcu->driver = NULL;
/* bake the modifiers, by sampling the curve at each frame */
fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
/* free the modifiers now */
free_fmodifiers(&fcu->modifiers);
/* restore driver */
fcu->driver = driver;
}

@ -148,7 +148,7 @@ static PackedFile *get_builtin_packedfile(void)
void *mem = MEM_mallocN(builtin_font_size, "vfd_builtin");
memcpy(mem, builtin_font_data, builtin_font_size);
return newPackedFileMemory(mem, builtin_font_size);
}
}
@ -205,7 +205,7 @@ static VFontData *vfont_get_data(VFont *vfont)
pf = get_builtin_packedfile();
}
}
if (pf) {
vfont->data = BLI_vfontdata_from_freetypefont(pf);
if (pf != vfont->packedfile) {
@ -246,10 +246,10 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
PackedFile *pf;
PackedFile *temp_pf = NULL;
bool is_builtin;
if (STREQ(filepath, FO_BUILTIN_NAME)) {
BLI_strncpy(filename, filepath, sizeof(filename));
pf = get_builtin_packedfile();
is_builtin = true;
}
@ -257,7 +257,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
BLI_split_file_part(filepath, filename, sizeof(filename));
pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain));
temp_pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain));
is_builtin = false;
}
@ -291,7 +291,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
freePackedFile(pf);
}
}
return vfont;
}
@ -348,13 +348,13 @@ static VFont *which_vfont(Curve *cu, CharInfo *info)
VFont *BKE_vfont_builtin_get(void)
{
VFont *vfont;
for (vfont = G_MAIN->vfont.first; vfont; vfont = vfont->id.next) {
if (BKE_vfont_is_builtin(vfont)) {
return vfont;
}
}
return BKE_vfont_load(G_MAIN, FO_BUILTIN_NAME);
}
@ -368,7 +368,7 @@ static void build_underline(Curve *cu, ListBase *nubase, const rctf *rect,
{
Nurb *nu2;
BPoint *bp;
nu2 = (Nurb *) MEM_callocN(sizeof(Nurb), "underline_nurb");
nu2->resolu = cu->resolu;
nu2->bezt = NULL;
@ -454,7 +454,7 @@ static void buildchar(Curve *cu, ListBase *nubase, unsigned int character, CharI
co = cosf(rot);
che = find_vfont_char(vfd, character);
/* Select the glyph data */
if (che)
nu1 = che->nurbsbase.first;
@ -488,10 +488,10 @@ static void buildchar(Curve *cu, ListBase *nubase, unsigned int character, CharI
}
memcpy(bezt2, bezt1, i * sizeof(struct BezTriple));
nu2->bezt = bezt2;
if (shear != 0.0f) {
bezt2 = nu2->bezt;
for (i = nu2->pntsu; i > 0; i--) {
bezt2->vec[0][0] += shear * bezt2->vec[0][1];
bezt2->vec[1][0] += shear * bezt2->vec[1][1];
@ -544,10 +544,10 @@ static void buildchar(Curve *cu, ListBase *nubase, unsigned int character, CharI
fp[7] = (fp[7] + ofsy) * fsize;
bezt2++;
}
BLI_addtail(nubase, nu2);
}
nu1 = nu1->next;
}
}
@ -557,7 +557,7 @@ int BKE_vfont_select_get(Object *ob, int *r_start, int *r_end)
Curve *cu = ob->data;
EditFont *ef = cu->editfont;
int start, end, direction;
if ((ob->type != OB_FONT) || (ef == NULL)) return 0;
BLI_assert(ef->len >= 0);
@ -681,7 +681,7 @@ bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
/* The VFont Data can not be found */
if (!vfd) return ok;
if (ef) {
slen = ef->len;
mem = ef->textbuf;
@ -734,9 +734,9 @@ bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
/* We assume the worst case: 1 character per line (is freed at end anyway) */
lineinfo = MEM_malloc_arrayN((slen * 2 + 1), sizeof(*lineinfo), "lineinfo");
linedist = cu->linedist;
curbox = 0;
textbox_scale(&tb_scale, &cu->tb[curbox], 1.0f / cu->fsize);
use_textbox = (tb_scale.w != 0.0f);
@ -886,7 +886,7 @@ makebreak:
}
else if (ascii == 9) { /* TAB */
float tabfac;
ct->xof = xof;
ct->yof = yof;
ct->linenr = lnr;
@ -911,27 +911,27 @@ makebreak:
sb->h = linedist * cu->fsize;
sb->w = xof * cu->fsize;
}
if (ascii == 32) {
wsfac = cu->wordspace;
wsfac = cu->wordspace;
wsnr++;
}
else {
wsfac = 1.0f;
}
/* Set the width of the character */
twidth = char_width(cu, che, info);
xof += (twidth * wsfac * (1.0f + (info->kern / 40.0f)) ) + xtrax;
if (sb) {
sb->w = (xof * cu->fsize) - sb->w;
}
}
ct++;
}
cu->lines = 1;
for (i = 0; i <= slen; i++) {
ascii = mem[i];
@ -1092,7 +1092,7 @@ makebreak:
copy_m3_m4(cmat, cu->textoncurve->obmat);
mul_m3_m3m3(cmat, cmat, imat3);
sizefac = normalize_v3(cmat[0]) / cu->fsize;
minx = miny = 1.0e20f;
maxx = maxy = -1.0e20f;
ct = chartransdata;
@ -1102,17 +1102,17 @@ makebreak:
if (miny > ct->yof) miny = ct->yof;
if (maxy < ct->yof) maxy = ct->yof;
}
/* we put the x-coordinaat exact at the curve, the y is rotated */
/* length correction */
distfac = sizefac * cu->textoncurve->curve_cache->path->totdist / (maxx - minx);
timeofs = 0.0f;
if (distfac > 1.0f) {
/* path longer than text: spacemode involves */
distfac = 1.0f / distfac;
if (cu->spacemode == CU_ALIGN_X_RIGHT) {
timeofs = 1.0f - distfac;
}
@ -1128,14 +1128,14 @@ makebreak:
}
distfac /= (maxx - minx);
timeofs += distfac * cu->xof; /* not cyclic */
ct = chartransdata;
for (i = 0; i < slen; i++, ct++) {
float ctime, dtime, vec[4], tvec[4], rotvec[3];
float si, co;
/* rotate around center character */
info = &custrinfo[i];
ascii = mem[i];
@ -1144,7 +1144,7 @@ makebreak:
}
che = find_vfont_char(vfd, ascii);
twidth = char_width(cu, che, info);
dtime = distfac * 0.5f * twidth;
@ -1156,16 +1156,16 @@ makebreak:
/* vec, tvec need 4 items */
where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL, NULL);
where_on_path(cu->textoncurve, ctime + dtime, tvec, rotvec, NULL, NULL, NULL);
mul_v3_fl(vec, sizefac);
ct->rot = (float)M_PI - atan2f(rotvec[1], rotvec[0]);
si = sinf(ct->rot);
co = cosf(ct->rot);
yof = ct->yof;
ct->xof = vec[0] + si * yof;
ct->yof = vec[1] + co * yof;
@ -1224,29 +1224,29 @@ makebreak:
}
}
}
/* cursor first */
if (ef) {
float si, co;
ct = &chartransdata[ef->pos];
si = sinf(ct->rot);
co = cosf(ct->rot);
f = ef->textcurs[0];
f[0] = cu->fsize * (-0.1f * co + ct->xof);
f[1] = cu->fsize * ( 0.1f * si + ct->yof);
f[2] = cu->fsize * ( 0.1f * co + ct->xof);
f[3] = cu->fsize * (-0.1f * si + ct->yof);
f[4] = cu->fsize * ( 0.1f * co + 0.8f * si + ct->xof);
f[5] = cu->fsize * (-0.1f * si + 0.8f * co + ct->yof);
f[6] = cu->fsize * (-0.1f * co + 0.8f * si + ct->xof);
f[7] = cu->fsize * ( 0.1f * si + 0.8f * co + ct->yof);
}
if (mode == FO_SELCHANGE) {
@ -1258,7 +1258,7 @@ makebreak:
if (mode == FO_EDIT) {
/* make nurbdata */
BKE_nurbList_free(r_nubase);
ct = chartransdata;
for (i = 0; i < slen; i++) {
unsigned int cha = (unsigned int) mem[i];

@ -27,7 +27,7 @@
* \ingroup bke
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -96,14 +96,14 @@ bool BKE_gpencil_free_strokes(bGPDframe *gpf)
void BKE_gpencil_free_frames(bGPDlayer *gpl)
{
bGPDframe *gpf_next;
/* error checking */
if (gpl == NULL) return;
/* free frames */
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf_next) {
gpf_next = gpf->next;
/* free strokes and their associated memory */
BKE_gpencil_free_strokes(gpf);
BLI_freelinkN(&gpl->frames, gpf);
@ -177,14 +177,14 @@ void BKE_gpencil_free_brushes(ListBase *list)
void BKE_gpencil_free_layers(ListBase *list)
{
bGPDlayer *gpl_next;
/* error checking */
if (list == NULL) return;
/* delete layers */
for (bGPDlayer *gpl = list->first; gpl; gpl = gpl_next) {
gpl_next = gpl->next;
/* free layers and their data */
BKE_gpencil_free_frames(gpl);
BLI_freelinkN(list, gpl);
@ -212,15 +212,15 @@ bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
{
bGPDframe *gpf = NULL, *gf = NULL;
short state = 0;
/* error checking */
if (gpl == NULL)
return NULL;
/* allocate memory for this frame */
gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe");
gpf->framenum = cframe;
/* find appropriate place to add frame */
if (gpl->frames.first) {
for (gf = gpl->frames.first; gf; gf = gf->next) {
@ -229,7 +229,7 @@ bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
state = -1;
break;
}
/* if current frame has already exceeded the frame to add, add before */
if (gf->framenum > cframe) {
BLI_insertlinkbefore(&gpl->frames, gf, gpf);
@ -238,14 +238,14 @@ bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
}
}
}
/* check whether frame was added successfully */
if (state == -1) {
printf("Error: Frame (%d) existed already for this layer. Using existing frame\n", cframe);
/* free the newly created one, and use the old one instead */
MEM_freeN(gpf);
/* return existing frame instead... */
BLI_assert(gf != NULL);
gpf = gf;
@ -254,7 +254,7 @@ bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
/* add to end then! */
BLI_addtail(&gpl->frames, gpf);
}
/* return frame */
return gpf;
}
@ -264,7 +264,7 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
{
bGPDframe *new_frame;
bool found = false;
/* Error checking/handling */
if (gpl == NULL) {
/* no layer */
@ -274,16 +274,16 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
/* no active frame, so just create a new one from scratch */
return BKE_gpencil_frame_addnew(gpl, cframe);
}
/* Create a copy of the frame */
new_frame = BKE_gpencil_frame_duplicate(gpl->actframe);
/* Find frame to insert it before */
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->framenum > cframe) {
/* Add it here */
BLI_insertlinkbefore(&gpl->frames, gpf, new_frame);
found = true;
break;
}
@ -294,23 +294,23 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
BKE_gpencil_free_strokes(new_frame);
MEM_freeN(new_frame);
new_frame = NULL;
found = true;
break;
}
}
if (found == false) {
/* Add new frame to the end */
BLI_addtail(&gpl->frames, new_frame);
}
/* Ensure that frame is set up correctly, and return it */
if (new_frame) {
new_frame->framenum = cframe;
gpl->actframe = new_frame;
}
return new_frame;
}
@ -318,17 +318,17 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setactive)
{
bGPDlayer *gpl;
/* check that list is ok */
if (gpd == NULL)
return NULL;
/* allocate memory for frame and add to end of list */
gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer");
/* add to datablock */
BLI_addtail(&gpd->layers, gpl);
/* set basic settings */
copy_v4_v4(gpl->color, U.gpencil_new_layer_col);
/* Since GPv2 thickness must be 0 */
@ -339,23 +339,23 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
/* onion-skinning settings */
if (gpd->flag & GP_DATA_SHOW_ONIONSKINS)
gpl->flag |= GP_LAYER_ONIONSKIN;
gpl->flag |= (GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL);
ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.145098f, 0.419608f, 0.137255f); /* green */
ARRAY_SET_ITEMS(gpl->gcolor_next, 0.125490f, 0.082353f, 0.529412f); /* blue */
/* high quality fill by default */
gpl->flag |= GP_LAYER_HQ_FILL;
/* auto-name */
BLI_strncpy(gpl->info, name, sizeof(gpl->info));
BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
/* make this one the active one */
if (setactive)
BKE_gpencil_layer_setactive(gpd, gpl);
/* return layer */
return gpl;
}
@ -625,18 +625,18 @@ bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const ch
bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
{
bGPdata *gpd;
/* allocate memory for a new block */
gpd = BKE_libblock_alloc(bmain, ID_GD, name, 0);
/* initial settings */
gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND);
/* for now, stick to view is also enabled by default
* since this is more useful...
*/
gpd->flag |= GP_DATA_VIEWALIGN;
return gpd;
}
@ -647,16 +647,16 @@ bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src)
{
bGPDstroke *gps_dst;
bGPDframe *gpf_dst;
/* error checking */
if (gpf_src == NULL) {
return NULL;
}
/* make a copy of the source frame */
gpf_dst = MEM_dupallocN(gpf_src);
gpf_dst->prev = gpf_dst->next = NULL;
/* copy strokes */
BLI_listbase_clear(&gpf_dst->strokes);
for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
@ -667,7 +667,7 @@ bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src)
gps_dst->flag |= GP_STROKE_RECALC_CACHES;
BLI_addtail(&gpf_dst->strokes, gps_dst);
}
/* return new frame */
return gpf_dst;
}
@ -727,28 +727,28 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
const bGPDframe *gpf_src;
bGPDframe *gpf_dst;
bGPDlayer *gpl_dst;
/* error checking */
if (gpl_src == NULL) {
return NULL;
}
/* make a copy of source layer */
gpl_dst = MEM_dupallocN(gpl_src);
gpl_dst->prev = gpl_dst->next = NULL;
/* copy frames */
BLI_listbase_clear(&gpl_dst->frames);
for (gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) {
/* make a copy of source frame */
gpf_dst = BKE_gpencil_frame_duplicate(gpf_src);
BLI_addtail(&gpl_dst->frames, gpf_dst);
/* if source frame was the current layer's 'active' frame, reassign that too */
if (gpf_src == gpl_dst->actframe)
gpl_dst->actframe = gpf_dst;
}
/* return new layer */
return gpl_dst;
}
@ -824,16 +824,16 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
{
bGPDspoint *pt;
int i;
/* error checking */
if (gps == NULL)
return;
/* we'll stop when we find the first selected point,
* so initially, we must deselect
*/
gps->flag &= ~GP_STROKE_SELECT;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
gps->flag |= GP_STROKE_SELECT;
@ -849,16 +849,16 @@ void BKE_gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
{
bGPDstroke *gps = (gpf) ? gpf->strokes.last : NULL;
int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */
/* error checking */
if (ELEM(NULL, gpf, gps))
return;
/* free the stroke and its data */
MEM_freeN(gps->points);
MEM_freeN(gps->triangles);
BLI_freelinkN(&gpf->strokes, gps);
/* if frame has no strokes after this, delete it */
if (BLI_listbase_is_empty(&gpf->strokes)) {
BKE_gpencil_layer_delframe(gpl, gpf);
@ -874,7 +874,7 @@ bool gpencil_layer_is_editable(const bGPDlayer *gpl)
/* Sanity check */
if (gpl == NULL)
return false;
/* Layer must be: Visible + Editable */
if ((gpl->flag & (GP_LAYER_HIDE | GP_LAYER_LOCKED)) == 0) {
/* Opacity must be sufficiently high that it is still "visible"
@ -884,7 +884,7 @@ bool gpencil_layer_is_editable(const bGPDlayer *gpl)
return true;
}
}
/* Something failed */
return false;
}
@ -893,7 +893,7 @@ bool gpencil_layer_is_editable(const bGPDlayer *gpl)
bGPDframe *BKE_gpencil_layer_find_frame(bGPDlayer *gpl, int cframe)
{
bGPDframe *gpf;
/* Search in reverse order, since this is often used for playback/adding,
* where it's less likely that we're interested in the earlier frames
*/
@ -902,7 +902,7 @@ bGPDframe *BKE_gpencil_layer_find_frame(bGPDlayer *gpl, int cframe)
return gpf;
}
}
return NULL;
}
@ -914,23 +914,23 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
{
bGPDframe *gpf = NULL;
short found = 0;
/* error checking */
if (gpl == NULL) return NULL;
/* check if there is already an active frame */
if (gpl->actframe) {
gpf = gpl->actframe;
/* do not allow any changes to layer's active frame if layer is locked from changes
* or if the layer has been set to stay on the current frame
*/
if (gpl->flag & GP_LAYER_FRAMELOCK)
return gpf;
/* do not allow any changes to actframe if frame has painting tag attached to it */
if (gpf->flag & GP_FRAME_PAINT)
if (gpf->flag & GP_FRAME_PAINT)
return gpf;
/* try to find matching frame */
if (gpf->framenum < cframe) {
for (; gpf; gpf = gpf->next) {
@ -943,7 +943,7 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
break;
}
}
/* set the appropriate frame */
if (addnew) {
if ((found) && (gpf->framenum == cframe))
@ -965,7 +965,7 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
break;
}
}
/* set the appropriate frame */
if (addnew) {
if ((found) && (gpf->framenum == cframe))
@ -985,7 +985,7 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
/* check which of the ends to start checking from */
const int first = ((bGPDframe *)(gpl->frames.first))->framenum;
const int last = ((bGPDframe *)(gpl->frames.last))->framenum;
if (abs(cframe - first) > abs(cframe - last)) {
/* find gp-frame which is less than or equal to cframe */
for (gpf = gpl->frames.last; gpf; gpf = gpf->prev) {
@ -1004,7 +1004,7 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
}
}
}
/* set the appropriate frame */
if (addnew) {
if ((found) && (gpf->framenum == cframe))
@ -1029,7 +1029,7 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
/* gpl->actframe should still be NULL */
}
}
/* return */
return gpl->actframe;
}
@ -1038,23 +1038,23 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
bool BKE_gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
{
bool changed = false;
/* error checking */
if (ELEM(NULL, gpl, gpf))
return false;
/* if this frame was active, make the previous frame active instead
/* if this frame was active, make the previous frame active instead
* since it's tricky to set active frame otherwise
*/
if (gpl->actframe == gpf)
gpl->actframe = gpf->prev;
else
gpl->actframe = NULL;
/* free the frame and its data */
changed = BKE_gpencil_free_strokes(gpf);
BLI_freelinkN(&gpl->frames, gpf);
return changed;
}
@ -1062,17 +1062,17 @@ bool BKE_gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
bGPDlayer *BKE_gpencil_layer_getactive(bGPdata *gpd)
{
bGPDlayer *gpl;
/* error checking */
if (ELEM(NULL, gpd, gpd->layers.first))
return NULL;
/* loop over layers until found (assume only one active) */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpl->flag & GP_LAYER_ACTIVE)
return gpl;
}
/* no active layer found */
return NULL;
}
@ -1081,15 +1081,15 @@ bGPDlayer *BKE_gpencil_layer_getactive(bGPdata *gpd)
void BKE_gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
{
bGPDlayer *gpl;
/* error checking */
if (ELEM(NULL, gpd, gpd->layers.first, active))
return;
/* loop over layers deactivating all */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next)
gpl->flag &= ~GP_LAYER_ACTIVE;
/* set as active one */
active->flag |= GP_LAYER_ACTIVE;
}
@ -1098,9 +1098,9 @@ void BKE_gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
void BKE_gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
{
/* error checking */
if (ELEM(NULL, gpd, gpl))
if (ELEM(NULL, gpd, gpl))
return;
/* free layer */
BKE_gpencil_free_frames(gpl);
BLI_freelinkN(&gpd->layers, gpl);
@ -1281,11 +1281,11 @@ void BKE_gpencil_palettecolor_changename(bGPdata *gpd, char *oldname, const char
bGPDlayer *gpl;
bGPDframe *gpf;
bGPDstroke *gps;
/* Sanity checks (gpd may not be set in the RNA pointers sometimes) */
if (ELEM(NULL, gpd, oldname, newname))
return;
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (gps = gpf->strokes.first; gps; gps = gps->next) {
@ -1295,7 +1295,7 @@ void BKE_gpencil_palettecolor_changename(bGPdata *gpd, char *oldname, const char
}
}
}
}
/* Delete all strokes of the color */
@ -1304,11 +1304,11 @@ void BKE_gpencil_palettecolor_delete_strokes(struct bGPdata *gpd, char *name)
bGPDlayer *gpl;
bGPDframe *gpf;
bGPDstroke *gps, *gpsn;
/* Sanity checks (gpd may not be set in the RNA pointers sometimes) */
if (ELEM(NULL, gpd, name))
return;
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (gps = gpf->strokes.first; gps; gps = gpsn) {

@ -78,7 +78,7 @@ void BKE_group_free(Group *group)
Group *BKE_group_add(Main *bmain, const char *name)
{
Group *group;
group = BKE_libblock_alloc(bmain, ID_GR, name, 0);
id_us_min(&group->id);
id_us_ensure_real(&group->id);
@ -126,22 +126,22 @@ void BKE_group_make_local(Main *bmain, Group *group, const bool lib_local)
static bool group_object_add_internal(Group *group, Object *ob)
{
GroupObject *go;
if (group == NULL || ob == NULL) {
return false;
}
/* check if the object has been added already */
if (BLI_findptr(&group->gobject, ob, offsetof(GroupObject, ob))) {
return false;
}
go = MEM_callocN(sizeof(GroupObject), "groupobject");
BLI_addtail(&group->gobject, go);
go->ob = ob;
id_us_ensure_real(&go->ob->id);
return true;
}
@ -171,7 +171,7 @@ static int group_object_unlink_internal(Group *group, Object *ob)
GroupObject *go, *gon;
int removed = 0;
if (group == NULL) return 0;
go = group->gobject.first;
while (go) {
gon = go->next;
@ -259,7 +259,7 @@ Group *BKE_group_object_find(Main *bmain, Group *group, Object *ob)
group = group->id.next;
else
group = bmain->group.first;
while (group) {
if (BKE_group_object_exists(group, ob))
return group;
@ -293,9 +293,9 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
static bAction *action = NULL;
static bool done = false;
bActionStrip *strip, *nstrip;
if (mode == 's') {
for (strip = parent->nlastrips.first; strip; strip = strip->next) {
if (strip->object == target) {
if (done == 0) {
@ -317,7 +317,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
BLI_freelistN(&target->nlastrips);
target->nlastrips = nlastrips;
target->action = action;
BLI_listbase_clear(&nlastrips); /* not needed, but yah... :) */
action = NULL;
done = false;
@ -334,7 +334,7 @@ void BKE_group_handle_recalc_and_update(
Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *UNUSED(parent), Group *group)
{
GroupObject *go;
#if 0 /* warning, isn't clearing the recalc flag on the object which causes it to run all the time,
* not just on frame change.
* This isn't working because the animation data is only re-evaluated on frame change so commenting for now
@ -343,24 +343,24 @@ void BKE_group_handle_recalc_and_update(
/* if animated group... */
if (parent->nlastrips.first) {
int cfrao;
/* switch to local time */
cfrao = scene->r.cfra;
/* we need a DAG per group... */
for (go = group->gobject.first; go; go = go->next) {
if (go->ob && go->recalc) {
go->ob->recalc = go->recalc;
group_replaces_nla(parent, go->ob, 's');
BKE_object_handle_update(eval_ctx, scene, go->ob);
group_replaces_nla(parent, go->ob, 'e');
/* leave recalc tags in case group members are in normal scene */
go->ob->recalc = go->recalc;
}
}
/* restore */
scene->r.cfra = cfrao;
}

@ -105,7 +105,7 @@ static int get_next_free_id(void)
/* if we haven't used up the int number range, we just return the next int */
if (gNextIconId >= gFirstIconId)
return gNextIconId++;
/* now we try to find the smallest icon id not stored in the gIcons hash */
while (BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(startId)) && startId >= gFirstIconId)
startId++;
@ -203,7 +203,7 @@ void BKE_previewimg_freefunc(void *link)
if (prv->gputexture[i])
GPU_texture_free(prv->gputexture[i]);
}
MEM_freeN(prv);
}
}
@ -468,11 +468,11 @@ void BKE_icon_changed(const int icon_id)
BLI_assert(BLI_thread_is_main());
Icon *icon = NULL;
if (!icon_id || G.background) return;
icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
if (icon) {
/* We *only* expect ID-tied icons here, not non-ID icon/preview! */
BLI_assert(icon->id_type != 0);
@ -599,7 +599,7 @@ Icon *BKE_icon_get(const int icon_id)
Icon *icon = NULL;
icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
if (!icon) {
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return NULL;

@ -47,7 +47,7 @@ typedef struct {
const char *name, *plural;
const char *i18n_context;
int flags;
#define IDTYPE_FLAGS_ISLINKABLE (1 << 0)
} IDType;
@ -99,7 +99,7 @@ static IDType idtypes[] = {
/* -1 for ID_ID */
BLI_STATIC_ASSERT((ARRAY_SIZE(idtypes) - 1 == MAX_LIBARRAY), "Missing IDType");
static IDType *idtype_from_name(const char *str)
static IDType *idtype_from_name(const char *str)
{
int i = ARRAY_SIZE(idtypes);
@ -118,7 +118,7 @@ static IDType *idtype_from_code(short idcode)
while (i--)
if (idcode == idtypes[i].code)
return &idtypes[i];
return NULL;
}

@ -86,7 +86,7 @@ IDProperty *IDP_NewIDPArray(const char *name)
prop->type = IDP_IDPARRAY;
prop->len = 0;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
return prop;
}
@ -113,14 +113,14 @@ IDProperty *IDP_CopyIDPArray(const IDProperty *array, const int flag)
memcpy(GETPROP(narray, i), tmp, sizeof(IDProperty));
MEM_freeN(tmp);
}
return narray;
}
static void IDP_FreeIDPArray(IDProperty *prop, const bool do_id_user)
{
int i;
BLI_assert(prop->type == IDP_IDPARRAY);
for (i = 0; i < prop->len; i++)
@ -472,7 +472,7 @@ static IDProperty *IDP_CopyID(const IDProperty *prop, const int flag)
static IDProperty *IDP_CopyGroup(const IDProperty *prop, const int flag)
{
IDProperty *newp, *link;
BLI_assert(prop->type == IDP_GROUP);
newp = idp_generic_copy(prop, flag);
newp->len = prop->len;
@ -1024,7 +1024,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
prop->type = type;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
return prop;
}

File diff suppressed because it is too large Load Diff

@ -106,14 +106,14 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
{
Key *key;
char *el;
key = BKE_libblock_alloc(bmain, ID_KE, "Key", 0);
key->type = KEY_NORMAL;
key->from = id;
key->uidgen = 1;
/* XXX the code here uses some defines which will soon be deprecated... */
switch (GS(id->name)) {
case ID_ME:
@ -150,7 +150,7 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
default:
break;
}
return key;
}
@ -192,24 +192,24 @@ Key *BKE_key_copy_nolib(Key *key)
{
Key *keyn;
KeyBlock *kbn, *kb;
keyn = MEM_dupallocN(key);
keyn->adt = NULL;
BLI_duplicatelist(&keyn->block, &key->block);
kb = key->block.first;
kbn = keyn->block.first;
while (kbn) {
if (kbn->data) kbn->data = MEM_dupallocN(kbn->data);
if (kb == key->refkey) keyn->refkey = kbn;
kbn = kbn->next;
kb = kb->next;
}
return keyn;
}
@ -223,7 +223,7 @@ void BKE_key_sort(Key *key)
KeyBlock *kb;
KeyBlock *kb2;
/* locate the key which is out of position */
/* locate the key which is out of position */
for (kb = key->block.first; kb; kb = kb->next)
if ((kb->next) && (kb->pos > kb->next->pos))
break;
@ -232,7 +232,7 @@ void BKE_key_sort(Key *key)
if (kb) {
kb = kb->next; /* next key is the out-of-order one */
BLI_remlink(&key->block, kb);
/* find the right location and insert before */
for (kb2 = key->block.first; kb2; kb2 = kb2->next) {
if (kb2->pos > kb->pos) {
@ -251,7 +251,7 @@ void BKE_key_sort(Key *key)
void key_curve_position_weights(float t, float data[4], int type)
{
float t2, t3, fc;
if (type == KEY_LINEAR) {
data[0] = 0.0f;
data[1] = -t + 1.0f;
@ -293,7 +293,7 @@ void key_curve_position_weights(float t, float data[4], int type)
void key_curve_tangent_weights(float t, float data[4], int type)
{
float t2, fc;
if (type == KEY_LINEAR) {
data[0] = 0.0f;
data[1] = -1.0f;
@ -332,7 +332,7 @@ void key_curve_tangent_weights(float t, float data[4], int type)
void key_curve_normal_weights(float t, float data[4], int type)
{
float fc;
if (type == KEY_LINEAR) {
data[0] = 0.0f;
data[1] = 0.0f;
@ -415,7 +415,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
t[3] = k[3]->pos;
k1 = k[3];
}
while (t[2] < fac) { /* find correct location */
if (k1->next == NULL) {
if (cycl) {
@ -441,7 +441,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
if (ofs > 2.1f + lastpos) break;
}
bsplinetype = 0;
if (k[1]->type == KEY_BSPLINE || k[2]->type == KEY_BSPLINE) bsplinetype = 1;
@ -499,7 +499,7 @@ static void flerp(int tot, float *in, float *f0, float *f1, float *f2, float *f3
static void rel_flerp(int tot, float *in, float *ref, float *out, float fac)
{
int a;
for (a = 0; a < tot; a++) {
in[a] -= fac * (ref[a] - out[a]);
}
@ -588,7 +588,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
return;
if (end > tot) end = tot;
if (tot != kb->totelem) {
ktot = 0.0;
flagflo = 1;
@ -605,9 +605,9 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
/* this exception is needed curves with multiple splines */
if (start != 0) {
poin += poinsize * start;
if (flagflo) {
ktot += start * kd;
a = (int)floor(ktot);
@ -620,13 +620,13 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
k1 += start * key->elemsize;
}
}
if (mode == KEY_MODE_BEZTRIPLE) {
elemstr[0] = 1;
elemstr[1] = IPO_BEZTRIPLE;
elemstr[2] = 0;
}
/* just do it here, not above! */
elemsize = key->elemsize;
if (mode == KEY_MODE_BEZTRIPLE) elemsize *= 3;
@ -668,7 +668,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
poin += *ofsp;
cp += 2; ofsp++;
}
/* are we going to be nasty? */
if (flagflo) {
ktot += kd;
@ -682,7 +682,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
k1 += elemsize;
kref += elemsize;
}
if (mode == KEY_MODE_BEZTRIPLE) {
a += 2;
}
@ -748,13 +748,13 @@ void BKE_key_evaluate_relative(const int start, int end, const int tot, char *ba
/* step 1 init */
cp_key(start, end, tot, basispoin, key, actkb, key->refkey, NULL, mode);
/* step 2: do it */
for (kb = key->block.first, keyblock_index = 0; kb; kb = kb->next, keyblock_index++) {
if (kb != key->refkey) {
float icuval = kb->curval;
/* only with value, and no difference allowed */
if (!(kb->flag & KEYBLOCK_MUTE) && icuval != 0.0f && kb->totelem == tot) {
KeyBlock *refb;
@ -764,7 +764,7 @@ void BKE_key_evaluate_relative(const int start, int end, const int tot, char *ba
/* reference now can be any block */
refb = BLI_findlink(&key->block, kb->relative);
if (refb == NULL) continue;
poin = basispoin;
from = key_block_get_data(key, actkb, kb, &freefrom);
reffrom = key_block_get_data(key, actkb, refb, &freereffrom);
@ -772,18 +772,18 @@ void BKE_key_evaluate_relative(const int start, int end, const int tot, char *ba
poin += start * poinsize;
reffrom += key->elemsize * start; // key elemsize yes!
from += key->elemsize * start;
for (b = start; b < end; b++) {
weight = weights ? (*weights * icuval) : icuval;
cp = key->elemstr;
if (mode == KEY_MODE_BEZTRIPLE) cp = elemstr;
ofsp = ofs;
while (cp[0]) { /* (cp[0] == amount) */
switch (cp[1]) {
case IPO_FLOAT:
rel_flerp(3, (float *)poin, (float *)reffrom, (float *)from, weight);
@ -803,14 +803,14 @@ void BKE_key_evaluate_relative(const int start, int end, const int tot, char *ba
}
poin += *ofsp;
cp += 2;
ofsp++;
}
reffrom += elemsize;
from += elemsize;
if (mode == KEY_MODE_BEZTRIPLE) b += 2;
if (weights) weights++;
}
@ -837,7 +837,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
if (!key_pointer_size(key, mode, &poinsize, &ofs[0]))
return;
if (end > tot) end = tot;
k1 = key_block_get_data(key, actkb, k[0], &freek1);
@ -891,7 +891,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
if (start != 0) {
poin += poinsize * start;
if (flagdo & 1) {
if (flagflo & 1) {
k1tot += start * k1d;
@ -957,10 +957,10 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
if (mode == KEY_MODE_BEZTRIPLE) elemsize *= 3;
for (a = start; a < end; a++) {
cp = key->elemstr;
if (mode == KEY_MODE_BEZTRIPLE) cp = elemstr;
ofsp = ofs;
while (cp[0]) { /* (cp[0] == amount) */
@ -984,7 +984,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
BLI_assert(!"invalid 'cp[1]'");
return;
}
poin += *ofsp;
cp += 2;
ofsp++;
@ -1038,7 +1038,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
k4 += elemsize;
}
}
if (mode == KEY_MODE_BEZTRIPLE) a += 2;
}
@ -1055,10 +1055,10 @@ static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cac
BMIter iter;
BMVert *eve;
int totvert = 0, defgrp_index = 0;
/* no vgroup string set? */
if (vgroup[0] == 0) return NULL;
/* gather dvert and totvert */
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
@ -1073,9 +1073,9 @@ static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cac
dvert = lt->dvert;
totvert = lt->pntsu * lt->pntsv * lt->pntsw;
}
if (dvert == NULL) return NULL;
/* find the group (weak loop-in-loop) */
defgrp_index = defgroup_name_index(ob, vgroup);
if (defgrp_index != -1) {
@ -1197,7 +1197,7 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float
{
Nurb *nu;
int a, step;
for (a = 0, nu = cu->nurb.first; nu; nu = nu->next, a += step) {
if (nu->bp) {
step = nu->pntsu * nu->pntsv;
@ -1217,7 +1217,7 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const
{
Nurb *nu;
int a, step;
for (a = 0, nu = cu->nurb.first; nu; nu = nu->next, a += step) {
if (nu->bp) {
step = nu->pntsu * nu->pntsv;
@ -1263,7 +1263,7 @@ static void do_latt_key(Object *ob, Key *key, char *out, const int tot)
KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob);
float t[4];
int flag;
if (key->type == KEY_RELATIVE) {
float **per_keyblock_weights;
per_keyblock_weights = BKE_keyblock_get_per_block_weights(ob, key, NULL);
@ -1272,7 +1272,7 @@ static void do_latt_key(Object *ob, Key *key, char *out, const int tot)
}
else {
const float ctime_scaled = key->ctime / 100.0f;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0) {
@ -1331,7 +1331,7 @@ float *BKE_key_evaluate_object_ex(
/* if nothing to interpolate, cancel */
if (tot == 0 || size == 0)
return NULL;
/* allocate array */
if (arr == NULL) {
out = MEM_callocN(size, "BKE_key_evaluate_object out");
@ -1346,11 +1346,11 @@ float *BKE_key_evaluate_object_ex(
/* prevent python from screwing this up? anyhoo, the from pointer could be dropped */
key->from = (ID *)ob->data;
if (ob->shapeflag & OB_SHAPE_LOCK) {
/* shape locked, copy the locked shape instead of blending */
KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1);
if (kb && (kb->flag & KEYBLOCK_MUTE))
kb = key->refkey;
@ -1358,7 +1358,7 @@ float *BKE_key_evaluate_object_ex(
kb = key->block.first;
ob->shapenr = 1;
}
if (OB_TYPE_SUPPORT_VGROUP(ob->type)) {
float *weights = get_weights_array(ob, kb->vgroup, NULL);
@ -1370,13 +1370,13 @@ float *BKE_key_evaluate_object_ex(
cp_cu_key(ob->data, key, actkb, kb, 0, tot, out, tot);
}
else {
if (ob->type == OB_MESH) do_mesh_key(ob, key, out, tot);
else if (ob->type == OB_LATTICE) do_latt_key(ob, key, out, tot);
else if (ob->type == OB_CURVE) do_curve_key(ob, key, out, tot);
else if (ob->type == OB_SURF) do_curve_key(ob, key, out, tot);
}
if (r_totelem) {
*r_totelem = tot;
}
@ -1451,14 +1451,14 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
KeyBlock *kb;
float curpos = -0.1;
int tot;
kb = key->block.last;
if (kb) curpos = kb->pos;
kb = MEM_callocN(sizeof(KeyBlock), "Keyblock");
BLI_addtail(&key->block, kb);
kb->type = KEY_CARDINAL;
tot = BLI_listbase_count(&key->block);
if (name) {
BLI_strncpy(kb->name, name, sizeof(kb->name));
@ -1476,7 +1476,7 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
key->totkey++;
if (key->totkey == 1) key->refkey = kb;
kb->slidermin = 0.0f;
kb->slidermax = 1.0f;
@ -1523,10 +1523,10 @@ KeyBlock *BKE_keyblock_add_ctime(Key *key, const char *name, const bool do_force
}
/* only the active keyblock */
KeyBlock *BKE_keyblock_from_object(Object *ob)
KeyBlock *BKE_keyblock_from_object(Object *ob)
{
Key *key = BKE_key_from_object(ob);
if (key) {
KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1);
return kb;
@ -1538,7 +1538,7 @@ KeyBlock *BKE_keyblock_from_object(Object *ob)
KeyBlock *BKE_keyblock_from_object_reference(Object *ob)
{
Key *key = BKE_key_from_object(ob);
if (key)
return key->refkey;
@ -1550,18 +1550,18 @@ KeyBlock *BKE_keyblock_from_key(Key *key, int index)
{
KeyBlock *kb;
int i;
if (key) {
kb = key->block.first;
for (i = 1; i < key->totkey; i++) {
kb = kb->next;
if (index == i)
return kb;
}
}
return NULL;
}
@ -1585,23 +1585,23 @@ void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src)
kb_dst->slidermax = kb_src->slidermax;
}
/* Get RNA-Path for 'value' setting of the given ShapeKey
/* Get RNA-Path for 'value' setting of the given ShapeKey
* NOTE: the user needs to free the returned string once they're finish with it
*/
char *BKE_keyblock_curval_rnapath_get(Key *key, KeyBlock *kb)
{
PointerRNA ptr;
PropertyRNA *prop;
/* sanity checks */
if (ELEM(NULL, key, kb))
return NULL;
/* create the RNA pointer */
RNA_pointer_create(&key->id, &RNA_ShapeKey, kb, &ptr);
/* get pointer to the property too */
prop = RNA_struct_find_property(&ptr, "value");
/* return the path */
return RNA_path_from_ID_to_property(&ptr, prop);
}
@ -1689,7 +1689,7 @@ void BKE_keyblock_update_from_curve(Curve *UNUSED(cu), KeyBlock *kb, ListBase *n
}
}
else {
;
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a; a--, fp += 4, bp++) {
copy_v3_v3(fp, bp->vec);

@ -100,7 +100,7 @@ void BKE_lamp_init(Lamp *la)
la->sky_colorspace = BLI_XYZ_CIE;
la->sky_exposure = 1.0f;
la->shadow_frustum_size = 10.0f;
curvemapping_initialize(la->curfalloff);
}
@ -166,7 +166,7 @@ Lamp *BKE_lamp_localize(Lamp *la)
Lamp *lan;
int a;
lan = BKE_libblock_copy_nolib(&la->id, false);
for (a = 0; a < MAX_MTEX; a++) {
@ -175,12 +175,12 @@ Lamp *BKE_lamp_localize(Lamp *la)
memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
}
}
lan->curfalloff = curvemapping_copy(la->curfalloff);
if (la->nodetree)
lan->nodetree = ntreeLocalize(la->nodetree);
lan->preview = NULL;
return lan;
@ -198,7 +198,7 @@ void BKE_lamp_free(Lamp *la)
for (a = 0; a < MAX_MTEX; a++) {
MEM_SAFE_FREE(la->mtex[a]);
}
BKE_animdata_free((ID *)la, false);
curvemapping_free(la->curfalloff);
@ -209,7 +209,7 @@ void BKE_lamp_free(Lamp *la)
MEM_freeN(la->nodetree);
la->nodetree = NULL;
}
BKE_previewimg_free(&la->preview);
BKE_icon_id_delete(&la->id);
la->id.icon_id = 0;
@ -224,7 +224,7 @@ static void lamp_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime
/* nodetree itself */
if (ntree->adt && ntree->adt->drivers.first)
BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS);
/* nodes */
for (node = ntree->nodes.first; node; node = node->next)
if (node->id && node->type == NODE_GROUP)
@ -240,11 +240,11 @@ void lamp_drivers_update(Scene *scene, Lamp *la, float ctime)
return;
la->id.tag |= LIB_TAG_DOIT;
/* lamp itself */
if (la->adt && la->adt->drivers.first)
BKE_animsys_evaluate_animdata(scene, &la->id, la->adt, ctime, ADT_RECALC_DRIVERS);
/* nodes */
if (la->nodetree)
lamp_node_drivers_update(scene, la->nodetree, ctime);

@ -156,13 +156,13 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
int i, u, v, w;
float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
float *co, (*vertexCos)[3] = NULL;
/* vertex weight groups are just freed all for now */
if (lt->dvert) {
BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
lt->dvert = NULL;
}
while (uNew * vNew * wNew > 32000) {
if (uNew >= vNew && uNew >= wNew) uNew--;
else if (vNew >= uNew && vNew >= wNew) vNew--;
@ -207,7 +207,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
}
}
}
if (ltOb) {
float mat[4][4];
int typeu = lt->typeu, typev = lt->typev, typew = lt->typew;
@ -242,9 +242,9 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
lt->actbp = LT_ACTBP_NONE;
MEM_freeN(lt->def);
lt->def = MEM_callocN(lt->pntsu * lt->pntsv * lt->pntsw * sizeof(BPoint), "lattice bp");
bp = lt->def;
for (i = 0; i < lt->pntsu * lt->pntsv * lt->pntsw; i++, bp++) {
copy_v3_v3(bp->vec, vertexCos[i]);
}
@ -257,9 +257,9 @@ void BKE_lattice_init(Lattice *lt)
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(lt, id));
lt->flag = LT_GRID;
lt->typeu = lt->typev = lt->typew = KEY_BSPLINE;
lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
lt->actbp = LT_ACTBP_NONE;
@ -360,14 +360,14 @@ LatticeDeformData *init_latt_deform(Object *oblatt, Object *ob)
if (lt->editlatt) lt = lt->editlatt->latt;
bp = lt->def;
fp = latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw, "latticedata");
/* for example with a particle system: (ob == NULL) */
if (ob == NULL) {
/* in deformspace, calc matrix */
invert_m4_m4(latmat, oblatt->obmat);
/* back: put in deform array */
invert_m4_m4(imat, latmat);
}
@ -375,11 +375,11 @@ LatticeDeformData *init_latt_deform(Object *oblatt, Object *ob)
/* in deformspace, calc matrix */
invert_m4_m4(imat, oblatt->obmat);
mul_m4_m4m4(latmat, imat, ob->obmat);
/* back: put in deform array */
invert_m4_m4(imat, latmat);
}
for (w = 0, fw = lt->fw; w < lt->pntsw; w++, fw += lt->dw) {
for (v = 0, fv = lt->fv; v < lt->pntsv; v++, fv += lt->dv) {
for (u = 0, fu = lt->fu; u < lt->pntsu; u++, bp++, co += 3, fp += 3, fu += lt->du) {
@ -555,7 +555,7 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di
BevList *bl;
float ctime1;
int cycl = 0;
/* test for cyclic */
bl = ob->curve_cache->bev.first;
if (!bl->nr) return false;
@ -567,14 +567,14 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di
else {
ctime1 = ctime;
}
/* vec needs 4 items */
if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {
if (cycl == 0) {
Path *path = ob->curve_cache->path;
float dvec[3];
if (ctime < 0.0f) {
sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
mul_v3_fl(dvec, ctime * (float)path->len);
@ -642,7 +642,7 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
}
}
}
if (where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
float quat[4], cent[3];
@ -688,7 +688,7 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
/* scale if enabled */
if (cu->flag & CU_PATH_RADIUS)
mul_v3_fl(cent, radius);
/* local rotation */
normalize_qt(quat);
mul_qt_v3(quat, cent);
@ -732,7 +732,7 @@ void curve_deform_verts(
cd.dmin[0] = cd.dmin[1] = cd.dmin[2] = -1.0f;
cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 0.0f;
}
/* Check whether to use vertex groups (only possible if target is a Mesh or Lattice).
* We want either a Mesh/Lattice with no derived data, or derived data with deformverts.
*/
@ -805,12 +805,12 @@ void curve_deform_verts(
else {
/* set mesh min max bounds */
INIT_MINMAX(cd.dmin, cd.dmax);
for (a = 0; a < numVerts; a++) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
minmax_v3v3_v3(cd.dmin, cd.dmax, vertexCos[a]);
}
for (a = 0; a < numVerts; a++) {
/* already in 'cd.curvespace', prev for loop */
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
@ -828,7 +828,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
{
CurveDeform cd;
float quat[4];
if (cuOb->type != OB_CURVE) {
unit_m3(mat);
return;
@ -836,21 +836,21 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
init_curve_deform(cuOb, target, &cd);
cd.no_rot_axis = no_rot_axis; /* option to only rotate for XY, for example */
copy_v3_v3(cd.dmin, orco);
copy_v3_v3(cd.dmax, orco);
mul_m4_v3(cd.curvespace, vec);
if (calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) {
float qmat[3][3];
quat_to_mat3(qmat, quat);
mul_m3_m3m3(mat, qmat, cd.objectspace3);
}
else
unit_m3(mat);
mul_m4_v3(cd.objectspace, vec);
}
@ -938,11 +938,11 @@ void outside_lattice(Lattice *lt)
if (lt->pntsu > 1) du = 1.0f / ((float)lt->pntsu - 1);
if (lt->pntsv > 1) dv = 1.0f / ((float)lt->pntsv - 1);
if (lt->pntsw > 1) dw = 1.0f / ((float)lt->pntsw - 1);
for (w = 0; w < lt->pntsw; w++) {
for (v = 0; v < lt->pntsv; v++) {
for (u = 0; u < lt->pntsu; u++, bp++) {
if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 || w == lt->pntsw - 1) {
/* pass */
@ -950,41 +950,41 @@ void outside_lattice(Lattice *lt)
else {
bp->hide = 1;
bp->f1 &= ~SELECT;
/* u extrema */
bp1 = latt_bp(lt, 0, v, w);
bp2 = latt_bp(lt, lt->pntsu - 1, v, w);
fac1 = du * u;
bp->vec[0] = (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
bp->vec[1] = (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
bp->vec[2] = (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
/* v extrema */
bp1 = latt_bp(lt, u, 0, w);
bp2 = latt_bp(lt, u, lt->pntsv - 1, w);
fac1 = dv * v;
bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
/* w extrema */
bp1 = latt_bp(lt, u, v, 0);
bp2 = latt_bp(lt, u, v, lt->pntsw - 1);
fac1 = dw * w;
bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
mul_v3_fl(bp->vec, 1.0f / 3.0f);
}
}
}
}
}
else {
@ -1005,9 +1005,9 @@ float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3]
if (lt->editlatt) lt = lt->editlatt->latt;
numVerts = *r_numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
vertexCos = MEM_mallocN(sizeof(*vertexCos) * numVerts, "lt_vcos");
for (i = 0; i < numVerts; i++) {
copy_v3_v3(vertexCos[i], lt->def[i].vec);
}
@ -1044,7 +1044,7 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene = scene;
if (!(mti->flags & eModifierTypeFlag_AcceptsLattice)) continue;
if (!(md->mode & eModifierMode_Realtime)) continue;
if (editmode && !(md->mode & eModifierMode_Editmode)) continue;
@ -1057,14 +1057,14 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
/* always displist to make this work like derivedmesh */
if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts);
{
DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl");
dl->type = DL_VERTS;
dl->parts = 1;
dl->nr = numVerts;
dl->verts = (float *) vertexCos;
BLI_addtail(&ob->curve_cache->disp, dl);
}
}
@ -1146,7 +1146,7 @@ void BKE_lattice_minmax_dl(Object *ob, Lattice *lt, float min[3], float max[3])
}
else {
int i, numVerts;
if (lt->editlatt) lt = lt->editlatt->latt;
numVerts = lt->pntsu * lt->pntsv * lt->pntsw;

@ -139,7 +139,7 @@
# include "PIL_time_utildefines.h"
#endif
/* GS reads the memory pointed at in a specific ordering.
/* GS reads the memory pointed at in a specific ordering.
* only use this definition, makes little and big endian systems
* work fine, in conjunction with MAKE_ID */
@ -685,7 +685,7 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
{
ID *newid = NULL;
PointerRNA idptr;
if (id) {
/* if property isn't editable, we're going to have an extra block hanging around until we save */
if (RNA_property_editable(ptr, prop)) {
@ -701,12 +701,12 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
RNA_id_pointer_create(newid, &idptr);
RNA_property_pointer_set(ptr, prop, idptr);
RNA_property_update(C, ptr, prop);
return true;
}
}
}
return false;
}
@ -992,9 +992,9 @@ int set_listbasepointers(Main *main, ListBase **lb)
lb[INDEX_ID_TE] = &(main->tex);
lb[INDEX_ID_MA] = &(main->mat);
lb[INDEX_ID_VF] = &(main->vfont);
/* Important!: When adding a new object type,
* the specific data should be inserted here
* the specific data should be inserted here
*/
lb[INDEX_ID_AR] = &(main->armature);
@ -1025,7 +1025,7 @@ int set_listbasepointers(Main *main, ListBase **lb)
lb[INDEX_ID_SCE] = &(main->scene);
lb[INDEX_ID_WM] = &(main->wm);
lb[INDEX_ID_MSK] = &(main->mask);
lb[INDEX_ID_NULL] = NULL;
return (MAX_LIBARRAY - 1);
@ -1280,7 +1280,7 @@ void BKE_libblock_init_empty(ID *id)
static void id_copy_animdata(Main *bmain, ID *id, const bool do_action)
{
AnimData *adt = BKE_animdata_from_id(id);
if (adt) {
IdAdtTemplate *iat = (IdAdtTemplate *)id;
iat->adt = BKE_animdata_copy(bmain, iat->adt, do_action); /* could be set to false, need to investigate */
@ -1383,7 +1383,7 @@ void BKE_main_free(Main *mainvar)
while (a--) {
ListBase *lb = lbarray[a];
ID *id;
while ( (id = lb->first) ) {
#if 1
BKE_libblock_free_ex(mainvar, id, false, false);
@ -1623,11 +1623,11 @@ ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *nam
void id_sort_by_name(ListBase *lb, ID *id)
{
ID *idtest;
/* insert alphabetically */
if (lb->first != lb->last) {
BLI_remlink(lb, id);
idtest = lb->first;
while (idtest) {
if (BLI_strcasecmp(idtest->name, id->name) > 0 || (idtest->lib && !id->lib)) {
@ -1641,7 +1641,7 @@ void id_sort_by_name(ListBase *lb, ID *id)
BLI_addtail(lb, id);
}
}
}
/**
@ -1651,9 +1651,9 @@ void id_sort_by_name(ListBase *lb, ID *id)
static ID *is_dupid(ListBase *lb, ID *id, const char *name)
{
ID *idtest = NULL;
for (idtest = lb->first; idtest; idtest = idtest->next) {
/* if idtest is not a lib */
/* if idtest is not a lib */
if (id != idtest && !ID_IS_LINKED(idtest)) {
/* do not test alphabetic! */
/* optimized */
@ -1662,7 +1662,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name)
}
}
}
return idtest;
}
@ -1751,8 +1751,8 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
* or 1 greater than the largest used number if all those low ones are taken.
* We can't be bothered to look for the lowest unused number beyond (MAX_IN_USE - 1). */
/* If the original name has no numeric suffix,
* rather than just chopping and adding numbers,
/* If the original name has no numeric suffix,
* rather than just chopping and adding numbers,
* shave off the end chars until we have a unique name.
* Check the null terminators match as well so we don't get Cube.000 -> Cube.00 */
if (nr == 0 && name[left_len] == '\0') {
@ -1763,7 +1763,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
len = left_len - 1;
idtest = is_dupid(lb, id, name);
while (idtest && len > 1) {
name[len--] = '\0';
idtest = is_dupid(lb, id, name);
@ -1771,7 +1771,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
if (idtest == NULL) return true;
/* otherwise just continue and use a number suffix */
}
if (nr > 999 && left_len > (MAX_ID_NAME - 8)) {
/* this would overflow name buffer */
left[MAX_ID_NAME - 8] = 0;
@ -1834,7 +1834,7 @@ bool new_id(ListBase *lb, ID *id, const char *tname)
#endif
id_sort_by_name(lb, id);
return result;
}
@ -2349,7 +2349,7 @@ void BLI_libblock_ensure_unique_name(Main *bmain, const char *name)
lb = which_libbase(bmain, GS(name));
if (lb == NULL) return;
/* search for id */
idtest = BLI_findstring(lb, name + 2, offsetof(ID, name) + 2);

@ -1004,7 +1004,7 @@ void BKE_libblock_free(Main *bmain, void *idv)
void BKE_libblock_free_us(Main *bmain, void *idv) /* test users */
{
ID *id = idv;
id_us_min(id);
/* XXX This is a temp (2.77) hack so that we keep same behavior as in 2.76 regarding groups when deleting an object.
@ -1020,7 +1020,7 @@ void BKE_libblock_free_us(Main *bmain, void *idv) /* test users */
if (id->us == 0) {
BKE_libblock_unlink(bmain, id, false, false);
BKE_libblock_free(bmain, id);
}
}

@ -49,8 +49,8 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_array_utils.h"
@ -90,14 +90,14 @@ void BKE_material_free(Material *ma)
int a;
BKE_animdata_free((ID *)ma, false);
for (a = 0; a < MAX_MTEX; a++) {
MEM_SAFE_FREE(ma->mtex[a]);
}
MEM_SAFE_FREE(ma->ramp_col);
MEM_SAFE_FREE(ma->ramp_spec);
/* is no lib link block, but material extension */
if (ma->nodetree) {
ntreeFreeTree(ma->nodetree);
@ -154,13 +154,13 @@ void BKE_material_init(Material *ma)
ma->tx_falloff = 1.0;
ma->shad_alpha = 1.0f;
ma->vcol_alpha = 0;
ma->gloss_mir = ma->gloss_tra = 1.0;
ma->samp_gloss_mir = ma->samp_gloss_tra = 18;
ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005;
ma->dist_mir = 0.0;
ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
ma->rampfac_col = 1.0;
ma->rampfac_spec = 1.0;
ma->pr_lamp = 3; /* two lamps, is bits */
@ -197,11 +197,11 @@ void BKE_material_init(Material *ma)
ma->vol.ms_spread = 0.2f;
ma->vol.ms_diff = 1.f;
ma->vol.ms_intensity = 1.f;
ma->game.flag = GEMAT_BACKCULL;
ma->game.alpha_blend = 0;
ma->game.face_orientation = 0;
ma->mode = MA_TRACEBLE | MA_SHADBUF | MA_SHADOW | MA_RAYBIAS | MA_TANGENT_STR | MA_ZTRANSP;
ma->mode2 = MA_CASTSHADOW;
ma->shade_flag = MA_APPROX_OCCLUSION;
@ -213,9 +213,9 @@ Material *BKE_material_add(Main *bmain, const char *name)
Material *ma;
ma = BKE_libblock_alloc(bmain, ID_MA, name, 0);
BKE_material_init(ma);
return ma;
}
@ -282,7 +282,7 @@ Material *BKE_material_localize(Material *ma)
Material *man;
int a;
man = BKE_libblock_copy_nolib(&ma->id, false);
/* no increment for texture ID users, in previewrender.c it prevents decrement */
@ -292,18 +292,18 @@ Material *BKE_material_localize(Material *ma)
memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
}
}
if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col);
if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec);
man->texpaintslot = NULL;
man->preview = NULL;
if (ma->nodetree)
man->nodetree = ntreeLocalize(ma->nodetree);
BLI_listbase_clear(&man->gpumaterial);
return man;
}
@ -317,7 +317,7 @@ Material ***give_matarar(Object *ob)
Mesh *me;
Curve *cu;
MetaBall *mb;
if (ob->type == OB_MESH) {
me = ob->data;
return &(me->mat);
@ -338,7 +338,7 @@ short *give_totcolp(Object *ob)
Mesh *me;
Curve *cu;
MetaBall *mb;
if (ob->type == OB_MESH) {
me = ob->data;
return &(me->totcol);
@ -512,7 +512,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data
DAG_relations_tag_update(bmain);
}
}
return ret;
}
@ -546,7 +546,7 @@ Material *give_current_material(Object *ob, short act)
const short *totcolp;
if (ob == NULL) return NULL;
/* if object cannot have material, (totcolp == NULL) */
totcolp = give_totcolp(ob);
if (totcolp == NULL || ob->totcol == 0) return NULL;
@ -572,12 +572,12 @@ Material *give_current_material(Object *ob, short act)
if (act > ob->totcol) act = ob->totcol;
matarar = give_matarar(ob);
if (matarar && *matarar) ma = (*matarar)[act - 1];
else ma = NULL;
}
return ma;
}
@ -720,18 +720,18 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig
if (act > MAXMAT) return;
if (act < 1) act = 1;
/* prevent crashing when using accidentally */
BLI_assert(!ID_IS_LINKED(ob));
if (ID_IS_LINKED(ob)) return;
/* test arraylens */
totcolp = give_totcolp(ob);
matarar = give_matarar(ob);
if (totcolp == NULL || matarar == NULL) return;
if (act > *totcolp) {
matar = MEM_callocN(sizeof(void *) * act, "matarray1");
@ -775,7 +775,7 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig
break;
}
}
/* do it */
ob->matbits[act - 1] = bit;
@ -910,14 +910,14 @@ short BKE_object_material_slot_find_index(Object *ob, Material *ma)
{
Material ***matarar;
short a, *totcolp;
if (ma == NULL) return 0;
totcolp = give_totcolp(ob);
matarar = give_matarar(ob);
if (totcolp == NULL || matarar == NULL) return 0;
for (a = 0; a < *totcolp; a++)
if ((*matarar)[a] == ma)
break;
@ -930,7 +930,7 @@ bool BKE_object_material_slot_add(Main *bmain, Object *ob)
{
if (ob == NULL) return false;
if (ob->totcol >= MAXMAT) return false;
assign_material(bmain, ob, NULL, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
ob->actcol = ob->totcol;
return true;
@ -940,25 +940,25 @@ static void do_init_render_material(Main *bmain, Material *ma, int r_mode, float
{
MTex *mtex;
int a, needuv = 0, needtang = 0;
if (ma->flarec == 0) ma->flarec = 1;
/* add all texcoflags from mtex, texco and mapto were cleared in advance */
for (a = 0; a < MAX_MTEX; a++) {
/* separate tex switching */
if (ma->septex & (1 << a)) continue;
mtex = ma->mtex[a];
if (mtex && mtex->tex && (mtex->tex->type | (mtex->tex->use_nodes && mtex->tex->nodetree) )) {
ma->texco |= mtex->texco;
ma->mapto |= mtex->mapto;
/* always get derivatives for these textures */
if (ELEM(mtex->tex->type, TEX_IMAGE, TEX_ENVMAP)) ma->texco |= TEXCO_OSA;
else if (mtex->texflag & (MTEX_COMPAT_BUMP | MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA;
if (ma->texco & (TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM | TEXCO_STRAND | TEXCO_STRESS)) needuv = 1;
else if (ma->texco & (TEXCO_GLOB | TEXCO_UV | TEXCO_OBJECT | TEXCO_SPEED)) needuv = 1;
else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW)) needuv = 1;
@ -970,13 +970,13 @@ static void do_init_render_material(Main *bmain, Material *ma, int r_mode, float
if (needtang) ma->mode |= MA_NORMAP_TANG;
else ma->mode &= ~MA_NORMAP_TANG;
if (ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) {
needuv = 1;
if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */
}
if (needuv) ma->texco |= NEED_UV;
/* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */
if (r_mode & R_RAYTRACE) {
if ((ma->mode & (MA_RAYMIRROR | MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) {
@ -984,7 +984,7 @@ static void do_init_render_material(Main *bmain, Material *ma, int r_mode, float
if (r_mode & R_OSA) ma->texco |= TEXCO_OSA;
}
}
if (amb) {
ma->ambr = ma->amb * amb[0];
ma->ambg = ma->amb * amb[1];
@ -1050,9 +1050,9 @@ static void init_render_nodetree(Main *bmain, bNodeTree *ntree, Material *basema
void init_render_material(Main *bmain, Material *mat, int r_mode, float *amb)
{
do_init_render_material(bmain, mat, r_mode, amb);
if (mat->nodetree && mat->use_nodes) {
/* mode_l will take the pipeline options from the main material, and the or-ed
* result of non-pipeline options from the nodes. shadeless is an exception,
@ -1061,7 +1061,7 @@ void init_render_material(Main *bmain, Material *mat, int r_mode, float *amb)
mat->mode2_l = mat->mode2 & MA_MODE2_PIPELINE;
mat->nmap_tangent_names_count = 0;
init_render_nodetree(bmain, mat->nodetree, mat, r_mode, amb);
if (!mat->nodetree->execdata)
mat->nodetree->execdata = ntreeShaderBeginExecTree(mat->nodetree);
}
@ -1077,7 +1077,7 @@ void init_render_material(Main *bmain, Material *mat, int r_mode, float *amb)
void init_render_materials(Main *bmain, int r_mode, float *amb, bool do_default_material)
{
Material *ma;
/* clear these flags before going over materials, to make sure they
* are cleared only once, otherwise node materials contained in other
* node materials can go wrong */
@ -1092,7 +1092,7 @@ void init_render_materials(Main *bmain, int r_mode, float *amb, bool do_default_
for (ma = bmain->mat.first; ma; ma = ma->id.next) {
/* is_used flag comes back in convertblender.c */
ma->flag &= ~MA_IS_USED;
if (ma->id.us)
if (ma->id.us)
init_render_material(bmain, ma, r_mode, amb);
}
@ -1114,7 +1114,7 @@ void end_render_materials(Main *bmain)
{
Material *ma;
for (ma = bmain->mat.first; ma; ma = ma->id.next)
if (ma->id.us)
if (ma->id.us)
end_render_material(ma);
}
@ -1162,7 +1162,7 @@ static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float c
if (ntree->adt && ntree->adt->drivers.first) {
BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS);
}
/* nodes */
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id) {
@ -1176,7 +1176,7 @@ static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float c
}
}
/* Calculate all drivers for materials
/* Calculate all drivers for materials
* FIXME: this is really a terrible method which may result in some things being calculated
* multiple times. However, without proper despgraph support for these things, we are forced
* into this sort of thing...
@ -1185,7 +1185,7 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
{
//if (G.f & G_DEBUG)
// printf("material_drivers_update(%s, %s)\n", scene->id.name, ma->id.name);
/* Prevent infinite recursion by checking (and tagging the material) as having been visited already
* (see BKE_scene_update_tagged()). This assumes ma->id.tag & LIB_TAG_DOIT isn't set by anything else
* in the meantime... [#32017]
@ -1194,12 +1194,12 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
return;
ma->id.tag |= LIB_TAG_DOIT;
/* material itself */
if (ma->adt && ma->adt->drivers.first) {
BKE_animsys_evaluate_animdata(scene, &ma->id, ma->adt, ctime, ADT_RECALC_DRIVERS);
}
/* nodes */
if (ma->nodetree) {
material_node_drivers_update(scene, ma->nodetree, ctime);
@ -1213,7 +1213,7 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
Material *mao, ***matarar;
short *totcolp;
short a, actcol;
if (ob == NULL || ob->totcol == 0) {
return false;
}
@ -1227,10 +1227,10 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
/* take a mesh/curve/mball as starting point, remove 1 index,
* AND with all objects that share the ob->data
*
*
* after that check indices in mesh/curve/mball!!!
*/
totcolp = give_totcolp(ob);
matarar = give_matarar(ob);
@ -1242,21 +1242,21 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
if (ob->actcol > ob->totcol) {
ob->actcol = ob->totcol;
}
/* we delete the actcol */
mao = (*matarar)[ob->actcol - 1];
if (mao)
id_us_min(&mao->id);
for (a = ob->actcol; a < ob->totcol; a++)
(*matarar)[a - 1] = (*matarar)[a];
(*totcolp)--;
if (*totcolp == 0) {
MEM_freeN(*matarar);
*matarar = NULL;
}
actcol = ob->actcol;
for (Object *obt = bmain->object.first; obt; obt = obt->id.next) {
@ -1269,14 +1269,14 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
mao = obt->mat[actcol - 1];
if (mao)
id_us_min(&mao->id);
for (a = actcol; a < obt->totcol; a++) {
obt->mat[a - 1] = obt->mat[a];
obt->matbits[a - 1] = obt->matbits[a];
}
obt->totcol--;
if (obt->actcol > obt->totcol) obt->actcol = obt->totcol;
if (obt->totcol == 0) {
MEM_freeN(obt->mat);
MEM_freeN(obt->matbits);
@ -1308,7 +1308,7 @@ static bNode *nodetree_uv_node_recursive(bNode *node)
{
bNode *inode;
bNodeSocket *sock;
for (sock = node->inputs.first; sock; sock = sock->next) {
if (sock->link) {
inode = sock->link->fromnode;
@ -1320,7 +1320,7 @@ static bNode *nodetree_uv_node_recursive(bNode *node)
}
}
}
return NULL;
}
@ -1332,7 +1332,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
bool use_nodes = BKE_scene_use_new_shading_nodes(scene);
bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene);
if (!ma)
return;
@ -1347,7 +1347,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
ma->paint_clone_slot = 0;
return;
}
if (use_nodes || ma->use_nodes) {
bNode *node, *active_node;
@ -1376,11 +1376,11 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
if (active_node == node)
ma->paint_active_slot = index;
ma->texpaintslot[index].ima = (Image *)node->id;
/* for new renderer, we need to traverse the treeback in search of a UV node */
if (use_nodes) {
bNode *uvnode = nodetree_uv_node_recursive(node);
if (uvnode) {
NodeShaderUVMap *storage = (NodeShaderUVMap *)uvnode->storage;
ma->texpaintslot[index].uvname = storage->uv_map;
@ -1419,7 +1419,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
ma->texpaintslot[index].ima = (*mtex)->tex->ima;
ma->texpaintslot[index].uvname = (*mtex)->uvname;
ma->texpaintslot[index].index = i;
index++;
}
}
@ -1428,12 +1428,12 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
ma->paint_active_slot = 0;
ma->paint_clone_slot = 0;
return;
}
}
ma->tot_slots = count;
if (ma->paint_active_slot >= count) {
ma->paint_active_slot = count - 1;
}
@ -1460,7 +1460,7 @@ void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob)
void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
{
float tmp, facm = 1.0f - fac;
switch (type) {
case MA_RAMP_BLEND:
r_col[0] = facm * (r_col[0]) + fac * col[0];
@ -1806,10 +1806,10 @@ static int encode_tfaceflag(MTFace *tf, int convertall)
/* light tface flag is ignored in GLSL mode */
flag &= ~TF_LIGHT;
/* 15 is how big the flag can be - hardcoded here and in decode_tfaceflag() */
flag |= tf->transp << 15;
/* increase 1 so flag 0 is different than no flag yet */
return flag + 1;
}
@ -1825,25 +1825,25 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall)
alphablend = flag >> 15; /* encoded in the encode_tfaceflag function */
(*game).flag = 0;
/* General Material Options */
if ((flag & TF_DYNAMIC) == 0) (*game).flag |= GEMAT_NOPHYSICS;
/* Material Offline Rendering Properties */
if (convertall) {
if (flag & TF_OBCOL) ma->shade_flag |= MA_OBCOLOR;
}
/* Special Face Properties */
if ((flag & TF_TWOSIDE) == 0) (*game).flag |= GEMAT_BACKCULL;
if (flag & TF_INVISIBLE) (*game).flag |= GEMAT_INVISIBLE;
if (flag & TF_BMFONT) (*game).flag |= GEMAT_TEXT;
/* Face Orientation */
if (flag & TF_BILLBOARD) (*game).face_orientation |= GEMAT_HALO;
else if (flag & TF_BILLBOARD2) (*game).face_orientation |= GEMAT_BILLBOARD;
else if (flag & TF_SHADOW) (*game).face_orientation |= GEMAT_SHADOW;
/* Alpha Blend */
if (flag & TF_ALPHASORT && ELEM(alphablend, TF_ALPHA, TF_ADD)) (*game).alpha_blend = GEMAT_ALPHA_SORT;
else if (alphablend & TF_ALPHA) (*game).alpha_blend = GEMAT_ALPHA;
@ -1867,7 +1867,7 @@ static int check_tfaceneedmaterial(int flag)
/* light tface flag is ignored in GLSL mode */
flag &= ~TF_LIGHT;
/* automatic detected if tex image has alpha */
flag &= ~(TF_ALPHA << 15);
/* automatic detected if using texture */
@ -1948,7 +1948,7 @@ static short convert_tfacenomaterial(Main *bmain, Mesh *me, MTFace *tf, int flag
Material *ma;
char idname[MAX_ID_NAME];
short mat_nr = -1;
/* new material, the name uses the flag*/
BLI_snprintf(idname, sizeof(idname), "MAMaterial.TF.%0*d", integer_getdigits(flag), flag);
@ -1967,7 +1967,7 @@ static short convert_tfacenomaterial(Main *bmain, Mesh *me, MTFace *tf, int flag
if (ma) {
printf("TexFace Convert: Material \"%s\" created.\n", idname + 2);
mat_nr = mesh_addmaterial(bmain, me, ma);
/* if needed set "Face Textures [Alpha]" Material options */
set_facetexture_flags(ma, tf->tpage);
@ -2005,7 +2005,7 @@ static void convert_tfacematerial(Main *bmain, Material *ma)
/* check if this mesh uses this material */
for (a = 0; a < me->totcol; a++)
if (me->mat[a] == ma) break;
/* no material found */
if (a == me->totcol) continue;
@ -2048,9 +2048,9 @@ static void convert_tfacematerial(Main *bmain, Material *ma)
continue;
}
}
/* if the material has a texture but no texture channel
* set "Face Textures [Alpha]" Material options
* set "Face Textures [Alpha]" Material options
* actually we need to run it always, because of old behavior
* of using face texture if any texture channel was present (multitex) */
//if ((!mat_new->mtex[0]) && (!mat_new->mtex[0]->tex))
@ -2084,7 +2084,7 @@ int do_version_tface(Main *main)
int a;
int flag;
int index;
/* Operator in help menu has been removed for 2.7x */
int fileload = 1;
@ -2100,9 +2100,9 @@ int do_version_tface(Main *main)
/* mark all the materials to conversion with a flag
* if there is tface create a complete flag for that storing in flag
* if there is tface and flag > 0: creates a new flag based on this face
* if flags are different set flag to -1
* if flags are different set flag to -1
*/
/* 1st part: marking mesh materials to update */
for (me = main->mesh.first; me; me = me->id.next) {
if (ID_IS_LINKED(me)) continue;
@ -2113,7 +2113,7 @@ int do_version_tface(Main *main)
if (!cdl) continue;
nomaterialslots = (me->totcol == 0 ? 1 : 0);
/* loop over all the faces*/
for (a = 0, mf = me->mface; a < me->totface; a++, mf++) {
/* texface data for this face */
@ -2126,11 +2126,11 @@ int do_version_tface(Main *main)
if ((tf->mode & TF_CONVERTED)) continue;
else tf->mode |= TF_CONVERTED;
}
/* no material slots */
if (nomaterialslots) {
flag = encode_tfaceflag(tf, 1);
/* create/find a new material and assign to the face */
if (check_tfaceneedmaterial(flag)) {
mf->mat_nr = convert_tfacenomaterial(main, me, tf, flag);
@ -2142,7 +2142,7 @@ int do_version_tface(Main *main)
}
else if (mf->mat_nr < me->totcol) {
ma = me->mat[mf->mat_nr];
/* no material create one if necessary */
if (!ma) {
/* find a new material and assign to the face */
@ -2161,7 +2161,7 @@ int do_version_tface(Main *main)
* later we could, but it's better not */
else if (ID_IS_LINKED(ma))
continue;
/* material already marked as disputed */
else if (ma->game.flag == MAT_BGE_DISPUTED)
continue;
@ -2173,17 +2173,17 @@ int do_version_tface(Main *main)
/* first time changing this material */
if (ma->game.flag == 0)
ma->game.flag = -flag;
/* mark material as disputed */
else if (ma->game.flag != -flag) {
ma->game.flag = MAT_BGE_DISPUTED;
continue;
}
/* material ok so far */
else {
ma->game.flag = -flag;
/* some people uses multitexture with TexFace by creating a texture
* channel which not necessarily the tf->tpage image. But the game engine
* was enabling it. Now it's required to set "Face Texture [Alpha] in the
@ -2218,7 +2218,7 @@ int do_version_tface(Main *main)
}
}
/* 2nd part - conversion */
/* skip library files */
@ -2238,7 +2238,7 @@ int do_version_tface(Main *main)
}
continue;
}
/* no conflicts in this material - 90% of cases
* convert from tface system to material */
else if (ma->game.flag < 0) {
@ -2251,15 +2251,15 @@ int do_version_tface(Main *main)
/* check if this mesh uses this material */
for (a = 0; a < me->totcol; a++)
if (me->mat[a] == ma) break;
/* no material found */
if (a == me->totcol) continue;
/* get the active tface layer */
index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
cdl = (index == -1) ? NULL : &me->fdata.layers[index];
if (!cdl) continue;
/* loop over all the faces and stop at the ones that use the material*/
for (a = 0, mf = me->mface; a < me->totface; a++, mf++) {
if (me->mat[mf->mat_nr] == ma) {

@ -86,7 +86,7 @@ void BKE_mball_init(MetaBall *mb)
mb->size[0] = mb->size[1] = mb->size[2] = 1.0;
mb->texflag = MB_AUTOSPACE;
mb->wiresize = 0.4f;
mb->rendersize = 0.2f;
mb->thresh = 0.6f;
@ -197,7 +197,7 @@ void BKE_mball_texspace_calc(Object *ob)
if (ob->bb == NULL) ob->bb = MEM_callocN(sizeof(BoundBox), "mb boundbox");
bb = ob->bb;
/* Weird one, this. */
/* INIT_MINMAX(min, max); */
(min)[0] = (min)[1] = (min)[2] = 1.0e30f;

@ -106,7 +106,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
const float thresh_sq = thresh * thresh;
CustomDataLayer *l1, *l2;
int i, i1 = 0, i2 = 0, tot, j;
for (i = 0; i < c1->totlayer; i++) {
if (ELEM(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
@ -125,7 +125,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
if (i1 != i2)
return MESHCMP_CDLAYERS_MISMATCH;
l1 = c1->layers; l2 = c2->layers;
tot = i1;
i1 = 0; i2 = 0;
@ -143,52 +143,52 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
i2++;
l2++;
}
if (l1->type == CD_MVERT) {
MVert *v1 = l1->data;
MVert *v2 = l2->data;
int vtot = m1->totvert;
for (j = 0; j < vtot; j++, v1++, v2++) {
if (len_squared_v3v3(v1->co, v2->co) > thresh_sq)
return MESHCMP_VERTCOMISMATCH;
/* I don't care about normals, let's just do coodinates */
}
}
/*we're order-agnostic for edges here*/
if (l1->type == CD_MEDGE) {
MEdge *e1 = l1->data;
MEdge *e2 = l2->data;
int etot = m1->totedge;
EdgeHash *eh = BLI_edgehash_new_ex(__func__, etot);
for (j = 0; j < etot; j++, e1++) {
BLI_edgehash_insert(eh, e1->v1, e1->v2, e1);
}
for (j = 0; j < etot; j++, e2++) {
if (!BLI_edgehash_lookup(eh, e2->v1, e2->v2))
return MESHCMP_EDGEUNKNOWN;
}
BLI_edgehash_free(eh, NULL);
}
if (l1->type == CD_MPOLY) {
MPoly *p1 = l1->data;
MPoly *p2 = l2->data;
int ptot = m1->totpoly;
for (j = 0; j < ptot; j++, p1++, p2++) {
MLoop *lp1, *lp2;
int k;
if (p1->totloop != p2->totloop)
return MESHCMP_POLYMISMATCH;
lp1 = m1->mloop + p1->loopstart;
lp2 = m2->mloop + p2->loopstart;
for (k = 0; k < p1->totloop; k++, lp1++, lp2++) {
if (lp1->v != lp2->v)
return MESHCMP_POLYVERTMISMATCH;
@ -199,7 +199,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
MLoop *lp1 = l1->data;
MLoop *lp2 = l2->data;
int ltot = m1->totloop;
for (j = 0; j < ltot; j++, lp1++, lp2++) {
if (lp1->v != lp2->v)
return MESHCMP_LOOPMISMATCH;
@ -209,22 +209,22 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
MLoopUV *lp1 = l1->data;
MLoopUV *lp2 = l2->data;
int ltot = m1->totloop;
for (j = 0; j < ltot; j++, lp1++, lp2++) {
if (len_squared_v2v2(lp1->uv, lp2->uv) > thresh_sq)
return MESHCMP_LOOPUVMISMATCH;
}
}
if (l1->type == CD_MLOOPCOL) {
MLoopCol *lp1 = l1->data;
MLoopCol *lp2 = l2->data;
int ltot = m1->totloop;
for (j = 0; j < ltot; j++, lp1++, lp2++) {
if (ABS(lp1->r - lp2->r) > thresh ||
ABS(lp1->g - lp2->g) > thresh ||
ABS(lp1->b - lp2->b) > thresh ||
if (ABS(lp1->r - lp2->r) > thresh ||
ABS(lp1->g - lp2->g) > thresh ||
ABS(lp1->b - lp2->b) > thresh ||
ABS(lp1->a - lp2->a) > thresh)
{
return MESHCMP_LOOPCOLMISMATCH;
@ -236,14 +236,14 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
MDeformVert *dv1 = l1->data;
MDeformVert *dv2 = l2->data;
int dvtot = m1->totvert;
for (j = 0; j < dvtot; j++, dv1++, dv2++) {
int k;
MDeformWeight *dw1 = dv1->dw, *dw2 = dv2->dw;
if (dv1->totweight != dv2->totweight)
return MESHCMP_DVERT_TOTGROUPMISMATCH;
for (k = 0; k < dv1->totweight; k++, dw1++, dw2++) {
if (dw1->def_nr != dw2->def_nr)
return MESHCMP_DVERT_GROUPMISMATCH;
@ -253,7 +253,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
}
}
}
return 0;
}
@ -266,22 +266,22 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh)
{
int c;
if (!me1 || !me2)
return "Requires two input meshes";
if (me1->totvert != me2->totvert)
if (me1->totvert != me2->totvert)
return "Number of verts don't match";
if (me1->totedge != me2->totedge)
return "Number of edges don't match";
if (me1->totpoly != me2->totpoly)
return "Number of faces don't match";
if (me1->totloop != me2->totloop)
return "Number of loops don't match";
if ((c = customdata_compare(&me1->vdata, &me2->vdata, me1, me2, thresh)))
return cmpcode_to_str(c);
@ -293,7 +293,7 @@ const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh)
if ((c = customdata_compare(&me1->pdata, &me2->pdata, me1, me2, thresh)))
return cmpcode_to_str(c);
return NULL;
}
@ -400,7 +400,7 @@ void BKE_mesh_update_customdata_pointers(Mesh *me, const bool do_ensure_tess_cd)
me->mface = CustomData_get_layer(&me->fdata, CD_MFACE);
me->mcol = CustomData_get_layer(&me->fdata, CD_MCOL);
me->mtface = CustomData_get_layer(&me->fdata, CD_MTFACE);
me->mpoly = CustomData_get_layer(&me->pdata, CD_MPOLY);
me->mloop = CustomData_get_layer(&me->ldata, CD_MLOOP);
@ -673,13 +673,13 @@ void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3])
BoundBox *bb;
float min[3], max[3];
float mloc[3], msize[3];
if (me->bb == NULL) me->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
bb = me->bb;
if (!r_loc) r_loc = mloc;
if (!r_size) r_size = msize;
INIT_MINMAX(min, max);
if (!BKE_mesh_minmax(me, min, max)) {
min[0] = min[1] = min[2] = -1.0f;
@ -687,11 +687,11 @@ void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3])
}
mid_v3_v3v3(r_loc, min, max);
r_size[0] = (max[0] - min[0]) / 2.0f;
r_size[1] = (max[1] - min[1]) / 2.0f;
r_size[2] = (max[2] - min[2]) / 2.0f;
BKE_boundbox_init_from_minmax(bb, min, max);
bb->flag &= ~BOUNDBOX_DIRTY;
@ -874,7 +874,7 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
Mesh *BKE_mesh_from_object(Object *ob)
{
if (ob == NULL) return NULL;
if (ob->type == OB_MESH) return ob->data;
else return NULL;
@ -885,9 +885,9 @@ void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *me)
Mesh *old = NULL;
multires_force_update(ob);
if (ob == NULL) return;
if (ob->type == OB_MESH) {
old = ob->data;
if (old)
@ -895,7 +895,7 @@ void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *me)
ob->data = me;
id_us_plus((ID *)me);
}
test_object_materials(bmain, ob, (ID *)me);
test_object_modifiers(ob);
@ -966,7 +966,7 @@ void BKE_mesh_material_remap(Mesh *me, const unsigned int *remap, unsigned int r
}
void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth)
void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth)
{
Mesh *me = meshOb->data;
int i;
@ -981,7 +981,7 @@ void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth)
mp->flag &= ~ME_SMOOTH;
}
}
for (i = 0; i < me->totface; i++) {
MFace *mf = &me->mface[i];
@ -1023,7 +1023,7 @@ int poly_find_loop_from_vert(
if (loopstart->v == vert)
return j;
}
return -1;
}
@ -1040,7 +1040,7 @@ int poly_get_adj_loops_from_vert(
int corner = poly_find_loop_from_vert(poly,
&mloop[poly->loopstart],
vert);
if (corner != -1) {
#if 0 /* unused - this loop */
const MLoop *ml = &mloop[poly->loopstart + corner];
@ -1076,7 +1076,7 @@ bool BKE_mesh_minmax(const Mesh *me, float r_min[3], float r_max[3])
for (mvert = me->mvert; i--; mvert++) {
minmax_v3v3_v3(r_min, r_max, mvert->co);
}
return (me->totvert != 0);
}
@ -1119,7 +1119,7 @@ void BKE_mesh_translate(Mesh *me, const float offset[3], const bool do_keys)
for (mvert = me->mvert; i--; mvert++) {
add_v3_v3(mvert->co, offset);
}
if (do_keys && me->key) {
KeyBlock *kb;
for (kb = me->key->block.first; kb; kb = kb->next) {

@ -165,7 +165,7 @@ void BKE_mesh_calc_normals_mapping_ex(
/* if (fnors != r_faceNors) MEM_freeN(fnors); */ /* NO NEED TO ALLOC YET */
fnors = pnors = NULL;
}
typedef struct MeshCalcNormalsData {
@ -178,7 +178,7 @@ typedef struct MeshCalcNormalsData {
} MeshCalcNormalsData;
static void mesh_calc_normals_poly_cb(
void *__restrict userdata,
void *__restrict userdata,
const int pidx,
const ParallelRangeTLS *__restrict UNUSED(tls))
{
@ -189,7 +189,7 @@ static void mesh_calc_normals_poly_cb(
}
static void mesh_calc_normals_poly_prepare_cb(
void *__restrict userdata,
void *__restrict userdata,
const int pidx,
const ParallelRangeTLS *__restrict UNUSED(tls))
{
@ -378,14 +378,14 @@ void BKE_mesh_calc_normals_tessface(
for (i = 0; i < numVerts; i++) {
MVert *mv = &mverts[i];
float *no = tnorms[i];
if (UNLIKELY(normalize_v3(no) == 0.0f)) {
normalize_v3_v3(no, mv->co);
}
normal_float_to_short_v3(mv->no, no);
}
cleanup:
MEM_freeN(tnorms);
@ -2442,19 +2442,19 @@ static bool mesh_calc_center_centroid_ex(
const MLoopTri *lt;
float totweight;
int i;
zero_v3(r_center);
if (looptri_num == 0)
return false;
totweight = 0.0f;
for (i = 0, lt = looptri; i < looptri_num; i++, lt++) {
const MVert *v1 = &mverts[mloop[lt->tri[0]].v];
const MVert *v2 = &mverts[mloop[lt->tri[1]].v];
const MVert *v3 = &mverts[mloop[lt->tri[2]].v];
float area;
area = area_tri_v3(v1->co, v2->co, v3->co);
madd_v3_v3fl(r_center, v1->co, area);
madd_v3_v3fl(r_center, v2->co, area);
@ -2463,9 +2463,9 @@ static bool mesh_calc_center_centroid_ex(
}
if (totweight == 0.0f)
return false;
mul_v3_fl(r_center, 1.0f / (3.0f * totweight));
return true;
}
@ -2485,18 +2485,18 @@ void BKE_mesh_calc_volume(
float center[3];
float totvol;
int i;
if (r_volume)
*r_volume = 0.0f;
if (r_center)
zero_v3(r_center);
if (looptri_num == 0)
return;
if (!mesh_calc_center_centroid_ex(mverts, mverts_num, looptri, looptri_num, mloop, center))
return;
totvol = 0.0f;
for (i = 0, lt = looptri; i < looptri_num; i++, lt++) {
@ -2504,7 +2504,7 @@ void BKE_mesh_calc_volume(
const MVert *v2 = &mverts[mloop[lt->tri[1]].v];
const MVert *v3 = &mverts[mloop[lt->tri[2]].v];
float vol;
vol = volume_tetrahedron_signed_v3(center, v1->co, v2->co, v3->co);
if (r_volume) {
totvol += vol;
@ -2516,7 +2516,7 @@ void BKE_mesh_calc_volume(
madd_v3_v3fl(r_center, v3->co, vol);
}
}
/* Note: Depending on arbitrary centroid position,
* totvol can become negative even for a valid mesh.
* The true value is always the positive value.

@ -121,7 +121,7 @@ ModifierData *modifier_new(int type)
{
const ModifierTypeInfo *mti = modifierType_getInfo(type);
ModifierData *md = MEM_callocN(mti->structSize, mti->structName);
/* note, this name must be made unique later */
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
@ -478,7 +478,7 @@ bool modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode
if (scene != NULL && mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return false;
if (md->mode & eModifierMode_DisableTemporary) return false;
if ((required_mode & eModifierMode_Editmode) && !(mti->flags & eModifierTypeFlag_SupportsEditmode)) return false;
return true;
}
@ -494,7 +494,7 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierDat
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
curr = MEM_callocN(sizeof(CDMaskLink), "CDMaskLink");
if (modifier_isEnabled(scene, md, required_mode)) {
if (mti->requiredDataMask)
curr->mask = mti->requiredDataMask(ob, md);
@ -603,7 +603,7 @@ Object *modifiers_isDeformedByArmature(Object *ob)
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
ArmatureModifierData *amd = NULL;
/* return the first selected armature, this lets us use multiple armatures */
for (; md; md = md->next) {
if (md->type == eModifierType_Armature) {
@ -612,10 +612,10 @@ Object *modifiers_isDeformedByArmature(Object *ob)
return amd->object;
}
}
if (amd) /* if were still here then return the last armature */
return amd->object;
return NULL;
}
@ -627,7 +627,7 @@ Object *modifiers_isDeformedByLattice(Object *ob)
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
LatticeModifierData *lmd = NULL;
/* return the first selected lattice, this lets us use multiple lattices */
for (; md; md = md->next) {
if (md->type == eModifierType_Lattice) {
@ -636,10 +636,10 @@ Object *modifiers_isDeformedByLattice(Object *ob)
return lmd->object;
}
}
if (lmd) /* if were still here then return the last lattice */
return lmd->object;
return NULL;
}
@ -651,7 +651,7 @@ Object *modifiers_isDeformedByCurve(Object *ob)
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
CurveModifierData *cmd = NULL;
/* return the first selected curve, this lets us use multiple curves */
for (; md; md = md->next) {
if (md->type == eModifierType_Curve) {
@ -660,10 +660,10 @@ Object *modifiers_isDeformedByCurve(Object *ob)
return cmd->object;
}
}
if (cmd) /* if were still here then return the last curve */
return cmd->object;
return NULL;
}
@ -697,7 +697,7 @@ bool modifiers_isCorrectableDeformed(struct Scene *scene, Object *ob)
if (ob->mode == OB_MODE_EDIT)
required_mode |= eModifierMode_Editmode;
for (; md; md = md->next) {
if (!modifier_isEnabled(scene, md, required_mode)) {
/* pass */

@ -189,7 +189,7 @@ static BLI_bitmap *multires_mdisps_downsample_hidden(BLI_bitmap *old_hidden,
for (x = 0; x < new_gridsize; x++) {
old_value = BLI_BITMAP_TEST(old_hidden,
factor * y * old_gridsize + x * factor);
BLI_BITMAP_SET(new_hidden, y * new_gridsize + x, old_value);
}
}
@ -204,7 +204,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
BLI_bitmap **grid_hidden = ccgdm->gridHidden;
int *gridOffset;
int i, j;
gridOffset = ccgdm->dm.getGridOffset(&ccgdm->dm);
for (i = 0; i < me->totpoly; i++) {
@ -212,7 +212,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
int g = gridOffset[i] + j;
const MDisps *md = &mdisps[g];
BLI_bitmap *gh = md->hidden;
if (gh) {
grid_hidden[g] =
multires_mdisps_downsample_hidden(gh, md->level, level);
@ -226,7 +226,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
{
BLI_bitmap *subd;
BLI_assert(md->hidden);
/* nothing to do if already subdivided enough */
@ -237,7 +237,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
md->level,
new_level,
NULL);
/* swap in the subdivided data */
MEM_freeN(md->hidden);
md->hidden = subd;
@ -250,7 +250,7 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
int gridsize = BKE_ccg_gridsize(level);
int gridarea = SQUARE(gridsize);
int i, j;
for (i = 0; i < me->totpoly; i++) {
bool hide = false;
@ -474,7 +474,7 @@ static int get_levels_from_disps(Object *ob)
for (j = 0; j < me->mpoly[i].totloop; j++, md++) {
if (md->totdisp == 0) continue;
while (1) {
int side = (1 << (totlvl - 1)) + 1;
int lvl_totdisp = side * side;
@ -484,9 +484,9 @@ static int get_levels_from_disps(Object *ob)
totlvl--;
else
totlvl++;
}
break;
}
}
@ -537,7 +537,7 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
if (mdisps[i].disps)
MEM_freeN(mdisps[i].disps);
if (mdisps[i].level && mdisps[i].hidden)
multires_mdisps_subdivide_hidden(&mdisps[i], lvl);
@ -735,7 +735,7 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl
if (alloc_paint_mask)
flags |= SUBSURF_ALLOC_PAINT_MASK;
return subsurf_make_derived_from_derived(dm, &smd, NULL, flags);
}
@ -801,7 +801,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
/* find center */
for (j = 0; j < pmap[i].count; j++) {
const MPoly *p = &me->mpoly[pmap[i].indices[j]];
/* this double counts, not sure if that's bad or good */
for (k = 0; k < p->totloop; ++k) {
int vndx = me->mloop[p->loopstart + k].v;
@ -827,18 +827,18 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
fake_poly.loopstart = 0;
fake_loops = MEM_malloc_arrayN(p->totloop, sizeof(MLoop), "fake_loops");
fake_co = MEM_malloc_arrayN(p->totloop, 3 * sizeof(float), "fake_co");
for (k = 0; k < p->totloop; ++k) {
int vndx = me->mloop[p->loopstart + k].v;
fake_loops[k].v = k;
if (vndx == i)
copy_v3_v3(fake_co[k], center);
else
copy_v3_v3(fake_co[k], origco[vndx]);
}
BKE_mesh_calc_poly_normal_coords(&fake_poly, fake_loops,
(const float(*)[3])fake_co, no);
MEM_freeN(fake_loops);
@ -853,7 +853,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
copy_v3_v3(push, avg_no);
mul_v3_fl(push, dist);
add_v3_v3(me->mvert[i].co, push);
}
MEM_freeN(origco);
@ -942,7 +942,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
ccgSubSurf_updateLevels(ss, lvl, NULL, 0);
/* reallocate displacements */
multires_reallocate_mdisps(me->totloop, mdisps, totlvl);
multires_reallocate_mdisps(me->totloop, mdisps, totlvl);
/* compute displacements */
multiresModifier_disp_run(highdm, me, NULL, CALC_DISPLACEMENTS, subGridData, totlvl);
@ -955,7 +955,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
}
else {
/* only reallocate, nothing to upsample */
multires_reallocate_mdisps(me->totloop, mdisps, totlvl);
multires_reallocate_mdisps(me->totloop, mdisps, totlvl);
}
multires_set_tot_level(ob, mmd, totlvl);
@ -1128,7 +1128,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
int *gridOffset;
int i, gridSize, dGridSize, dSkip;
int totloop, totpoly;
/* this happens in the dm made by bmesh_mdisps_space_set */
if (dm2 && CustomData_has_layer(&dm2->loopData, CD_MDISPS)) {
mpoly = CustomData_get_layer(&dm2->polyData, CD_MPOLY);
@ -1140,7 +1140,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
totloop = me->totloop;
totpoly = me->totpoly;
}
if (!mdisps) {
if (op == CALC_DISPLACEMENTS)
mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_DEFAULT, NULL, me->totloop);
@ -1214,7 +1214,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
if (mdisps) {
int lvl = ccgdm->multires.lvl;
int totlvl = ccgdm->multires.totlvl;
if (lvl < totlvl) {
DerivedMesh *lowdm, *cddm, *highdm;
CCGElem **highGridData, **lowGridData, **subGridData, **gridData, *diffGrid;
@ -1311,7 +1311,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
if (mdisps) {
int i;
for (i = 0; i < me->totloop; i++) {
MDisps *md = &mdisps[i];
BLI_bitmap *gh = grid_hidden[i];
@ -1325,7 +1325,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
md->hidden);
if (md->hidden)
MEM_freeN(md->hidden);
md->hidden = gh;
}
}
@ -1342,10 +1342,10 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
MultiresModifierData *mmd = get_multires_modifier(NULL, ob, 1);
int *gridOffset, totlvl;
int i, k, numGrids, gridSize, dGridSize, dSkip;
if (!mmd)
return;
mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
if (!mdisps) {
@ -1354,7 +1354,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
totlvl = mmd->totlvl;
ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple, false);
subsurf = subsurf_dm_create_local(ob, dm, totlvl,
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
@ -1369,7 +1369,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
subGridData[i] = MEM_calloc_arrayN(key.elem_size, gridSize * gridSize, "subGridData");
memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize);
}
/* numGrids = ccgdm->dm->getNumGrids((DerivedMesh *)ccgdm); */ /*UNUSED*/
gridSize = ccgdm->getGridSize((DerivedMesh *)ccgdm);
gridData = ccgdm->getGridData((DerivedMesh *)ccgdm);
@ -1384,7 +1384,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
for (i = 0; i < dm->numPolyData; ++i) {
const int numVerts = mpoly[i].totloop;
int S, x, y, gIndex = gridOffset[i];
for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
MDisps *mdisp = &mdisps[mpoly[i].loopstart + S];
/* CCGElem *grid = gridData[gIndex]; */ /* UNUSED */
@ -1405,7 +1405,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
float *co = CCG_grid_elem_co(&key, subgrid, x, y);
float mat[3][3], dco[3];
/* construct tangent space matrix */
grid_tangent_matrix(mat, &key, x, y, subgrid);
@ -1420,7 +1420,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
else if (from == MULTIRES_SPACE_ABSOLUTE) {
copy_v3_v3(dco, data);
}
/*now, convert to desired displacement type*/
if (to == MULTIRES_SPACE_TANGENT) {
invert_m3(mat);
@ -1544,10 +1544,10 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
const int st_max = st - 1;
float urat, vrat, uopp;
float d[4][3], d2[2][3];
if (!disps || isnan(u) || isnan(v))
return;
if (u < 0)
u = 0;
else if (u >= st)
@ -1564,7 +1564,7 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
if (x2 >= st) x2 = st_max;
if (y2 >= st) y2 = st_max;
urat = u - x;
vrat = v - y;
uopp = 1 - urat;
@ -1639,7 +1639,7 @@ void multires_load_old_250(Mesh *me)
for (i = 0; i < me->totface; i++)
if (mdisps[i].totdisp)
old_mdisps_convert(&me->mface[i], &mdisps[i]);
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
mdisps2 = CustomData_get_layer(&me->ldata, CD_MDISPS);
@ -1648,7 +1648,7 @@ void multires_load_old_250(Mesh *me)
for (i = 0; i < me->totface; i++, mf++) {
int nvert = mf->v4 ? 4 : 3;
int totdisp = mdisps[i].totdisp / nvert;
for (j = 0; j < nvert; j++, k++) {
mdisps2[k].disps = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disp in conversion");
mdisps2[k].totdisp = totdisp;
@ -1709,11 +1709,11 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult
{
int i, j;
IndexNode *node = NULL;
(*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert face map");
(*mem) = MEM_calloc_arrayN(totface, 4 * sizeof(IndexNode), "vert face map mem");
node = *mem;
/* Find the users */
for (i = 0; i < totface; ++i) {
for (j = 0; j < (mface[i].v[3] ? 4 : 3); ++j, ++node) {
@ -1728,11 +1728,11 @@ static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const Mult
{
int i, j;
IndexNode *node = NULL;
(*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert edge map");
(*mem) = MEM_calloc_arrayN(totedge, 2 * sizeof(IndexNode), "vert edge map mem");
node = *mem;
/* Find the users */
for (i = 0; i < totedge; ++i) {
for (j = 0; j < 2; ++j, ++node) {
@ -1853,7 +1853,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
vd = ccgSubSurf_getFaceCenterData(f);
copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co);
i++;
for (S = 0; S < numVerts; S++) {
for (x = 1; x < gridSize - 1; x++, i++) {
vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
@ -2084,7 +2084,7 @@ static void multires_load_old_vcols(Mesh *me)
* so we can assume the active vcol layer is the correct one */
if (!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL)))
return;
for (i = 0; i < me->totface; ++i) {
for (j = 0; j < 4; ++j) {
mcol[i * 4 + j].a = colface[i].col[j].a;
@ -2163,7 +2163,7 @@ void multires_load_old(Object *ob, Mesh *me)
/* Add a multires modifier to the object */
md = ob->modifiers.first;
while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
md = md->next;
md = md->next;
mmd = (MultiresModifierData *)modifier_new(eModifierType_Multires);
BLI_insertlinkbefore(&ob->modifiers, md, mmd);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -146,7 +146,7 @@ static ThreadMutex vparent_lock = BLI_MUTEX_INITIALIZER;
void BKE_object_workob_clear(Object *workob)
{
memset(workob, 0, sizeof(Object));
workob->size[0] = workob->size[1] = workob->size[2] = 1.0f;
workob->dscale[0] = workob->dscale[1] = workob->dscale[2] = 1.0f;
workob->rotmode = ROT_MODE_EUL;
@ -356,7 +356,7 @@ void BKE_object_free_derived_caches(Object *ob)
ob->derivedDeform->release(ob->derivedDeform);
ob->derivedDeform = NULL;
}
BKE_object_free_curve_cache(ob);
}
@ -432,9 +432,9 @@ void BKE_object_free(Object *ob)
free_sensors(&ob->sensors);
free_controllers(&ob->controllers);
free_actuators(&ob->actuators);
BKE_constraints_free_ex(&ob->constraints, false);
free_partdeflect(ob->pd);
BKE_rigidbody_free_object(ob);
BKE_rigidbody_free_constraint(ob);
@ -472,7 +472,7 @@ bool BKE_object_is_in_editmode(const Object *ob)
{
if (ob->data == NULL)
return false;
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
if (me->edit_btmesh)
@ -480,25 +480,25 @@ bool BKE_object_is_in_editmode(const Object *ob)
}
else if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
if (arm->edbo)
return true;
}
else if (ob->type == OB_FONT) {
Curve *cu = ob->data;
if (cu->editfont)
return true;
}
else if (ob->type == OB_MBALL) {
MetaBall *mb = ob->data;
if (mb->editelems)
return true;
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
if (lt->editlatt)
return true;
}
@ -532,9 +532,9 @@ bool BKE_object_is_in_wpaint_select_vert(const Object *ob)
bool BKE_object_exists_check(Main *bmain, const Object *obtest)
{
Object *ob;
if (obtest == NULL) return false;
ob = bmain->object.first;
while (ob) {
if (ob == obtest) return true;
@ -595,12 +595,12 @@ void BKE_object_init(Object *ob)
ob->col[0] = ob->col[1] = ob->col[2] = 1.0;
ob->col[3] = 1.0;
ob->size[0] = ob->size[1] = ob->size[2] = 1.0;
ob->dscale[0] = ob->dscale[1] = ob->dscale[2] = 1.0;
/* objects should default to having Euler XYZ rotations,
* but rotations default to quaternions
/* objects should default to having Euler XYZ rotations,
* but rotations default to quaternions
*/
ob->rotmode = ROT_MODE_EUL;
@ -612,7 +612,7 @@ void BKE_object_init(Object *ob)
/* rotation locks should be 4D for 4 component rotations by default... */
ob->protectflag = OB_LOCK_ROT4D;
unit_m4(ob->constinv);
unit_m4(ob->parentinv);
unit_m4(ob->obmat);
@ -628,7 +628,7 @@ void BKE_object_init(Object *ob)
ob->trackflag = OB_POSY;
ob->upflag = OB_POSZ;
}
ob->dupon = 1; ob->dupoff = 0;
ob->dupsta = 1; ob->dupend = 100;
ob->dupfacesca = 1.0;
@ -658,7 +658,7 @@ void BKE_object_init(Object *ob)
ob->fluidsimSettings = NULL;
BLI_listbase_clear(&ob->pc_ids);
/* Animation Visualization defaults */
animviz_settings_init(&ob->avs);
}
@ -695,7 +695,7 @@ Object *BKE_object_add(
ob->data = BKE_object_obdata_add_from_type(bmain, type, name);
ob->lay = scene->lay;
base = BKE_scene_base_add(scene, ob);
BKE_scene_base_deselect_all(scene);
BKE_scene_base_select(scene, base);
@ -721,7 +721,7 @@ void BKE_object_lod_add(Object *ob)
base->obhysteresis = 10;
last = ob->currentlod = base;
}
lod->distance = last->distance + 25.0f;
lod->obhysteresis = 10;
lod->flags = OB_LOD_USE_MESH | OB_LOD_USE_MAT;
@ -841,9 +841,9 @@ struct Object *BKE_object_lod_matob_get(Object *ob, Scene *scene)
SoftBody *copy_softbody(const SoftBody *sb, const int flag)
{
SoftBody *sbn;
if (sb == NULL) return(NULL);
sbn = MEM_dupallocN(sb);
if ((flag & LIB_ID_COPY_CACHES) == 0) {
@ -869,10 +869,10 @@ SoftBody *copy_softbody(const SoftBody *sb, const int flag)
if (sb->bspring)
sbn->bspring = MEM_dupallocN(sb->bspring);
}
sbn->keys = NULL;
sbn->totkey = sbn->totpointkey = 0;
sbn->scratch = NULL;
sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches, flag);
@ -915,10 +915,10 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int f
if (key)
key = MEM_dupallocN(key);
if (boid)
boid = MEM_dupallocN(boid);
for (p = 0, pa = psysn->particles; p < psysn->totpart; p++, pa++) {
if (boid)
pa->boid = boid++;
@ -944,11 +944,11 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int f
psysn->effectors = NULL;
psysn->tree = NULL;
psysn->bvhtree = NULL;
BLI_listbase_clear(&psysn->pathcachebufs);
BLI_listbase_clear(&psysn->childcachebufs);
psysn->renderdata = NULL;
/* XXX Never copy caches here? */
psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches, flag & ~LIB_ID_COPY_CACHES);
@ -998,7 +998,7 @@ void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src, const
}
else if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *) md;
if (smd->type == MOD_SMOKE_TYPE_FLOW) {
if (smd->flow) {
if (smd->flow->psys == psys)
@ -1021,31 +1021,31 @@ void BKE_object_copy_softbody(Object *ob_dst, const Object *ob_src)
static void copy_object_pose(Object *obn, const Object *ob, const int flag)
{
bPoseChannel *chan;
/* note: need to clear obn->pose pointer first, so that BKE_pose_copy_data works (otherwise there's a crash) */
obn->pose = NULL;
BKE_pose_copy_data_ex(&obn->pose, ob->pose, flag, true); /* true = copy constraints */
for (chan = obn->pose->chanbase.first; chan; chan = chan->next) {
bConstraint *con;
chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
/* XXX Remapping object pointing onto itself should be handled by generic BKE_library_remap stuff, but...
* the flush_constraint_targets callback am not sure about, so will delay that for now. */
for (con = chan->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == ob)
ct->tar = obn;
}
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 0);
}
@ -1123,12 +1123,12 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
}
if (ob_src->iuser) ob_dst->iuser = MEM_dupallocN(ob_src->iuser);
if (ob_src->bb) ob_dst->bb = MEM_dupallocN(ob_src->bb);
ob_dst->flag &= ~OB_FROMGROUP;
BLI_listbase_clear(&ob_dst->modifiers);
for (md = ob_src->modifiers.first; md; md = md->next) {
ModifierData *nmd = modifier_new(md->type);
BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
@ -1165,7 +1165,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
ob_dst->rigidbody_constraint = BKE_rigidbody_copy_constraint(ob_src, flag_subdata);
BKE_object_copy_particlesystems(ob_dst, ob_src, flag_subdata);
ob_dst->derivedDeform = NULL;
ob_dst->derivedFinal = NULL;
@ -1175,7 +1175,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
ob_dst->mpath = NULL;
copy_object_lod(ob_dst, ob_src, flag_subdata);
/* Do not copy runtime curve data. */
ob_dst->curve_cache = NULL;
@ -1267,34 +1267,34 @@ static void armature_set_id_extern(Object *ob)
bArmature *arm = ob->data;
bPoseChannel *pchan;
unsigned int lay = arm->layer_protected;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (!(pchan->bone->layer & lay))
id_lib_extern((ID *)pchan->custom);
}
}
void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
{
if ((target->adt) && (target->adt->drivers.first)) {
FCurve *fcu;
/* add new animdata block */
if (!ob->adt)
ob->adt = BKE_animdata_add_id(&ob->id);
/* make a copy of all the drivers (for now), then correct any links that need fixing */
free_fcurves(&ob->adt->drivers);
copy_fcurves(&ob->adt->drivers, &target->adt->drivers);
for (fcu = ob->adt->drivers.first; fcu; fcu = fcu->next) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* all drivers */
DRIVER_TARGETS_LOOPER(dvar)
DRIVER_TARGETS_LOOPER(dvar)
{
if (dtar->id) {
if ((Object *)dtar->id == target)
@ -1325,14 +1325,14 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
printf("cannot make proxy\n");
return;
}
ob->proxy = target;
ob->proxy_group = gob;
id_lib_extern(&target->id);
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
DAG_id_tag_update(&target->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
/* copy transform
* - gob means this proxy comes from a group, just apply the matrix
* so the object wont move from its dupli-transform.
@ -1354,13 +1354,13 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
ob->parent = target->parent; /* libdata */
copy_m4_m4(ob->parentinv, target->parentinv);
}
/* copy animdata stuff - drivers only for now... */
BKE_object_copy_proxy_drivers(ob, target);
/* skip constraints? */
/* FIXME: this is considered by many as a bug */
/* set object type and link to data */
ob->type = target->type;
ob->data = target->data;
@ -1377,24 +1377,24 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
ob->matbits = NULL;
if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
int i;
ob->actcol = target->actcol;
ob->totcol = target->totcol;
ob->mat = MEM_dupallocN(target->mat);
ob->matbits = MEM_dupallocN(target->matbits);
for (i = 0; i < target->totcol; i++) {
/* don't need to run test_object_materials since we know this object is new and not used elsewhere */
id_us_plus((ID *)ob->mat[i]);
id_us_plus((ID *)ob->mat[i]);
}
}
/* type conversions */
if (target->type == OB_ARMATURE) {
copy_object_pose(ob, target, 0); /* data copy, object pointers in constraints */
BKE_pose_rest(ob->pose); /* clear all transforms in channels */
BKE_pose_rebuild(ob, ob->data); /* set all internal links */
armature_set_id_extern(ob);
}
else if (target->type == OB_EMPTY) {
@ -1478,7 +1478,7 @@ void BKE_object_scale_to_mat3(Object *ob, float mat[3][3])
void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
{
float rmat[3][3], dmat[3][3];
/* 'dmat' is the delta-rotation matrix, which will get (pre)multiplied
* with the rotation matrix to yield the appropriate rotation
*/
@ -1497,14 +1497,14 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
else {
/* quats are normalized before use to eliminate scaling issues */
float tquat[4];
normalize_qt_qt(tquat, ob->quat);
quat_to_mat3(rmat, tquat);
normalize_qt_qt(tquat, ob->dquat);
quat_to_mat3(dmat, tquat);
}
/* combine these rotations */
if (use_drot)
mul_m3_m3m3(mat, dmat, rmat);
@ -1628,7 +1628,7 @@ void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */
float smat[3][3];
float rmat[3][3];
/*float q1[4];*/
/* size */
BKE_object_scale_to_mat3(ob, smat);
@ -1640,9 +1640,9 @@ void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */
void BKE_object_to_mat4(Object *ob, float mat[4][4])
{
float tmat[3][3];
BKE_object_to_mat3(ob, tmat);
copy_m4_m3(mat, tmat);
add_v3_v3v3(mat[3], ob->loc, ob->dloc);
@ -1689,7 +1689,7 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
/* catch exceptions: curve paths used as a duplicator */
if (enable_cu_speed) {
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
* but this will only work if it actually is animated...
* but this will only work if it actually is animated...
*
* we divide the curvetime calculated in the previous step by the length of the path, to get a time
* factor, which then gets clamped to lie within 0.0 - 1.0 range
@ -1713,10 +1713,10 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
if (cu->pathlen) {
ctime /= cu->pathlen;
}
CLAMP(ctime, 0.0f, 1.0f);
}
unit_m4(mat);
/* vec: 4 items! */
@ -1726,7 +1726,7 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
#if 0
float si, q[4];
vec_to_quat(quat, dir, ob->trackflag, ob->upflag);
/* the tilt */
normalize_v3(dir);
q[0] = cosf(0.5 * vec[3]);
@ -1741,7 +1741,7 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
normalize_qt(quat);
quat_to_mat4(mat, quat);
}
if (cu->flag & CU_PATH_RADIUS) {
float tmat[4][4], rmat[4][4];
scale_m4_fl(tmat, radius);
@ -1750,22 +1750,22 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
}
copy_v3_v3(mat[3], vec);
}
return true;
}
static void ob_parbone(Object *ob, Object *par, float mat[4][4])
{
{
bPoseChannel *pchan;
float vec[3];
if (par->type != OB_ARMATURE) {
unit_m4(mat);
return;
}
/* Make sure the bone is still valid */
pchan = BKE_pose_channel_find_name(par->pose, ob->parsubstr);
if (!pchan || !pchan->bone) {
@ -1793,14 +1793,14 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4])
static void give_parvert(Object *par, int nr, float vec[3])
{
zero_v3(vec);
if (par->type == OB_MESH) {
Mesh *me = par->data;
BMEditMesh *em = me->edit_btmesh;
DerivedMesh *dm;
dm = (em) ? em->derivedFinal : par->derivedFinal;
if (dm) {
int count = 0;
int numVerts = dm->getNumVerts(dm);
@ -1976,16 +1976,16 @@ void BKE_object_get_parent_matrix(Scene *scene, Object *ob, Object *par, float p
ok = 1;
}
}
if (ok) mul_m4_m4m4(parentmat, par->obmat, tmat);
else copy_m4_m4(parentmat, par->obmat);
break;
case PARBONE:
ob_parbone(ob, par, tmat);
mul_m4_m4m4(parentmat, par->obmat, tmat);
break;
case PARVERT1:
unit_m4(parentmat);
give_parvert(par, ob->par1, vec);
@ -1993,10 +1993,10 @@ void BKE_object_get_parent_matrix(Scene *scene, Object *ob, Object *par, float p
break;
case PARVERT3:
ob_parvert3(ob, par, tmat);
mul_m4_m4m4(parentmat, par->obmat, tmat);
break;
case PARSKEL:
copy_m4_m4(parentmat, par->obmat);
break;
@ -2013,22 +2013,22 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
float totmat[4][4];
float tmat[4][4];
float locmat[4][4];
BKE_object_to_mat4(ob, locmat);
if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
BKE_object_get_parent_matrix(scene, ob, par, totmat);
/* total */
mul_m4_m4m4(tmat, totmat, ob->parentinv);
mul_m4_m4m4(obmat, tmat, locmat);
if (r_originmat) {
/* usable originmat */
copy_m3_m4(r_originmat, tmat);
}
/* origin, for help line */
if (set_origin) {
if ((ob->partype & PARTYPE) == PARSKEL) {
@ -2065,18 +2065,18 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
RigidBodyWorld *rbw, float r_originmat[3][3])
{
if (ob == NULL) return;
/* execute drivers only, as animation has already been done */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
if (ob->parent) {
Object *par = ob->parent;
float slowmat[4][4];
/* calculate parent matrix */
solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, true);
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
* An old-fashioned hack which probably doesn't really cut it anymore
*/
if (ob->partype & PARSLOW) {
@ -2092,7 +2092,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
rbw = rbw ? rbw : scene->rigidbody_world;
/* read values pushed into RBO from sim/cache... */
BKE_rigidbody_sync_transforms(rbw, ob, ctime);
/* solve constraints */
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
bConstraintOb *cob;
@ -2100,7 +2100,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
BKE_constraints_solve(&ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob);
}
/* set negative scale flag in object */
if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
@ -2122,9 +2122,9 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
float slowmat[4][4];
Object *par = ob->parent;
solve_parenting(scene, ob, par, obmat, slowmat, NULL, false);
if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
}
@ -2146,7 +2146,7 @@ void BKE_object_where_is_calc(Scene *scene, Object *ob)
void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
{
BKE_object_workob_clear(workob);
unit_m4(workob->obmat);
unit_m4(workob->parentinv);
unit_m4(workob->constinv);
@ -2154,7 +2154,7 @@ void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
workob->trackflag = ob->trackflag;
workob->upflag = ob->upflag;
workob->partype = ob->partype;
workob->par1 = ob->par1;
workob->par2 = ob->par2;
@ -2207,7 +2207,7 @@ BoundBox *BKE_boundbox_alloc_unit(void)
bb = MEM_callocN(sizeof(BoundBox), "OB-BoundBox");
BKE_boundbox_init_from_minmax(bb, min, max);
return bb;
}
@ -2215,7 +2215,7 @@ void BKE_boundbox_init_from_minmax(BoundBox *bb, const float min[3], const float
{
bb->vec[0][0] = bb->vec[1][0] = bb->vec[2][0] = bb->vec[3][0] = min[0];
bb->vec[4][0] = bb->vec[5][0] = bb->vec[6][0] = bb->vec[7][0] = max[0];
bb->vec[0][1] = bb->vec[1][1] = bb->vec[4][1] = bb->vec[5][1] = min[1];
bb->vec[2][1] = bb->vec[3][1] = bb->vec[6][1] = bb->vec[7][1] = max[1];
@ -2250,7 +2250,7 @@ void BKE_boundbox_minmax(const BoundBox *bb, float obmat[4][4], float r_min[3],
BoundBox *BKE_object_boundbox_get(Object *ob)
{
BoundBox *bb = NULL;
if (ob->type == OB_MESH) {
bb = BKE_mesh_boundbox_get(ob);
}
@ -2282,13 +2282,13 @@ void BKE_object_boundbox_flag(Object *ob, int flag, const bool set)
void BKE_object_dimensions_get(Object *ob, float vec[3])
{
BoundBox *bb = NULL;
bb = BKE_object_boundbox_get(ob);
if (bb) {
float scale[3];
mat4_to_size(scale, ob->obmat);
vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
@ -2301,17 +2301,17 @@ void BKE_object_dimensions_get(Object *ob, float vec[3])
void BKE_object_dimensions_set(Object *ob, const float value[3])
{
BoundBox *bb = NULL;
bb = BKE_object_boundbox_get(ob);
if (bb) {
float scale[3], len[3];
mat4_to_size(scale, ob->obmat);
len[0] = bb->vec[4][0] - bb->vec[0][0];
len[1] = bb->vec[2][1] - bb->vec[0][1];
len[2] = bb->vec[1][2] - bb->vec[0][2];
if (len[0] > 0.f) ob->size[0] = value[0] / len[0];
if (len[1] > 0.f) ob->size[1] = value[1] / len[1];
if (len[2] > 0.f) ob->size[2] = value[2] / len[2];
@ -2323,7 +2323,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
BoundBox bb;
float vec[3];
bool changed = false;
switch (ob->type) {
case OB_CURVE:
case OB_FONT:
@ -2669,7 +2669,7 @@ void BKE_object_handle_update_ex(Main *bmain,
object_handle_update_proxy(bmain, eval_ctx, scene, ob, do_proxy_update);
}
/* WARNING: "scene" here may not be the scene object actually resides in.
/* WARNING: "scene" here may not be the scene object actually resides in.
* When dealing with background-sets, "scene" is actually the active scene.
* e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n
* rigid bodies depend on their world so use BKE_object_handle_update_ex() to also pass along the corrent rigid body world
@ -2714,10 +2714,10 @@ void BKE_object_sculpt_modifiers_changed(Object *ob)
int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot)
{
if (ob->data == NULL)
return 0;
switch (GS(((ID *)ob->data)->name)) {
case ID_ME:
{
@ -2766,7 +2766,7 @@ static int pc_cmp(const void *a, const void *b)
else return 0;
}
int BKE_object_insert_ptcache(Object *ob)
int BKE_object_insert_ptcache(Object *ob)
{
LinkData *link = NULL;
int i = 0;
@ -2791,18 +2791,18 @@ static int pc_findindex(ListBase *listbase, int index)
{
LinkData *link = NULL;
int number = 0;
if (listbase == NULL) return -1;
link = listbase->first;
while (link) {
if (GET_INT_FROM_POINTER(link->data) == index)
return number;
number++;
link = link->next;
}
return -1;
}
@ -2927,7 +2927,7 @@ static KeyBlock *insert_curvekey(Main *bmain, Object *ob, const char *name, cons
}
KeyBlock *BKE_object_shapekey_insert(Main *bmain, Object *ob, const char *name, const bool from_mix)
{
{
switch (ob->type) {
case OB_MESH:
return insert_meshkey(bmain, ob, name, from_mix);

@ -132,7 +132,7 @@ bDeformGroup *BKE_object_defgroup_add_name(Object *ob, const char *name)
/**
* Add a vgroup of default name to object. *Does not* handle MDeformVert data at all!
*/
bDeformGroup *BKE_object_defgroup_add(Object *ob)
bDeformGroup *BKE_object_defgroup_add(Object *ob)
{
return BKE_object_defgroup_add_name(ob, DATA_("Group"));
}

@ -126,7 +126,7 @@ static void init_context(
static void copy_dupli_context(DupliContext *r_ctx, const DupliContext *ctx, Object *ob, float mat[4][4], int index, bool animated)
{
*r_ctx = *ctx;
r_ctx->animated |= animated; /* object animation makes all children animated */
/* XXX annoying, previously was done by passing an ID* argument, this at least is more explicit */
@ -1281,7 +1281,7 @@ DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist)
{
DupliApplyData *apply_data = NULL;
int num_objects = BLI_listbase_count(duplilist);
if (num_objects > 0) {
DupliObject *dob;
int i;
@ -1302,7 +1302,7 @@ DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist)
/* copy obmat from duplis */
copy_m4_m4(apply_data->extra[i].obmat, dob->ob->obmat);
copy_m4_m4(dob->ob->obmat, dob->mat);
/* copy layers from the main duplicator object */
apply_data->extra[i].lay = dob->ob->lay;
dob->ob->lay = ob->lay;
@ -1322,7 +1322,7 @@ void duplilist_restore(ListBase *duplilist, DupliApplyData *apply_data)
for (dob = duplilist->last, i = apply_data->num_objects - 1; dob; dob = dob->prev, --i) {
copy_m4_m4(dob->ob->obmat, apply_data->extra[i].obmat);
dob->ob->transflag &= ~OB_DUPLICALCDERIVED;
dob->ob->lay = apply_data->extra[i].lay;
}
}

@ -156,7 +156,7 @@ static float gaussRand(RNG *rng)
{
/* Note: to avoid numerical problems with very small numbers, we make these variables singe-precision floats,
* but later we call the double-precision log() and sqrt() functions instead of logf() and sqrtf().
*/
*/
float x;
float y;
float length2;

@ -34,7 +34,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#ifndef WIN32
#ifndef WIN32
#include <unistd.h>
#else
#include <io.h>
@ -90,14 +90,14 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
return(oldseek);
}
void rewindPackedFile(PackedFile *pf)
{
seekPackedFile(pf, 0, SEEK_SET);
}
int readPackedFile(PackedFile *pf, void *data, int size)
{
{
if ((pf != NULL) && (size >= 0) && (data != NULL)) {
if (size + pf->seek > pf->size) {
size = pf->size - pf->seek;
@ -125,7 +125,7 @@ int countPackedFiles(Main *bmain)
VFont *vf;
bSound *sound;
int count = 0;
/* let's check if there are packed files... */
for (ima = bmain->image.first; ima; ima = ima->id.next)
if (BKE_image_has_packedfile(ima))
@ -167,7 +167,7 @@ PackedFile *newPackedFileMemory(void *mem, int memlen)
PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
pf->data = mem;
pf->size = memlen;
return pf;
}
@ -177,14 +177,14 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
int file, filelen;
char name[FILE_MAX];
void *data;
/* render result has no filename and can be ignored
* any other files with no name can be ignored too */
if (filename[0] == '\0')
return NULL;
//XXX waitcursor(1);
/* convert relative filenames to absolute filenames */
BLI_strncpy(name, filename, sizeof(name));
@ -219,7 +219,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
}
//XXX waitcursor(0);
return (pf);
}
@ -230,7 +230,7 @@ void packAll(Main *bmain, ReportList *reports, bool verbose)
VFont *vfont;
bSound *sound;
int tot = 0;
for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (BKE_image_has_packedfile(ima) == false && !ID_IS_LINKED(ima)) {
if (ima->source == IMA_SRC_FILE) {
@ -257,7 +257,7 @@ void packAll(Main *bmain, ReportList *reports, bool verbose)
tot++;
}
}
if (tot > 0)
BKE_reportf(reports, RPT_INFO, "Packed %d files", tot);
else if (verbose)
@ -275,7 +275,7 @@ static char *find_new_name(char *name)
char tempname[FILE_MAX];
char *newname;
size_t len;
if (fop_exists(name)) {
for (number = 1; number <= 999; number++) {
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number);
@ -300,12 +300,12 @@ int writePackedFile(
char name[FILE_MAX];
char tempname[FILE_MAX];
/* void *data; */
if (guimode) {} //XXX waitcursor(1);
BLI_strncpy(name, filename, sizeof(name));
BLI_path_abs(name, ref_file_name);
if (BLI_exists(name)) {
for (number = 1; number <= 999; number++) {
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number);
@ -317,10 +317,10 @@ int writePackedFile(
}
}
}
/* make sure the path to the file exists... */
BLI_make_existing_file(name);
file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
if (file == -1) {
BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name);
@ -334,10 +334,10 @@ int writePackedFile(
else {
BKE_reportf(reports, RPT_INFO, "Saved packed file to: %s", name);
}
close(file);
}
if (remove_tmp) {
if (ret_value == RET_ERROR) {
if (BLI_rename(tempname, name) != 0) {
@ -350,7 +350,7 @@ int writePackedFile(
}
}
}
if (guimode) {} //XXX waitcursor(0);
return (ret_value);
@ -370,10 +370,10 @@ int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile
int ret_val, i, len, file;
char buf[4096];
char name[FILE_MAX];
BLI_strncpy(name, filename, sizeof(name));
BLI_path_abs(name, ref_file_name);
if (BLI_stat(name, &st) == -1) {
ret_val = PF_NOFILE;
}
@ -408,11 +408,11 @@ int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile
}
}
}
close(file);
}
}
return(ret_val);
}
@ -430,7 +430,7 @@ char *unpackFile(
{
char *newname = NULL;
const char *temp = NULL;
if (pf != NULL) {
switch (how) {
case -1:
@ -484,12 +484,12 @@ char *unpackFile(
printf("unpackFile: unknown return_value %d\n", how);
break;
}
if (temp) {
newname = BLI_strdup(temp);
}
}
return newname;
}
@ -539,7 +539,7 @@ int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how)
char localname[FILE_MAX], absname[FILE_MAX];
char *newname;
int ret_value = RET_ERROR;
if (vfont != NULL) {
unpack_generate_paths(vfont->name, (ID *)vfont, absname, localname, sizeof(absname), sizeof(localname));
newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, vfont->packedfile, how);
@ -551,7 +551,7 @@ int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how)
MEM_freeN(newname);
}
}
return (ret_value);
}
@ -576,7 +576,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
ret_value = RET_OK;
}
}
return(ret_value);
}
@ -633,16 +633,16 @@ int unpackLibraries(Main *bmain, ReportList *reports)
Library *lib;
char *newname;
int ret_value = RET_ERROR;
for (lib = bmain->library.first; lib; lib = lib->id.next) {
if (lib->packedfile && lib->name[0]) {
newname = unpackFile(reports, BKE_main_blendfile_path(bmain), lib->filepath, lib->filepath, lib->packedfile, PF_WRITE_ORIGINAL);
if (newname != NULL) {
ret_value = RET_OK;
printf("Unpacked .blend library: %s\n", newname);
freePackedFile(lib->packedfile);
lib->packedfile = NULL;
@ -650,24 +650,24 @@ int unpackLibraries(Main *bmain, ReportList *reports)
}
}
}
return(ret_value);
}
void packLibraries(Main *bmain, ReportList *reports)
{
Library *lib;
/* test for relativenss */
for (lib = bmain->library.first; lib; lib = lib->id.next)
if (!BLI_path_is_rel(lib->name))
break;
if (lib) {
BKE_reportf(reports, RPT_ERROR, "Cannot pack absolute file: '%s'", lib->name);
return;
}
for (lib = bmain->library.first; lib; lib = lib->id.next)
if (lib->packedfile == NULL)
lib->packedfile = newPackedFile(reports, lib->name, BKE_main_blendfile_path(bmain));

@ -160,7 +160,7 @@ Paint *BKE_paint_get_active(Scene *sce)
{
if (sce) {
ToolSettings *ts = sce->toolsettings;
if (sce->basact && sce->basact->object) {
switch (sce->basact->object->mode) {
case OB_MODE_SCULPT:
@ -601,7 +601,7 @@ float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level,
{
int factor = BKE_ccg_factor(level, gpm->level);
int gridsize = BKE_ccg_gridsize(gpm->level);
return gpm->data[(y * factor) * gridsize + (x * factor)];
}

@ -197,7 +197,7 @@ ParticleSystem *psys_get_current(Object *ob)
if (psys->flag & PSYS_CURRENT)
return psys;
}
return NULL;
}
short psys_get_current_num(Object *ob)
@ -210,7 +210,7 @@ short psys_get_current_num(Object *ob)
for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++)
if (psys->flag & PSYS_CURRENT)
return i;
return i;
}
void psys_set_current_num(Object *ob, int index)
@ -348,7 +348,7 @@ void psys_check_group_weights(ParticleSettings *part)
dw = part->dupliweights.first;
while (dw && dw->ob != go->ob)
dw = dw->next;
if (!dw) {
dw = MEM_callocN(sizeof(ParticleDupliWeight), "ParticleDupliWeight");
dw->ob = go->ob;
@ -387,7 +387,7 @@ int psys_uses_gravity(ParticleSimulationData *sim)
static void fluid_free_settings(SPHFluidSettings *fluid)
{
if (fluid)
MEM_freeN(fluid);
MEM_freeN(fluid);
}
/** Free (or release) any data used by this particle settings (does not free the partsett itself). */
@ -396,7 +396,7 @@ void BKE_particlesettings_free(ParticleSettings *part)
int a;
BKE_animdata_free((ID *)part, false);
for (a = 0; a < MAX_MTEX; a++) {
MEM_SAFE_FREE(part->mtex[a]);
}
@ -407,7 +407,7 @@ void BKE_particlesettings_free(ParticleSettings *part)
curvemapping_free(part->roughcurve);
if (part->twistcurve)
curvemapping_free(part->twistcurve);
free_partdeflect(part->pd);
free_partdeflect(part->pd2);
@ -438,7 +438,7 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
psys->pointcache = NULL;
modifier_free((ModifierData *)psys->clmd);
psys->clmd = NULL;
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
}
@ -517,10 +517,10 @@ void psys_free_particles(ParticleSystem *psys)
MEM_freeN(pa->hair);
}
}
if (psys->particles->keys)
MEM_freeN(psys->particles->keys);
if (psys->particles->boid)
MEM_freeN(psys->particles->boid);
@ -555,11 +555,11 @@ void psys_free_pdd(ParticleSystem *psys)
}
/* free everything */
void psys_free(Object *ob, ParticleSystem *psys)
{
{
if (psys) {
int nr = 0;
ParticleSystem *tpsys;
psys_free_path_cache(psys, NULL);
free_hair(ob, psys, 1);
@ -574,7 +574,7 @@ void psys_free(Object *ob, ParticleSystem *psys)
psys->child = NULL;
psys->totchild = 0;
}
/* check if we are last non-visible particle system */
for (tpsys = ob->particlesystem.first; tpsys; tpsys = tpsys->next) {
if (tpsys->part) {
@ -592,7 +592,7 @@ void psys_free(Object *ob, ParticleSystem *psys)
BKE_ptcache_free_list(&psys->ptcaches);
psys->pointcache = NULL;
BLI_freelistN(&psys->targets);
BLI_bvhtree_free(psys->bvhtree);
@ -680,7 +680,7 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
data = psys->renderdata;
if (!data)
return;
if (data->elems)
MEM_freeN(data->elems);
@ -765,7 +765,7 @@ bool psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float
if (!(psys->renderdata && (psys->part->simplify_flag & PART_SIMPLIFY_ENABLE)))
return false;
data = psys->renderdata;
if (!data->do_simplify)
return false;
@ -822,7 +822,7 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4,
value += w[3] * v4;
CLAMP(value, 0.f, 1.f);
return value;
}
@ -1075,7 +1075,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
while (pind->kkey[1]->time < real_t)
pind->kkey[1]++;
pind->kkey[0] = pind->kkey[1] - 1;
}
else if (pind->cache) {
@ -1236,7 +1236,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
if (mface->v4) {
v4 = mvert[mface->v4].co;
normal_short_to_float_v3(n4, mvert[mface->v4].no);
interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w);
if (nor) {
@ -1256,7 +1256,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
normal_tri_v3(nor, v1, v2, v3);
}
}
/* calculate tangent vectors */
if (utan && vtan) {
if (tface) {
@ -1364,7 +1364,7 @@ void psys_interpolate_mcol(const MCol *mcol, int quad, const float w[4], MCol *m
cp1 = (const char *)&mcol[0];
cp2 = (const char *)&mcol[1];
cp3 = (const char *)&mcol[2];
if (quad) {
cp4 = (char *)&mcol[3];
@ -1395,7 +1395,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int
MFace *mf = dm->getTessFaceData(dm, index, CD_MFACE);
return interpolate_particle_value(values[mf->v1], values[mf->v2], values[mf->v3], values[mf->v4], fw, mf->v4);
}
}
return 0.0f;
}
@ -1418,7 +1418,7 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4
psys_w_to_origspace(w, co);
co[2] = 0.0f;
if (quad) {
v[3][0] = osface->uv[3][0]; v[3][1] = osface->uv[3][1]; v[3][2] = 0.0f;
interp_weights_poly_v3(neww, v, 4, co);
@ -1501,7 +1501,7 @@ int psys_particle_dm_face_lookup(
}
psys_w_to_origspace(fw, uv);
if (poly_nodes) {
/* we can have a restricted linked list of faces to check, faster! */
LinkNode *tessface_node = poly_nodes[pindex_orig];
@ -1687,7 +1687,7 @@ float psys_particle_value_from_verts(DerivedMesh *dm, short from, ParticleData *
if (!psys_map_index_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw))
return 0.0f;
return psys_interpolate_value_from_verts(dm, from, mapindex, mapfw, values);
}
@ -1764,13 +1764,13 @@ CustomDataMask psys_emitter_customdata_mask(ParticleSystem *psys)
break;
}
}
/* particles only need this if they are after a non deform modifier, and
* the modifier stack will only create them in that case. */
dataMask |= CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORIGINDEX;
dataMask |= CD_MASK_ORCO;
return dataMask;
}
@ -1814,10 +1814,10 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
LOOP_PARTICLES {
psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, state.co, 0, 0, 0, 0, 0);
mul_m4_v3(sim->ob->obmat, state.co);
mul_mat3_m4_v3(sim->ob->obmat, state.vel);
pd_point_from_particle(sim, pa, &state, &point);
for (eff = effectors->first; eff; eff = eff->next) {
@ -1855,22 +1855,22 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i
if (effectors) for (eff = effectors->first; eff; eff = eff->next) {
pd = eff->pd;
if (pd->forcefield != PFIELD_GUIDE)
continue;
data = eff->guide_data + index;
if (data->strength <= 0.0f)
continue;
guidetime = time / (1.0f - pd->free_end);
if (guidetime > 1.0f)
continue;
cu = (Curve *)eff->ob->data;
if (pd->flag & PFIELD_GUIDE_PATH_ADD) {
if (where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0)
return 0;
@ -1879,14 +1879,14 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i
if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0)
return 0;
}
mul_m4_v3(eff->ob->obmat, guidevec);
mul_mat3_m4_v3(eff->ob->obmat, guidedir);
normalize_v3(guidedir);
copy_v3_v3(vec_to_point, data->vec_to_point);
if (guidetime != 0.0f) {
/* curve direction */
cross_v3_v3v3(temp, eff->guide_dir, guidedir);
@ -1894,52 +1894,52 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i
angle = saacos(angle);
axis_angle_to_quat(rot2, temp, angle);
mul_qt_v3(rot2, vec_to_point);
/* curve tilt */
axis_angle_to_quat(rot2, guidedir, guidevec[3] - eff->guide_loc[3]);
mul_qt_v3(rot2, vec_to_point);
}
/* curve taper */
if (cu->taperobj)
mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100));
else { /* curve size*/
if (cu->flag & CU_PATH_RADIUS) {
mul_v3_fl(vec_to_point, radius);
}
}
if (clumpcurve)
curvemapping_changed_all(clumpcurve);
if (roughcurve)
curvemapping_changed_all(roughcurve);
{
ParticleKey key;
float par_co[3] = {0.0f, 0.0f, 0.0f};
float par_vel[3] = {0.0f, 0.0f, 0.0f};
float par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
float orco_offset[3] = {0.0f, 0.0f, 0.0f};
copy_v3_v3(key.co, vec_to_point);
do_kink(&key, par_co, par_vel, par_rot, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0);
do_clump(&key, par_co, guidetime, orco_offset, pd->clump_fac, pd->clump_pow, 1.0f,
part->child_flag & PART_CHILD_USE_CLUMP_NOISE, part->clump_noise_size, clumpcurve);
copy_v3_v3(vec_to_point, key.co);
}
add_v3_v3(vec_to_point, guidevec);
//sub_v3_v3v3(pa_loc, pa_loc, pa_zero);
madd_v3_v3fl(effect, vec_to_point, data->strength);
madd_v3_v3fl(veffect, guidedir, data->strength);
totstrength += data->strength;
if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT)
totstrength *= weight;
}
if (totstrength != 0.0f) {
if (totstrength > 1.0f)
mul_v3_fl(effect, 1.0f / totstrength);
@ -2096,7 +2096,7 @@ static bool psys_thread_context_init_path(
if (totchild && part->childtype == PART_CHILD_FACES) {
totparent = (int)(totchild * part->parents * 0.3f);
if ((psys->renderdata || use_render_params) && part->child_nbr && part->ren_child_nbr)
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
@ -2170,7 +2170,7 @@ static void psys_task_init_path(ParticleTask *task, ParticleSimulationData *sim)
{
/* init random number generator */
int seed = 31415926 + sim->psys->seed;
task->rng_path = BLI_rng_new(seed);
}
@ -2277,7 +2277,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
/* get the original coordinates (orco) for texture usage */
cpa_num = cpa->num;
foffset = cpa->foffset;
cpa_fuv = cpa->fuv;
cpa_from = PART_FROM_FACE;
@ -2426,14 +2426,14 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
if (pa->flag & PARS_UNEXIST) pa = NULL;
}
if (pa) {
ListBase modifiers;
BLI_listbase_clear(&modifiers);
psys_particle_on_emitter(ctx->sim.psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset,
par_co, NULL, NULL, NULL, par_orco, NULL);
psys_apply_child_modifiers(ctx, &modifiers, cpa, &ptex, orco, ornor, hairmat, child_keys, par, par_orco);
}
else
@ -2471,57 +2471,57 @@ void psys_cache_child_paths(
ParticleTask *tasks_parent, *tasks_child;
int numtasks_parent, numtasks_child;
int i, totchild, totparent;
if (sim->psys->flag & PSYS_GLOBAL_HAIR)
return;
/* create a task pool for child path tasks */
if (!psys_thread_context_init_path(&ctx, sim, sim->scene, cfra, editupdate, use_render_params))
return;
task_scheduler = BLI_task_scheduler_get();
task_pool = BLI_task_pool_create(task_scheduler, &ctx);
totchild = ctx.totchild;
totparent = ctx.totparent;
if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) {
; /* just overwrite the existing cache */
}
else {
/* clear out old and create new empty path cache */
free_child_path_cache(sim->psys);
sim->psys->childcache = psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx.segments + ctx.extra_segments + 1);
sim->psys->totchildcache = totchild;
}
/* cache parent paths */
ctx.parent_pass = 1;
psys_tasks_create(&ctx, 0, totparent, &tasks_parent, &numtasks_parent);
for (i = 0; i < numtasks_parent; ++i) {
ParticleTask *task = &tasks_parent[i];
psys_task_init_path(task, sim);
BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW);
}
BLI_task_pool_work_and_wait(task_pool);
/* cache child paths */
ctx.parent_pass = 0;
psys_tasks_create(&ctx, totparent, totchild, &tasks_child, &numtasks_child);
for (i = 0; i < numtasks_child; ++i) {
ParticleTask *task = &tasks_child[i];
psys_task_init_path(task, sim);
BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW);
}
BLI_task_pool_work_and_wait(task_pool);
BLI_task_pool_free(task_pool);
psys_tasks_free(tasks_parent, numtasks_parent);
psys_tasks_free(tasks_child, numtasks_child);
psys_thread_context_free(&ctx);
}
@ -2577,15 +2577,15 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
ParticleCacheKey *ca, **cache;
DerivedMesh *hair_dm = (psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL;
ParticleKey result;
Material *ma;
ParticleInterpolationData pind;
ParticleTexture ptex;
PARTICLE_P;
float birthtime = 0.0, dietime = 0.0;
float t, time = 0.0, dfra = 1.0 /* , frs_sec = sim->scene->r.frs_sec*/ /*UNUSED*/;
float col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
@ -2622,7 +2622,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if ((psys->flag & PSYS_GLOBAL_HAIR) == 0) {
if ((psys->part->flag & PART_CHILD_EFFECT) == 0)
vg_effector = psys_cache_vgroup(psmd->dm_final, psys, PSYS_VG_EFFECTOR);
if (!psys->totchild)
vg_length = psys_cache_vgroup(psmd->dm_final, psys, PSYS_VG_LENGTH);
}
@ -2697,7 +2697,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (part->type == PART_HAIR) {
HairKey *hkey;
for (k = 0, hkey = pa->hair; k < pa->totkey; ++k, ++hkey) {
mul_v3_m4v3(hkey->world_co, hairmat, hkey->co);
}
@ -2775,7 +2775,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
{
ParticleCacheKey *ca, **cache = edit->pathcache;
ParticleEditSettings *pset = &scene->toolsettings->particle;
PTCacheEditPoint *point = NULL;
PTCacheEditKey *ekey = NULL;
@ -2785,7 +2785,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
ParticleInterpolationData pind;
ParticleKey result;
float birthtime = 0.0f, dietime = 0.0f;
float t, time = 0.0f, keytime = 0.0f /*, frs_sec */;
float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f};
@ -3060,7 +3060,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
sub_v3_v3v3(mat[1], v2, v1);
normalize_v3(mat[1]);
}
/* third as a cross product */
cross_v3_v3v3(mat[0], mat[1], mat[2]);
}
@ -3077,7 +3077,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m
mface = dm->getTessFaceData(dm, i, CD_MFACE);
osface = dm->getTessFaceData(dm, i, CD_ORIGSPACE);
if (orco && (orcodata = dm->getVertDataArray(dm, CD_ORCO))) {
copy_v3_v3(v[0], orcodata[mface->v1]);
copy_v3_v3(v[1], orcodata[mface->v2]);
@ -3106,7 +3106,7 @@ void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, Pa
unit_m4(hairmat);
return;
}
psys_face_mat(0, dm, pa, hairmat, 0);
psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0, 0);
copy_v3_v3(hairmat[3], vec);
@ -3255,7 +3255,7 @@ static void default_particle_settings(ParticleSettings *part)
part->grid_res = 10;
part->timetweak = 1.0;
part->courant_target = 0.2;
part->integrator = PART_INT_MIDPOINT;
part->phystype = PART_PHYS_NEWTON;
part->hair_step = 5;
@ -3326,7 +3326,7 @@ ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name)
ParticleSettings *part;
part = BKE_libblock_alloc(bmain, ID_PA, name, 0);
default_particle_settings(part);
return part;
@ -3335,24 +3335,24 @@ ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name)
void BKE_particlesettings_clump_curve_init(ParticleSettings *part)
{
CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
cumap->cm[0].curve[0].x = 0.0f;
cumap->cm[0].curve[0].y = 1.0f;
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
part->clumpcurve = cumap;
}
void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
{
CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
cumap->cm[0].curve[0].x = 0.0f;
cumap->cm[0].curve[0].y = 1.0f;
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
part->roughcurve = cumap;
}
@ -3427,7 +3427,7 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int index, const f
MFace *mf;
MTFace *tf;
int i;
tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, name);
if (tf == NULL)
@ -3624,7 +3624,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
ATTR_FALLTHROUGH;
case TEXCO_ORCO:
psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0);
if (me->bb == NULL || (me->bb->flag & BOUNDBOX_DIRTY)) {
BKE_mesh_texspace_calc(me);
}
@ -3720,7 +3720,7 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED
{
ParticleSettings *part = psys->part;
float size; // time XXX
if (part->childtype == PART_CHILD_FACES) {
int w = 0;
size = 0.0;
@ -3857,7 +3857,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
}
else {
float par_co[3], par_orco[3];
cpa = psys->child + p - totpart;
if (state->time < 0.0f)
@ -4134,9 +4134,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
/* convert velocity to timestep size */
mul_v3_fl(keys[1].vel, dfra * timestep);
mul_v3_fl(keys[2].vel, dfra * timestep);
psys_interpolate_particle(-1, keys, keytime, state, 1);
/* convert back to real velocity */
mul_v3_fl(state->vel, 1.f / (dfra * timestep));
@ -4162,7 +4162,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
if (sim->psys->lattice_deform_data)
calc_latt_deform(sim->psys->lattice_deform_data, state->co, psys->lattice_strength);
}
return 1;
}
}
@ -4200,7 +4200,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
mtface += cpa->num;
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
}
psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, 0, 0, 0, orco, 0);
return;
}
@ -4411,7 +4411,7 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
mul_m4_v3(imat, hkey->co);
}
}
end_latt_deform(psys->lattice_deform_data);
psys->lattice_deform_data = NULL;

@ -94,7 +94,7 @@ static void distribute_simple_children(Scene *scene, Object *ob, DerivedMesh *fi
for (p=0; p<psys->totpart; p++,cpa++) {
float length=2.0;
cpa->parent=p;
/* create even spherical distribution inside unit sphere */
while (length>=1.0f) {
cpa->fuv[0]=2.0f*BLI_frand()-1.0f;
@ -136,7 +136,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
/* determine major axis */
axis = axis_dominant_v3_single(delta);
d = delta[axis]/(float)res;
size[axis] = res;
@ -198,7 +198,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
totface=dm->getNumTessFaces(dm);
mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE);
for (a=0; a<amax; a++) {
if (a==0) { a0mul=res*res; a1mul=res; a2mul=1; }
else if (a==1) { a0mul=res; a1mul=1; a2mul=res*res; }
@ -350,13 +350,13 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
x= 0;
num2 = 2 * num;
for (i=0; i<num2; i+=2) {
jit[i] = x + amount*rad1*(0.5f - BLI_rng_get_float(rng));
jit[i+1] = i/(2.0f*num) + amount*rad1*(0.5f - BLI_rng_get_float(rng));
jit[i]-= (float)floor(jit[i]);
jit[i+1]-= (float)floor(jit[i+1]);
x+= rad3;
x -= (float)floor(x);
}
@ -417,10 +417,10 @@ static int distribute_binary_search(float *sum, int n, float value)
while (low < high) {
mid = (low + high) / 2;
if ((sum[mid] >= value) && (sum[mid - 1] < value))
return mid;
if (sum[mid] > value) {
high = mid - 1;
}
@ -472,22 +472,22 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i
}
}
}
#if ONLY_WORKING_WITH_PA_VERTS
if (ctx->tree) {
KDTreeNearest ptn[3];
int w, maxw;
psys_particle_on_dm(ctx->dm,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0);
BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1);
maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
for (w=0; w<maxw; w++) {
pa->verts[w]=ptn->num;
}
}
#endif
if (rng_skip_tot > 0) /* should never be below zero */
BLI_rng_skip(thread->rng, rng_skip_tot);
}
@ -501,10 +501,10 @@ static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, i
int rng_skip_tot= PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */
MFace *mface;
pa->num = i = ctx->index[p];
mface = dm->getTessFaceData(dm,i,CD_MFACE);
switch (distr) {
case PART_DISTR_JIT:
if (ctx->jitlevel == 1) {
@ -524,12 +524,12 @@ static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, i
randu= BLI_rng_get_float(thread->rng);
randv= BLI_rng_get_float(thread->rng);
rng_skip_tot -= 2;
psys_uv_to_w(randu, randv, mface->v4, pa->fuv);
break;
}
pa->foffset= 0.0f;
if (rng_skip_tot > 0) /* should never be below zero */
BLI_rng_skip(thread->rng, rng_skip_tot);
}
@ -542,13 +542,13 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
int distr= ctx->distr;
int i, intersect, tot;
int rng_skip_tot= PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */
MFace *mface;
MVert *mvert=dm->getVertDataArray(dm,CD_MVERT);
pa->num = i = ctx->index[p];
mface = dm->getTessFaceData(dm,i,CD_MFACE);
switch (distr) {
case PART_DISTR_JIT:
if (ctx->jitlevel == 1) {
@ -568,30 +568,30 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
randu= BLI_rng_get_float(thread->rng);
randv= BLI_rng_get_float(thread->rng);
rng_skip_tot -= 2;
psys_uv_to_w(randu, randv, mface->v4, pa->fuv);
break;
}
pa->foffset= 0.0f;
/* experimental */
tot=dm->getNumTessFaces(dm);
psys_interpolate_face(mvert,mface,0,0,pa->fuv,co,nor,0,0,0,0);
normalize_v3(nor);
negate_v3(nor);
min_d=FLT_MAX;
intersect=0;
for (i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++) {
if (i==pa->num) continue;
v1=mvert[mface->v1].co;
v2=mvert[mface->v2].co;
v3=mvert[mface->v3].co;
if (isect_ray_tri_v3(co, nor, v2, v3, v1, &cur_d, NULL)) {
if (cur_d<min_d) {
min_d=cur_d;
@ -601,7 +601,7 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
}
if (mface->v4) {
v4=mvert[mface->v4].co;
if (isect_ray_tri_v3(co, nor, v4, v1, v3, &cur_d, NULL)) {
if (cur_d<min_d) {
min_d=cur_d;
@ -623,7 +623,7 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
break;
}
}
if (rng_skip_tot > 0) /* should never be below zero */
BLI_rng_skip(thread->rng, rng_skip_tot);
}
@ -637,40 +637,40 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
int cfrom= ctx->cfrom;
int i;
int rng_skip_tot= PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */
MFace *mf;
if (ctx->index[p] < 0) {
cpa->num=0;
cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3]=0.0f;
cpa->pa[0]=cpa->pa[1]=cpa->pa[2]=cpa->pa[3]=0;
return;
}
mf= dm->getTessFaceData(dm, ctx->index[p], CD_MFACE);
randu= BLI_rng_get_float(thread->rng);
randv= BLI_rng_get_float(thread->rng);
rng_skip_tot -= 2;
psys_uv_to_w(randu, randv, mf->v4, cpa->fuv);
cpa->num = ctx->index[p];
if (ctx->tree) {
KDTreeNearest ptn[10];
int w,maxw;//, do_seams;
float maxd /*, mind,dd */, totw= 0.0f;
int parent[10];
float pweight[10];
psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL);
BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1);
maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
maxd=ptn[maxw-1].dist;
/* mind=ptn[0].dist; */ /* UNUSED */
/* the weights here could be done better */
for (w=0; w<maxw; w++) {
parent[w]=ptn[w].index;
@ -680,7 +680,7 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
parent[w]=-1;
pweight[w]=0.0f;
}
for (w=0,i=0; w<maxw && i<4; w++) {
if (parent[w]>=0) {
cpa->pa[i]=parent[w];
@ -693,13 +693,13 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
cpa->pa[i]=-1;
cpa->w[i]=0.0f;
}
if (totw > 0.0f) {
for (w = 0; w < 4; w++) {
cpa->w[w] /= totw;
}
}
cpa->parent=cpa->pa[0];
}
@ -715,7 +715,7 @@ static void exec_distribute_parent(TaskPool * __restrict UNUSED(pool), void *tas
int p;
BLI_rng_skip(task->rng, PSYS_RND_DIST_SKIP * task->begin);
pa= psys->particles + task->begin;
switch (psys->part->from) {
case PART_FROM_FACE:
@ -739,20 +739,20 @@ static void exec_distribute_child(TaskPool * __restrict UNUSED(pool), void *task
ParticleSystem *psys = task->ctx->sim.psys;
ChildParticle *cpa;
int p;
/* RNG skipping at the beginning */
cpa = psys->child;
for (p = 0; p < task->begin; ++p, ++cpa) {
if (task->ctx->skip) /* simplification skip */
BLI_rng_skip(task->rng, PSYS_RND_DIST_SKIP * task->ctx->skip[p]);
BLI_rng_skip(task->rng, PSYS_RND_DIST_SKIP);
}
for (; p < task->end; ++p, ++cpa) {
if (task->ctx->skip) /* simplification skip */
BLI_rng_skip(task->rng, PSYS_RND_DIST_SKIP * task->ctx->skip[p]);
distribute_children_exec(task, cpa, p);
}
}
@ -825,28 +825,28 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
int jitlevel= 1, distr;
float *element_weight=NULL,*jitter_offset=NULL, *vweight=NULL;
float cur, maxweight=0.0, tweight, totweight, inv_totweight, co[3], nor[3], orco[3];
if (ELEM(NULL, ob, psys, psys->part))
return 0;
part=psys->part;
totpart=psys->totpart;
if (totpart==0)
return 0;
if (!finaldm->deformedOnly && !finaldm->getTessFaceDataArray(finaldm, CD_ORIGINDEX)) {
printf("Can't create particles with the current modifier stack, disable destructive modifiers\n");
// XXX error("Can't paint with the current modifier stack, disable destructive modifiers");
return 0;
}
/* XXX This distribution code is totally broken in case from == PART_FROM_CHILD, it's always using finaldm
* even if use_modifier_stack is unset... But making things consistent here break all existing edited
* hair systems, so better wait for complete rewrite.
*/
psys_thread_context_init(ctx, sim);
/* First handle special cases */
if (from == PART_FROM_CHILD) {
/* Simple children */
@ -878,7 +878,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
return 0;
}
}
/* Create trees and original coordinates if needed */
if (from == PART_FROM_CHILD) {
distr=PART_DISTR_RAND;
@ -906,7 +906,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
else {
distr = part->distr;
BLI_srandom(31415926 + psys->seed);
if (psys->part->use_modifier_stack)
dm = finaldm;
else
@ -964,7 +964,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
MVert *v1, *v2, *v3, *v4;
float totarea=0.f, co1[3], co2[3], co3[3], co4[3];
float (*orcodata)[3];
orcodata= dm->getVertDataArray(dm, CD_ORCO);
for (i=0; i<totelem; i++) {
@ -996,7 +996,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
}
cur = mf->v4 ? area_quad_v3(co1, co2, co3, co4) : area_tri_v3(co1, co2, co3);
if (cur > maxweight)
maxweight = cur;
@ -1028,7 +1028,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
for (i=0;i<totelem; i++) {
MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3];
if (mf->v4) {
tweight += vweight[mf->v4];
tweight /= 4.0f;
@ -1101,7 +1101,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
}
else {
double step, pos;
step = (totpart < 2) ? 0.5 : 1.0 / (double)totpart;
/* This is to address tricky issues with vertex-emitting when user tries (and expects) exact 1-1 vert/part
* distribution (see T47983 and its two example files). It allows us to consider pos as
@ -1145,17 +1145,17 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
/* Create jittering if needed */
if (distr==PART_DISTR_JIT && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
jitlevel= part->userjit;
if (jitlevel == 0) {
jitlevel= totpart/totelem;
if (part->flag & PART_EDISTR) jitlevel*= 2; /* looks better in general, not very scientific */
if (jitlevel<3) jitlevel= 3;
}
jit= MEM_callocN((2+ jitlevel*2)*sizeof(float), "jit");
/* for small amounts of particles we use regular jitter since it looks
* a bit better, for larger amounts we switch to hammersley sequence
* a bit better, for larger amounts we switch to hammersley sequence
* because it is much faster */
if (jitlevel < 25)
init_mv_jit(jit, jitlevel, psys->seed, part->jitfac);
@ -1192,7 +1192,7 @@ static void psys_task_init_distribute(ParticleTask *task, ParticleSimulationData
{
/* init random number generator */
int seed = 31415926 + sim->psys->seed;
task->rng = BLI_rng_new(seed);
}
@ -1204,19 +1204,19 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
ParticleTask *tasks;
DerivedMesh *finaldm = sim->psmd->dm_final;
int i, totpart, numtasks;
/* create a task pool for distribution tasks */
if (!psys_thread_context_init_distribute(&ctx, sim, from))
return;
task_scheduler = BLI_task_scheduler_get();
task_pool = BLI_task_pool_create(task_scheduler, &ctx);
totpart = (from == PART_FROM_CHILD ? sim->psys->totchild : sim->psys->totpart);
psys_tasks_create(&ctx, 0, totpart, &tasks, &numtasks);
for (i = 0; i < numtasks; ++i) {
ParticleTask *task = &tasks[i];
psys_task_init_distribute(task, sim);
if (from == PART_FROM_CHILD)
BLI_task_pool_push(task_pool, exec_distribute_child, task, false, TASK_PRIORITY_LOW);
@ -1224,16 +1224,16 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
BLI_task_pool_push(task_pool, exec_distribute_parent, task, false, TASK_PRIORITY_LOW);
}
BLI_task_pool_work_and_wait(task_pool);
BLI_task_pool_free(task_pool);
psys_calc_dmcache(sim->ob, finaldm, sim->psmd->dm_deformed, sim->psys);
if (ctx.dm != finaldm)
ctx.dm->release(ctx.dm);
psys_tasks_free(tasks, numtasks);
psys_thread_context_free(&ctx);
}
@ -1277,12 +1277,12 @@ static float psys_render_projected_area(ParticleSystem *psys, const float center
{
ParticleRenderData *data = psys->renderdata;
float co[4], view[3], ortho1[3], ortho2[3], w, dx, dy, radius;
/* transform to view space */
copy_v3_v3(co, center);
co[3] = 1.0f;
mul_m4_v4(data->viewmat, co);
/* compute two vectors orthogonal to view vector */
normalize_v3_v3(view, co);
ortho_basis_v3v3_v3(ortho1, ortho2, view);
@ -1320,7 +1320,7 @@ static float psys_render_projected_area(ParticleSystem *psys, const float center
*viewport *= psys_render_viewport_falloff(vprate, -(co[1] + radius), data->winy);
else if (co[1] - radius > data->winy)
*viewport *= psys_render_viewport_falloff(vprate, (co[1] - radius) - data->winy, data->winy);
return area;
}

@ -238,7 +238,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
}
}
}
if (psys->particles) {
totsaved=MIN2(psys->totpart,totpart);
/*save old pars*/
@ -268,7 +268,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
MEM_freeN(psys->particles);
psys_free_pdd(psys);
}
psys->particles=newpars;
psys->totpart=totpart;
@ -313,14 +313,14 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm_final, DerivedMesh *dm_deform
{
/* use for building derived mesh mapping info:
*
* node: the allocated links - total derived mesh element count
* node: the allocated links - total derived mesh element count
* nodearray: the array of nodes aligned with the base mesh's elements, so
* each original elements can reference its derived elements
*/
Mesh *me= (Mesh*)ob->data;
bool use_modifier_stack= psys->part->use_modifier_stack;
PARTICLE_P;
/* CACHE LOCATIONS */
if (!dm_final->deformedOnly) {
/* Will use later to speed up subsurf/derivedmesh */
@ -424,7 +424,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm_final, DerivedMesh *dm_deform
/* TODO PARTICLE, make the following line unnecessary, each function
* should know to use the num or num_dmcache, set the num_dmcache to
* an invalid value, just in case */
LOOP_PARTICLES {
pa->num_dmcache = DMCACHE_NOTFOUND;
}
@ -453,15 +453,15 @@ void psys_tasks_create(ParticleThreadContext *ctx, int startpart, int endpart, P
int numtasks = ceil_ii((endpart - startpart), MAX_PARTICLES_PER_TASK);
float particles_per_task = (float)(endpart - startpart) / (float)numtasks, p, pnext;
int i;
tasks = MEM_callocN(sizeof(ParticleTask) * numtasks, "ParticleThread");
*r_numtasks = numtasks;
*r_tasks = tasks;
p = (float)startpart;
for (i = 0; i < numtasks; i++, p = pnext) {
pnext = p + particles_per_task;
tasks[i].ctx = ctx;
tasks[i].begin = (int)p;
tasks[i].end = min_ii((int)pnext, endpart);
@ -471,7 +471,7 @@ void psys_tasks_create(ParticleThreadContext *ctx, int startpart, int endpart, P
void psys_tasks_free(ParticleTask *tasks, int numtasks)
{
int i;
/* threads */
for (i = 0; i < numtasks; ++i) {
if (tasks[i].rng)
@ -534,7 +534,7 @@ static void initialize_particle_texture(ParticleSimulationData *sim, ParticleDat
ParticleTexture ptex;
psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
switch (part->type) {
case PART_EMITTER:
if (ptex.exist < psys_frand(psys, p + 125)) {
@ -558,7 +558,7 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa)
{
ParticleSettings *part = sim->psys->part;
float birth_time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart;
pa->flag &= ~PARS_UNEXIST;
pa->time = part->sta + (part->end - part->sta) * birth_time;
@ -617,7 +617,7 @@ static void free_unexisting_particles(ParticleSimulationData *sim)
if (psys->totunexist) {
int newtotpart = psys->totpart - psys->totunexist;
ParticleData *npa, *newpars;
npa = newpars = MEM_callocN(newtotpart * sizeof(ParticleData), "particles");
for (p=0, pa=psys->particles; p<newtotpart; p++, pa++, npa++) {
@ -705,7 +705,7 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
else
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
/* get possible textural influence */
psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra);
@ -713,7 +713,7 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
/* let's convert: */
/* -location */
mul_m4_v3(ob->obmat, loc);
/* -normal */
mul_mat3_m4_v3(ob->obmat, nor);
normalize_v3(nor);
@ -731,10 +731,10 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
copy_v3_v3(utan, nor);
mul_v3_fl(utan,dot_v3v3(vtan,nor));
sub_v3_v3(vtan, utan);
normalize_v3(vtan);
}
/* -velocity (boids need this even if there's no random velocity) */
if (part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)) {
@ -755,7 +755,7 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
mul_mat3_m4_v3(ob->obmat,r_ave);
normalize_v3(r_ave);
}
/* -rotation */
if (part->randrotfac != 0.0f) {
r_rot[0] = 2.0f * (psys_frand(psys, p + 16) - 0.5f);
@ -792,7 +792,7 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
negate_v3_v3(mat[2], r_vel);
normalize_v3(mat[2]);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
/* apply rotation */
mat3_to_quat_is_ok( q,mat);
copy_qt_qt(state->rot, q);
@ -811,11 +811,11 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
sub_v3_v3v3(vel, loc, state->co);
mul_v3_fl(vel, part->obfac/dtime);
}
/* *emitter normal */
if (part->normfac != 0.f)
madd_v3_v3fl(vel, nor, part->normfac);
/* *emitter tangent */
if (sim->psmd && part->tanfac != 0.f)
madd_v3_v3fl(vel, vtan, part->tanfac);
@ -844,7 +844,7 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
/* *particle */
if (part->partfac != 0.f)
madd_v3_v3fl(vel, p_vel, part->partfac);
mul_v3_v3fl(state->vel, vel, ptex.ivel);
/* -location from emitter */
@ -883,7 +883,7 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
use_global_space = true;
break;
}
/* create rotation quat */
@ -992,7 +992,7 @@ static void evaluate_emitter_anim(Scene *scene, Object *ob, float cfra)
{
if (ob->parent)
evaluate_emitter_anim(scene, ob->parent, cfra);
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
BKE_object_where_is_calc_time(scene, ob, cfra);
@ -1006,7 +1006,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
ParticleTexture ptex;
int p = pa - psys->particles;
part=psys->part;
/* get precise emitter matrix if particle is born */
if (part->type != PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
evaluate_emitter_anim(sim->scene, sim->ob, pa->time);
@ -1083,7 +1083,7 @@ static void reset_all_particles(ParticleSimulationData *sim, float dtime, float
{
ParticleData *pa;
int p, totpart=sim->psys->totpart;
for (p=from, pa=sim->psys->particles+from; p<totpart; p++, pa++)
reset_particle(sim, pa, dtime, cfra);
}
@ -1144,7 +1144,7 @@ static void set_keyed_keys(ParticleSimulationData *sim)
int keyed_flag = 0;
ksim.scene= sim->scene;
/* no proper targets so let's clear and bail out */
if (psys->totkeyed==0) {
free_keyed_keys(psys);
@ -1154,16 +1154,16 @@ static void set_keyed_keys(ParticleSimulationData *sim)
if (totpart && psys->particles->totkey != totkeys) {
free_keyed_keys(psys);
key = MEM_callocN(totpart*totkeys*sizeof(ParticleKey), "Keyed keys");
LOOP_PARTICLES {
pa->keys = key;
pa->totkey = totkeys;
key += totkeys;
}
}
psys->flag &= ~PSYS_KEYED;
@ -1245,17 +1245,17 @@ static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_READ);
need_rebuild = !psys->bvhtree || psys->bvhtree_frame != cfra;
BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
if (need_rebuild) {
LOOP_SHOWN_PARTICLES {
totpart++;
}
BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_WRITE);
BLI_bvhtree_free(psys->bvhtree);
psys->bvhtree = BLI_bvhtree_new(totpart, 0.0, 4, 6);
LOOP_SHOWN_PARTICLES {
if (pa->alive == PARS_ALIVE) {
if (pa->state.time == cfra)
@ -1265,9 +1265,9 @@ static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
}
}
BLI_bvhtree_balance(psys->bvhtree);
psys->bvhtree_frame = cfra;
BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
}
}
@ -1361,7 +1361,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
if (external_acceleration)
add_v3_v3(acceleration, external_acceleration);
/* calculate next state */
add_v3_v3(states[i].vel, impulse);
@ -1494,7 +1494,7 @@ static void sph_springs_modify(ParticleSystem *psys, float dtime)
SPHFluidSettings *fluid = psys->part->fluid;
ParticleData *pa1, *pa2;
ParticleSpring *spring = psys->fluid_springs;
float h, d, Rij[3], rij, Lij;
int i;
@ -1587,9 +1587,9 @@ static void sph_evaluate_func(BVHTree *tree, ParticleSystem **psys, float co[3],
}
else {
BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_READ);
BLI_bvhtree_range_query(psys[i]->bvhtree, co, interaction_radius, callback, pfr);
BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
}
}
@ -1769,7 +1769,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
}
}
}
/* Artificial buoyancy force in negative gravity direction */
if (fluid->buoyancy > 0.f && gravity)
madd_v3_v3fl(force, gravity, fluid->buoyancy * (density-rest_density));
@ -2516,7 +2516,7 @@ static int collision_sphere_to_edges(ParticleCollision *col, float radius, Parti
result->uv[0] = u;
hit = cur;
*t = ct;
}
@ -2541,7 +2541,7 @@ static int collision_sphere_to_verts(ParticleCollision *col, float radius, Parti
cur->inside = 0;
ct = collision_newton_rhapson(col, radius, cur, nr_distance_to_vert);
if (ct >= 0.f && ct < *t) {
*result = *cur;
@ -2688,7 +2688,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
/* get exact velocity right before collision */
madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1);
/* convert collider velocity from 1/framestep to 1/s TODO: here we assume 1 frame step for collision modifier */
mul_v3_fl(pce->vel, col->inv_timestep);
@ -2705,14 +2705,14 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
/* angular <-> linear velocity */
if (dynamic_rotation) {
float vr_tan[3], v1_tan[3], ave[3];
/* linear velocity of particle surface */
cross_v3_v3v3(vr_tan, pce->nor, pa->state.ave);
mul_v3_fl(vr_tan, pa->size);
/* change to coordinates that move with the collision plane */
sub_v3_v3v3(v1_tan, v0_tan, vc_tan);
/* The resulting velocity is a weighted average of particle cm & surface
* velocity. This weight (related to particle's moment of inertia) could
* be made a parameter for angular <-> linear conversion.
@ -2775,7 +2775,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
v0[2] = 0.0f;
}
}
/* re-apply acceleration to final location and velocity */
madd_v3_v3v3fl(pa->state.co, co, v0, dt2);
madd_v3_v3fl(pa->state.co, col->acc, 0.5f*dt2*dt2);
@ -2784,7 +2784,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
/* make sure particle stays on the right side of the surface */
if (!through) {
distance = collision_point_distance_with_normal(co, pce, -1.f, col, nor);
if (distance < col->radius + COLLISION_MIN_DISTANCE)
madd_v3_v3fl(co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
@ -2885,7 +2885,7 @@ static void collision_check(ParticleSimulationData *sim, int p, float dfra, floa
/* 10 iterations to catch multiple collisions */
while (collision_count < PARTICLE_COLLISION_MAX_COLLISIONS) {
if (collision_detect(pa, &col, &hit, sim->colliders)) {
collision_count++;
if (collision_count == PARTICLE_COLLISION_MAX_COLLISIONS)
@ -2989,19 +2989,19 @@ static bool psys_hair_use_simulation(ParticleData *pa, float max_length)
* but this can happen in old files when e.g. cutting hair.
*/
const float min_length = 0.1f * max_length;
HairKey *key;
int k;
if (pa->totkey < 2)
return false;
for (k=1, key=pa->hair+1; k<pa->totkey; k++,key++) {
float length = len_v3v3(key->co, (key-1)->co);
if (length < min_length)
return false;
}
return true;
}
@ -3012,7 +3012,7 @@ static MDeformVert *hair_set_pinning(MDeformVert *dvert, float weight)
dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight");
dvert->totweight = 1;
}
dvert->dw->weight = weight;
dvert++;
}
@ -3034,7 +3034,7 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
float hairmat[4][4];
float max_length;
float hair_radius;
dm = *r_dm;
if (!dm) {
*r_dm = dm = CDDM_new(totpoint, totedge, 0, 0, 0);
@ -3043,12 +3043,12 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
mvert = CDDM_get_verts(dm);
medge = CDDM_get_edges(dm);
dvert = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
hairdata = *r_hairdata;
if (!hairdata) {
*r_hairdata = hairdata = MEM_mallocN(sizeof(ClothHairData) * totpoint, "hair data");
}
/* calculate maximum segment length */
max_length = 0.0f;
LOOP_PARTICLES {
@ -3060,12 +3060,12 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
}
}
}
psys->clmd->sim_parms->vgroup_mass = 1;
/* XXX placeholder for more flexible future hair settings */
hair_radius = part->size;
/* make vgroup for pin roots etc.. */
hair_index = 1;
LOOP_PARTICLES {
@ -3153,7 +3153,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
int totedge;
float (*deformedVerts)[3];
bool realloc_roots;
if (!psys->clmd) {
psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
psys->clmd->sim_parms->goalspring = 0.0f;
@ -3161,7 +3161,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
}
/* count simulated points */
totpoint = 0;
totedge = 0;
@ -3172,7 +3172,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
totpoint += pa->totkey + 1; /* +1 for virtual root point */
}
}
realloc_roots = false; /* whether hair root info array has to be reallocated */
if (psys->hair_in_dm) {
DerivedMesh *dm = psys->hair_in_dm;
@ -3182,36 +3182,36 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
realloc_roots = true;
}
}
if (!psys->hair_in_dm || !psys->clmd->hairdata || realloc_roots) {
if (psys->clmd->hairdata) {
MEM_freeN(psys->clmd->hairdata);
psys->clmd->hairdata = NULL;
}
}
hair_create_input_dm(sim, totpoint, totedge, &psys->hair_in_dm, &psys->clmd->hairdata);
if (psys->hair_out_dm)
psys->hair_out_dm->release(psys->hair_out_dm);
psys->clmd->point_cache = psys->pointcache;
/* for hair sim we replace the internal cloth effector weights temporarily
* to use the particle settings
*/
clmd_effweights = psys->clmd->sim_parms->effector_weights;
psys->clmd->sim_parms->effector_weights = psys->part->effector_weights;
deformedVerts = MEM_mallocN(sizeof(*deformedVerts) * psys->hair_in_dm->getNumVerts(psys->hair_in_dm), "do_hair_dynamics vertexCos");
psys->hair_out_dm = CDDM_copy(psys->hair_in_dm);
psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts);
clothModifier_do(psys->clmd, sim->scene, sim->ob, psys->hair_in_dm, deformedVerts);
CDDM_apply_vert_coords(psys->hair_out_dm, deformedVerts);
MEM_freeN(deformedVerts);
/* restore cloth effector weights */
psys->clmd->sim_parms->effector_weights = clmd_effweights;
}
@ -3260,11 +3260,11 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
PARTICLE_P;
invert_m4_m4(ob->imat, ob->obmat);
psys->lattice_deform_data= psys_create_lattice_deform_data(sim);
if (psys->totpart==0) return;
/* save new keys for elements if needed */
LOOP_PARTICLES {
/* first time alloc */
@ -3417,7 +3417,7 @@ static void dynamics_step_sph_ddr_task_cb_ex(
}
static void dynamics_step_sph_classical_basic_integrate_task_cb_ex(
void *__restrict userdata,
void *__restrict userdata,
const int p,
const ParallelRangeTLS *__restrict UNUSED(tls))
{
@ -3556,7 +3556,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
{
ParticleTarget *pt = psys->targets.first;
psys_update_particle_bvhtree(psys, cfra);
for (; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */
if (pt->ob)
psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra);
@ -3613,7 +3613,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
LOOP_DYNAMIC_PARTICLES {
/* do global forces & effectors */
basic_integrate(sim, p, pa->state.time, cfra);
/* deflection */
if (sim->colliders)
collision_check(sim, p, pa->state.time, cfra);
@ -3627,7 +3627,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
{
LOOP_DYNAMIC_PARTICLES {
bbd.goal_ob = NULL;
boid_brain(&bbd, p, pa);
if (pa->alive != PARS_DYING) {
@ -3761,7 +3761,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
float disp, dietime;
psys_update_effectors(sim);
disp= psys_get_current_display_percentage(psys);
LOOP_PARTICLES {
@ -3811,7 +3811,7 @@ static void particles_fluid_step(
#ifdef WITH_MOD_FLUID
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(sim->ob, eModifierType_Fluidsim);
if ( fluidmd && fluidmd->fss) {
FluidsimSettings *fss= fluidmd->fss;
ParticleSettings *part = psys->part;
@ -3822,7 +3822,7 @@ static void particles_fluid_step(
int p, j, totpart;
int readMask, activeParts = 0, fileParts = 0;
gzFile gzf;
// XXX if (ob==G.obedit) // off...
// return;
@ -3831,7 +3831,7 @@ static void particles_fluid_step(
BLI_path_abs(filename, modifier_path_relbase(bmain, sim->ob));
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
gzf = BLI_gzopen(filename, "rb");
if (!gzf) {
@ -3839,46 +3839,46 @@ static void particles_fluid_step(
// XXX bad level call elbeemDebugOut(debugStrBuffer);
return;
}
gzread(gzf, &totpart, sizeof(totpart));
totpart = (use_render_params) ? totpart:(part->disp*totpart) / 100;
part->totpart= totpart;
part->sta=part->end = 1.0f;
part->lifetime = sim->scene->r.efra + 1;
/* allocate particles */
realloc_particles(sim, part->totpart);
// set up reading mask
readMask = fss->typeFlags;
for (p=0, pa=psys->particles; p<totpart; p++, pa++) {
int ptype=0;
gzread(gzf, &ptype, sizeof( ptype ));
gzread(gzf, &ptype, sizeof( ptype ));
if (ptype & readMask) {
activeParts++;
gzread(gzf, &(pa->size), sizeof(float));
pa->size /= 10.0f;
for (j=0; j<3; j++) {
float wrf;
gzread(gzf, &wrf, sizeof( wrf ));
gzread(gzf, &wrf, sizeof( wrf ));
pa->state.co[j] = wrf;
//fprintf(stderr,"Rj%d ",j);
}
for (j=0; j<3; j++) {
float wrf;
gzread(gzf, &wrf, sizeof( wrf ));
gzread(gzf, &wrf, sizeof( wrf ));
pa->state.vel[j] = wrf;
}
zero_v3(pa->state.ave);
unit_qt(pa->state.rot);
pa->time = 1.f;
pa->dietime = sim->scene->r.efra + 1;
pa->lifetime = sim->scene->r.efra;
@ -3888,18 +3888,18 @@ static void particles_fluid_step(
else {
// skip...
for (j=0; j<2*3+1; j++) {
float wrf; gzread(gzf, &wrf, sizeof( wrf ));
float wrf; gzread(gzf, &wrf, sizeof( wrf ));
}
}
fileParts++;
}
gzclose(gzf);
totpart = psys->totpart = activeParts;
BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d\n", psys->totpart,activeParts,fileParts,readMask);
// bad level call
// XXX elbeemDebugOut(debugStrBuffer);
} // fluid sim particles done
}
#else
@ -3945,7 +3945,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
pid = &ptcacheid;
BKE_ptcache_id_from_particles(pid, sim->ob, psys);
BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL);
/* clear everything on start frame, or when psys needs full reset! */
@ -3954,7 +3954,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
BKE_ptcache_validate(cache, startframe);
cache->flag &= ~PTCACHE_REDO_NEEDED;
}
CLAMP(cache_cfra, startframe, endframe);
}
@ -4063,7 +4063,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
}
}
}
/* 4. only write cache starting from second frame */
if (pid) {
BKE_ptcache_validate(cache, (int)cache_cfra);

@ -133,7 +133,7 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node)
BB vb;
BB_reset(&vb);
if (node->flag & PBVH_Leaf) {
PBVHVertexIter vd;
@ -184,10 +184,10 @@ static int partition_indices(int *prim_indices, int lo, int hi, int axis,
for (;; ) {
for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) ;
for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) ;
if (!(i < j))
return i;
SWAP(int, prim_indices[i], prim_indices[j]);
i++;
}
@ -217,7 +217,7 @@ static int partition_indices_material(PBVH *bvh, int lo, int hi)
for (; grid_materials_match(first, &flagmats[indices[i]]); i++) ;
for (; !grid_materials_match(first, &flagmats[indices[j]]); j--) ;
}
if (!(i < j))
return i;
@ -389,7 +389,7 @@ static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc,
/* Still need vb for searches */
update_vb(bvh, &bvh->nodes[node_index], prim_bbc, offset, count);
if (bvh->looptri)
build_mesh_leaf_node(bvh, bvh->nodes + node_index);
else {
@ -1293,7 +1293,7 @@ void BKE_pbvh_get_grid_updates(PBVH *bvh, bool clear, void ***r_gridfaces, int *
}
pbvh_iter_end(&iter);
const int tot = BLI_gset_len(face_set);
if (tot == 0) {
*r_totface = 0;
@ -1396,7 +1396,7 @@ void BKE_pbvh_node_mark_normals_update(PBVHNode *node)
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden)
{
BLI_assert(node->flag & PBVH_Leaf);
if (fully_hidden)
node->flag |= PBVH_FullyHidden;
else
@ -1421,7 +1421,7 @@ void BKE_pbvh_node_num_verts(
int *r_uniquevert, int *r_totvert)
{
int tot;
switch (bvh->type) {
case PBVH_GRIDS:
tot = node->totprim * bvh->gridkey.grid_area;
@ -2059,7 +2059,7 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3],
{
float vmin[3], vmax[3];
PlaneAABBIsect ret = ISECT_INSIDE;
for (int i = 0; i < 4; ++i) {
for (int axis = 0; axis < 3; ++axis) {
if (planes[i][axis] > 0) {
@ -2071,7 +2071,7 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3],
vmax[axis] = bb_min[axis];
}
}
if (dot_v3v3(planes[i], vmin) + planes[i][3] > 0)
return ISECT_OUTSIDE;
else if (dot_v3v3(planes[i], vmax) + planes[i][3] >= 0)
@ -2087,7 +2087,7 @@ bool BKE_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data)
/* BKE_pbvh_node_get_BB */
bb_min = node->vb.bmin;
bb_max = node->vb.bmax;
return test_planes_aabb(bb_min, bb_max, data) != ISECT_OUTSIDE;
}
@ -2097,7 +2097,7 @@ bool BKE_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data)
/* BKE_pbvh_node_get_BB */
bb_min = node->vb.bmin;
bb_max = node->vb.bmax;
return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE;
}
@ -2322,22 +2322,22 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
const int *vert_indices;
int *grid_indices;
int totgrid, gridsize, uniq_verts, totvert;
vi->grid = NULL;
vi->no = NULL;
vi->fno = NULL;
vi->mvert = NULL;
BKE_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids);
BKE_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert);
BKE_pbvh_node_get_verts(bvh, node, &vert_indices, &verts);
vi->key = &bvh->gridkey;
vi->grids = grids;
vi->grid_indices = grid_indices;
vi->totgrid = (grids) ? totgrid : 1;
vi->gridsize = gridsize;
if (mode == PBVH_ITER_ALL)
vi->totvert = totvert;
else

@ -121,7 +121,7 @@
/* could be made into a pointcache option */
#define DURIAN_POINTCACHE_LIB_OK 1
static int ptcache_data_size[] = {
static int ptcache_data_size[] = {
sizeof(unsigned int), // BPHYS_DATA_INDEX
3 * sizeof(float), // BPHYS_DATA_LOCATION
3 * sizeof(float), // BPHYS_DATA_VELOCITY
@ -151,7 +151,7 @@ static int ptcache_basic_header_read(PTCacheFile *pf)
/* Custom functions should read these basic elements too! */
if (!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
error = 1;
if (!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
error = 1;
@ -162,7 +162,7 @@ static int ptcache_basic_header_write(PTCacheFile *pf)
/* Custom functions should write these basic elements too! */
if (!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
return 0;
if (!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
return 0;
@ -240,7 +240,7 @@ void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, flo
{
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, index, key->co);
PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel);
/* no rotation info, so make something nice up */
if (data[BPHYS_DATA_ROTATION]==NULL) {
vec_to_quat(key->rot, key->vel, OB_NEGX, OB_POSZ);
@ -316,7 +316,7 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
if (data[BPHYS_DATA_SIZE]) {
PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size);
}
if (data[BPHYS_DATA_TIMES]) {
float times[3];
PTCACHE_DATA_TO(data, BPHYS_DATA_TIMES, 0, &times);
@ -494,7 +494,7 @@ static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUS
ClothModifierData *clmd= cloth_v;
Cloth *cloth= clmd->clothObject;
ClothVertex *vert = cloth->verts + index;
if (old_data) {
memcpy(vert->x, data, 3 * sizeof(float));
memcpy(vert->xconst, data + 3, 3 * sizeof(float));
@ -560,7 +560,7 @@ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if (sds->fluid) {
return sds->base_res[0]*sds->base_res[1]*sds->base_res[2];
}
@ -577,7 +577,7 @@ static void ptcache_smoke_error(void *smoke_v, const char *message)
#define SMOKE_CACHE_VERSION "1.04"
static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
{
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
int ret = 0;
@ -589,7 +589,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
ptcache_file_write(pf, &sds->active_fields, 1, sizeof(int));
ptcache_file_write(pf, &sds->res, 3, sizeof(int));
ptcache_file_write(pf, &sds->dx, 1, sizeof(float));
if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
@ -636,7 +636,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
ptcache_file_write(pf, &sds->active_color, 3, sizeof(float));
MEM_freeN(out);
ret = 1;
}
@ -679,7 +679,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
ptcache_file_compressed_write(pf, (unsigned char *)tcv, in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, out, mode);
MEM_freeN(out);
ret = 1;
}
@ -691,7 +691,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if (sds->fluid) {
const size_t res = sds->res[0] * sds->res[1] * sds->res[2];
const unsigned int out_len = (unsigned int)res * sizeof(float);
@ -705,7 +705,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v)
sds->active_color[0] = 0.7f;
sds->active_color[1] = 0.7f;
sds->active_color[2] = 0.7f;
smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, NULL, &heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len);
@ -758,7 +758,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v)
}
}
return 1;
return 1;
}
static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
@ -814,13 +814,13 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1);
}
}
if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
unsigned char *obstacles;
unsigned int out_len = (unsigned int)res * sizeof(float);
smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len);
@ -1195,7 +1195,7 @@ static void ptcache_dynamicpaint_error(void *UNUSED(sd), const char *UNUSED(mess
#define DPAINT_CACHE_VERSION "1.01"
static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
{
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v;
int cache_compress = 1;
@ -1237,7 +1237,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v;
char version[4];
/* version header */
ptcache_file_read(pf, version, 1, sizeof(char) * 4);
if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) {
@ -1282,13 +1282,13 @@ static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int UNUS
{
RigidBodyWorld *rbw = rb_v;
Object *ob = NULL;
if (rbw->objects)
ob = rbw->objects[index];
if (ob && ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
if (rbo->type == RBO_TYPE_ACTIVE) {
#ifdef WITH_BULLET
RB_body_get_position(rbo->physics_object, rbo->pos);
@ -1305,15 +1305,15 @@ static void ptcache_rigidbody_read(int index, void *rb_v, void **data, float UNU
{
RigidBodyWorld *rbw = rb_v;
Object *ob = NULL;
if (rbw->objects)
ob = rbw->objects[index];
if (ob && ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
if (rbo->type == RBO_TYPE_ACTIVE) {
if (old_data) {
memcpy(rbo->pos, data, 3 * sizeof(float));
memcpy(rbo->orn, data + 3, 4 * sizeof(float));
@ -1329,23 +1329,23 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
{
RigidBodyWorld *rbw = rb_v;
Object *ob = NULL;
if (rbw->objects)
ob = rbw->objects[index];
if (ob && ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
if (rbo->type == RBO_TYPE_ACTIVE) {
ParticleKey keys[4];
ParticleKey result;
float dfra;
memset(keys, 0, sizeof(keys));
copy_v3_v3(keys[1].co, rbo->pos);
copy_qt_qt(keys[1].rot, rbo->orn);
if (old_data) {
memcpy(keys[2].co, data, 3 * sizeof(float));
memcpy(keys[2].rot, data + 3, 4 * sizeof(float));
@ -1353,13 +1353,13 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
else {
BKE_ptcache_make_particle_key(&keys[2], 0, data, cfra2);
}
dfra = cfra2 - cfra1;
/* note: keys[0] and keys[3] unused for type < 1 (crappy) */
psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &result, true);
interp_qt_qtqt(result.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
copy_v3_v3(rbo->pos, result.co);
copy_qt_qt(rbo->orn, result.rot);
}
@ -1368,7 +1368,7 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
static int ptcache_rigidbody_totpoint(void *rb_v, int UNUSED(cfra))
{
RigidBodyWorld *rbw = rb_v;
return rbw->numbodies;
}
@ -1525,7 +1525,7 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
pid->ob= ob;
pid->calldata= smd;
pid->type= PTCACHE_TYPE_SMOKE_DOMAIN;
pid->stack_index= sds->point_cache[0]->index;
@ -1609,9 +1609,9 @@ void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSu
void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *rbw)
{
memset(pid, 0, sizeof(PTCacheID));
pid->ob= ob;
pid->calldata= rbw;
pid->type= PTCACHE_TYPE_RIGIDBODY;
@ -1620,29 +1620,29 @@ void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *r
pid->ptcaches= &rbw->ptcaches;
pid->totpoint= pid->totwrite= ptcache_rigidbody_totpoint;
pid->error = ptcache_rigidbody_error;
pid->write_point = ptcache_rigidbody_write;
pid->read_point = ptcache_rigidbody_read;
pid->interpolate_point = ptcache_rigidbody_interpolate;
pid->write_stream = NULL;
pid->read_stream = NULL;
pid->write_openvdb_stream = NULL;
pid->read_openvdb_stream = NULL;
pid->write_extra_data = NULL;
pid->read_extra_data = NULL;
pid->interpolate_extra_data = NULL;
pid->write_header = ptcache_basic_header_write;
pid->read_header = ptcache_basic_header_read;
pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_ROTATION);
pid->info_types= 0;
pid->stack_index = pid->cache->index;
pid->default_step = 1;
pid->max_step = 1;
pid->file_type = PTCACHE_FILE_PTCACHE;
@ -1665,7 +1665,7 @@ void BKE_ptcache_ids_from_object(Main *bmain, ListBase *lb, Object *ob, Scene *s
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
if (psys->part==NULL)
continue;
/* check to make sure point cache is actually used by the particles */
if (ELEM(psys->part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
continue;
@ -1673,7 +1673,7 @@ void BKE_ptcache_ids_from_object(Main *bmain, ListBase *lb, Object *ob, Scene *s
/* hair needs to be included in id-list for cache edit mode to work */
/* if (psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DYNAMICS)==0) */
/* continue; */
if (psys->part->type == PART_FLUID)
continue;
@ -1709,7 +1709,7 @@ void BKE_ptcache_ids_from_object(Main *bmain, ListBase *lb, Object *ob, Scene *s
}
}
}
if (scene && ob->rigidbody_object && scene->rigidbody_world) {
pid = MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_rigidbody(pid, ob, scene->rigidbody_world);
@ -1799,20 +1799,20 @@ static int ptcache_path(PTCacheID *pid, char *filename)
BLI_split_file_part(blendfilename, file, sizeof(file));
i = strlen(file);
/* remove .blend */
if (i > 6)
file[i-6] = '\0';
BLI_snprintf(filename, MAX_PTCACHE_PATH, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */
BLI_path_abs(filename, blendfilename);
return BLI_add_slash(filename); /* new strlen() */
}
/* use the temp path. this is weak but better then not using point cache at all */
/* temporary directory is assumed to exist and ALWAYS has a trailing slash */
BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH, BKE_tempdir_session());
return BLI_add_slash(filename); /* new strlen() */
}
@ -1823,9 +1823,9 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
char *newname;
filename[0] = '\0';
newname = filename;
if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return 0; /* save blend file before using disk pointcache */
/* start with temp dir */
if (do_path) {
len = ptcache_path(pid, filename);
@ -1841,8 +1841,8 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
}
}
else {
int temp = (int)strlen(pid->cache->name);
strcpy(newname, pid->cache->name);
int temp = (int)strlen(pid->cache->name);
strcpy(newname, pid->cache->name);
newname+=temp;
len += temp;
}
@ -1864,7 +1864,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
}
len += 16;
}
return len; /* make sure the above string is always 16 chars */
}
@ -1881,7 +1881,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
return NULL;
#endif
if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return NULL; /* save blend file before using disk pointcache */
ptcache_filename(pid, filename, cfra, 1, 1);
if (mode==PTCACHE_FILE_READ) {
@ -1975,7 +1975,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
out_len= LZO_OUT_LEN(in_len);
if (mode == 1) {
LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
if (!(r == LZO_E_OK) || (out_len >= in_len))
compressed = 0;
@ -1985,7 +1985,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
#endif
#ifdef WITH_LZMA
if (mode == 2) {
r = LzmaCompress(out, &out_len, in, in_len, //assume sizeof(char)==1....
props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2);
@ -1995,7 +1995,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
compressed = 2;
}
#endif
ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char));
if (compressed) {
unsigned int size = out_len;
@ -2031,18 +2031,18 @@ static int ptcache_file_data_read(PTCacheFile *pf)
if ((pf->data_types & (1<<i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i]))
return 0;
}
return 1;
}
static int ptcache_file_data_write(PTCacheFile *pf)
{
{
int i;
for (i=0; i<BPHYS_TOT_DATA; i++) {
if ((pf->data_types & (1<<i)) && !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i]))
return 0;
}
return 1;
}
static int ptcache_file_header_begin_read(PTCacheFile *pf)
@ -2050,12 +2050,12 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf)
unsigned int typeflag=0;
int error=0;
char bphysics[8];
pf->data_types = 0;
if (fread(bphysics, sizeof(char), 8, pf->fp) != 8)
error = 1;
if (!error && !STREQLEN(bphysics, "BPHYSICS", 8))
error = 1;
@ -2064,7 +2064,7 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf)
pf->type = (typeflag & PTCACHE_TYPEFLAG_TYPEMASK);
pf->flag = (typeflag & PTCACHE_TYPEFLAG_FLAGMASK);
/* if there was an error set file as it was */
if (error)
fseek(pf->fp, 0, SEEK_SET);
@ -2075,13 +2075,13 @@ static int ptcache_file_header_begin_write(PTCacheFile *pf)
{
const char *bphysics = "BPHYSICS";
unsigned int typeflag = pf->type + pf->flag;
if (fwrite(bphysics, sizeof(char), 8, pf->fp) != 8)
return 0;
if (!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp))
return 0;
return 1;
}
@ -2362,14 +2362,14 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
if (error && G.debug & G_DEBUG)
printf("Error reading from disk cache\n");
return pm;
}
static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
{
PTCacheFile *pf = NULL;
unsigned int i, error = 0;
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame);
pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame);
@ -2384,10 +2384,10 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
pf->totpoint = pm->totpoint;
pf->type = pid->type;
pf->flag = 0;
if (pm->extradata.first)
pf->flag |= PTCACHE_TYPEFLAG_EXTRADATA;
if (pid->cache->compression)
pf->flag |= PTCACHE_TYPEFLAG_COMPRESS;
@ -2443,7 +2443,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
}
ptcache_file_close(pf);
if (error && G.debug & G_DEBUG)
printf("Error writing to disk cache\n");
@ -2492,7 +2492,7 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra)
}
ptcache_file_close(pf);
return error == 0;
}
@ -2537,7 +2537,7 @@ static int ptcache_read(PTCacheID *pid, int cfra)
}
else {
pm = pid->cache->mem_cache.first;
while (pm && pm->frame != cfra)
pm = pm->next;
}
@ -2562,7 +2562,7 @@ static int ptcache_read(PTCacheID *pid, int cfra)
index = pm->cur[BPHYS_DATA_INDEX];
pid->read_point(*index, pid->calldata, pm->cur, (float)pm->frame, NULL);
BKE_ptcache_mem_pointers_incr(pm);
}
@ -2591,7 +2591,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
}
else {
pm = pid->cache->mem_cache.first;
while (pm && pm->frame != cfra2)
pm = pm->next;
}
@ -2729,7 +2729,7 @@ static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint)
{
PTCacheFile *pf = NULL;
int error = 0;
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, cfra);
pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra);
@ -2801,7 +2801,7 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra))
fra--;
pm2 = ptcache_disk_frame_to_mem(pid, fra);
}
else
@ -2949,7 +2949,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
unsigned int sta, end;
/* mode is same as fopen's modes */
DIR *dir;
DIR *dir;
struct dirent *de;
char path[MAX_PTCACHE_PATH];
char filename[MAX_PTCACHE_FILE];
@ -2982,11 +2982,11 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
case PTCACHE_CLEAR_AFTER:
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
ptcache_path(pid, path);
dir = opendir(path);
if (dir==NULL)
return;
len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */
/* append underscore terminator to ensure we don't match similar names
* from objects whose names start with the same prefix
@ -2995,9 +2995,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
BLI_strncpy(filename + len, "_", sizeof(filename) - 2 - len);
len += 1;
}
BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
@ -3014,7 +3014,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
if ((mode == PTCACHE_CLEAR_BEFORE && frame < cfra) ||
(mode == PTCACHE_CLEAR_AFTER && frame > cfra))
{
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, false, false);
if (pid->cache->cached_frames && frame >=sta && frame <= end)
@ -3043,7 +3043,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
BLI_freelistN(&pid->cache->mem_cache);
if (pid->cache->cached_frames)
if (pid->cache->cached_frames)
memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
}
else {
@ -3065,7 +3065,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
}
break;
case PTCACHE_CLEAR_FRAME:
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
if (BKE_ptcache_id_exist(pid, cfra)) {
@ -3102,10 +3102,10 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
if (pid->cache->cached_frames && pid->cache->cached_frames[cfra-pid->cache->startframe]==0)
return 0;
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
char filename[MAX_PTCACHE_FILE];
ptcache_filename(pid, filename, cfra, 1, 1);
return BLI_exists(filename);
@ -3145,7 +3145,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
if (timescale) {
time= BKE_scene_frame_get(scene);
nexttime = BKE_scene_frame_get_from_ctime(scene, CFRA + 1.0f);
*timescale= MAX2(nexttime - time, 0.0f);
}
@ -3183,7 +3183,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
/* mode is same as fopen's modes */
DIR *dir;
DIR *dir;
struct dirent *de;
char path[MAX_PTCACHE_PATH];
char filename[MAX_PTCACHE_FILE];
@ -3191,9 +3191,9 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
unsigned int len; /* store the length of the string */
ptcache_path(pid, path);
len = ptcache_filename(pid, filename, (int)cfra, 0, 0); /* no path */
dir = opendir(path);
if (dir==NULL)
return;
@ -3201,7 +3201,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
const char *fext = ptcache_file_extension(pid);
BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
@ -3309,7 +3309,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
/* particles or cloth in that case -jahka */
else if (psys->clmd) {
BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd);
if (mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
if (mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
else
skip = 1;
@ -3366,19 +3366,19 @@ void BKE_ptcache_remove(void)
char path[MAX_PTCACHE_PATH];
char path_full[MAX_PTCACHE_PATH];
int rmdir = 1;
ptcache_path(NULL, path);
if (BLI_exists(path)) {
/* The pointcache dir exists? - remove all pointcache */
DIR *dir;
DIR *dir;
struct dirent *de;
dir = opendir(path);
if (dir==NULL)
return;
while ((de = readdir(dir)) != NULL) {
if (FILENAME_IS_CURRPAR(de->d_name)) {
/* do nothing */
@ -3397,7 +3397,7 @@ void BKE_ptcache_remove(void)
else {
rmdir = 0; /* path dosnt exist */
}
if (rmdir) {
BLI_delete(path, true, false);
}
@ -3507,7 +3507,7 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, const ListBase *ptcach
return ptcaches_new->first;
}
/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on
/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on
* every user action changing stuff, and then it runs a complete bake??? (ton) */
/* Baking */
@ -3553,7 +3553,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
int startframe = MAXFRAME, endframe = baker->anim_init ? scene->r.sfra : CFRA;
int bake = baker->bake;
int render = baker->render;
G.is_break = false;
/* set caches to baking mode and figure out start frame */
@ -3745,7 +3745,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
scene->r.framelen = frameleno;
CFRA = cfrao;
if (bake) { /* already on cfra unless baking */
BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay);
}
@ -3827,7 +3827,7 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
cache->flag ^= PTCACHE_DISK_CACHE;
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
cache->flag ^= PTCACHE_DISK_CACHE;
cache->last_exact = last_exact;
BKE_ptcache_id_time(pid, NULL, 0.0f, NULL, NULL, NULL);
@ -3847,7 +3847,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
char old_name[80];
int len; /* store the length of the string */
/* mode is same as fopen's modes */
DIR *dir;
DIR *dir;
struct dirent *de;
char path[MAX_PTCACHE_PATH];
char old_filename[MAX_PTCACHE_FILE];
@ -3906,7 +3906,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
int end = -1;
/* mode is same as fopen's modes */
DIR *dir;
DIR *dir;
struct dirent *de;
char path[MAX_PTCACHE_PATH];
char filename[MAX_PTCACHE_FILE];
@ -3916,9 +3916,9 @@ void BKE_ptcache_load_external(PTCacheID *pid)
return;
ptcache_path(pid, path);
len = ptcache_filename(pid, filename, 1, 0, 0); /* no path */
dir = opendir(path);
if (dir==NULL)
return;
@ -3929,7 +3929,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
BLI_snprintf(ext, sizeof(ext), "_%02d%s", cache->index, fext);
else
BLI_strncpy(ext, fext, sizeof(ext));
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
@ -3985,7 +3985,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
if (pf) {
while (ptcache_file_read(pf, old_data, 1, elemsize))
cache->totpoint++;
ptcache_file_close(pf);
}
}
@ -4063,7 +4063,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
}
bytes += sizeof(PTCacheMem);
totframes++;
}

@ -50,10 +50,10 @@
void BKE_bproperty_free(bProperty *prop)
{
if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
MEM_freeN(prop);
}
void BKE_bproperty_free_list(ListBase *lb)
@ -68,7 +68,7 @@ void BKE_bproperty_free_list(ListBase *lb)
bProperty *BKE_bproperty_copy(const bProperty *prop)
{
bProperty *propn;
propn = MEM_dupallocN(prop);
if (prop->poin && prop->poin != &prop->data) {
propn->poin = MEM_dupallocN(prop->poin);
@ -90,19 +90,19 @@ void BKE_bproperty_copy_list(ListBase *lbn, const ListBase *lbo)
BLI_addtail(lbn, propn);
prop = prop->next;
}
}
void BKE_bproperty_init(bProperty *prop)
{
/* also use when property changes type */
if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
prop->poin = NULL;
prop->data = 0;
switch (prop->type) {
case GPROP_BOOL:
case GPROP_INT:
@ -125,7 +125,7 @@ bProperty *BKE_bproperty_new(int type)
prop->type = type;
BKE_bproperty_init(prop);
strcpy(prop->name, "prop");
return prop;
@ -156,7 +156,7 @@ int BKE_bproperty_cmp(bProperty *prop, const char *str)
{
// extern int Gdfra; /* sector.c */
float fvalue, ftest;
switch (prop->type) {
case GPROP_BOOL:
if (BLI_strcasecmp(str, "true") == 0) {
@ -168,7 +168,7 @@ int BKE_bproperty_cmp(bProperty *prop, const char *str)
else return 1;
}
/* no break, do GPROP_int too! */
case GPROP_INT:
return prop->data - atoi(str);
@ -185,7 +185,7 @@ int BKE_bproperty_cmp(bProperty *prop, const char *str)
case GPROP_STRING:
return strcmp(prop->poin, str);
}
return 0;
}
#endif
@ -211,7 +211,7 @@ void BKE_bproperty_set(bProperty *prop, const char *str)
strcpy(prop->poin, str); /* TODO - check size? */
break;
}
}
void BKE_bproperty_add(bProperty *prop, const char *str)

@ -270,10 +270,10 @@ char *BKE_reports_string(ReportList *reports, ReportType level)
void BKE_reports_print(ReportList *reports, ReportType level)
{
char *cstring = BKE_reports_string(reports, level);
if (cstring == NULL)
return;
puts(cstring);
fflush(stdout);
MEM_freeN(cstring);
@ -282,12 +282,12 @@ void BKE_reports_print(ReportList *reports, ReportType level)
Report *BKE_reports_last_displayable(ReportList *reports)
{
Report *report;
for (report = reports->list.last; report; report = report->prev) {
if (ELEM(report->type, RPT_ERROR, RPT_WARNING, RPT_INFO))
return report;
}
return NULL;
}

@ -286,7 +286,7 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
int totvert;
int tottri;
const MLoop *mloop;
dm = rigidbody_get_mesh(ob);
/* ensure mesh validity, then grab data */
@ -309,7 +309,7 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
/* init mesh data for collision shape */
mdata = RB_trimesh_data_new(tottri, totvert);
RB_trimesh_add_vertices(mdata, (float *)mvert, totvert, sizeof(MVert));
/* loop over all faces, adding them as triangles to the collision shape
@ -328,7 +328,7 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
RB_trimesh_add_triangle_indices(mdata, i, UNPACK3(vtri));
}
}
RB_trimesh_finish(mdata);
/* construct collision shape
@ -519,21 +519,21 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
const MLoopTri *lt = NULL;
int totvert, tottri = 0;
const MLoop *mloop = NULL;
/* ensure mesh validity, then grab data */
if (dm == NULL)
return;
mvert = dm->getVertArray(dm);
totvert = dm->getNumVerts(dm);
lt = dm->getLoopTriArray(dm);
tottri = dm->getNumLoopTri(dm);
mloop = dm->getLoopArray(dm);
if (totvert > 0 && tottri > 0) {
BKE_mesh_calc_volume(mvert, totvert, lt, tottri, mloop, &volume, NULL);
}
/* cleanup temp data */
if (ob->rigidbody_object->mesh_source == RBO_MESH_BASE) {
dm->release(dm);
@ -602,21 +602,21 @@ void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3])
const MLoopTri *looptri;
int totvert, tottri;
const MLoop *mloop;
/* ensure mesh validity, then grab data */
if (dm == NULL)
return;
mvert = dm->getVertArray(dm);
totvert = dm->getNumVerts(dm);
looptri = dm->getLoopTriArray(dm);
tottri = dm->getNumLoopTri(dm);
mloop = dm->getLoopArray(dm);
if (totvert > 0 && tottri > 0) {
BKE_mesh_calc_volume(mvert, totvert, looptri, tottri, mloop, NULL, r_center);
}
/* cleanup temp data */
if (ob->rigidbody_object->mesh_source == RBO_MESH_BASE) {
dm->release(dm);
@ -1332,7 +1332,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
/* XXX TODO For rebuild: remove all constraints first.
* Otherwise we can end up deleting objects that are still
* referenced by constraints, corrupting bullet's internal list.
*
*
* Memory management needs redesign here, this is just a dirty workaround.
*/
if (rebuild && rbw->constraints) {
@ -1394,7 +1394,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
rigidbody_update_sim_ob(scene, rbw, ob, rbo);
}
}
/* update constraints */
if (rbw->constraints == NULL) /* no constraints, move on */
return;

@ -60,13 +60,13 @@ void free_sensor(bSensor *sens)
if (sens->links) MEM_freeN(sens->links);
if (sens->data) MEM_freeN(sens->data);
MEM_freeN(sens);
}
void free_sensors(ListBase *lb)
{
bSensor *sens;
while ((sens = BLI_pophead(lb))) {
free_sensor(sens);
}
@ -75,7 +75,7 @@ void free_sensors(ListBase *lb)
bSensor *copy_sensor(bSensor *sens, const int UNUSED(flag))
{
bSensor *sensn;
sensn= MEM_dupallocN(sens);
sensn->flag |= SENS_NEW;
if (sens->data) {
@ -83,14 +83,14 @@ bSensor *copy_sensor(bSensor *sens, const int UNUSED(flag))
}
if (sens->links) sensn->links= MEM_dupallocN(sens->links);
return sensn;
}
void copy_sensors(ListBase *lbn, const ListBase *lbo, const int flag)
{
bSensor *sens, *sensn;
lbn->first= lbn->last= NULL;
sens= lbo->first;
while (sens) {
@ -107,11 +107,11 @@ void init_sensor(bSensor *sens)
bMouseSensor *ms;
bJoystickSensor *js;
bRaySensor *rs;
if (sens->data) MEM_freeN(sens->data);
sens->data= NULL;
sens->pulse = 0;
switch (sens->type) {
case SENS_ALWAYS:
sens->pulse = 0;
@ -177,12 +177,12 @@ bSensor *new_sensor(int type)
sens= MEM_callocN(sizeof(bSensor), "Sensor");
sens->type= type;
sens->flag= SENS_SHOW;
init_sensor(sens);
strcpy(sens->name, "sensor");
// XXX make_unique_prop_names(sens->name);
return sens;
}
@ -192,7 +192,7 @@ void unlink_controller(bController *cont)
{
bSensor *sens;
Object *ob;
/* check for controller pointers in sensors */
ob= G.main->object.first;
while (ob) {
@ -208,7 +208,7 @@ void unlink_controller(bController *cont)
void unlink_controllers(ListBase *lb)
{
bController *cont;
for (cont= lb->first; cont; cont= cont->next)
unlink_controller(cont);
}
@ -220,13 +220,13 @@ void free_controller(bController *cont)
/* the controller itself */
if (cont->data) MEM_freeN(cont->data);
MEM_freeN(cont);
}
void free_controllers(ListBase *lb)
{
bController *cont;
while ((cont = BLI_pophead(lb))) {
if (cont->slinks)
MEM_freeN(cont->slinks);
@ -237,7 +237,7 @@ void free_controllers(ListBase *lb)
bController *copy_controller(bController *cont, const int UNUSED(flag))
{
bController *contn;
cont->mynew=contn= MEM_dupallocN(cont);
contn->flag |= CONT_NEW;
if (cont->data) {
@ -247,14 +247,14 @@ bController *copy_controller(bController *cont, const int UNUSED(flag))
if (cont->links) contn->links= MEM_dupallocN(cont->links);
contn->slinks= NULL;
contn->totslinks= 0;
return contn;
}
void copy_controllers(ListBase *lbn, const ListBase *lbo, const int flag)
{
bController *cont, *contn;
lbn->first= lbn->last= NULL;
cont= lbo->first;
while (cont) {
@ -267,10 +267,10 @@ void copy_controllers(ListBase *lbn, const ListBase *lbo, const int flag)
void init_controller(bController *cont)
{
/* also use when controller changes type, leave actuators... */
if (cont->data) MEM_freeN(cont->data);
cont->data= NULL;
switch (cont->type) {
case CONT_EXPRESSION:
cont->data= MEM_callocN(sizeof(bExpressionCont), "expcont");
@ -290,10 +290,10 @@ bController *new_controller(int type)
cont->flag= CONT_SHOW;
init_controller(cont);
strcpy(cont->name, "cont");
// XXX make_unique_prop_names(cont->name);
return cont;
}
@ -303,7 +303,7 @@ void unlink_actuator(bActuator *act)
{
bController *cont;
Object *ob;
/* check for actuator pointers in controllers */
ob= G.main->object.first;
while (ob) {
@ -319,7 +319,7 @@ void unlink_actuator(bActuator *act)
void unlink_actuators(ListBase *lb)
{
bActuator *act;
for (act= lb->first; act; act= act->next)
unlink_actuator(act);
}
@ -353,7 +353,7 @@ void free_actuator(bActuator *act)
void free_actuators(ListBase *lb)
{
bActuator *act;
while ((act = BLI_pophead(lb))) {
free_actuator(act);
}
@ -362,13 +362,13 @@ void free_actuators(ListBase *lb)
bActuator *copy_actuator(bActuator *act, const int flag)
{
bActuator *actn;
act->mynew=actn= MEM_dupallocN(act);
actn->flag |= ACT_NEW;
if (act->data) {
actn->data= MEM_dupallocN(act->data);
}
switch (act->type) {
case ACT_ACTION:
case ACT_SHAPEACTION:
@ -394,7 +394,7 @@ bActuator *copy_actuator(bActuator *act, const int flag)
void copy_actuators(ListBase *lbn, const ListBase *lbo, const int flag)
{
bActuator *act, *actn;
lbn->first= lbn->last= NULL;
act= lbo->first;
while (act) {
@ -415,10 +415,10 @@ void init_actuator(bActuator *act)
bArmatureActuator *arma;
bMouseActuator *ma;
bEditObjectActuator *eoa;
if (act->data) MEM_freeN(act->data);
act->data= NULL;
switch (act->type) {
case ACT_ACTION:
case ACT_SHAPEACTION:
@ -523,12 +523,12 @@ bActuator *new_actuator(int type)
act= MEM_callocN(sizeof(bActuator), "Actuator");
act->type= type;
act->flag= ACT_SHOW;
init_actuator(act);
strcpy(act->name, "act");
// XXX make_unique_prop_names(act->name);
return act;
}
@ -538,7 +538,7 @@ void clear_sca_new_poins_ob(Object *ob)
bSensor *sens;
bController *cont;
bActuator *act;
sens= ob->sensors.first;
while (sens) {
sens->flag &= ~SENS_NEW;
@ -561,7 +561,7 @@ void clear_sca_new_poins_ob(Object *ob)
void clear_sca_new_poins(void)
{
Object *ob;
ob= G.main->object.first;
while (ob) {
clear_sca_new_poins_ob(ob);
@ -575,7 +575,7 @@ void set_sca_new_poins_ob(Object *ob)
bController *cont;
bActuator *act;
int a;
sens= ob->sensors.first;
while (sens) {
if (sens->flag & SENS_NEW) {
@ -597,8 +597,8 @@ void set_sca_new_poins_ob(Object *ob)
}
cont= cont->next;
}
act= ob->actuators.first;
while (act) {
if (act->flag & ACT_NEW) {
@ -649,7 +649,7 @@ void set_sca_new_poins_ob(Object *ob)
void set_sca_new_poins(void)
{
Object *ob;
ob= G.main->object.first;
while (ob) {
set_sca_new_poins_ob(ob);
@ -872,7 +872,7 @@ void sca_move_controller(bController *cont_to_move, Object *ob, int move_up)
/* locate the controller that has the same state mask but is earlier in the list */
tmp = cont->prev;
while (tmp) {
if (tmp->state_mask & cont->state_mask)
if (tmp->state_mask & cont->state_mask)
break;
tmp = tmp->prev;
}
@ -886,7 +886,7 @@ void sca_move_controller(bController *cont_to_move, Object *ob, int move_up)
else if (val == 2 && cont->next) {
tmp = cont->next;
while (tmp) {
if (tmp->state_mask & cont->state_mask)
if (tmp->state_mask & cont->state_mask)
break;
tmp = tmp->next;
}
@ -939,7 +939,7 @@ void sca_move_actuator(bActuator *act_to_move, Object *ob, int move_up)
void link_logicbricks(void **poin, void ***ppoin, short *tot, short size)
{
void **old_links= NULL;
int ibrick;
/* check if the bricks are already linked */
@ -953,7 +953,7 @@ void link_logicbricks(void **poin, void ***ppoin, short *tot, short size)
(*tot) ++;
*ppoin = MEM_callocN((*tot)*size, "new link");
for (ibrick=0; ibrick < *(tot) - 1; ibrick++) {
(*ppoin)[ibrick] = old_links[ibrick];
}

@ -131,10 +131,10 @@ static void remove_sequencer_fcurves(Scene *sce)
if (adt && adt->action) {
FCurve *fcu, *nextfcu;
for (fcu = adt->action->curves.first; fcu; fcu = nextfcu) {
nextfcu = fcu->next;
if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
action_groups_remove_channel(adt->action, fcu);
free_fcurve(fcu);
@ -499,14 +499,14 @@ void BKE_scene_free(Scene *sce)
BLI_freelistN(&sce->transform_spaces);
BLI_freelistN(&sce->r.layers);
BLI_freelistN(&sce->r.views);
BKE_toolsettings_free(sce->toolsettings);
sce->toolsettings = NULL;
DAG_scene_free(sce);
if (sce->depsgraph)
DEG_graph_free(sce->depsgraph);
MEM_SAFE_FREE(sce->stats);
MEM_SAFE_FREE(sce->fps_info);
@ -529,7 +529,7 @@ void BKE_scene_init(Scene *sce)
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(sce, id));
sce->lay = sce->layact = 1;
sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE;
sce->r.cfra = 1;
sce->r.sfra = 1;
@ -569,7 +569,7 @@ void BKE_scene_init(Scene *sce)
sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT;
sce->r.gauss = 1.0;
/* deprecated but keep for upwards compat */
sce->r.postgamma = 1.0;
sce->r.posthue = 0.0;
@ -626,7 +626,7 @@ void BKE_scene_init(Scene *sce)
sce->r.border.ymax = 1.0f;
sce->r.preview_start_resolution = 64;
sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE;
sce->r.unit_line_thickness = 1.0f;
@ -762,7 +762,7 @@ void BKE_scene_init(Scene *sce)
sce->gm.gravity = 9.8f;
sce->gm.physicsEngine = WOPHY_BULLET;
sce->gm.mode = 32; //XXX ugly harcoding, still not sure we should drop mode. 32 == 1 << 5 == use_occlusion_culling
sce->gm.mode = 32; //XXX ugly harcoding, still not sure we should drop mode. 32 == 1 << 5 == use_occlusion_culling
sce->gm.occlusionRes = 128;
sce->gm.ticrate = 60;
sce->gm.maxlogicstep = 5;
@ -814,22 +814,22 @@ void BKE_scene_init(Scene *sce)
copy_v2_fl2(sce->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
sce->preview = NULL;
/* GP Sculpt brushes */
{
GP_BrushEdit_Settings *gset = &sce->toolsettings->gp_sculpt;
GP_EditBrush_Data *gp_brush;
gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH];
gp_brush->size = 25;
gp_brush->strength = 0.3f;
gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE;
gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS];
gp_brush->size = 25;
gp_brush->strength = 0.5f;
gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH];
gp_brush->size = 25;
gp_brush->strength = 0.5f;
@ -839,28 +839,28 @@ void BKE_scene_init(Scene *sce)
gp_brush->size = 50;
gp_brush->strength = 0.3f;
gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH];
gp_brush->size = 25;
gp_brush->strength = 0.3f;
gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST];
gp_brush->size = 50;
gp_brush->strength = 0.3f; // XXX?
gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH];
gp_brush->size = 50;
gp_brush->strength = 0.5f; // XXX?
gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMIZE];
gp_brush->size = 25;
gp_brush->strength = 0.5f;
gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
}
/* GP Stroke Placement */
sce->toolsettings->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
sce->toolsettings->gpencil_v2d_align = GP_PROJECT_VIEWSPACE;
@ -912,10 +912,10 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
Group *group;
GroupObject *go;
int flag;
/* check for cyclic sets, for reading old files but also for definite security (py?) */
BKE_scene_validate_setscene(bmain, scene);
/* can happen when switching modes in other scenes */
if (scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT))
scene->obedit = NULL;
@ -941,12 +941,12 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
for (base = scene->base.first; base; base = base->next) {
ob = base->object;
ob->lay = base->lay;
/* group patch... */
base->flag &= ~(OB_FROMGROUP);
flag = ob->flag & (OB_FROMGROUP);
base->flag |= flag;
/* not too nice... for recovering objects with lost data */
//if (ob->pose == NULL) base->flag &= ~OB_POSEMODE;
ob->flag = base->flag;
@ -973,7 +973,7 @@ int BKE_scene_base_iter_next(Main *bmain, EvaluationContext *eval_ctx, SceneBase
Scene **scene, int val, Base **base, Object **ob)
{
bool run_again = true;
/* init */
if (val == 0) {
iter->phase = F_START;
@ -1027,19 +1027,19 @@ int BKE_scene_base_iter_next(Main *bmain, EvaluationContext *eval_ctx, SceneBase
}
}
}
if (*base == NULL) {
iter->phase = F_START;
}
else {
if (iter->phase != F_DUPLI) {
if ( (*base)->object->transflag & OB_DUPLI) {
/* groups cannot be duplicated for mballs yet,
* this enters eternal loop because of
/* groups cannot be duplicated for mballs yet,
* this enters eternal loop because of
* makeDispListMBall getting called inside of group_duplilist */
if ((*base)->object->dup_group == NULL) {
iter->duplilist = object_duplilist_ex(bmain, eval_ctx, (*scene), (*base)->object, false);
iter->dupob = iter->duplilist->first;
if (!iter->dupob) {
@ -1072,13 +1072,13 @@ int BKE_scene_base_iter_next(Main *bmain, EvaluationContext *eval_ctx, SceneBase
else if (iter->phase == F_DUPLI) {
iter->phase = F_SCENE;
(*base)->flag &= ~OB_FROMDUPLI;
if (iter->dupli_refob) {
/* Restore last object's real matrix. */
copy_m4_m4(iter->dupli_refob->obmat, iter->omat);
iter->dupli_refob = NULL;
}
free_object_duplilist(iter->duplilist);
iter->duplilist = NULL;
run_again = true;
@ -1099,7 +1099,7 @@ int BKE_scene_base_iter_next(Main *bmain, EvaluationContext *eval_ctx, SceneBase
Object *BKE_scene_camera_find(Scene *sc)
{
Base *base;
for (base = sc->base.first; base; base = base->next)
if (base->object->type == OB_CAMERA)
return base->object;
@ -1225,7 +1225,7 @@ void BKE_scene_base_unlink(Scene *sce, Base *base)
/* remove rigid body object from world before removing object */
if (base->object->rigidbody_object)
BKE_rigidbody_remove_object(sce, base->object);
BLI_remlink(&sce->base, base);
if (sce->basact == base)
sce->basact = NULL;
@ -1257,7 +1257,7 @@ bool BKE_scene_validate_setscene(Main *bmain, Scene *sce)
if (sce->set == NULL) return true;
totscene = BLI_listbase_count(&bmain->scene);
for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) {
/* more iterations than scenes means we have a cycle */
if (a > totscene) {
@ -1284,7 +1284,7 @@ float BKE_scene_frame_get_from_ctime(const Scene *scene, const float frame)
float ctime = frame;
ctime += scene->r.subframe;
ctime *= scene->r.framelen;
return ctime;
}
@ -1299,7 +1299,7 @@ void BKE_scene_frame_set(struct Scene *scene, double cfra)
}
#ifdef WITH_LEGACY_DEPSGRAPH
/* drivers support/hacks
/* drivers support/hacks
* - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render
* - these are always run since the depsgraph can't handle non-object data
* - these happen after objects are all done so that we can read in their final transform values,
@ -1309,7 +1309,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
{
SceneRenderLayer *srl;
float ctime = BKE_scene_frame_get(scene);
/* scene itself */
if (scene->adt && scene->adt->drivers.first) {
BKE_animsys_evaluate_animdata(scene, &scene->id, scene->adt, ctime, ADT_RECALC_DRIVERS);
@ -1320,16 +1320,16 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
if (scene->world) {
ID *wid = (ID *)scene->world;
AnimData *adt = BKE_animdata_from_id(wid);
if (adt && adt->drivers.first)
BKE_animsys_evaluate_animdata(scene, wid, adt, ctime, ADT_RECALC_DRIVERS);
}
/* nodes */
if (scene->nodetree) {
ID *nid = (ID *)scene->nodetree;
AnimData *adt = BKE_animdata_from_id(nid);
if (adt && adt->drivers.first)
BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, ADT_RECALC_DRIVERS);
}
@ -1338,7 +1338,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
if (scene->world && scene->world->nodetree) {
ID *nid = (ID *)scene->world->nodetree;
AnimData *adt = BKE_animdata_from_id(nid);
if (adt && adt->drivers.first)
BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, ADT_RECALC_DRIVERS);
}
@ -1364,32 +1364,32 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
static void scene_depsgraph_hack(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Scene *scene_parent)
{
Base *base;
scene->customdata_mask = scene_parent->customdata_mask;
/* sets first, we allow per definition current scene to have
* dependencies on sets, but not the other way around. */
if (scene->set)
scene_depsgraph_hack(bmain, eval_ctx, scene->set, scene_parent);
for (base = scene->base.first; base; base = base->next) {
Object *ob = base->object;
if (ob->depsflag) {
int recalc = 0;
// printf("depshack %s\n", ob->id.name + 2);
if (ob->depsflag & OB_DEPS_EXTRA_OB_RECALC)
recalc |= OB_RECALC_OB;
if (ob->depsflag & OB_DEPS_EXTRA_DATA_RECALC)
recalc |= OB_RECALC_DATA;
ob->recalc |= recalc;
BKE_object_handle_update(bmain, eval_ctx, scene_parent, ob);
if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) {
GroupObject *go;
for (go = ob->dup_group->gobject.first; go; go = go->next) {
if (go->ob)
go->ob->recalc |= recalc;
@ -1782,7 +1782,7 @@ static void scene_update_tagged_recursive(EvaluationContext *eval_ctx, Main *bma
/* update masking curves */
BKE_mask_update_scene(bmain, scene);
}
#endif /* WITH_LEGACY_DEPSGRAPH */
@ -1868,9 +1868,9 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
DAG_ids_flush_tagged(bmain);
/* removed calls to quick_cache, see pointcache.c */
/* clear "LIB_TAG_DOIT" flag from all materials, to prevent infinite recursion problems later
* when trying to find materials with drivers that need evaluating [#32017]
* when trying to find materials with drivers that need evaluating [#32017]
*/
BKE_main_id_tag_idcode(bmain, ID_MA, LIB_TAG_DOIT, false);
BKE_main_id_tag_idcode(bmain, ID_LA, LIB_TAG_DOIT, false);
@ -1897,7 +1897,7 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
{
AnimData *adt = BKE_animdata_from_id(&scene->id);
float ctime = BKE_scene_frame_get(scene);
if (adt && (adt->recalc & ADT_RECALC_ANIM))
BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0);
}
@ -1975,7 +1975,7 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
/* update animated image textures for particles, modifiers, gpu, etc,
* call this at the start so modifiers with textures don't lag 1 frame */
BKE_image_update_frame(bmain, sce->r.cfra);
#ifdef WITH_LEGACY_DEPSGRAPH
/* rebuild rigid body worlds before doing the actual frame update
* this needs to be done on start frame but animation playback usually starts one frame later
@ -1985,9 +1985,9 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
scene_rebuild_rbw_recursive(sce, ctime);
}
#endif
BKE_sound_set_cfra(sce->r.cfra);
/* clear animation overrides */
/* XXX TODO... */
@ -2029,7 +2029,7 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
#endif
/* clear "LIB_TAG_DOIT" flag from all materials, to prevent infinite recursion problems later
* when trying to find materials with drivers that need evaluating [#32017]
* when trying to find materials with drivers that need evaluating [#32017]
*/
BKE_main_id_tag_idcode(bmain, ID_MA, LIB_TAG_DOIT, false);
BKE_main_id_tag_idcode(bmain, ID_LA, LIB_TAG_DOIT, false);
@ -2041,7 +2041,7 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
scene_do_rb_simulation_recursive(sce, ctime);
}
#endif
/* BKE_object_handle_update() on all objects, groups and sets */
#ifdef WITH_LEGACY_DEPSGRAPH
if (use_new_eval) {
@ -2347,7 +2347,7 @@ int BKE_render_num_threads(const RenderData *rd)
threads = rd->threads;
else
threads = BLI_system_thread_count();
return max_ii(threads, 1);
}

@ -64,7 +64,7 @@ static void spacetype_free(SpaceType *st)
ARegionType *art;
PanelType *pt;
HeaderType *ht;
for (art = st->regiontypes.first; art; art = art->next) {
BLI_freelistN(&art->drawcalls);
@ -83,7 +83,7 @@ static void spacetype_free(SpaceType *st)
BLI_freelistN(&art->paneltypes);
BLI_freelistN(&art->headertypes);
}
BLI_freelistN(&st->regiontypes);
BLI_freelistN(&st->toolshelf);
@ -92,18 +92,18 @@ static void spacetype_free(SpaceType *st)
void BKE_spacetypes_free(void)
{
SpaceType *st;
for (st = spacetypes.first; st; st = st->next) {
spacetype_free(st);
}
BLI_freelistN(&spacetypes);
}
SpaceType *BKE_spacetype_from_id(int spaceid)
{
SpaceType *st;
for (st = spacetypes.first; st; st = st->next) {
if (st->spaceid == spaceid)
return st;
@ -114,11 +114,11 @@ SpaceType *BKE_spacetype_from_id(int spaceid)
ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
{
ARegionType *art;
for (art = st->regiontypes.first; art; art = art->next)
if (art->regionid == regionid)
return art;
printf("Error, region type %d missing in - name:\"%s\", id:%d\n", regionid, st->name, st->spaceid);
return st->regiontypes.first;
}
@ -126,7 +126,7 @@ ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
{
ARegionType *art;
for (art = st->regiontypes.first; art; art = art->next) {
if (art->regionid == regionid) {
return art;
@ -144,7 +144,7 @@ const ListBase *BKE_spacetypes_list(void)
void BKE_spacetype_register(SpaceType *st)
{
SpaceType *stype;
/* sanity check */
stype = BKE_spacetype_from_id(st->spaceid);
if (stype) {
@ -152,7 +152,7 @@ void BKE_spacetype_register(SpaceType *st)
spacetype_free(stype);
MEM_freeN(stype);
}
BLI_addtail(&spacetypes, st);
}
@ -167,20 +167,20 @@ void BKE_spacedata_freelist(ListBase *lb)
{
SpaceLink *sl;
ARegion *ar;
for (sl = lb->first; sl; sl = sl->next) {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
/* free regions for pushed spaces */
for (ar = sl->regionbase.first; ar; ar = ar->next)
BKE_area_region_free(st, ar);
BLI_freelistN(&sl->regionbase);
if (st && st->free)
if (st && st->free)
st->free(sl);
}
BLI_freelistN(lb);
}
@ -188,7 +188,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
{
ARegion *newar = MEM_dupallocN(ar);
Panel *pa, *newpa, *patab;
newar->prev = newar->next = NULL;
BLI_listbase_clear(&newar->handlers);
BLI_listbase_clear(&newar->uiblocks);
@ -198,7 +198,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
newar->swinid = 0;
newar->regiontimer = NULL;
newar->headerstr = NULL;
/* use optional regiondata callback */
if (ar->regiondata) {
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
@ -216,7 +216,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
if (ar->v2d.tab_offset)
newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset);
BLI_listbase_clear(&newar->panels);
BLI_duplicatelist(&newar->panels, &ar->panels);
@ -236,7 +236,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
pa = pa->next;
}
}
return newar;
}
@ -245,10 +245,10 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
{
ARegion *ar;
/* to be sure */
BLI_listbase_clear(lb1);
for (ar = lb2->first; ar; ar = ar->next) {
ARegion *arnew = BKE_area_region_copy(st, ar);
BLI_addtail(lb1, arnew);
@ -260,17 +260,17 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
{
SpaceLink *sl;
BLI_listbase_clear(lb1); /* to be sure */
for (sl = lb2->first; sl; sl = sl->next) {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
if (st && st->duplicate) {
SpaceLink *slnew = st->duplicate(sl);
BLI_addtail(lb1, slnew);
region_copylist(st, &slnew->regionbase, &sl->regionbase);
}
}
@ -282,14 +282,14 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
void BKE_spacedata_draw_locks(int set)
{
SpaceType *st;
for (st = spacetypes.first; st; st = st->next) {
ARegionType *art;
for (art = st->regiontypes.first; art; art = art->next) {
if (set)
if (set)
art->do_lock = art->lock;
else
else
art->do_lock = false;
}
}
@ -317,16 +317,16 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
if (st) {
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
if (art && art->free)
art->free(ar);
if (ar->regiondata)
printf("regiondata free error\n");
}
else if (ar->type && ar->type->free)
ar->type->free(ar);
if (ar->v2d.tab_offset) {
MEM_freeN(ar->v2d.tab_offset);
ar->v2d.tab_offset = NULL;
@ -370,14 +370,14 @@ void BKE_screen_area_free(ScrArea *sa)
{
SpaceType *st = BKE_spacetype_from_id(sa->spacetype);
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next)
BKE_area_region_free(st, ar);
BLI_freelistN(&sa->regionbase);
BKE_spacedata_freelist(&sa->spacedata);
BLI_freelistN(&sa->actionzones);
}
@ -388,17 +388,17 @@ void BKE_screen_free(bScreen *sc)
ARegion *ar;
/* No animdata here. */
for (ar = sc->regionbase.first; ar; ar = ar->next)
BKE_area_region_free(NULL, ar);
BLI_freelistN(&sc->regionbase);
for (sa = sc->areabase.first; sa; sa = san) {
san = sa->next;
BKE_screen_area_free(sa);
}
BLI_freelistN(&sc->vertbase);
BLI_freelistN(&sc->edgebase);
BLI_freelistN(&sc->areabase);
@ -433,7 +433,7 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
{
if (sa) {
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == type)
return ar;

@ -127,7 +127,7 @@ static ImBuf *prepare_effect_imbufs(const SeqRenderData *context, ImBuf *ibuf1,
else {
out = IMB_allocImBuf(x, y, 32, IB_rect);
}
if (out->rect_float) {
if (ibuf1 && !ibuf1->rect_float) {
BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf1, true);
@ -140,7 +140,7 @@ static ImBuf *prepare_effect_imbufs(const SeqRenderData *context, ImBuf *ibuf1,
if (ibuf3 && !ibuf3->rect_float) {
BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf3, true);
}
IMB_colormanagement_assign_float_colorspace(out, scene->sequencer_colorspace_settings.name);
}
else {
@ -369,7 +369,7 @@ static void do_alphaunder_effect_byte(
tempc[1] = (fac * rt1[1] + rt2[1]);
tempc[2] = (fac * rt1[2] + rt2[2]);
tempc[3] = (fac * rt1[3] + rt2[3]);
premul_float_to_straight_uchar(rt, tempc);
}
}
@ -384,10 +384,10 @@ static void do_alphaunder_effect_byte(
while (x--) {
straight_uchar_to_premul_float(rt1, cp1);
straight_uchar_to_premul_float(rt2, cp2);
if (rt2[3] <= 0.0f && fac4 >= 1.0f) *((unsigned int *) rt) = *((unsigned int *) cp1);
else if (rt2[3] >= 1.0f) *((unsigned int *) rt) = *((unsigned int *) cp2);
else {
else {
fac = (fac4 * (1.0f - rt2[3]));
if (fac <= 0) *((unsigned int *)rt) = *((unsigned int *)cp2);
@ -396,7 +396,7 @@ static void do_alphaunder_effect_byte(
tempc[1] = (fac * rt1[1] + rt2[1]);
tempc[2] = (fac * rt1[2] + rt2[2]);
tempc[3] = (fac * rt1[3] + rt2[3]);
premul_float_to_straight_uchar(rt, tempc);
}
}
@ -628,7 +628,7 @@ static float gamma_range_table[RE_GAMMA_TABLE_SIZE + 1];
static float gamfactor_table[RE_GAMMA_TABLE_SIZE];
static float inv_gamma_range_table[RE_GAMMA_TABLE_SIZE + 1];
static float inv_gamfactor_table[RE_GAMMA_TABLE_SIZE];
static float color_domain_table[RE_GAMMA_TABLE_SIZE + 1];
static float color_domain_table[RE_GAMMA_TABLE_SIZE + 1];
static float color_step;
static float inv_color_step;
static float valid_gamma;
@ -642,7 +642,7 @@ static void makeGammaTables(float gamma)
valid_gamma = gamma;
valid_inv_gamma = 1.0f / gamma;
color_step = 1.0f / RE_GAMMA_TABLE_SIZE;
inv_color_step = (float) RE_GAMMA_TABLE_SIZE;
inv_color_step = (float) RE_GAMMA_TABLE_SIZE;
/* We could squeeze out the two range tables to gain some memory */
for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) {
@ -674,7 +674,7 @@ static float gammaCorrect(float c)
{
int i;
float res;
i = floorf(c * inv_color_step);
/* Clip to range [0, 1]: outside, just do the complete calculation.
* We may have some performance problems here. Stretching up the LUT
@ -685,7 +685,7 @@ static float gammaCorrect(float c)
else if (i >= RE_GAMMA_TABLE_SIZE) res = powf(c, valid_gamma);
else res = gamma_range_table[i] +
((c - color_domain_table[i]) * gamfactor_table[i]);
return res;
}
@ -710,17 +710,17 @@ static void gamtabs(float gamma)
{
float val, igamma = 1.0f / gamma;
int a;
/* gamtab: in short, out short */
for (a = 0; a < 65536; a++) {
val = a;
val /= 65535.0f;
if (gamma == 2.0f)
val = sqrtf(val);
else if (gamma != 1.0f)
val = powf(val, igamma);
gamtab[a] = (65535.99f * val);
}
/* inverse gamtab1 : in byte, out short */
@ -1317,7 +1317,7 @@ BLI_INLINE void apply_blend_function_byte(
rt1 = rect1;
rt2 = rect2;
rt = out;
while (y--) {
while (y--) {
for (x = xo; x > 0; x--) {
achannel = rt2[3];
rt2[3] = (unsigned int) achannel * facf0;
@ -1331,7 +1331,7 @@ BLI_INLINE void apply_blend_function_byte(
if (y == 0) {
break;
}
y--;
y--;
for (x = xo; x > 0; x--) {
achannel = rt2[3];
rt2[3] = (unsigned int) achannel * facf1;
@ -1356,7 +1356,7 @@ BLI_INLINE void apply_blend_function_float(
rt1 = rect1;
rt2 = rect2;
rt = out;
while (y--) {
while (y--) {
for (x = xo; x > 0; x--) {
achannel = rt2[3];
rt2[3] = achannel * facf0;
@ -1370,7 +1370,7 @@ BLI_INLINE void apply_blend_function_float(
if (y == 0) {
break;
}
y--;
y--;
for (x = xo; x > 0; x--) {
achannel = rt2[3];
rt2[3] = achannel * facf1;
@ -1771,7 +1771,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
/* case DO_CROSS_WIPE: */
/* BOX WIPE IS NOT WORKING YET */
#if 0
case DO_BOX_WIPE:
case DO_BOX_WIPE:
if (!wipe->forward)
facf0 = 1.0f - facf0; /* Go the other direction */
@ -1852,7 +1852,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
else output = in_band(hwidth, fabsf(temp2 - pointdist), 1, 1);
if (!wipe->forward) output = 1 - output;
break;
}
if (output < 0) output = 0;
@ -2053,7 +2053,7 @@ static void init_transform_effect(Sequence *seq)
transform->yIni = 0.0f;
transform->rotIni = 0.0f;
transform->interpolation = 1;
transform->percent = 1;
transform->uniform_scale = 0;
@ -2085,7 +2085,7 @@ static void transform_image(
xo = x;
yo = y;
/* Rotate */
s = sinf(rotate);
c = cosf(rotate);
@ -2128,7 +2128,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x
{
TransformVars *transform = (TransformVars *) seq->effectdata;
float scale_x, scale_y, translate_x, translate_y, rotate_radians;
/* Scale */
if (transform->uniform_scale) {
scale_x = scale_y = transform->ScalexIni;
@ -2292,7 +2292,7 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
index = (x + (height - 1 - y) * width) * 4;
copy_v4_v4(temp + index, curColor2);
}
/* Do the main body */
for (y = halfWidth; y < height - halfWidth; y++) {
fy = 0;
@ -2461,12 +2461,12 @@ static ImBuf *do_glow_effect(
static void init_solid_color(Sequence *seq)
{
SolidColorVars *cv;
if (seq->effectdata)
MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(SolidColorVars), "solidcolor");
cv = (SolidColorVars *)seq->effectdata;
cv->col[0] = cv->col[1] = cv->col[2] = 0.5;
}
@ -2520,7 +2520,7 @@ static ImBuf *do_solid_color(
col1[2] = facf1 * cv->col[2] * 255;
rect = (unsigned char *)out->rect;
for (y = 0; y < out->y; y++) {
for (x = 0; x < out->x; x++, rect += 4) {
rect[0] = col0[0];
@ -2553,7 +2553,7 @@ static ImBuf *do_solid_color(
col1[2] = facf1 * cv->col[2];
rect_float = out->rect_float;
for (y = 0; y < out->y; y++) {
for (x = 0; x < out->x; x++, rect_float += 4) {
rect_float[0] = col0[0];
@ -2622,7 +2622,7 @@ static ImBuf *do_multicam(
else {
out = i;
}
return out;
}
@ -2697,7 +2697,7 @@ static ImBuf *do_adjustment(
else {
out = i;
}
return out;
}
@ -2876,7 +2876,7 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for
facf *= seq->seq1->len;
}
facf *= v->globalSpeed;
if (facf >= seq->seq1->len) {
facf = seq->seq1->len - 1;
}

@ -746,10 +746,10 @@ void BKE_sequence_calc_disp(Scene *scene, Sequence *seq)
seq->startstill = 0;
if (seq->endofs && seq->endstill)
seq->endstill = 0;
seq->startdisp = seq->start + seq->startofs - seq->startstill;
seq->enddisp = seq->start + seq->len - seq->endofs + seq->endstill;
seq->handsize = 10.0; /* 10 frames */
if (seq->enddisp - seq->startdisp < 10) {
seq->handsize = (float)(0.5 * (seq->enddisp - seq->startdisp));
@ -1011,7 +1011,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r
BKE_sequence_tx_set_final_right(seq, prev_enddisp);
BKE_sequence_single_fix(seq);
}
BKE_sequence_calc(scene, seq);
}
@ -1275,7 +1275,7 @@ static void multibuf(ImBuf *ibuf, const float fmul)
rt_float[1] *= fmul;
rt_float[2] *= fmul;
rt_float[3] *= fmul;
rt_float += 4;
}
}
@ -1306,9 +1306,9 @@ static float give_stripelem_index(Sequence *seq, float cfra)
else if (cfra >= end) nr = end - sta;
else nr = cfra - sta;
}
if (seq->strobe < 1.0f) seq->strobe = 1.0f;
if (seq->strobe > 1.0f) {
nr -= fmodf((double)nr, (double)seq->strobe);
}
@ -1329,7 +1329,7 @@ StripElem *BKE_sequencer_give_stripelem(Sequence *seq, int cfra)
if (nr == -1 || se == NULL)
return NULL;
se += nr + seq->anim_startofs;
}
return se;
@ -1426,7 +1426,7 @@ static int get_shown_sequences(ListBase *seqbasep, int cfra, int chanshown, Sequ
}
}
}
chanshown = b;
for (; b > 0; b--) {
@ -1656,7 +1656,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render
return false;
}
/* MOVIE tracks (only exception: custom files) are now handled
/* MOVIE tracks (only exception: custom files) are now handled
* internally by ImBuf module for various reasons: proper time code
* support, quicker index build, using one file instead
* of a full directory of jpeg files, etc. Trying to support old
@ -2097,7 +2097,7 @@ void BKE_sequencer_proxy_set(struct Sequence *seq, bool value)
}
else {
seq->flag &= ~SEQ_USE_PROXY;
}
}
}
/*********************** color balance *************************/
@ -2197,7 +2197,7 @@ static void color_balance_byte_byte(StripColorBalance *cb_, unsigned char *rect,
else
p[c] = t;
}
premul_float_to_straight_uchar(cp, p);
cp += 4;
@ -2549,7 +2549,7 @@ static ImBuf *input_preprocess(const SeqRenderData *context, Sequence *seq, floa
if (seq->flag & SEQ_FLIPX) {
IMB_flipx(ibuf);
}
if (seq->flag & SEQ_FLIPY) {
IMB_flipy(ibuf);
}
@ -2753,7 +2753,7 @@ static ImBuf *seq_render_effect_strip_impl(
if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
sh.get_default_fac(seq, cfra, &fac, &facf);
if ((scene->r.mode & R_FIELDS) == 0)
facf = fac;
}
@ -3072,7 +3072,7 @@ static ImBuf *seq_render_movieclip_strip(const SeqRenderData *context, Sequence
}
memset(&user, 0, sizeof(MovieClipUser));
BKE_movieclip_user_set_frame(&user, nr + seq->anim_startofs + seq->clip->start_frame);
user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
@ -3284,7 +3284,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
BKE_scene_camera_switch_update(scene);
camera = scene->camera;
}
if (have_comp == false && camera == NULL) {
goto finally;
}
@ -3666,13 +3666,13 @@ static bool seq_must_swap_input_in_blend_mode(Sequence *seq)
{
bool swap_input = false;
/* bad hack, to fix crazy input ordering of
/* bad hack, to fix crazy input ordering of
* those two effects */
if (ELEM(seq->blend_mode, SEQ_TYPE_ALPHAOVER, SEQ_TYPE_ALPHAUNDER, SEQ_TYPE_OVERDROP)) {
swap_input = true;
}
return swap_input;
}
@ -3749,7 +3749,7 @@ static ImBuf *seq_render_strip_stack(
if (out) {
return out;
}
if (count == 1) {
Sequence *seq = seq_arr[0];
@ -3874,7 +3874,7 @@ ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int cha
{
Editing *ed = BKE_sequencer_editing_get(context->scene, false);
ListBase *seqbasep;
if (ed == NULL) return NULL;
if ((chanshown < 0) && !BLI_listbase_is_empty(&ed->metastack)) {
@ -3925,23 +3925,23 @@ static pthread_cond_t wakeup_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t frame_done_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t frame_done_cond = PTHREAD_COND_INITIALIZER;
static volatile bool seq_thread_shutdown = true;
static volatile bool seq_thread_shutdown = true;
static volatile int seq_last_given_monoton_cfra = 0;
static int monoton_cfra = 0;
typedef struct PrefetchThread {
struct PrefetchThread *next, *prev;
Scene *scene;
struct PrefetchQueueElem *current;
pthread_t pthread;
int running;
} PrefetchThread;
typedef struct PrefetchQueueElem {
struct PrefetchQueueElem *next, *prev;
int rectx;
int recty;
float cfra;
@ -3971,7 +3971,7 @@ void BKE_sequencer_give_ibuf_prefetch_request(const SeqRenderData *context, floa
pthread_mutex_lock(&queue_lock);
BLI_addtail(&prefetch_wait, e);
pthread_mutex_unlock(&queue_lock);
pthread_mutex_lock(&wakeup_lock);
pthread_cond_signal(&wakeup_cond);
pthread_mutex_unlock(&wakeup_lock);
@ -4057,7 +4057,7 @@ ImBuf *BKE_sequencer_give_ibuf_threaded(const SeqRenderData *context, float cfra
pthread_mutex_unlock(&frame_done_lock);
}
}
return e ? e->ibuf : NULL;
}
@ -4173,30 +4173,30 @@ void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
BKE_sequencer_free_imbuf(scene, &seq->seqbase, for_render);
}
if (seq->type == SEQ_TYPE_SCENE) {
/* FIXME: recurs downwards,
/* FIXME: recurs downwards,
* but do recurs protection somehow! */
}
}
}
static bool update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *changed_seq, int len_change, int ibuf_change)
{
Sequence *subseq;
bool free_imbuf = false;
/* recurs downwards to see if this seq depends on the changed seq */
if (seq == NULL)
return false;
if (seq == changed_seq)
free_imbuf = true;
for (subseq = seq->seqbase.first; subseq; subseq = subseq->next)
if (update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change))
free_imbuf = true;
if (seq->seq1)
if (update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change))
free_imbuf = true;
@ -4206,7 +4206,7 @@ static bool update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *cha
if (seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2))
if (update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change))
free_imbuf = true;
if (free_imbuf) {
if (ibuf_change) {
if (seq->type == SEQ_TYPE_MOVIE) {
@ -4216,11 +4216,11 @@ static bool update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *cha
BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
}
}
if (len_change)
BKE_sequence_calc(scene, seq);
}
return free_imbuf;
}
@ -4228,9 +4228,9 @@ void BKE_sequencer_update_changed_seq_and_deps(Scene *scene, Sequence *changed_s
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
if (ed == NULL) return;
for (seq = ed->seqbase.first; seq; seq = seq->next)
update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change);
}
@ -4487,9 +4487,9 @@ Sequence *BKE_sequencer_foreground_frame_get(Scene *scene, int frame)
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq, *best_seq = NULL;
int best_machine = -1;
if (!ed) return NULL;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame)
continue;
@ -4948,7 +4948,7 @@ static void seq_free_animdata(Scene *scene, Sequence *seq)
while (fcu) {
if (STREQLEN(fcu->rna_path, str, str_len)) {
FCurve *next_fcu = fcu->next;
BLI_remlink(&scene->adt->action->curves, fcu);
free_fcurve(fcu);
@ -5202,7 +5202,7 @@ Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel);
seq->type = SEQ_TYPE_IMAGE;
seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
@ -5390,7 +5390,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq->anim_preseek = IMB_anim_get_preseek(anim_arr[0]);
BLI_strncpy(seq->name + 2, "Movie", SEQ_NAME_MAXSTR - 2);
BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
/* adjust scene's frame rate settings to match */
if (seq_load->flag & SEQ_LOAD_SYNC_FPS) {
IMB_anim_get_fps(anim_arr[0], &scene->r.frs_sec, &scene->r.frs_sec_base, true);

Some files were not shown because too many files have changed in this diff Show More