diff options
author | Joseph Eagar <joeedh@gmail.com> | 2010-03-09 07:32:40 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2010-03-09 07:32:40 +0300 |
commit | 71003b9bcc88ecf6138c3debb9abba4637c8e61a (patch) | |
tree | 7f85d40231311a36a72f731a7c07b8dbd6fff577 /source/blender/blenkernel | |
parent | ea540496c8281dcba899fb6b29c1bcfbb53a0482 (diff) | |
parent | 790d6ca256e6b572826b2bf214c6fd6c8a623969 (diff) |
merge with trunk at r27259 and commit of a patch by anthony jones to fix msvc (though further work may be needed because changes made by the merge
Diffstat (limited to 'source/blender/blenkernel')
170 files changed, 3532 insertions, 1994 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index c0b11791c1e..0284aa277c6 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -641,8 +641,8 @@ void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh * /* returns an array of deform matrices for crazyspace correction, and the number of modifiers left */ -int editbmesh_get_first_deform_matrices(struct Object *, struct BMEditMesh *em, float (**deformmats)[3][3], - float (**deformcos)[3]); +int editbmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct EditMesh *em, + float (**deformmats)[3][3], float (**deformcos)[3]); void weight_to_rgb(float input, float *fr, float *fg, float *fb); diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 6029ce01794..1b38e276ca4 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index 4862f4e5c46..79b4d50586a 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -53,7 +53,9 @@ void animviz_free_motionpath_cache(struct bMotionPath *mpath); void animviz_free_motionpath(struct bMotionPath *mpath); struct bMotionPath *animviz_verify_motionpaths(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan); -void animviz_calc_motionpaths(struct Scene *scene, struct Object *ob); + +void animviz_get_object_motionpaths(Object *ob, ListBase *targets); +void animviz_calc_motionpaths(struct Scene *scene, ListBase *targets); /* ---------------------------------------------------- */ /* Curve Paths */ diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index ad89d3bbd53..f6950ba07b8 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. @@ -43,7 +43,10 @@ struct AnimMapper; /* ************************************* */ /* AnimData API */ -/* Get AnimData from the given ID-block. */ +/* Check if the given ID-block can have AnimData */ +short id_type_can_have_animdata(struct ID *id); + +/* Get AnimData from the given ID-block */ struct AnimData *BKE_animdata_from_id(struct ID *id); /* Add AnimData to the given ID-block */ @@ -67,11 +70,11 @@ void BKE_animdata_make_local(struct AnimData *adt); /* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */ struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char name[], short flag, short keyingflag); -/* Add a destination to a KeyingSet */ -void BKE_keyingset_add_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode); +/* Add a path to a KeyingSet */ +void BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode); /* Find the destination matching the criteria given */ -struct KS_Path *BKE_keyingset_find_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode); +struct KS_Path *BKE_keyingset_find_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode); /* Copy all KeyingSets in the given list */ void BKE_keyingsets_copy(struct ListBase *newlist, struct ListBase *list); @@ -92,6 +95,16 @@ void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, ch void BKE_all_animdata_fix_paths_rename(char *prefix, char *oldName, char *newName); /* ************************************* */ +/* Batch AnimData API */ + +/* Define for callback looper used in BKE_animdata_main_cb */ +typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data); + + +/* Loop over all datablocks applying callback */ +void BKE_animdata_main_cb(struct Main *main, ID_AnimData_Edit_Callback func, void *user_data); + +/* ************************************* */ // TODO: overrides, remapping, and path-finding api's /* ************************************* */ diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 03f23f07c8c..7e3d7f2a2ce 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -91,7 +91,7 @@ void where_is_armature (struct bArmature *arm); void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone); void armature_rebuild_pose(struct Object *ob, struct bArmature *arm); void where_is_pose (struct Scene *scene, struct Object *ob); -void where_is_pose_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime); +void where_is_pose_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, int do_extra); /* get_objectspace_bone_matrix has to be removed still */ void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed); @@ -105,6 +105,9 @@ void armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], flo void armature_loc_pose_to_bone(struct bPoseChannel *pchan, float *inloc, float *outloc); void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); +void pchan_apply_mat4(struct bPoseChannel *pchan, float mat[][4]); +void pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]); + /* Rotation Mode Conversions - Used for PoseChannels + Objects... */ void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 973e70b6f51..229a573a9bd 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -41,9 +41,11 @@ struct ListBase; struct MemFile; struct bContext; struct ReportList; - -#define BLENDER_VERSION 250 -#define BLENDER_SUBVERSION 11 +struct Scene; +struct Main; + +#define BLENDER_VERSION 252 +#define BLENDER_SUBVERSION 0 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 @@ -62,12 +64,6 @@ void BKE_userdef_free(void); void set_blender_test_break_cb(void (*func)(void) ); int blender_test_break(void); -void pushdata(void *data, int len); -void popfirst(void *data); -void poplast(void *data); -void free_pushpop(void); -void pushpop_test(void); - /* global undo */ extern void BKE_write_undo(struct bContext *C, char *name); extern void BKE_undo_step(struct bContext *C, int step); @@ -77,6 +73,7 @@ extern char *BKE_undo_menu_string(void); extern void BKE_undo_number(struct bContext *C, int nr); void BKE_undo_save(char *fname); extern void BKE_undo_save_quit(void); +extern struct Main *BKE_undo_get_main(struct Scene **scene); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h index fc43ae0f9a5..f8e556ab43f 100644 --- a/source/blender/blenkernel/BKE_bmesh.h +++ b/source/blender/blenkernel/BKE_bmesh.h @@ -22,7 +22,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_bmeshCustomData.h b/source/blender/blenkernel/BKE_bmeshCustomData.h index e910fc13ed4..d2b72019b68 100644 --- a/source/blender/blenkernel/BKE_bmeshCustomData.h +++ b/source/blender/blenkernel/BKE_bmeshCustomData.h @@ -22,7 +22,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_bmfont.h b/source/blender/blenkernel/BKE_bmfont.h index 52f6a99ecdc..6a47dcbd6c4 100644 --- a/source/blender/blenkernel/BKE_bmfont.h +++ b/source/blender/blenkernel/BKE_bmfont.h @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_bmfont_types.h b/source/blender/blenkernel/BKE_bmfont_types.h index f7b24d8bbc3..77a618c1be4 100644 --- a/source/blender/blenkernel/BKE_bmfont_types.h +++ b/source/blender/blenkernel/BKE_bmfont_types.h @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_boids.h b/source/blender/blenkernel/BKE_boids.h index fb65c9c8920..ffd803f21a5 100644 --- a/source/blender/blenkernel/BKE_boids.h +++ b/source/blender/blenkernel/BKE_boids.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 by Janne Karhu. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_booleanops.h b/source/blender/blenkernel/BKE_booleanops.h index a32f21af859..d323725ec19 100644 --- a/source/blender/blenkernel/BKE_booleanops.h +++ b/source/blender/blenkernel/BKE_booleanops.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_booleanops_mesh.h b/source/blender/blenkernel/BKE_booleanops_mesh.h index 1d8685f410c..7c2d619659a 100644 --- a/source/blender/blenkernel/BKE_booleanops_mesh.h +++ b/source/blender/blenkernel/BKE_booleanops_mesh.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index cf8af56a5a9..fcc636215c9 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_bullet.h b/source/blender/blenkernel/BKE_bullet.h index 1c3bb175d66..b695bdc91ae 100644 --- a/source/blender/blenkernel/BKE_bullet.h +++ b/source/blender/blenkernel/BKE_bullet.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index e2911a30b25..5a1db432589 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index 13219c8bb30..44d3995cffd 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 54dd82317fc..a8a0d7daa89 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index 5ca8ad892ac..689fa96ffa6 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 85215592ff0..3e1d4fe927b 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. @@ -31,9 +31,20 @@ struct CurveMapping; struct CurveMap; +struct Histogram; struct ImBuf; struct rctf; +#if defined _WIN32 +# define DO_INLINE __inline +#elif defined (__sgi) +# define DO_INLINE +#elif defined (__sun) || defined (__sun__) +# define DO_INLINE +#else +# define DO_INLINE static inline +#endif + typedef enum CurveMappingPreset { CURVE_PRESET_LINE, CURVE_PRESET_SHARP, @@ -70,6 +81,7 @@ void curvemapping_initialize(struct CurveMapping *cumap); void curvemapping_table_RGBA(struct CurveMapping *cumap, float **array, int *size); void colorcorrection_do_ibuf(struct ImBuf *ibuf, const char *profile); +void histogram_update(struct Histogram *hist, struct ImBuf *ibuf); #endif diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index e9110b99098..9c5e89bff76 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -30,6 +30,7 @@ #ifndef BKE_CONSTRAINT_H #define BKE_CONSTRAINT_H +struct ID; struct bConstraint; struct bConstraintTarget; struct ListBase; @@ -57,6 +58,11 @@ typedef struct bConstraintOb { /* ---------------------------------------------------------------------------- */ +/* Callback format for performing operations on ID-pointers for Constraints */ +typedef void (*ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, void *userdata); + +/* ....... */ + /* Constraint Type-Info (shorthand in code = cti): * This struct provides function pointers for runtime, so that functions can be * written more generally (with fewer/no special exceptions for various constraints). @@ -80,6 +86,8 @@ typedef struct bConstraintTypeInfo { void (*free_data)(struct bConstraint *con); /* adjust pointer to other ID-data using ID_NEW(), but not to targets (optional) */ void (*relink_data)(struct bConstraint *con); + /* run the provided callback function on all the ID-blocks linked to the constraint */ + void (*id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata); /* copy any special data that is allocated separately (optional) */ 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) */ @@ -116,6 +124,7 @@ void unique_constraint_name(struct bConstraint *con, struct ListBase *list); void free_constraints(struct ListBase *list); void copy_constraints(struct ListBase *dst, const struct ListBase *src); void relink_constraints(struct ListBase *list); +void id_loop_constraints(struct ListBase *list, ConstraintIDFunc func, void *userdata); void free_constraint_data(struct bConstraint *con); /* Constraint API function prototypes */ @@ -127,6 +136,7 @@ struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel * int remove_constraint(ListBase *list, struct bConstraint *con); int remove_constraint_index(ListBase *list, int index); +void remove_constraints_type(ListBase *list, short type, short last_only); /* Constraints + Proxies function prototypes */ void extract_proxylocal_constraints(struct ListBase *dst, struct ListBase *src); diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 2c013a5231a..ae3fdb91edf 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 2d1bec09dbf..5fb44c52307 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 6c4df250061..7d4bae20ba5 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_customdata_file.h b/source/blender/blenkernel/BKE_customdata_file.h index 5cbff193cd3..9bcef7636c6 100644 --- a/source/blender/blenkernel/BKE_customdata_file.h +++ b/source/blender/blenkernel/BKE_customdata_file.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 8a34b286881..702cb100e18 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -40,15 +40,31 @@ struct ListBase; struct bDeformGroup; struct MDeformVert; -void copy_defgroups (struct ListBase *lb1, struct ListBase *lb2); -struct bDeformGroup *copy_defgroup (struct bDeformGroup *ingroup); -struct bDeformGroup *get_named_vertexgroup (Object *ob, char *name); -int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); -int get_named_vertexgroup_num (Object *ob, const char *name); -void unique_vertexgroup_name (struct bDeformGroup *dg, struct Object *ob); +void defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2); +struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup); +struct bDeformGroup *defgroup_find_name(struct Object *ob, char *name); +int defgroup_find_index(struct Object *ob, struct bDeformGroup *dg); +int *defgroup_flip_map(struct Object *ob, int use_default); +int defgroup_flip_index(struct Object *ob, int index, int use_default); +int defgroup_name_index(struct Object *ob, const char *name); +void defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob); -float deformvert_get_weight(const struct MDeformVert *dvert, int group_num); -float vertexgroup_get_vertex_weight(const struct MDeformVert *dvert, int index, int group_num); +struct MDeformWeight *defvert_find_index(const struct MDeformVert *dv, int defgroup); +struct MDeformWeight *defvert_verify_index(struct MDeformVert *dv, int defgroup); + +float defvert_find_weight(const struct MDeformVert *dvert, int group_num); +float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num); + +void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert); +void defvert_sync(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int use_verify); +void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int *flip_map, int use_verify); +void defvert_remap (struct MDeformVert *dvert, int *map); +void defvert_flip(struct MDeformVert *dvert, int *flip_map); +void defvert_normalize(struct MDeformVert *dvert); + +/* utility function, note that 32 chars is the maximum string length since its only + * used with defgroups currently */ +void flip_side_name(char *name, const char *from_name, int strip_number); #endif diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 44f8238d4d9..6a44051806e 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. @@ -103,6 +103,8 @@ void DAG_scene_sort(struct Scene *sce); void DAG_scene_update_flags(struct Scene *sce, unsigned int lay); /* flushes all recalc flags in objects down the dependency tree */ void DAG_scene_flush_update(struct Scene *sce, unsigned int lay, int time); + /* tag objects for update on file load */ +void DAG_on_load_update(void); /* flag all IDs that need recalc because they're animated, influencing this ID only. only for objects currently */ diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index da625b946ce..a250456f5c1 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index 9a0a724ab9a..837fede3c8a 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_endian.h b/source/blender/blenkernel/BKE_endian.h index dc5efd5ea46..d61b81fb6ce 100644 --- a/source/blender/blenkernel/BKE_endian.h +++ b/source/blender/blenkernel/BKE_endian.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h index 5c47eeabfe8..bd5af66c6a8 100644 --- a/source/blender/blenkernel/BKE_exotic.h +++ b/source/blender/blenkernel/BKE_exotic.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index d3457a5f5ae..9df6bfdbe7c 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. @@ -34,8 +34,11 @@ struct ChannelDriver; struct DriverVar; struct DriverTarget; +struct bAction; struct BezTriple; struct StructRNA; +struct PointerRNA; +struct PropertyRNA; #include "DNA_curve_types.h" @@ -191,6 +194,9 @@ struct FCurve *id_data_find_fcurve(ID *id, void *data, struct StructRNA *type, c */ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName); +/* find an f-curve based on an rna property */ +struct FCurve *rna_get_fcurve(struct PointerRNA *ptr, struct PropertyRNA *prop, int rnaindex, struct bAction **action, int *driven); + /* Binary search algorithm for finding where to 'insert' BezTriple with given frame number. * Returns the index to insert at (data already at that index will be offset if replace is 0) */ diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h index 145ae48e732..d99e7b42cff 100644 --- a/source/blender/blenkernel/BKE_fluidsim.h +++ b/source/blender/blenkernel/BKE_fluidsim.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index d328ccd57f4..10811c0776d 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 9684aa1c602..6084b0cfb73 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -21,7 +21,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -60,7 +60,7 @@ typedef struct Global { /* strings of recent opend files */ struct ListBase recent_files; - short afbreek, moving; + short afbreek, moving, file_loaded; short background; short winpos, displaymode; /* used to be in Render */ short rendering; /* to indicate render is busy, prevent renderwindow events etc */ @@ -113,7 +113,7 @@ typedef struct Global { /* #define G_FACESELECT (1 << 8) use (mesh->editflag & ME_EDIT_PAINT_MASK) */ #define G_DEBUG (1 << 12) -#define G_DOSCRIPTLINKS (1 << 13) +#define G_SCRIPT_AUTOEXEC (1 << 13) /* #define G_NOFROZEN (1 << 17) also removed */ #define G_GREASEPENCIL (1 << 17) diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 1892c8e71a4..65bcb54408b 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index 877e09b037f..d1491cc1616 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -37,8 +37,7 @@ struct Object; struct bAction; struct Scene; -void free_group_object(struct GroupObject *go); -void free_group(struct Group *group); +void free_group_objects(struct Group *group); void unlink_group(struct Group *group); struct Group *add_group(char *name); struct Group *copy_group(struct Group *group); diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h index 737adea78be..252191803f2 100644 --- a/source/blender/blenkernel/BKE_icons.h +++ b/source/blender/blenkernel/BKE_icons.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006-2007 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 7981fadccb6..9634b872e91 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -82,6 +82,9 @@ void IDP_UnlinkID(struct IDProperty *prop); /*-------- Group Functions -------*/ +/* Sync values from one group to another, only where they match */ +void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src); + /* replaces all properties with the same name in a destination group from a source group. */ diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 6b8d9d1768e..6b22b10cf24 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -128,10 +128,7 @@ struct Image *BKE_image_verify_viewer(int type, const char *name); void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf); /* called on frame change or before render */ -void BKE_image_user_calc_imanr(struct ImageUser *iuser, int cfra, int fieldnr); - -/* produce image export path */ -int BKE_get_image_export_path(struct Image *im, const char *dest_dir, char *abs, int abs_size, char *rel, int rel_size); +void BKE_image_user_calc_frame(struct ImageUser *iuser, int cfra, int fieldnr); /* fix things in ImageUser when new image gets assigned */ void BKE_image_user_new_image(struct Image *ima, struct ImageUser *iuser); @@ -142,9 +139,6 @@ struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct Im /* for multilayer images as well as for render-viewer */ struct RenderResult *BKE_image_acquire_renderresult(struct Scene *scene, struct Image *ima); void BKE_image_release_renderresult(struct Scene *scene, struct Image *ima); - -/* frees all ibufs used by any image datablocks */ -void BKE_image_free_image_ibufs(void); /* goes over all textures that use images */ void BKE_image_free_all_textures(void); diff --git a/source/blender/blenkernel/BKE_ipo.h b/source/blender/blenkernel/BKE_ipo.h index e12170b73c9..3bc707a674a 100644 --- a/source/blender/blenkernel/BKE_ipo.h +++ b/source/blender/blenkernel/BKE_ipo.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index c7574d1bb08..b3a3b4a5e9f 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 2e4a5334c68..d99296068d9 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 0e978128cf6..b859dbe6f51 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -42,6 +42,7 @@ struct bContext; void *alloc_libblock(struct ListBase *lb, short type, const char *name); void *copy_libblock(void *rt); +void copy_libblock_data(struct ID *id, const struct ID *id_from); void id_lib_extern(struct ID *id); void id_us_plus(struct ID *id); diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 6881bdfdb2c..d4d76b2e6e1 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -24,7 +24,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 3ea7cae2c86..7ec5d172130 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -77,6 +77,12 @@ int material_in_material(struct Material *parmat, struct Material *mat); void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col); +/* copy/paste */ +void clear_matcopybuf(void); +void free_matcopybuf(void); +void copy_matcopybuf(struct Material *ma); +void paste_matcopybuf(struct Material *ma); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index ff9ac693ba8..e28e2c4d86e 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 0801bb27a6a..5839239a7a5 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index c9dbac1cf5d..493ee281395 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -280,10 +280,10 @@ void modifier_unique_name(struct ListBase *modifiers, struct ModifierData *m void modifier_copyData(struct ModifierData *md, struct ModifierData *target); int modifier_dependsOnTime(struct ModifierData *md); int modifier_supportsMapping(struct ModifierData *md); -int modifier_couldBeCage(struct ModifierData *md); +int modifier_couldBeCage(struct Scene *scene, struct ModifierData *md); int modifier_isCorrectableDeformed(struct ModifierData *md); int modifier_sameTopology(ModifierData *md); -int modifier_isEnabled(struct ModifierData *md, int required_mode); +int modifier_isEnabled(struct Scene *scene, struct ModifierData *md, int required_mode); void modifier_setError(struct ModifierData *md, char *format, ...); void modifiers_foreachObjectLink(struct Object *ob, @@ -294,7 +294,7 @@ void modifiers_foreachIDLink(struct Object *ob, void *userData); struct ModifierData *modifiers_findByType(struct Object *ob, ModifierType type); void modifiers_clearErrors(struct Object *ob); -int modifiers_getCageIndex(struct Object *ob, +int modifiers_getCageIndex(struct Scene *scene, struct Object *ob, int *lastPossibleCageIndex_r, int virtual_); int modifiers_isSoftbodyEnabled(struct Object *ob); @@ -314,7 +314,8 @@ int modifiers_indexInObject(struct Object *ob, struct ModifierData *md * evaluation, assuming the data indicated by dataMask is required at the * end of the stack. */ -struct LinkNode *modifiers_calcDataMasks(struct Object *ob, +struct LinkNode *modifiers_calcDataMasks(struct Scene *scene, + struct Object *ob, struct ModifierData *md, CustomDataMask dataMask, int required_mode); diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 2f372f80957..22f70d079ca 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 by Nicholas Bishop * All rights reserved. @@ -40,6 +40,7 @@ struct Object; void multires_mark_as_modified(struct Object *ob); void multires_force_update(struct Object *ob); +void multires_force_render_update(struct Object *ob); struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*, struct Object *, int, int); diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 989043c1d67..5b842965225 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. @@ -83,6 +83,7 @@ struct NlaStrip *BKE_nlastrip_find_active(struct NlaTrack *nlt); void BKE_nlastrip_set_active(struct AnimData *adt, struct NlaStrip *strip); short BKE_nlastrip_within_bounds(struct NlaStrip *strip, float min, float max); +void BKE_nlastrip_recalculate_bounds(struct NlaStrip *strip); void BKE_nlastrip_validate_name(struct AnimData *adt, struct NlaStrip *strip); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 8da732af2dd..a6ebb72320c 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2005 Blender Foundation. * All rights reserved. @@ -354,6 +354,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); #define CMP_NODE_DIST_MATTE 257 #define CMP_NODE_VIEW_LEVELS 258 #define CMP_NODE_COLOR_MATTE 259 +#define CMP_NODE_COLORBALANCE 260 +#define CMP_NODE_HUECORRECT 261 #define CMP_NODE_GLARE 301 #define CMP_NODE_TONEMAP 302 @@ -431,7 +433,7 @@ extern struct ListBase node_all_textures; /* API */ int ntreeTexTagAnimated(struct bNodeTree *ntree); void ntreeTexSetPreviewFlag(int); -void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, short thread, struct Tex *tex, short which_output, int cfra, int preview); +int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, int osatex, short thread, struct Tex *tex, short which_output, int cfra, int preview, struct ShadeInput *shi, struct MTex *mtex); void ntreeTexCheckCyclics(struct bNodeTree *ntree); char* ntreeTexOutputMenu(struct bNodeTree *ntree); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index d0c2052f0d6..a6a641a3219 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -67,6 +67,7 @@ void object_link_modifiers(struct Object *ob, struct Object *from); void object_free_modifiers(struct Object *ob); void object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); +void object_copy_proxy_drivers(struct Object *ob, struct Object *target); void unlink_object(struct Scene *scene, struct Object *ob); int exist_object(struct Object *obtest); @@ -111,10 +112,13 @@ void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]); struct BoundBox *object_get_boundbox(struct Object *ob); void object_boundbox_flag(struct Object *ob, int flag, int set); void minmax_object(struct Object *ob, float *min, float *max); -void minmax_object_duplis(struct Scene *scene, struct Object *ob, float *min, float *max); +int minmax_object_duplis(struct Scene *scene, struct Object *ob, float *min, float *max); void solve_tracking (struct Object *ob, float targetmat[][4]); int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]); +void *object_tfm_backup(struct Object *ob); +void object_tfm_restore(struct Object *ob, void *obtfm_pt); + void object_handle_update(struct Scene *scene, struct Object *ob); float give_timeoffset(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index b6513bede99..58cf144483f 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 161ae2c3c5c..6742d0fd924 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 by Nicholas Bishop * All rights reserved. diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 32202d9d462..45166ebf022 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 by Janne Karhu. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_plugin_types.h b/source/blender/blenkernel/BKE_plugin_types.h index fe5aafe5874..0bb1400858d 100644 --- a/source/blender/blenkernel/BKE_plugin_types.h +++ b/source/blender/blenkernel/BKE_plugin_types.h @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 4b26eaa6d76..10550ccdc05 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. @@ -55,6 +55,7 @@ /* File open options, for BKE_ptcache_file_open */ #define PTCACHE_FILE_READ 0 #define PTCACHE_FILE_WRITE 1 +#define PTCACHE_FILE_UPDATE 2 /* PTCacheID types */ #define PTCACHE_TYPE_SOFTBODY 0 @@ -213,7 +214,7 @@ typedef struct PTCacheEdit { struct ParticleSystem *psys; struct ParticleData *particles; struct KDTree *emitter_field; - float *emitter_cosnos; + float *emitter_cosnos; /* localspace face centers and normals (average of its verts), from the derived mesh */ int *mirror_cache; struct ParticleCacheKey **pathcache; /* path cache (runtime) */ diff --git a/source/blender/blenkernel/BKE_property.h b/source/blender/blenkernel/BKE_property.h index 78a9ecddaac..b9cca612846 100644 --- a/source/blender/blenkernel/BKE_property.h +++ b/source/blender/blenkernel/BKE_property.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_report.h b/source/blender/blenkernel/BKE_report.h index 1d72b1c81f0..62381bbc1f5 100644 --- a/source/blender/blenkernel/BKE_report.h +++ b/source/blender/blenkernel/BKE_report.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h index 1b8e61f136f..910f381823c 100644 --- a/source/blender/blenkernel/BKE_sca.h +++ b/source/blender/blenkernel/BKE_sca.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index c372004bd19..5e5131f9ccc 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -68,6 +68,9 @@ int next_object(struct Scene *scene, int val, struct Base **base, struct Object struct Object *scene_find_camera(struct Scene *sc); struct Object *scene_find_camera_switch(struct Scene *scene); // DURIAN_CAMERA_SWITCH +char *scene_find_marker_name(struct Scene *scene, int frame); +char *scene_find_last_marker_name(struct Scene *scene, int frame); + struct Base *scene_add_base(struct Scene *sce, struct Object *ob); void scene_deselect_all(struct Scene *sce); void scene_select_base(struct Scene *sce, struct Base *selbase); diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 21150af7144..ee9a4db049f 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -84,6 +84,8 @@ typedef struct SpaceType { void (*operatortypes)(void); /* add default items to WM keymap */ void (*keymap)(struct wmKeyConfig *); + /* on startup, define dropboxes for spacetype+regions */ + void (*dropboxes)(void); /* return context data */ int (*context)(const struct bContext *, const char*, struct bContextDataResult *); @@ -93,7 +95,7 @@ typedef struct SpaceType { /* tool shelf definitions */ ListBase toolshelf; - + /* read and write... */ /* default keymaps to add */ @@ -142,6 +144,8 @@ typedef struct ARegionType { /* hardcoded constraints, smaller than these values region is not visible */ int minsizex, minsizey; + /* when new region opens (region prefsizex/y are zero then */ + int prefsizex, prefsizey; /* default keymaps to add */ int keymapflag; } ARegionType; @@ -230,6 +234,8 @@ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar); void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar); void BKE_screen_area_free(struct ScrArea *sa); +struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); + /* screen */ void free_screen(struct bScreen *sc); unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene); diff --git a/source/blender/blenkernel/BKE_script.h b/source/blender/blenkernel/BKE_script.h index a4c3d946654..4ea1ee6db85 100644 --- a/source/blender/blenkernel/BKE_script.h +++ b/source/blender/blenkernel/BKE_script.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index dc7b6d3ad9b..b0a810203cf 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. @@ -28,8 +28,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef BKE_SEQUENCE_H -#define BKE_SEQUENCE_H +#ifndef BKE_SEQUENCER_H +#define BKE_SEQUENCER_H struct Editing; struct Sequence; @@ -77,8 +77,6 @@ void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int us seq_end(&iter); \ } -#endif - /* Wipe effect */ enum {DO_SINGLE_WIPE, DO_DOUBLE_WIPE, DO_BOX_WIPE, DO_CROSS_WIPE, @@ -152,8 +150,8 @@ struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, struct ImBuf *give_ibuf_seq_threaded(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size); struct ImBuf *give_ibuf_seq_direct(struct Scene *scene, int rectx, int recty, int cfra, int render_size, struct Sequence *seq); void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size); -void calc_sequence(struct Sequence *seq); -void calc_sequence_disp(struct Sequence *seq); +void calc_sequence(struct Scene *scene, struct Sequence *seq); +void calc_sequence_disp(struct Scene *scene, struct Sequence *seq); void new_tstripdata(struct Sequence *seq); void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq); void sort_seq(struct Scene *scene); @@ -193,9 +191,10 @@ int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene); int seqbase_isolated_sel_check(struct ListBase *seqbase); void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage); -void seq_update_sound(struct Sequence *seq); -void seq_update_muting(struct Editing *ed); +void seq_update_sound(struct Scene* scene, struct Sequence *seq); +void seq_update_muting(struct Scene* scene, struct Editing *ed); void seqbase_sound_reload(Scene *scene, ListBase *seqbase); +void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq); void clear_scene_in_allseqs(struct Scene *sce); struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive); @@ -206,6 +205,7 @@ void active_seq_set(struct Scene *scene, struct Sequence *seq); /* api for adding new sequence strips */ typedef struct SeqLoadInfo { int start_frame; + int end_frame; int channel; int flag; /* use sound, replace sel */ int type; @@ -229,8 +229,6 @@ struct Sequence *alloc_sequence(ListBase *lb, int cfra, int machine); void seq_load_apply(struct Scene *scene, struct Sequence *seq, struct SeqLoadInfo *seq_load); -void seqUniqueName(ListBase *seqbasep, struct Sequence *seq); - struct Sequence *sequencer_add_image_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); struct Sequence *sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); @@ -238,3 +236,5 @@ struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbase /* copy/paste */ extern ListBase seqbase_clipboard; extern int seqbase_clipboard_frame; + +#endif // BKE_SEQUENCER_H diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index 5b413ae4e44..4b6c5ba5459 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_simple_deform.h b/source/blender/blenkernel/BKE_simple_deform.h index 161871a64bc..b5f4a2514dd 100644 --- a/source/blender/blenkernel/BKE_simple_deform.h +++ b/source/blender/blenkernel/BKE_simple_deform.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_sketch.h b/source/blender/blenkernel/BKE_sketch.h index 424dd5c9f80..c46604f09f0 100644 --- a/source/blender/blenkernel/BKE_sketch.h +++ b/source/blender/blenkernel/BKE_sketch.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Contributor(s): none yet. * diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h index 0f8e9c5edf5..4547f869439 100644 --- a/source/blender/blenkernel/BKE_smoke.h +++ b/source/blender/blenkernel/BKE_smoke.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index 92cb5542ad1..e7fbf50ad82 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 8722485b97d..fa035d62d62 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -36,12 +36,14 @@ struct bSound; struct bContext; struct ListBase; struct Main; +struct Sequence; -void sound_init(); +void sound_init(struct Main *main); void sound_exit(); -void sound_disable(); +void sound_force_device(int device); +int sound_define_from_str(char *str); struct bSound* sound_new_file(struct Main *main, char* filename); @@ -62,20 +64,32 @@ void sound_load(struct Main *main, struct bSound* sound); void sound_free(struct bSound* sound); -void sound_unlink(struct bContext *C, struct bSound* sound); +#ifdef AUD_CAPI +AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume); +#endif -struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip); +void sound_create_scene(struct Scene *scene); -void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle); +void sound_destroy_scene(struct Scene *scene); -void sound_update_playing(struct bContext *C); +void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip); -void sound_scrub(struct bContext *C); +void sound_remove_scene_sound(struct Scene *scene, void* handle); -#ifdef AUD_CAPI -AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, int end, float volume); -#endif +void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute); + +void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip); + +void sound_play_scene(struct Scene *scene); + +void sound_stop_scene(struct Scene *scene); + +void sound_seek_scene(struct bContext *C); + +float sound_sync_scene(struct Scene *scene); + +int sound_scene_playing(struct Scene *scene); -void sound_stop_all(struct bContext *C); +int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length); #endif diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index a0db944530e..a7926e90e02 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_suggestions.h b/source/blender/blenkernel/BKE_suggestions.h index 473e3f547f2..59369d6ac14 100644 --- a/source/blender/blenkernel/BKE_suggestions.h +++ b/source/blender/blenkernel/BKE_suggestions.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008, Blender Foundation * All rights reserved. diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 185e32ecdfa..244fffa06ea 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 95ada45f5d8..ace352395d2 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -31,6 +31,7 @@ #ifndef BKE_TEXTURE_H #define BKE_TEXTURE_H +struct bNode; struct Brush; struct ColorBand; struct EnvMap; @@ -75,6 +76,8 @@ struct Tex *give_current_lamp_texture(struct Lamp *la); struct Tex *give_current_world_texture(struct World *world); struct Tex *give_current_brush_texture(struct Brush *br); +struct bNode *give_current_material_texture_node(struct Material *ma); + int give_active_mtex(struct ID *id, struct MTex ***mtex_ar, short *act); void set_active_mtex(struct ID *id, short act); diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h index 5d5f8cddf47..36ccc1f1497 100644 --- a/source/blender/blenkernel/BKE_unit.h +++ b/source/blender/blenkernel/BKE_unit.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Contributor(s): Campbell Barton * diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 7d77efc1ff2..1ad411b4c89 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -230,5 +230,13 @@ extern "C" { } #endif +/*little macro so inline keyword works*/ +#if defined(_MSC_VER) +#define BM_INLINE static __forceinline +#else +#define BM_INLINE static inline __attribute((always_inline)) #endif +#define BMEMSET(mem, val, size) {unsigned int _i; char *_c = (char*) mem; for (_i=0; _i<size; _i++) *_c++ = val;} + +#endif diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h index b8d89364e67..9d763e8f003 100644 --- a/source/blender/blenkernel/BKE_world.h +++ b/source/blender/blenkernel/BKE_world.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index e2778ebb54c..c7f26d9b76c 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index 98c385ea2e1..311676b37b5 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -45,6 +45,8 @@ extern "C" { #define FFMPEG_FLV 8 #define FFMPEG_MKV 9 #define FFMPEG_OGG 10 +#define FFMPEG_WAV 11 +#define FFMPEG_MP3 12 #define FFMPEG_PRESET_NONE 0 #define FFMPEG_PRESET_DVD 1 diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h index 50b905cfd75..036e0dbd774 100644 --- a/source/blender/blenkernel/BKE_writeframeserver.h +++ b/source/blender/blenkernel/BKE_writeframeserver.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index b1cbd16512e..da5e73bbb45 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) 2006, Blender Foundation # All rights reserved. @@ -73,6 +73,10 @@ ELSE(WITH_PYTHON) ADD_DEFINITIONS(-DDISABLE_PYTHON) ENDIF(WITH_PYTHON) +IF(WITH_OPENMP) + ADD_DEFINITIONS(-DPARALLEL=1) +ENDIF(WITH_OPENMP) + IF(NOT WITH_ELBEEM) ADD_DEFINITIONS(-DDISABLE_ELBEEM) ENDIF(NOT WITH_ELBEEM) diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 602a1234f95..dfd1e00c104 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -56,6 +56,10 @@ if env['WITH_BF_QUICKTIME']: if env['WITH_BF_BULLET']: defs.append('USE_BULLET') +if env['OURPLATFORM'] == 'darwin': + if env['WITH_BF_OPENMP']: + defs.append('PARALLEL=1') + if env['BF_NO_ELBEEM']: defs.append('DISABLE_ELBEEM') diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 47e33c0e81e..503ee973be0 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/intern/BME_Customdata.c b/source/blender/blenkernel/intern/BME_Customdata.c index ea149e03959..fa6d19f7751 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -22,7 +22,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. @@ -83,8 +83,8 @@ void BME_CD_Create(BME_CustomData *data, BME_CustomDataInit *init, int initalloc /*alloc our layers*/ if(data->totlayer){ /*alloc memory*/ - data->layers = MEM_callocN(sizeof(BME_CustomDataLayer)*data->totlayer, "BMesh Custom Data Layers"); - data->pool = BLI_mempool_create(data->totsize, initalloc, initalloc); + data->layers = MEM_callocN(sizeof(BME_CustomDataLayer)*data->totlayer, "BMesh Custom Data Layers", 1); + data->pool = BLI_mempool_create(data->totsize, initalloc, initalloc, 1); /*initialize layer data*/ for(i=0; i < BME_CD_NUMTYPES; i++){ if(init->layout[i]){ diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index 0f372790a9d..160a073be80 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index d0b4ab6a9ca..647671d0ed8 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index f635cfcfcd2..f1f9f27031b 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 Blender Foundation. * All rights reserved. @@ -55,10 +55,10 @@ BME_Mesh *BME_make_mesh(int allocsize[4]) /*allocate the structure*/ BME_Mesh *bm = MEM_callocN(sizeof(BME_Mesh),"BMesh"); /*allocate the memory pools for the mesh elements*/ - bm->vpool = BLI_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0]); - bm->epool = BLI_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1]); - bm->lpool = BLI_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2]); - bm->ppool = BLI_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3]); + bm->vpool = BLI_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0], 1); + bm->epool = BLI_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1], 1); + bm->lpool = BLI_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2], 1); + bm->ppool = BLI_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3], 1); return bm; } /* diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index 22ee48e4f7e..da0ce4da43b 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index fd41624d27c..fe82d2dab95 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index dc863869ad8..eb316c64af4 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -6,6 +6,7 @@ #include "CCGSubSurf.h" +#include "MEM_guardedalloc.h" #include "BLO_sys_types.h" // for intptr_t support #ifdef _MSC_VER @@ -467,12 +468,10 @@ static void *_edge_getCo(CCGEdge *e, int lvl, int x, int dataSize) { int levelBase = lvl + (1<<lvl) - 1; return &EDGE_getLevelData(e)[dataSize*(levelBase + x)]; } -#if 0 static float *_edge_getNo(CCGEdge *e, int lvl, int x, int dataSize, int normalDataOffset) { int levelBase = lvl + (1<<lvl) - 1; return (float*) &EDGE_getLevelData(e)[dataSize*(levelBase + x) + normalDataOffset]; } -#endif static void *_edge_getCoVert(CCGEdge *e, CCGVert *v, int lvl, int x, int dataSize) { int levelBase = lvl + (1<<lvl) - 1; if (v==e->v0) { @@ -535,6 +534,12 @@ static CCG_INLINE void *_face_getIECo(CCGFace *f, int lvl, int S, int x, int lev byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize)); return &gridBase[dataSize*x*spacing]; } +static CCG_INLINE void *_face_getIENo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize, int normalDataOffset) { + int maxGridSize = 1 + (1<<(levels-1)); + int spacing = 1<<(levels-lvl); + byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize)); + return &gridBase[dataSize*x*spacing + normalDataOffset]; +} static CCG_INLINE void *_face_getIFCo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize) { int maxGridSize = 1 + (1<<(levels-1)); int spacing = 1<<(levels-lvl); @@ -685,8 +690,8 @@ void ccgSubSurf_free(CCGSubSurf *ss) { _ehash_free(ss->oldEMap, (EHEntryFreeFP) _edge_free, ss); _ehash_free(ss->oldVMap, (EHEntryFreeFP) _vert_free, ss); - CCGSUBSURF_free(ss, ss->tempVerts); - CCGSUBSURF_free(ss, ss->tempEdges); + MEM_freeN(ss->tempVerts); + MEM_freeN(ss->tempEdges); } CCGSUBSURF_free(ss, ss->r); @@ -811,8 +816,8 @@ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss) { ss->numGrids = 0; ss->lenTempArrays = 12; - ss->tempVerts = CCGSUBSURF_alloc(ss, sizeof(*ss->tempVerts)*ss->lenTempArrays); - ss->tempEdges = CCGSUBSURF_alloc(ss, sizeof(*ss->tempEdges)*ss->lenTempArrays); + ss->tempVerts = MEM_mallocN(sizeof(*ss->tempVerts)*ss->lenTempArrays, "CCGSubsurf tempVerts"); + ss->tempEdges = MEM_mallocN(sizeof(*ss->tempEdges)*ss->lenTempArrays, "CCGSubsurf tempEdges"); ss->syncState = eSyncState_Vert; @@ -1002,10 +1007,9 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV int j, k, topologyChanged = 0; if (numVerts>ss->lenTempArrays) { - int oldLen = ss->lenTempArrays; ss->lenTempArrays = (numVerts<ss->lenTempArrays*2)?ss->lenTempArrays*2:numVerts; - ss->tempVerts = CCGSUBSURF_realloc(ss, ss->tempVerts, sizeof(*ss->tempVerts)*ss->lenTempArrays, sizeof(*ss->tempVerts)*oldLen); - ss->tempEdges = CCGSUBSURF_realloc(ss, ss->tempEdges, sizeof(*ss->tempEdges)*ss->lenTempArrays, sizeof(*ss->tempEdges)*oldLen); + ss->tempVerts = MEM_reallocN(ss->tempVerts, sizeof(*ss->tempVerts)*ss->lenTempArrays); + ss->tempEdges = MEM_reallocN(ss->tempEdges, sizeof(*ss->tempEdges)*ss->lenTempArrays); } if (ss->syncState==eSyncState_Partial) { @@ -1120,8 +1124,8 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss) { _ehash_free(ss->oldFMap, (EHEntryFreeFP) _face_unlinkMarkAndFree, ss); _ehash_free(ss->oldEMap, (EHEntryFreeFP) _edge_unlinkMarkAndFree, ss); _ehash_free(ss->oldVMap, (EHEntryFreeFP) _vert_free, ss); - CCGSUBSURF_free(ss, ss->tempEdges); - CCGSUBSURF_free(ss, ss->tempVerts); + MEM_freeN(ss->tempEdges); + MEM_freeN(ss->tempVerts); ss->lenTempArrays = 0; @@ -1139,8 +1143,11 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss) { return eCCGError_None; } +#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset) +#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset) #define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset) #define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize) +#define FACE_getIENo(f, lvl, S, x) _face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset) static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, int numEffectedV, int numEffectedE, int numEffectedF) { @@ -1304,6 +1311,26 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, } } } + + VertDataCopy((float*)((byte*)FACE_getCenterData(f) + normalDataOffset), + FACE_getIFNo(f, lvl, S, 0, 0)); + + for (x=1; x<gridSize-1; x++) + NormCopy(FACE_getIENo(f, lvl, S, x), + FACE_getIFNo(f, lvl, S, x, 0)); + } + } + + for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) { + CCGEdge *e = (CCGEdge*) effectedE[ptrIdx]; + + if (e->numFaces) { + CCGFace *f = e->faces[0]; + int x; + + for (x=0; x<edgeSize; x++) + NormCopy(EDGE_getNo(e, lvl, x), + _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } } } @@ -1664,8 +1691,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, #pragma omp critical { - q = CCGSUBSURF_alloc(ss, ss->meshIFC.vertDataSize); - r = CCGSUBSURF_alloc(ss, ss->meshIFC.vertDataSize); + q = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf q"); + r = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf r"); } #pragma omp for schedule(static) @@ -1754,8 +1781,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, #pragma omp critical { - CCGSUBSURF_free(ss, q); - CCGSUBSURF_free(ss, r); + MEM_freeN(q); + MEM_freeN(r); } } @@ -1810,9 +1837,9 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { int curLvl, nextLvl; void *q = ss->q, *r = ss->r; - effectedV = CCGSUBSURF_alloc(ss, sizeof(*effectedV)*ss->vMap->numEntries); - effectedE = CCGSUBSURF_alloc(ss, sizeof(*effectedE)*ss->eMap->numEntries); - effectedF = CCGSUBSURF_alloc(ss, sizeof(*effectedF)*ss->fMap->numEntries); + effectedV = MEM_mallocN(sizeof(*effectedV)*ss->vMap->numEntries, "CCGSubsurf effectedV"); + effectedE = MEM_mallocN(sizeof(*effectedE)*ss->eMap->numEntries, "CCGSubsurf effectedE"); + effectedF = MEM_mallocN(sizeof(*effectedF)*ss->fMap->numEntries, "CCGSubsurf effectedF"); numEffectedV = numEffectedE = numEffectedF = 0; for (i=0; i<ss->vMap->curSize; i++) { CCGVert *v = (CCGVert*) ss->vMap->buckets[i]; @@ -2070,9 +2097,9 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { e->flags = 0; } - CCGSUBSURF_free(ss, effectedF); - CCGSUBSURF_free(ss, effectedE); - CCGSUBSURF_free(ss, effectedV); + MEM_freeN(effectedF); + MEM_freeN(effectedE); + MEM_freeN(effectedV); } static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces, int *freeFaces) @@ -2081,7 +2108,7 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces int i, num; if(!*faces) { - array = CCGSUBSURF_alloc(ss, sizeof(*array)*ss->fMap->numEntries); + array = MEM_mallocN(sizeof(*array)*ss->fMap->numEntries, "CCGSubsurf allFaces"); num = 0; for (i=0; i<ss->fMap->curSize; i++) { CCGFace *f = (CCGFace*) ss->fMap->buckets[i]; @@ -2104,8 +2131,8 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces, CCGEdge **arrayE; int numV, numE, i, j; - arrayV = CCGSUBSURF_alloc(ss, sizeof(*arrayV)*ss->vMap->numEntries); - arrayE = CCGSUBSURF_alloc(ss, sizeof(*arrayE)*ss->eMap->numEntries); + arrayV = MEM_mallocN(sizeof(*arrayV)*ss->vMap->numEntries, "CCGSubsurf arrayV"); + arrayE = MEM_mallocN(sizeof(*arrayE)*ss->eMap->numEntries, "CCGSubsurf arrayV"); numV = numE = 0; for (i=0; i<numFaces; i++) { @@ -2183,7 +2210,7 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF } } - if(freeF) CCGSUBSURF_free(ss, effectedF); + if(freeF) MEM_freeN(effectedF); return eCCGError_None; } @@ -2225,7 +2252,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, } } - if(freeF) CCGSUBSURF_free(ss, effectedF); + if(freeF) MEM_freeN(effectedF); return eCCGError_None; } @@ -2270,9 +2297,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in VertDataZero(FACE_getCenterData(f)); for (S=0; S<f->numVerts; S++) - if (FACE_getEdges(f)[S]->flags&Edge_eEffected) - for (x=0; x<gridSize; x++) - VertDataZero(FACE_getIECo(f, lvl, S, x)); + for (x=0; x<gridSize; x++) + VertDataZero(FACE_getIECo(f, lvl, S, x)); for (S=0; S<f->numVerts; S++) { int prevS = (S+f->numVerts-1)%f->numVerts; @@ -2284,10 +2310,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx)); for (x=1; x<gridSize-1; x++) { - if (FACE_getEdges(f)[S]->flags&Edge_eEffected) - VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0)); - if (FACE_getEdges(f)[prevS]->flags&Edge_eEffected) - VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x)); + VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0)); + VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x)); } for (x=0; x<gridSize-1; x++) { @@ -2324,9 +2348,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts); for (S=0; S<f->numVerts; S++) - if (FACE_getEdges(f)[S]->flags&Edge_eEffected) - for (x=1; x<gridSize-1; x++) - VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f); + for (x=1; x<gridSize-1; x++) + VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f); for (S=0; S<f->numVerts; S++) { int prevS = (S+f->numVerts-1)%f->numVerts; @@ -2359,9 +2382,9 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in for (i=0; i<numEffectedF; i++) effectedF[i]->flags = 0; - CCGSUBSURF_free(ss, effectedE); - CCGSUBSURF_free(ss, effectedV); - if(freeF) CCGSUBSURF_free(ss, effectedF); + MEM_freeN(effectedE); + MEM_freeN(effectedV); + if(freeF) MEM_freeN(effectedF); return eCCGError_None; } @@ -2388,9 +2411,9 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf for (i=0; i<numEffectedF; i++) effectedF[i]->flags = 0; - CCGSUBSURF_free(ss, effectedE); - CCGSUBSURF_free(ss, effectedV); - if(freeF) CCGSUBSURF_free(ss, effectedF); + MEM_freeN(effectedE); + MEM_freeN(effectedV); + if(freeF) MEM_freeN(effectedF); return eCCGError_None; } @@ -2422,9 +2445,9 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i for (i=0; i<numEffectedF; i++) effectedF[i]->flags = 0; - CCGSUBSURF_free(ss, effectedE); - CCGSUBSURF_free(ss, effectedV); - if(freeF) CCGSUBSURF_free(ss, effectedF); + MEM_freeN(effectedE); + MEM_freeN(effectedV); + if(freeF) MEM_freeN(effectedF); return eCCGError_None; } diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 7973c2cd89d..34c85c624d3 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2005 Blender Foundation. * All rights reserved. @@ -1860,7 +1860,7 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm) static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform, - int needMapping, CustomDataMask dataMask, int index) + int needMapping, CustomDataMask dataMask, int index, int useCache) { Mesh *me = ob->data; ModifierData *firstmd, *md; @@ -1881,7 +1881,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* we always want to keep original indices */ dataMask |= CD_MASK_ORIGINDEX; - datamasks = modifiers_calcDataMasks(ob, md, dataMask, required_mode); + datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode); curr = datamasks; if(deform_r) *deform_r = NULL; @@ -1897,7 +1897,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos md->scene= scene; - if(!modifier_isEnabled(md, required_mode)) continue; + if(!modifier_isEnabled(scene, md, required_mode)) continue; if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; if(mti->type == eModifierTypeType_OnlyDeform) { @@ -1946,7 +1946,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos md->scene= scene; - if(!modifier_isEnabled(md, required_mode)) continue; + if(!modifier_isEnabled(scene, md, required_mode)) continue; if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue; if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { modifier_setError(md, "Modifier requires original data, bad stack position."); @@ -2007,8 +2007,24 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos CDDM_calc_normals(dm); } - if(dataMask & CD_MASK_WEIGHT_MCOL) + if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT)) add_weight_mcol_dm(ob, dm); + + /* constructive modifiers need to have an origindex + * otherwise they wont have anywhere to copy the data from */ + if(needMapping) { + int *index, i; + DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); + DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); + DM_add_face_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); + + index = DM_get_vert_data_layer(dm, CD_ORIGINDEX); + for(i=0; i<dm->numVertData; i++) *index++= i; + index = DM_get_edge_data_layer(dm, CD_ORIGINDEX); + for(i=0; i<dm->numEdgeData; i++) *index++= i; + index = DM_get_face_data_layer(dm, CD_ORIGINDEX); + for(i=0; i<dm->numFaceData; i++) *index++= i; + } } /* create an orco derivedmesh in parallel */ @@ -2036,7 +2052,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if(!CustomData_has_layer(&dm->faceData, CD_ORIGSPACE)) DM_add_tessface_layer(dm, CD_ORIGSPACE, CD_DEFAULT, NULL); - ndm = mti->applyModifier(md, ob, dm, useRenderParams, !inputVertexCos); + ndm = mti->applyModifier(md, ob, dm, useRenderParams, useCache); if(ndm) { /* if the modifier returned a new dm, release the old one */ @@ -2072,6 +2088,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos CDDM_apply_vert_coords(finaldm, deformedVerts); CDDM_calc_normals(finaldm); + + if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT)) + add_weight_mcol_dm(ob, finaldm); } else if(dm) { finaldm = dm; } else { @@ -2082,7 +2101,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos CDDM_calc_normals(finaldm); } - if(dataMask & CD_MASK_WEIGHT_MCOL) + if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT)) add_weight_mcol_dm(ob, finaldm); } @@ -2122,12 +2141,12 @@ static float (*editbmesh_getVertexCos(BMEditMesh *em, int *numVerts_r))[3] return cos; } -static int editbmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm) +static int editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *dm) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; - if(!modifier_isEnabled(md, required_mode)) return 0; + if(!modifier_isEnabled(scene, md, required_mode)) return 0; if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { modifier_setError(md, "Modifier requires original data, bad stack position."); return 0; @@ -2144,7 +2163,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D float (*deformedVerts)[3] = NULL; CustomDataMask mask; DerivedMesh *dm, *orcodm = NULL; - int i, numVerts = 0, cageIndex = modifiers_getCageIndex(ob, NULL, 1); + int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1); LinkNode *datamasks, *curr; int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; @@ -2160,7 +2179,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D /* we always want to keep original indices */ dataMask |= CD_MASK_ORIGINDEX; - datamasks = modifiers_calcDataMasks(ob, md, dataMask, required_mode); + datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode); curr = datamasks; for(i = 0; md; i++, md = md->next, curr = curr->next) { @@ -2168,7 +2187,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D md->scene= scene; - if(!editbmesh_modifier_is_enabled(md, dm)) + if(!editbmesh_modifier_is_enabled(scene, md, dm)) continue; /* add an orco layer if needed by this modifier */ @@ -2346,14 +2365,15 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) { Object *obact = scene->basact?scene->basact->object:NULL; int editing = paint_facesel_test(ob); - int needMapping = editing && (ob==obact); + /* weight paint and face select need original indicies because of selection buffer drawing */ + int needMapping = (ob==obact) && (editing || (ob->mode & OB_MODE_WEIGHT_PAINT) || editing); float min[3], max[3]; - + clear_mesh_caches(ob); mesh_calc_modifiers(scene, ob, NULL, &ob->derivedDeform, &ob->derivedFinal, 0, 1, - needMapping, dataMask, -1); + needMapping, dataMask, -1, 1); INIT_MINMAX(min, max); @@ -2366,7 +2386,6 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) ob->derivedFinal->needsFree = 0; ob->derivedDeform->needsFree = 0; ob->lastDataMask = dataMask; - } static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask) @@ -2440,7 +2459,7 @@ DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask { DerivedMesh *final; - mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, -1); + mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, -1, 0); return final; } @@ -2449,7 +2468,7 @@ DerivedMesh *mesh_create_derived_index_render(Scene *scene, Object *ob, CustomDa { DerivedMesh *final; - mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, index); + mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, index, 0); return final; } @@ -2458,7 +2477,7 @@ DerivedMesh *mesh_create_derived_view(Scene *scene, Object *ob, CustomDataMask d { DerivedMesh *final; - mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 0, 1, 0, dataMask, -1); + mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 0, 1, 0, dataMask, -1, 0); return final; } @@ -2468,7 +2487,7 @@ DerivedMesh *mesh_create_derived_no_deform(Scene *scene, Object *ob, float (*ver { DerivedMesh *final; - mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, 0, 0, dataMask, -1); + mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, 0, 0, dataMask, -1, 0); return final; } @@ -2478,7 +2497,7 @@ DerivedMesh *mesh_create_derived_no_virtual(Scene *scene, Object *ob, float (*ve { DerivedMesh *final; - mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, -1, 0, dataMask, -1); + mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, -1, 0, dataMask, -1, 0); return final; } @@ -2489,7 +2508,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob, { DerivedMesh *final; - mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 1, 0, 0, dataMask, -1); + mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 1, 0, 0, dataMask, -1, 0); return final; } @@ -2586,12 +2605,12 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob) /* ********* crazyspace *************** */ -int editbmesh_get_first_deform_matrices(Object *ob, BMEditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) +int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) { ModifierData *md; DerivedMesh *dm; int i, a, numleft = 0, numVerts = 0; - int cageIndex = modifiers_getCageIndex(ob, NULL, 1); + int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1); float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL; modifiers_clearErrors(ob); @@ -2605,7 +2624,7 @@ int editbmesh_get_first_deform_matrices(Object *ob, BMEditMesh *em, float (**def for(i = 0; md && i <= cageIndex; i++, md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(!editbmesh_modifier_is_enabled(md, dm)) + if(!editbmesh_modifier_is_enabled(scene, md, dm)) continue; if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { @@ -2626,7 +2645,7 @@ int editbmesh_get_first_deform_matrices(Object *ob, BMEditMesh *em, float (**def } for(; md && i <= cageIndex; md = md->next, i++) - if(editbmesh_modifier_is_enabled(md, dm) && modifier_isCorrectableDeformed(md)) + if(editbmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md)) numleft++; if(dm) diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index 95c82d31890..70e1a785787 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -129,3 +129,8 @@ ifeq ($(WITH_QUICKTIME), true) CPPFLAGS += -DWITH_QUICKTIME endif +ifeq ($(OS), darwin) + ifeq ($(WITH_BF_OPENMP), true) + CPPFLAGS += -DPARALLEL=1 + endif +endif diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index a95cc7d1816..13f247e7c3c 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -748,7 +748,7 @@ void pose_add_group (Object *ob) grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup"); strcpy(grp->name, "Group"); BLI_addtail(&pose->agroups, grp); - BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32); + BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); pose->active_group= BLI_countlist(&pose->agroups); } @@ -1028,7 +1028,7 @@ void copy_pose_result(bPose *to, bPose *from) bPoseChannel *pchanto, *pchanfrom; if(to==NULL || from==NULL) { - printf("pose result copy error\n"); // debug temp + printf("pose result copy error to:%p from:%p\n", to, from); // debug temp return; } diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index f580bbbd526..5e9f799e49f 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -155,7 +155,7 @@ void animviz_free_motionpath(bMotionPath *mpath) /* ------------------- */ -/* Setup motion paths for the given data +/* Setup motion paths for the given data * - scene: current scene (for frame ranges, etc.) * - ob: object to add paths for (must be provided) * - pchan: posechannel to add paths for (optional; if not provided, object-paths are assumed) @@ -227,8 +227,10 @@ typedef struct MPathTarget { /* ........ */ -/* get list of motion paths to be baked (assumes the list is ready to be used) */ -static void motionpaths_get_bake_targets(Object *ob, ListBase *targets) +/* get list of motion paths to be baked for the given object + * - assumes the given list is ready to be used + */ +void animviz_get_object_motionpaths(Object *ob, ListBase *targets) { MPathTarget *mpt; @@ -261,6 +263,8 @@ static void motionpaths_get_bake_targets(Object *ob, ListBase *targets) } } +/* ........ */ + /* perform baking for the targets on the current frame */ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) { @@ -271,8 +275,10 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) bMotionPath *mpath= mpt->mpath; bMotionPathVert *mpv; - /* current frame must be within the range the cache works for */ - if (IN_RANGE(CFRA, mpath->start_frame, mpath->end_frame) == 0) + /* 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 */ @@ -298,36 +304,30 @@ 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 * - scene: current scene * - ob: object whose flagged motionpaths should get calculated * - recalc: whether we need to */ // TODO: include reports pointer? -void animviz_calc_motionpaths(Scene *scene, Object *ob) +void animviz_calc_motionpaths(Scene *scene, ListBase *targets) { - ListBase targets = {NULL, NULL}; MPathTarget *mpt; int sfra, efra; int cfra; - /* sanity checks */ - if (ob == NULL) - return; - - /* get motion paths to affect */ - motionpaths_get_bake_targets(ob, &targets); - - if (targets.first == NULL) + /* sanity check */ + if (ELEM(NULL, targets, targets->first)) return; /* set frame values */ cfra = CFRA; sfra = efra = cfra; - for (mpt= targets.first; mpt; mpt= mpt->next) { + // TODO: this method could be improved... + // 1) max range for standard baking + // 2) minimum range for recalc baking (i.e. between keyfames, but how?) + for (mpt= targets->first; mpt; mpt= mpt->next) { /* try to increase area to do (only as much as needed) */ sfra= MIN2(sfra, mpt->mpath->start_frame); efra= MAX2(efra, mpt->mpath->end_frame); @@ -341,23 +341,29 @@ void animviz_calc_motionpaths(Scene *scene, Object *ob) * that doesn't force complete update, but for now, this is the * most accurate way! */ - scene_update_for_newframe(scene, ob->lay); // XXX is the layer flag too restrictive? + scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving /* perform baking for targets */ - motionpaths_calc_bake_targets(scene, &targets); + motionpaths_calc_bake_targets(scene, targets); } /* reset original environment */ CFRA= cfra; - scene_update_for_newframe(scene, ob->lay); // XXX is the layer flag too restrictive? - - // TODO: make an API call for this too? - ob->avs.recalc &= ~ANIMVIZ_RECALC_PATHS; - if (ob->pose) - ob->pose->avs.recalc &= ~ANIMVIZ_RECALC_PATHS; + scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving - /* free temp data */ - BLI_freelistN(&targets); + /* 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; + } } /* ******************************************************************** */ @@ -1074,7 +1080,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p ParticleCacheKey *cache; float ctime, pa_time, scale = 1.0f; float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size=0.0; - float (*obmat)[4], (*oldobmat)[4]; + float (*obmat)[4], (*oldobmat)[4], recurs_mat[4][4]; int lay, a, b, counter, hair = 0; int totpart, totchild, totgroup=0, pa_num; @@ -1090,6 +1096,10 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if(!psys_check_enabled(par, psys)) return; + + /* particles are already in world space, don't want the object mat twice */ + if(par_space_mat) + mul_m4_m4m4(recurs_mat, psys->imat, par_space_mat); ctime = bsystem_time(scene, par, (float)scene->r.cfra, 0.0); @@ -1234,7 +1244,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p mul_m4_m4m4(tmat, oblist[b]->obmat, pamat); mul_mat3_m4_fl(tmat, size*scale); if(par_space_mat) - mul_m4_m4m4(mat, tmat, par_space_mat); + mul_m4_m4m4(mat, tmat, recurs_mat); else copy_m4_m4(mat, tmat); @@ -1260,7 +1270,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p VECADD(tmat[3], tmat[3], vec); if(par_space_mat) - mul_m4_m4m4(mat, tmat, par_space_mat); + mul_m4_m4m4(mat, tmat, recurs_mat); else copy_m4_m4(mat, tmat); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 2a5a12cc513..a880417a111 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. @@ -60,8 +60,8 @@ /* Getter/Setter -------------------------------------------- */ -/* Internal utility to check if ID can have AnimData */ -static short id_has_animdata (ID *id) +/* Check if ID can have AnimData */ +short id_type_can_have_animdata (ID *id) { /* sanity check */ if (id == NULL) @@ -99,7 +99,7 @@ AnimData *BKE_animdata_from_id (ID *id) * types that do to be of type IdAdtTemplate, and extract the * AnimData that way */ - if (id_has_animdata(id)) { + if (id_type_can_have_animdata(id)) { IdAdtTemplate *iat= (IdAdtTemplate *)id; return iat->adt; } @@ -117,7 +117,7 @@ AnimData *BKE_id_add_animdata (ID *id) * types that do to be of type IdAdtTemplate, and add the AnimData * to it using the template */ - if (id_has_animdata(id)) { + if (id_type_can_have_animdata(id)) { IdAdtTemplate *iat= (IdAdtTemplate *)id; /* check if there's already AnimData, in which case, don't add */ @@ -145,7 +145,7 @@ void BKE_free_animdata (ID *id) /* Only some ID-blocks have this info for now, so we cast the * types that do to be of type IdAdtTemplate */ - if (id_has_animdata(id)) { + if (id_type_can_have_animdata(id)) { IdAdtTemplate *iat= (IdAdtTemplate *)id; AnimData *adt= iat->adt; @@ -422,10 +422,54 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, c MEM_freeN(newN); } +/* Whole Database Ops -------------------------------------------- */ + +/* apply the given callback function on all data in main database */ +void BKE_animdata_main_cb (Main *main, ID_AnimData_Edit_Callback func, void *user_data) +{ + ID *id; + +#define ANIMDATA_IDS_CB(first) \ + for (id= first; id; id= id->next) { \ + AnimData *adt= BKE_animdata_from_id(id); \ + if (adt) func(id, adt, user_data); \ + } + + ANIMDATA_IDS_CB(main->nodetree.first); /* nodes */ + ANIMDATA_IDS_CB(main->tex.first); /* textures */ + ANIMDATA_IDS_CB(main->lamp.first); /* lamps */ + ANIMDATA_IDS_CB(main->mat.first); /* materials */ + ANIMDATA_IDS_CB(main->camera.first); /* cameras */ + ANIMDATA_IDS_CB(main->key.first); /* shapekeys */ + ANIMDATA_IDS_CB(main->mball.first); /* metaballs */ + ANIMDATA_IDS_CB(main->curve.first); /* curves */ + ANIMDATA_IDS_CB(main->armature.first); /* armatures */ + ANIMDATA_IDS_CB(main->mesh.first); /* meshes */ + ANIMDATA_IDS_CB(main->particle.first); /* particles */ + ANIMDATA_IDS_CB(main->object.first); /* objects */ + ANIMDATA_IDS_CB(main->world.first); /* worlds */ + + /* scenes */ + for (id= main->scene.first; id; id= id->next) { + AnimData *adt= BKE_animdata_from_id(id); + Scene *scene= (Scene *)id; + + /* do compositing nodes first (since these aren't included in main tree) */ + if (scene->nodetree) { + AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree); + if (adt2) func(id, adt2, user_data); + } + + /* now fix scene animation data as per normal */ + if (adt) func((ID *)id, adt, user_data); + } +} + /* Fix all RNA-Paths throughout the database (directly access the Global.main version) * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]> * i.e. pose.bones["Bone"] */ +/* TODO: use BKE_animdata_main_cb for looping over all data */ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newName) { Main *mainptr= G.main; @@ -503,7 +547,7 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa /* Find the first path that matches the given criteria */ // TODO: do we want some method to perform partial matches too? -KS_Path *BKE_keyingset_find_destination (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode) +KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode) { KS_Path *ksp; @@ -560,7 +604,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet"); if (name) - BLI_snprintf(ks->name, 64, name); + strncpy(ks->name, name, sizeof(ks->name)); else strcpy(ks->name, "KeyingSet"); @@ -571,7 +615,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho BLI_addtail(list, ks); /* make sure KeyingSet has a unique name (this helps with identification) */ - BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), 64); + BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), sizeof(ks->name)); /* return new KeyingSet for further editing */ return ks; @@ -580,7 +624,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho /* Add a destination to a KeyingSet. Nothing is returned for now... * Checks are performed to ensure that destination is appropriate for the KeyingSet in question */ -void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode) +void BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode) { KS_Path *ksp; @@ -599,7 +643,7 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name } /* don't add if there is already a matching KS_Path in the KeyingSet */ - if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode)) { + if (BKE_keyingset_find_path(ks, id, group_name, rna_path, array_index, groupmode)) { if (G.f & G_DEBUG) printf("ERROR: destination already exists in Keying Set \n"); return; @@ -733,26 +777,20 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(&new_ptr, prop)) { - if (RNA_property_editable_index(&new_ptr, prop, array_index)) - RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(&new_ptr, prop)) + RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_boolean_set(&new_ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(&new_ptr, prop)){ - if (RNA_property_editable_index(&new_ptr, prop, array_index)) - RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(&new_ptr, prop)) + RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_int_set(&new_ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(&new_ptr, prop)) { - if (RNA_property_editable_index(&new_ptr, prop, array_index)) - RNA_property_float_set_index(&new_ptr, prop, array_index, value); - } + if (RNA_property_array_length(&new_ptr, prop)) + RNA_property_float_set_index(&new_ptr, prop, array_index, value); else RNA_property_float_set(&new_ptr, prop, value); break; @@ -1476,26 +1514,20 @@ void nladata_flush_channels (ListBase *channels) switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(ptr, prop)) { - if (RNA_property_editable_index(ptr, prop, array_index)) - RNA_property_boolean_set_index(ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(ptr, prop)) + RNA_property_boolean_set_index(ptr, prop, array_index, (int)value); else RNA_property_boolean_set(ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(ptr, prop)) { - if (RNA_property_editable_index(ptr, prop, array_index)) - RNA_property_int_set_index(ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(ptr, prop)) + RNA_property_int_set_index(ptr, prop, array_index, (int)value); else RNA_property_int_set(ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(ptr, prop)) { - if (RNA_property_editable_index(ptr, prop, array_index)) - RNA_property_float_set_index(ptr, prop, array_index, value); - } + if (RNA_property_array_length(ptr, prop)) + RNA_property_float_set_index(ptr, prop, array_index, value); else RNA_property_float_set(ptr, prop, value); break; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 348daeaf45e..41fe3da248e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -275,7 +275,7 @@ void bone_flip_name (char *name, int strip_number) /* We first check the case with a .### extension, let's find the last period */ if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrance + index= strrchr(name, '.'); // last occurrence if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! if(strip_number==0) strcpy(number, index); @@ -1267,8 +1267,36 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) VECCOPY(outloc, nLocMat[3]); } + +/* Apply a 4x4 matrix to the pose bone, + * similar to object_apply_mat4() + */ +void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4]) +{ + /* location */ + copy_v3_v3(pchan->loc, mat[3]); + + /* scale */ + mat4_to_size(pchan->size, mat); + + /* rotation */ + if (pchan->rotmode == ROT_MODE_AXISANGLE) { + float tmp_quat[4]; + + /* need to convert to quat first (in temp var)... */ + mat4_to_quat(tmp_quat, mat); + quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, tmp_quat); + } + else if (pchan->rotmode == ROT_MODE_QUAT) { + mat4_to_quat(pchan->quat, mat); + } + else { + mat4_to_eulO(pchan->eul, pchan->rotmode, mat); + } +} + /* Remove rest-position effects from pose-transform for obtaining - * 'visual' transformation of pose-channel. + * 'visual' transformation of pose-channel. * (used by the Visual-Keyframing stuff) */ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]) @@ -1475,7 +1503,8 @@ void where_is_armature (bArmature *arm) } } -/* if bone layer is protected, copy the data from from->pose */ +/* if bone layer is protected, copy the data from from->pose + * when used with linked libraries this copies from the linked pose into the local pose */ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected) { bPose *pose= ob->pose, *frompose= from->pose; @@ -1516,9 +1545,10 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected pose->active_group= frompose->active_group; for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { + pchanp= get_pose_channel(frompose, pchan->name); + if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; - pchanp= get_pose_channel(frompose, pchan->name); /* copy posechannel to temp, but restore important pointers */ pchanw= *pchanp; @@ -1529,9 +1559,15 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected pchanw.path= NULL; /* this is freed so copy a copy, else undo crashes */ - if(pchanw.prop) + if(pchanw.prop) { pchanw.prop= IDP_CopyProperty(pchanw.prop); + /* use the values from the 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 @@ -1566,6 +1602,30 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected /* the final copy */ *pchan= pchanw; } + else { + /* always copy custom shape */ + pchan->custom= pchanp->custom; + pchan->custom_tx= pchanp->custom_tx; + + /* ID-Property Syncing */ + { + IDProperty *prop_orig= pchan->prop; + if(pchanp->prop) { + pchan->prop= IDP_CopyProperty(pchanp->prop); + if(prop_orig) { + /* copy existing values across when types match */ + IDP_SyncGroupValues(pchan->prop, prop_orig); + } + } + else { + pchan->prop= NULL; + } + if (prop_orig) { + IDP_FreeProperty(prop_orig); + MEM_freeN(prop_orig); + } + } + } } } @@ -1598,7 +1658,13 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) int counter=0; /* only done here */ - if(ob->pose==NULL) ob->pose= MEM_callocN(sizeof(bPose), "new pose"); + if(ob->pose==NULL) { + /* create new pose */ + ob->pose= MEM_callocN(sizeof(bPose), "new pose"); + + /* set default settings for animviz */ + animviz_settings_init(&ob->pose->avs); + } pose= ob->pose; /* clear */ @@ -1623,8 +1689,10 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) // printf("rebuild pose %s, %d bones\n", ob->id.name, counter); /* synchronize protected layers with proxy */ - if(ob->proxy) + if(ob->proxy) { + object_copy_proxy_drivers(ob, ob->proxy); pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected); + } update_pose_constraint_flags(ob->pose); // for IK detection for example @@ -1857,7 +1925,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o float splineVec[3], scaleFac, radius=1.0f; /* firstly, calculate the bone matrix the standard way, since this is needed for roll control */ - where_is_pose_bone(scene, ob, pchan, ctime); + where_is_pose_bone(scene, ob, pchan, ctime, 1); VECCOPY(poseHead, pchan->pose_head); VECCOPY(poseTail, pchan->pose_tail); @@ -1880,6 +1948,12 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* tail endpoint */ if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) { + /* apply curve's object-mode transforms to the position + * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root) + */ + if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0) + mul_m4_v3(ikData->tar->obmat, vec); + /* convert the position to pose-space, then store it */ mul_m4_v3(ob->imat, vec); interp_v3_v3v3(poseTail, pchan->pose_tail, vec, tailBlendFac); @@ -1890,6 +1964,12 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* head endpoint */ if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) { + /* apply curve's object-mode transforms to the position + * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root) + */ + if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0) + mul_m4_v3(ikData->tar->obmat, vec); + /* store the position, and convert it to pose space */ mul_m4_v3(ob->imat, vec); VECCOPY(poseHead, vec); @@ -2004,11 +2084,9 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o * the shape but be moved elsewhere */ if (ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) { - VECCOPY(poseMat[3], pchan->pose_head); - } - else { - VECCOPY(poseMat[3], poseHead); + VECCOPY(poseHead, pchan->pose_head); } + VECCOPY(poseMat[3], poseHead); /* finally, store the new transform */ copy_m4_m4(pchan->pose_mat, poseMat); @@ -2053,44 +2131,59 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_ /* ********************** THE POSE SOLVER ******************* */ - -/* loc/rot/size to mat4 */ -/* used in constraint.c too */ -void chan_calc_mat(bPoseChannel *chan) +/* loc/rot/size to given mat4 */ +void pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) { float smat[3][3]; float rmat[3][3]; float tmat[3][3]; /* get scaling matrix */ - size_to_mat3( smat,chan->size); + size_to_mat3(smat, pchan->size); /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ - if (chan->rotmode > 0) { + if (pchan->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - eulO_to_mat3( rmat,chan->eul, chan->rotmode); + eulO_to_mat3(rmat, pchan->eul, pchan->rotmode); } - else if (chan->rotmode == ROT_MODE_AXISANGLE) { + else if (pchan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - axis_angle_to_mat3( rmat,chan->rotAxis, chan->rotAngle); + axis_angle_to_mat3(rmat, pchan->rotAxis, pchan->rotAngle); } else { /* quats are normalised before use to eliminate scaling issues */ - normalize_qt(chan->quat); // TODO: do this with local vars only! - quat_to_mat3( rmat,chan->quat); + float quat[4]; + + /* NOTE: we now don't normalise the stored values anymore, since this was kindof evil in some cases + * but if this proves to be too problematic, switch back to the old system of operating directly on + * the stored copy + */ + QUATCOPY(quat, pchan->quat); + normalize_qt(quat); + quat_to_mat3(rmat, quat); } /* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */ mul_m3_m3m3(tmat, rmat, smat); - copy_m4_m3(chan->chan_mat, tmat); + copy_m4_m3(chan_mat, tmat); /* prevent action channels breaking chains */ /* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */ - if ((chan->bone==NULL) || !(chan->bone->flag & BONE_CONNECTED)) { - VECCOPY(chan->chan_mat[3], chan->loc); + if ((pchan->bone==NULL) || !(pchan->bone->flag & BONE_CONNECTED)) { + VECCOPY(chan_mat[3], pchan->loc); } } +/* loc/rot/size to mat4 */ +/* used in constraint.c too */ +void chan_calc_mat(bPoseChannel *pchan) +{ + /* this is just a wrapper around the copy of this function which calculates the matrix + * and stores the result in any given channel + */ + pchan_to_mat4(pchan, pchan->chan_mat); +} + /* NLA strip modifiers */ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseChannel *pchan) { @@ -2215,8 +2308,10 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha /* The main armature solver, does all constraints excluding IK */ -/* pchan is validated, as having bone and parent pointer */ -void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime) +/* pchan is validated, as having bone and parent pointer + * 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers. + */ +void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, int do_extra) { Bone *bone, *parbone; bPoseChannel *parchan; @@ -2228,8 +2323,9 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti parchan= pchan->parent; /* this gives a chan_mat with actions (ipos) results */ - chan_calc_mat(pchan); - + if(do_extra) chan_calc_mat(pchan); + else unit_m4(pchan->chan_mat); + /* construct the posemat based on PoseChannels, that we do before applying constraints */ /* pose_mat(b)= pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */ @@ -2294,32 +2390,34 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti add_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset); } - /* do NLA strip modifiers - i.e. curve follow */ - do_strip_modifiers(scene, ob, bone, pchan); - - /* Do constraints */ - if (pchan->constraints.first) { - bConstraintOb *cob; - - /* make a copy of location of PoseChannel for later */ - VECCOPY(vec, pchan->pose_mat[3]); - - /* prepare PoseChannel for Constraint solving - * - makes a copy of matrix, and creates temporary struct to use - */ - cob= constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); - - /* Solve PoseChannel's Constraints */ - solve_constraints(&pchan->constraints, cob, ctime); // ctime doesnt alter objects - - /* cleanup after Constraint Solving - * - applies matrix back to pchan, and frees temporary struct used - */ - constraints_clear_evalob(cob); + if(do_extra) { + /* do NLA strip modifiers - i.e. curve follow */ + do_strip_modifiers(scene, ob, bone, pchan); - /* prevent constraints breaking a chain */ - if(pchan->bone->flag & BONE_CONNECTED) { - VECCOPY(pchan->pose_mat[3], vec); + /* Do constraints */ + if (pchan->constraints.first) { + bConstraintOb *cob; + + /* make a copy of location of PoseChannel for later */ + VECCOPY(vec, pchan->pose_mat[3]); + + /* prepare PoseChannel for Constraint solving + * - makes a copy of matrix, and creates temporary struct to use + */ + cob= constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); + + /* Solve PoseChannel's Constraints */ + solve_constraints(&pchan->constraints, cob, ctime); // ctime doesnt alter objects + + /* cleanup after Constraint Solving + * - applies matrix back to pchan, and frees temporary struct used + */ + constraints_clear_evalob(cob); + + /* prevent constraints breaking a chain */ + if(pchan->bone->flag & BONE_CONNECTED) { + VECCOPY(pchan->pose_mat[3], vec); + } } } @@ -2391,7 +2489,7 @@ void where_is_pose (Scene *scene, Object *ob) } /* 5. otherwise just call the normal solver */ else if(!(pchan->flag & POSE_DONE)) { - where_is_pose_bone(scene, ob, pchan, ctime); + where_is_pose_bone(scene, ob, pchan, ctime, 1); } } /* 6. release the IK tree */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index f3e46104efc..81f3aeeffb6 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -103,76 +103,6 @@ short ENDIAN_ORDER; char versionstr[48]= ""; -/* ************************************************ */ -/* pushpop facility: to store data temporally, FIFO! */ - -ListBase ppmain={0, 0}; - -typedef struct PushPop { - struct PushPop *next, *prev; - void *data; - int len; -} PushPop; - -void pushdata(void *data, int len) -{ - PushPop *pp; - - pp= MEM_mallocN(sizeof(PushPop), "pushpop"); - BLI_addtail(&ppmain, pp); - pp->data= MEM_mallocN(len, "pushpop"); - pp->len= len; - memcpy(pp->data, data, len); -} - -void popfirst(void *data) -{ - PushPop *pp; - - pp= ppmain.first; - if(pp) { - memcpy(data, pp->data, pp->len); - BLI_remlink(&ppmain, pp); - MEM_freeN(pp->data); - MEM_freeN(pp); - } - else printf("error in popfirst\n"); -} - -void poplast(void *data) -{ - PushPop *pp; - - pp= ppmain.last; - if(pp) { - memcpy(data, pp->data, pp->len); - BLI_remlink(&ppmain, pp); - MEM_freeN(pp->data); - MEM_freeN(pp); - } - else printf("error in poplast\n"); -} - -void free_pushpop() -{ - PushPop *pp; - - pp= ppmain.first; - while(pp) { - BLI_remlink(&ppmain, pp); - MEM_freeN(pp->data); - MEM_freeN(pp); - } -} - -void pushpop_test() -{ - if(ppmain.first) printf("pushpop not empty\n"); - free_pushpop(); -} - - - /* ********** free ********** */ /* only to be called on exit blender */ @@ -278,7 +208,6 @@ static void clean_paths(Main *main) static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) { - Object *ob; bScreen *curscreen= NULL; Scene *curscene= NULL; int recover; @@ -362,8 +291,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) if (G.f & G_SWAP_EXCHANGE) bfd->globalf |= G_SWAP_EXCHANGE; else bfd->globalf &= ~G_SWAP_EXCHANGE; - if ((U.flag & USER_DONT_DOSCRIPTLINKS)) bfd->globalf &= ~G_DOSCRIPTLINKS; - G.f= bfd->globalf; if (!G.background) { @@ -374,8 +301,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) if(G.main->versionfile < 250) do_versions_ipos_to_animato(G.main); // XXX fixme... complicated versionpatching - /* in case of autosave or quit.blend, use original filename instead */ - if(recover && bfd->filename[0]) + /* in case of autosave or quit.blend, use original filename instead + * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */ + if(recover && bfd->filename[0] && G.relbase_valid) filename= bfd->filename; /* these are the same at times, should never copy to the same location */ @@ -387,14 +315,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) /* baseflags, groups, make depsgraph, etc */ set_scene_bg(CTX_data_scene(C)); - /* last stage of do_versions actually, that sets recalc flags for recalc poses */ - for(ob= G.main->object.first; ob; ob= ob->id.next) { - if(ob->type==OB_ARMATURE) - if(ob->recalc) object_handle_update(CTX_data_scene(C), ob); - } - - /* now tag update flags, to ensure deformers get calculated on redraw */ - DAG_scene_update_flags(CTX_data_scene(C), CTX_data_scene(C)->lay); + DAG_on_load_update(); MEM_freeN(bfd); } @@ -435,7 +356,7 @@ void BKE_userdef_free(void) BLI_freelistN(&U.uifonts); BLI_freelistN(&U.themes); BLI_freelistN(&U.keymaps); - + BLI_freelistN(&U.addons); } /* returns: @@ -449,6 +370,9 @@ int BKE_read_file(bContext *C, char *dir, void *unused, ReportList *reports) BlendFileData *bfd; int retval= 1; + if(strstr(dir, ".B25.blend")==0) /* dont print user-pref loading */ + printf("read blend: %s\n", dir); + bfd= BLO_read_from_file(dir, reports); if (bfd) { if(bfd->user) retval= 2; @@ -495,6 +419,7 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report return (bfd?1:0); } + /* ***************** testing for break ************* */ static void (*blender_test_break_cb)(void)= NULL; @@ -790,3 +715,20 @@ void BKE_undo_save(char *fname) else printf("Saved session recovery to %s\n", fname); } +/* sets curscene */ +Main *BKE_undo_get_main(Scene **scene) +{ + Main *mainp= NULL; + BlendFileData *bfd= BLO_read_from_memfile(G.main, G.sce, &curundo->memfile, NULL); + + if(bfd) { + mainp= bfd->main; + if(scene) + *scene= bfd->curscene; + + MEM_freeN(bfd); + } + + return mainp; +} + diff --git a/source/blender/blenkernel/intern/bmesh_private.h b/source/blender/blenkernel/intern/bmesh_private.h index dd7d20bcf15..713194c9806 100644 --- a/source/blender/blenkernel/intern/bmesh_private.h +++ b/source/blender/blenkernel/intern/bmesh_private.h @@ -22,7 +22,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 09770b2b4ba..409e7edb519 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 838e595d83f..b521ec41cba 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 by Janne Karhu. * All rights reserved. @@ -77,6 +77,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, EffectedPoint epoint; ListBase *effectors = bbd->sim->psys->effectors; EffectorCache *cur, *eff = NULL; + EffectorCache temp_eff; EffectorData efd, cur_efd; float mul = (rule->type == eBoidRuleType_Avoid ? 1.0 : -1.0); float priority = 0.0f, len = 0.0f; @@ -91,7 +92,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, if(gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != bpa->ground)) { if(gabr->ob == eob) { - /* TODO: objects without any effector and effectors with multiple points */ + /* TODO: effectors with multiple points */ if(get_effector_data(cur, &efd, &epoint, 0)) { if(cur->pd && cur->pd->forcefield == PFIELD_BOID) priority = mul * pd->f_strength * effector_falloff(cur, &efd, &epoint, bbd->part->effector_weights); @@ -105,7 +106,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, } else if(rule->type == eBoidRuleType_Goal && eob == bpa->ground) ; /* skip current object */ - else if(pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && get_effector_data(eff, &efd, &epoint, 0)) { + else if(pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && get_effector_data(cur, &cur_efd, &epoint, 0)) { float temp = mul * pd->f_strength * effector_falloff(cur, &cur_efd, &epoint, bbd->part->effector_weights); if(temp == 0.0f) @@ -125,11 +126,21 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, } } + /* if the object doesn't have effector data we have to fake it */ + if(eff == NULL && gabr->ob) { + memset(&temp_eff, 0, sizeof(EffectorCache)); + temp_eff.ob = gabr->ob; + temp_eff.scene = bbd->sim->scene; + eff = &temp_eff; + get_effector_data(eff, &efd, &epoint, 0); + priority = 1.0f; + } + /* then use that effector */ if(priority > (rule->type==eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) { /* with avoid, factor is "fear factor" */ Object *eob = eff->ob; - PartDeflect *pd = eob->pd; - float surface = pd->shape == PFIELD_SHAPE_SURFACE ? 1.0f : 0.0f; + PartDeflect *pd = eff->pd; + float surface = (pd && pd->shape == PFIELD_SHAPE_SURFACE) ? 1.0f : 0.0f; if(gabr->options & BRULE_GOAL_AVOID_PREDICT) { /* estimate future location of target */ @@ -151,8 +162,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, else if(rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing && priority > 2.0f * gabr->fear_factor) { /* detach from surface and try to fly away from danger */ - VECCOPY(efd.vec_to_point, bpa->gravity); - mul_v3_fl(efd.vec_to_point, -1.0f); + negate_v3_v3(efd.vec_to_point, bpa->gravity); } VECCOPY(bbd->wanted_co, efd.vec_to_point); @@ -219,10 +229,19 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * } /* then avoid that object */ if(hit.index>=0) { - /* TODO: not totally happy with this part */ t = hit.dist/col.ray_len; - VECCOPY(bbd->wanted_co, col.nor); + /* avoid head-on collision */ + if(dot_v3v3(col.nor, pa->prev_state.ave) < -0.99) { + /* don't know why, but uneven range [0.0,1.0] */ + /* works much better than even [-1.0,1.0] */ + bbd->wanted_co[0] = BLI_frand(); + bbd->wanted_co[1] = BLI_frand(); + bbd->wanted_co[2] = BLI_frand(); + } + else { + VECCOPY(bbd->wanted_co, col.nor); + } mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size); @@ -669,7 +688,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) { /* decide to flee */ if(closest_dist < fbr->flee_distance * fbr->distance) { - mul_v3_fl(bbd->wanted_co, -1.0f); + negate_v3(bbd->wanted_co); bbd->wanted_speed = val->max_speed; } else { /* wait for better odds */ @@ -1322,9 +1341,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) float grav[3]; /* Don't take gravity's strength in to account, */ /* otherwise amount of banking is hard to control. */ - VECCOPY(grav, ground_nor); - mul_v3_fl(grav, -1.0f); - + negate_v3_v3(grav, ground_nor); + project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel); sub_v3_v3v3(dvec, bpa->data.acc, dvec); @@ -1367,7 +1385,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECCOPY(mat[2], bpa->gravity); } - mul_v3_fl(mat[2], -1.0f); + negate_v3(mat[2]); cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 5ffcf62abd2..f9b9b33d4ae 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 15a3d042622..1e99661f445 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 99cd6975665..bc30b2669e8 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -89,6 +89,8 @@ Brush *add_brush(const char *name) brush->flag |= BRUSH_SPACE; brush_curve_preset(brush, CURVE_PRESET_SMOOTH); + + default_mtex(&brush->mtex); /* enable fake user by default */ brush->id.flag |= LIB_FAKEUSER; diff --git a/source/blender/blenkernel/intern/bullet.c b/source/blender/blenkernel/intern/bullet.c index 44e8ed1f08c..238d3e7f682 100644 --- a/source/blender/blenkernel/intern/bullet.c +++ b/source/blender/blenkernel/intern/bullet.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 6a3c416bbab..082910869bf 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 91e33eef08a..89fb01dc5c7 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. @@ -426,15 +426,17 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, } if(cddm->pbvh) { - float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL); + if(dm->numFaceData) { + float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL); - /* should be per face */ - if(dm->numFaceData && mface->flag & ME_SMOOTH) - glShadeModel(GL_SMOOTH); - - BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors); + /* should be per face */ + if(!setMaterial(mface->mat_nr+1, NULL)) + return; - glShadeModel(GL_FLAT); + glShadeModel((mface->flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT); + BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors); + glShadeModel(GL_FLAT); + } return; } @@ -781,7 +783,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us if(!mc) mc = DM_get_tessface_data_layer(dm, CD_MCOL); - if( GPU_buffer_legacy(dm) ) { + /* back-buffer always uses legacy since VBO's would need the + * color array temporarily overwritten for drawing, then reset. */ + if( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) { DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" ); for(i = 0; i < dm->numFaceData; i++, mf++) { int drawSmooth = (mf->flag & ME_SMOOTH); @@ -870,7 +874,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us dontdraw = 1; } else - orig = i; + orig = actualFace; if( dontdraw ) { state = 0; } @@ -1029,26 +1033,48 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo char *varray = 0; int numdata = 0, elementsize = 0, offset; int start = 0, numfaces = 0, prevdraw = 0, curface = 0; - GPUAttrib datatypes[32]; + int i; + + MFace *mf = mface; + GPUAttrib datatypes[GPU_MAX_ATTRIB]; /* TODO, messing up when switching materials many times - [#21056]*/ memset(&attribs, 0, sizeof(attribs)); GPU_vertex_setup(dm); GPU_normal_setup(dm); if( !GPU_buffer_legacy(dm) ) { - for(a = 0; a < dm->numFaceData; a++, mface++) { + for( i = 0; i < dm->drawObject->nelements/3; i++ ) { + + a = dm->drawObject->faceRemap[i]; + + mface = mf + a; new_matnr = mface->mat_nr + 1; if(new_matnr != matnr ) { numfaces = curface - start; if( numfaces > 0 ) { - if( prevdraw ) { - GPU_buffer_unlock(buffer); - GPU_interleaved_attrib_setup(buffer,datatypes,numdata); + + if( dodraw ) { + + if( numdata != 0 ) { + + GPU_buffer_unlock(buffer); + + GPU_interleaved_attrib_setup(buffer,datatypes,numdata); + } + glDrawArrays(GL_TRIANGLES,start*3,numfaces*3); - GPU_buffer_free(buffer,0); + + if( numdata != 0 ) { + + GPU_buffer_free(buffer,0); + + buffer = 0; + } + } } + numdata = 0; start = curface; prevdraw = dodraw; dodraw = setMaterial(matnr = new_matnr, &gattribs); @@ -1095,6 +1121,12 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo return; } } + else { + /* if the buffer was set, dont use it again. + * prevdraw was assumed true but didnt run so set to false - [#21036] */ + prevdraw= 0; + buffer= NULL; + } } } if(!dodraw) { @@ -1138,9 +1170,10 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } for(b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - VECCOPY((float *)&varray[elementsize*curface*3+offset],tf->uv[0]); - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[1]); - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[2]); + VECCOPY2D((float *)&varray[elementsize*curface*3+offset],tf->uv[0]); + VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[1]); + + VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[2]); offset += sizeof(float)*2; } for(b = 0; b < attribs.totmcol; b++) { @@ -1162,7 +1195,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo tang = attribs.tang.array[a*4 + 1]; VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); tang = attribs.tang.array[a*4 + 2]; - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); + VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); offset += sizeof(float)*3; } } @@ -1178,9 +1211,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } for(b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - VECCOPY((float *)&varray[elementsize*curface*3+offset],tf->uv[2]); - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[3]); - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[0]); + VECCOPY2D((float *)&varray[elementsize*curface*3+offset],tf->uv[2]); + VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[3]); + VECCOPY2D((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[0]); offset += sizeof(float)*2; } for(b = 0; b < attribs.totmcol; b++) { @@ -1202,11 +1235,12 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo tang = attribs.tang.array[a*4 + 3]; VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); tang = attribs.tang.array[a*4 + 0]; - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); + VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); offset += sizeof(float)*3; } } curface++; + i++; } } numfaces = curface - start; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 2fdfaaabc01..bb3c8476a2a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. @@ -479,7 +479,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } } - // unused in the moment, calculated seperately in implicit.c + // unused in the moment, calculated separately in implicit.c clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame; /* handle continuous simulation with the play button */ @@ -546,7 +546,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, implicit_set_positions(clmd); cache->flag |= PTCACHE_SIMULATION_VALID; } - else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { + else if( /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ /* if baked and nothing in cache, do nothing */ cache->flag &= ~PTCACHE_SIMULATION_VALID; cache->simframe= 0; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 2ea54ac1f03..b024ba5f4e1 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. @@ -313,6 +313,7 @@ gsl_poly_solve_quadratic (double a, double b, double c, * See Bridson et al. "Robust Treatment of Collision, Contact and Friction for Cloth Animation" * page 4, left column */ +#if 0 static int cloth_get_collision_time ( double a[3], double b[3], double c[3], double d[3], double e[3], double f[3], double solution[3] ) { int num_sols = 0; @@ -424,6 +425,7 @@ static int cloth_get_collision_time ( double a[3], double b[3], double c[3], dou return num_sols; } +#endif // w3 is not perfect @@ -837,6 +839,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo } #endif +#if 0 static float projectPointOntoLine(float *p, float *a, float *b) { float ba[3], pa[3]; @@ -1067,7 +1070,6 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float return 0; } -#if 0 static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair ) { EdgeCollPair edgecollpair; @@ -1548,8 +1550,8 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision // cloth - object collisions int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, float dt ) { - Cloth *cloth=NULL; - BVHTree *cloth_bvh=NULL; + Cloth *cloth= clmd->clothObject; + BVHTree *cloth_bvh= cloth->bvhtree; int i=0, numfaces = 0, numverts = 0, k, l, j; int rounds = 0; // result counts applied collisions; ic is for debug output; ClothVertex *verts = NULL; @@ -1557,16 +1559,12 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl Object **collobjs = NULL; int numcollobj = 0; - if ( ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) || ! ( ( ( Cloth * ) clmd->clothObject )->bvhtree ) ) - { + if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ) || cloth_bvh==NULL) return 0; - } - cloth = clmd->clothObject; verts = cloth->verts; - cloth_bvh = ( BVHTree * ) cloth->bvhtree; - numfaces = clmd->clothObject->numfaces; - numverts = clmd->clothObject->numverts; + numfaces = cloth->numfaces; + numverts = cloth->numverts; //////////////////////////////////////////////////////////// // static collisions @@ -1670,8 +1668,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl // collisions = 1; verts = cloth->verts; // needed for openMP - numfaces = clmd->clothObject->numfaces; - numverts = clmd->clothObject->numverts; + numfaces = cloth->numfaces; + numverts = cloth->numverts; verts = cloth->verts; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 09c65f4b21d..71b497660e9 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2005 Blender Foundation. * All rights reserved. @@ -143,6 +143,7 @@ void curvemapping_free(CurveMapping *cumap) for(a=0; a<CM_TOT; a++) { if(cumap->cm[a].curve) MEM_freeN(cumap->cm[a].curve); if(cumap->cm[a].table) MEM_freeN(cumap->cm[a].table); + if(cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable); } MEM_freeN(cumap); } @@ -159,6 +160,8 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap) cumapn->cm[a].curve= MEM_dupallocN(cumap->cm[a].curve); if(cumap->cm[a].table) cumapn->cm[a].table= MEM_dupallocN(cumap->cm[a].table); + if(cumap->cm[a].premultable) + cumapn->cm[a].premultable= MEM_dupallocN(cumap->cm[a].premultable); } return cumapn; } @@ -791,8 +794,7 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) pix_in= ibuf->rect_float; pix_out= tmpbuf->rect_float; -// pixc= (char *)ibuf->rect; - + if(ibuf->channels) stride= ibuf->channels; @@ -818,7 +820,6 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) SWAP(unsigned int *, tmpbuf->rect, ibuf->rect); IMB_freeImBuf(tmpbuf); - curvemapping_premultiply(cumap, 1); } @@ -878,3 +879,91 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) } } +/* ***************** Histogram **************** */ + +DO_INLINE int get_bin_float(float f) +{ + int bin= (int)(f*255); + + /* note: clamp integer instead of float to avoid problems with NaN */ + CLAMP(bin, 0, 255); + + //return (int) (((f + 0.25) / 1.5) * 255); + + return bin; +} + + +void histogram_update(Histogram *hist, ImBuf *ibuf) +{ + int x, y, n; + double div; + float *rf; + unsigned char *rc; + unsigned int *bin_r, *bin_g, *bin_b; + + if (hist->ok == 1 ) return; + + if (hist->xmax == 0.f) hist->xmax = 1.f; + if (hist->ymax == 0.f) hist->ymax = 1.f; + + /* hmmmm */ + if (!(ELEM(ibuf->channels, 3, 4))) return; + + hist->channels = 3; + + bin_r = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); + bin_g = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); + bin_b = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); + + if (ibuf->rect_float) { + hist->x_resolution = 256; + + /* divide into bins */ + rf = ibuf->rect_float; + for (y = 0; y < ibuf->y; y++) { + for (x = 0; x < ibuf->x; x++) { + bin_r[ get_bin_float(rf[0]) ] += 1; + bin_g[ get_bin_float(rf[1]) ] += 1; + bin_b[ get_bin_float(rf[2]) ] += 1; + rf+= ibuf->channels; + } + } + } + else if (ibuf->rect) { + hist->x_resolution = 256; + + rc = (unsigned char *)ibuf->rect; + for (y = 0; y < ibuf->y; y++) { + for (x = 0; x < ibuf->x; x++) { + bin_r[ rc[0] ] += 1; + bin_g[ rc[1] ] += 1; + bin_b[ rc[2] ] += 1; + rc += ibuf->channels; + } + } + } + + /* convert to float */ + n=0; + for (x=0; x<256; x++) { + if (bin_r[x] > n) + n = bin_r[x]; + if (bin_g[x] > n) + n = bin_g[x]; + if (bin_b[x] > n) + n = bin_b[x]; + } + div = 1.f/(double)n; + for (x=0; x<256; x++) { + hist->data_r[x] = bin_r[x] * div; + hist->data_g[x] = bin_g[x] * div; + hist->data_b[x] = bin_b[x] * div; + } + + MEM_freeN(bin_r); + MEM_freeN(bin_g); + MEM_freeN(bin_b); + + hist->ok=1; +} diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 04f04ca6a8c..9b5f049f7d1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -99,7 +99,7 @@ /* Find the first available, non-duplicate name for a given constraint */ void unique_constraint_name (bConstraint *con, ListBase *list) { - BLI_uniquename(list, con, "Const", '.', offsetof(bConstraint, name), 32); + BLI_uniquename(list, con, "Const", '.', offsetof(bConstraint, name), sizeof(con->name)); } /* ----------------- Evaluation Loop Preparation --------------- */ @@ -405,7 +405,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* function that sets the given matrix based on given vertex group in mesh */ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, float mat[][4]) { - DerivedMesh *dm; + DerivedMesh *dm = NULL; Mesh *me= ob->data; BMEditMesh *em = me->edit_btmesh; float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3]; @@ -418,7 +418,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f copy_m4_m4(mat, ob->obmat); /* get index of vertex group */ - dgroup = get_named_vertexgroup_num(ob, substring); + dgroup = defgroup_name_index(ob, substring); if (dgroup < 0) return; /* get DerivedMesh */ @@ -525,7 +525,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ copy_m4_m4(mat, ob->obmat); /* get index of vertex group */ - dgroup = get_named_vertexgroup_num(ob, substring); + dgroup = defgroup_name_index(ob, substring); if (dgroup < 0) return; if (dvert == NULL) return; @@ -649,6 +649,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { "bConstrNameConstraint", /* struct name */ constrname_free, /* free data */ constrname_relink, /* relink data */ + constrname_id_looper, /* id looper */ constrname_copy, /* copy data */ constrname_new_data, /* new data */ constrname_get_tars, /* get constraint targets */ @@ -775,6 +776,14 @@ static void childof_new_data (void *cdata) unit_m4(data->invmat); } +static void childof_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bChildOfConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int childof_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -859,6 +868,7 @@ static bConstraintTypeInfo CTI_CHILDOF = { "bChildOfConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + childof_id_looper, /* id looper */ NULL, /* copy data */ childof_new_data, /* new data */ childof_get_tars, /* get constraint targets */ @@ -877,6 +887,14 @@ static void trackto_new_data (void *cdata) data->reserved2 = UP_Z; } +static void trackto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bTrackToConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int trackto_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -1038,6 +1056,7 @@ static bConstraintTypeInfo CTI_TRACKTO = { "bTrackToConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + trackto_id_looper, /* id looper */ NULL, /* copy data */ trackto_new_data, /* new data */ trackto_get_tars, /* get constraint targets */ @@ -1059,6 +1078,17 @@ static void kinematic_new_data (void *cdata) data->flag= CONSTRAINT_IK_TIP|CONSTRAINT_IK_STRETCH|CONSTRAINT_IK_POS; } +static void kinematic_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bKinematicConstraint *data= con->data; + + /* chain target */ + func(con, (ID**)&data->tar, userdata); + + /* poletarget */ + func(con, (ID**)&data->poletar, userdata); +} + static int kinematic_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -1121,6 +1151,7 @@ static bConstraintTypeInfo CTI_KINEMATIC = { "bKinematicConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + kinematic_id_looper, /* id looper */ NULL, /* copy data */ kinematic_new_data, /* new data */ kinematic_get_tars, /* get constraint targets */ @@ -1141,6 +1172,14 @@ static void followpath_new_data (void *cdata) data->followflag = 0; } +static void followpath_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bFollowPathConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int followpath_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -1207,7 +1246,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } else { /* fixed position along curve */ - curvetime= data->offset; // XXX might need a more sensible value + curvetime= data->offset_fac; } if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) { @@ -1284,6 +1323,7 @@ static bConstraintTypeInfo CTI_FOLLOWPATH = { "bFollowPathConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + followpath_id_looper, /* id looper */ NULL, /* copy data */ followpath_new_data, /* new data */ followpath_get_tars, /* get constraint targets */ @@ -1332,6 +1372,7 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { "bLocLimitConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ NULL, /* get constraint targets */ @@ -1354,10 +1395,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t mat4_to_eulO( eul, cob->rotOrder,cob->matrix); - /* eulers: radians to degrees! */ - eul[0] = (float)(eul[0] / M_PI * 180); - eul[1] = (float)(eul[1] / M_PI * 180); - eul[2] = (float)(eul[2] / M_PI * 180); + /* constraint data uses radians internally */ /* limiting of euler values... */ if (data->flag & LIMIT_XROT) { @@ -1382,11 +1420,6 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t eul[2] = data->zmax; } - /* eulers: degrees to radians ! */ - eul[0] = (float)(eul[0] / 180 * M_PI); - eul[1] = (float)(eul[1] / 180 * M_PI); - eul[2] = (float)(eul[2] / 180 * M_PI); - loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } @@ -1397,6 +1430,7 @@ static bConstraintTypeInfo CTI_ROTLIMIT = { "bRotLimitConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ NULL, /* get constraint targets */ @@ -1456,6 +1490,7 @@ static bConstraintTypeInfo CTI_SIZELIMIT = { "bSizeLimitConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ NULL, /* get constraint targets */ @@ -1473,6 +1508,14 @@ static void loclike_new_data (void *cdata) data->flag = LOCLIKE_X|LOCLIKE_Y|LOCLIKE_Z; } +static void loclike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bLocateLikeConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int loclike_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -1538,6 +1581,7 @@ static bConstraintTypeInfo CTI_LOCLIKE = { "bLocateLikeConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + loclike_id_looper, /* id looper */ NULL, /* copy data */ loclike_new_data, /* new data */ loclike_get_tars, /* get constraint targets */ @@ -1555,6 +1599,14 @@ static void rotlike_new_data (void *cdata) data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; } +static void rotlike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bChildOfConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int rotlike_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -1640,6 +1692,7 @@ static bConstraintTypeInfo CTI_ROTLIKE = { "bRotateLikeConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + rotlike_id_looper, /* id looper */ NULL, /* copy data */ rotlike_new_data, /* new data */ rotlike_get_tars, /* get constraint targets */ @@ -1657,6 +1710,14 @@ static void sizelike_new_data (void *cdata) data->flag = SIZELIKE_X|SIZELIKE_Y|SIZELIKE_Z; } +static void sizelike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bSizeLikeConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int sizelike_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -1728,6 +1789,7 @@ static bConstraintTypeInfo CTI_SIZELIKE = { "bSizeLikeConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + sizelike_id_looper, /* id looper */ NULL, /* copy data */ sizelike_new_data, /* new data */ sizelike_get_tars, /* get constraint targets */ @@ -1738,6 +1800,14 @@ static bConstraintTypeInfo CTI_SIZELIKE = { /* ----------- Copy Transforms ------------- */ +static void translike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bTransLikeConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int translike_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -1781,6 +1851,7 @@ static bConstraintTypeInfo CTI_TRANSLIKE = { "bTransLikeConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + translike_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ translike_get_tars, /* get constraint targets */ @@ -1842,6 +1913,19 @@ static int pycon_get_tars (bConstraint *con, ListBase *list) return 0; } +static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bPythonConstraint *data= con->data; + bConstraintTarget *ct; + + /* targets */ + for (ct= data->targets.first; ct; ct= ct->next) + func(con, (ID**)&ct->tar, userdata); + + /* script */ + func(con, (ID**)&data->text, userdata); +} + /* Whether this approach is maintained remains to be seen (aligorith) */ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) { @@ -1864,7 +1948,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT /* only execute target calculation if allowed */ #ifndef DISABLE_PYTHON - if (G.f & G_DOSCRIPTLINKS) + if (G.f & G_SCRIPT_AUTOEXEC) BPY_pyconstraint_target(data, ct); #endif } @@ -1880,7 +1964,7 @@ static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targ bPythonConstraint *data= con->data; /* only evaluate in python if we're allowed to do so */ - if ((G.f & G_DOSCRIPTLINKS)==0) return; + if ((G.f & G_SCRIPT_AUTOEXEC)==0) return; /* currently removed, until I this can be re-implemented for multiple targets */ #if 0 @@ -1903,6 +1987,7 @@ static bConstraintTypeInfo CTI_PYTHON = { "bPythonConstraint", /* struct name */ pycon_free, /* free data */ pycon_relink, /* relink data */ + pycon_id_looper, /* id looper */ pycon_copy, /* copy data */ pycon_new_data, /* new data */ pycon_get_tars, /* get constraint targets */ @@ -1927,6 +2012,17 @@ static void actcon_new_data (void *cdata) data->type = 20; } +static void actcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bActionConstraint *data= con->data; + + /* target */ + func(con, (ID**)&data->tar, userdata); + + /* action */ + func(con, (ID**)&data->act, userdata); +} + static int actcon_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -2066,6 +2162,7 @@ static bConstraintTypeInfo CTI_ACTION = { "bActionConstraint", /* struct name */ NULL, /* free data */ actcon_relink, /* relink data */ + actcon_id_looper, /* id looper */ NULL, /* copy data */ actcon_new_data, /* new data */ actcon_get_tars, /* get constraint targets */ @@ -2084,6 +2181,14 @@ static void locktrack_new_data (void *cdata) data->lockflag = LOCK_Z; } +static void locktrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bLockTrackConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int locktrack_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -2419,6 +2524,7 @@ static bConstraintTypeInfo CTI_LOCKTRACK = { "bLockTrackConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + locktrack_id_looper, /* id looper */ NULL, /* copy data */ locktrack_new_data, /* new data */ locktrack_get_tars, /* get constraint targets */ @@ -2433,7 +2539,15 @@ static void distlimit_new_data (void *cdata) { bDistLimitConstraint *data= (bDistLimitConstraint *)cdata; - data->dist= 0.0; + data->dist= 0.0f; +} + +static void distlimit_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bDistLimitConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); } static int distlimit_get_tars (bConstraint *con, ListBase *list) @@ -2535,6 +2649,7 @@ static bConstraintTypeInfo CTI_DISTLIMIT = { "bDistLimitConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + distlimit_id_looper, /* id looper */ NULL, /* copy data */ distlimit_new_data, /* new data */ distlimit_get_tars, /* get constraint targets */ @@ -2555,6 +2670,14 @@ static void stretchto_new_data (void *cdata) data->bulge = 1.0; } +static void stretchto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bStretchToConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int stretchto_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -2715,6 +2838,7 @@ static bConstraintTypeInfo CTI_STRETCHTO = { "bStretchToConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + stretchto_id_looper, /* id looper */ NULL, /* copy data */ stretchto_new_data, /* new data */ stretchto_get_tars, /* get constraint targets */ @@ -2735,6 +2859,14 @@ static void minmax_new_data (void *cdata) data->flag = 0; } +static void minmax_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bMinMaxConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int minmax_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -2851,6 +2983,7 @@ static bConstraintTypeInfo CTI_MINMAX = { "bMinMaxConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + minmax_id_looper, /* id looper */ NULL, /* copy data */ minmax_new_data, /* new data */ minmax_get_tars, /* get constraint targets */ @@ -2869,6 +3002,14 @@ static void rbj_new_data (void *cdata) data->type=1; } +static void rbj_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bRigidBodyJointConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int rbj_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -2902,6 +3043,7 @@ static bConstraintTypeInfo CTI_RIGIDBODYJOINT = { "bRigidBodyJointConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + rbj_id_looper, /* id looper */ NULL, /* copy data */ rbj_new_data, /* new data */ rbj_get_tars, /* get constraint targets */ @@ -2912,6 +3054,14 @@ static bConstraintTypeInfo CTI_RIGIDBODYJOINT = { /* -------- Clamp To ---------- */ +static void clampto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bClampToConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int clampto_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -3079,6 +3229,7 @@ static bConstraintTypeInfo CTI_CLAMPTO = { "bClampToConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + clampto_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ clampto_get_tars, /* get constraint targets */ @@ -3098,6 +3249,14 @@ static void transform_new_data (void *cdata) data->map[2]= 2; } +static void transform_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bTransformConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int transform_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -3218,6 +3377,7 @@ static bConstraintTypeInfo CTI_TRANSFORM = { "bTransformConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + transform_id_looper, /* id looper */ NULL, /* copy data */ transform_new_data, /* new data */ transform_get_tars, /* get constraint targets */ @@ -3228,6 +3388,14 @@ static bConstraintTypeInfo CTI_TRANSFORM = { /* ---------- Shrinkwrap Constraint ----------- */ +static void shrinkwrap_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bShrinkwrapConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->target, userdata); +} + static int shrinkwrap_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -3375,6 +3543,7 @@ static bConstraintTypeInfo CTI_SHRINKWRAP = { "bShrinkwrapConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + shrinkwrap_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ shrinkwrap_get_tars, /* get constraint targets */ @@ -3392,6 +3561,14 @@ static void damptrack_new_data (void *cdata) data->trackflag = TRACK_Y; } +static void damptrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bDampTrackConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int damptrack_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -3494,6 +3671,7 @@ static bConstraintTypeInfo CTI_DAMPTRACK = { "bDampTrackConstraint", /* struct name */ NULL, /* free data */ NULL, /* relink data */ + damptrack_id_looper, /* id looper */ NULL, /* copy data */ damptrack_new_data, /* new data */ damptrack_get_tars, /* get constraint targets */ @@ -3522,6 +3700,14 @@ static void splineik_copy (bConstraint *con, bConstraint *srccon) dst->points= MEM_dupallocN(src->points); } +static void splineik_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bSplineIKConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + static int splineik_get_tars (bConstraint *con, ListBase *list) { if (con && list) { @@ -3576,6 +3762,7 @@ static bConstraintTypeInfo CTI_SPLINEIK = { "bSplineIKConstraint", /* struct name */ splineik_free, /* free data */ NULL, /* relink data */ + splineik_id_looper, /* id looper */ splineik_copy, /* copy data */ NULL, /* new data */ splineik_get_tars, /* get constraint targets */ @@ -3717,6 +3904,26 @@ int remove_constraint_index (ListBase *list, int index) return 0; } +/* Remove all the constraints of the specified type from the given constraint stack */ +void remove_constraints_type (ListBase *list, short type, short last_only) +{ + bConstraint *con, *conp; + + if (list == NULL) + return; + + /* remove from the end of the list to make it faster to find the last instance */ + for (con= list->last; con; con= conp) { + conp= con->prev; + + if (con->type == type) { + remove_constraint(list, con); + if (last_only) + return; + } + } +} + /* ......... */ /* Creates a new constraint, initialises its data, and returns it */ @@ -3838,8 +4045,30 @@ void relink_constraints (ListBase *conlist) } } +/* Run the given callback on all ID-blocks in list of constraints */ +void id_loop_constraints (ListBase *conlist, ConstraintIDFunc func, void *userdata) +{ + bConstraint *con; + + for (con= conlist->first; con; con= con->next) { + bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + + if (cti) { + if (cti->id_looper) + cti->id_looper(con, func, userdata); + } + } +} + /* ......... */ +/* helper for copy_constraints(), to be used for making sure that ID's are valid */ +static void con_extern_cb(bConstraint *con, ID **idpoin, void *userdata) +{ + if (*idpoin && (*idpoin)->lib) + id_lib_extern(*idpoin); +} + /* duplicate all of the constraints in a constraint stack */ void copy_constraints (ListBase *dst, const ListBase *src) { @@ -3854,12 +4083,16 @@ void copy_constraints (ListBase *dst, const ListBase *src) /* make a new copy of the constraint's data */ con->data = MEM_dupallocN(con->data); - // NOTE: depreceated... old animation system - id_us_plus((ID *)con->ipo); - /* only do specific constraints if required */ - if (cti && cti->copy_data) - cti->copy_data(con, srccon); + if (cti) { + /* perform custom copying operations if needed */ + if (cti->copy_data) + cti->copy_data(con, srccon); + + /* go over used ID-links for this constraint to ensure that they are valid for proxies */ + if (cti->id_looper) + cti->id_looper(con, con_extern_cb, NULL); + } } } @@ -3887,11 +4120,13 @@ void constraints_set_active (ListBase *list, bConstraint *con) { bConstraint *c; - for (c= list->first; c; c= c->next) { - if (c == con) - c->flag |= CONSTRAINT_ACTIVE; - else - c->flag &= ~CONSTRAINT_ACTIVE; + if (list) { + for (c= list->first; c; c= c->next) { + if (c == con) + c->flag |= CONSTRAINT_ACTIVE; + else + c->flag &= ~CONSTRAINT_ACTIVE; + } } } diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index fc1ef4aede9..26320e2475f 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -46,7 +46,9 @@ #include "BKE_screen.h" #include "BKE_global.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #include <string.h> @@ -413,13 +415,13 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res int ret= 0; memset(result, 0, sizeof(bContextDataResult)); - +#ifndef DISABLE_PYTHON if(CTX_py_dict_get(C)) { return BPY_context_get(C, member, result); // if (BPY_context_get(C, member, result)) // return 1; } - +#endif /* we check recursion to ensure that we do not get infinite * loops requesting data from ourselfs in a context callback */ @@ -484,7 +486,12 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void * { bContextDataResult result; - if(ctx_data_get((bContext*)C, member, &result)==1) { + /* if context is NULL, pointer must be NULL too and that is a valid return */ + if (C == NULL) { + *pointer= NULL; + return 1; + } + else if(ctx_data_get((bContext*)C, member, &result)==1) { *pointer= result.ptr.data; return 1; } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 75759733cad..fb27327c3be 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -191,6 +191,7 @@ Curve *copy_curve(Curve *cu) cun->path= 0; cun->editnurb= NULL; + cun->editfont= NULL; #if 0 // XXX old animation system /* single user ipo too */ @@ -1422,7 +1423,7 @@ static short bevelinside(BevList *bl1,BevList *bl2) prevbevp= bevp+(nr-1); while(nr--) { - min= prevbevp->vec[0]; + min= prevbevp->vec[1]; max= bevp->vec[1]; if(max<min) { min= max; @@ -2325,7 +2326,7 @@ void makeBevelList(Object *ob) /* * handlecodes: - * 1: nothing, 1:auto, 2:vector, 3:aligned + * 0: nothing, 1:auto, 2:vector, 3:aligned */ /* mode: is not zero when FCurve, is 2 when forced horizontal for autohandles */ diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e0f1c1342da..f2d9512ce18 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. @@ -2159,7 +2159,7 @@ void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData void CustomData_bmesh_init_pool(CustomData *data, int allocsize){ - if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize); + if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, 1); } void CustomData_bmesh_merge(CustomData *source, CustomData *dest, @@ -2721,8 +2721,10 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int customdata_external_filename(filename, id, external); cdf= cdf_create(CDF_TYPE_MESH); - if(!cdf_read_open(cdf, filename)) + if(!cdf_read_open(cdf, filename)) { + fprintf(stderr, "Failed to read %s layer from %s.\n", layerType_getName(layer->type), filename); return; + } for(i=0; i<data->totlayer; i++) { layer = &data->layers[i]; @@ -2762,6 +2764,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in if(!external) return; + /* test if there is anything to write */ for(i=0; i<data->totlayer; i++) { layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); @@ -2774,7 +2777,9 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in if(!update) return; + /* make sure data is read before we try to write */ CustomData_external_read(data, id, mask, totelem); + customdata_external_filename(filename, id, external); cdf= cdf_create(CDF_TYPE_MESH); @@ -2782,14 +2787,22 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->filesize) - cdf_layer_add(cdf, layer->type, layer->name, - typeInfo->filesize(cdf, layer->data, totelem)); + if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->filesize) { + if(layer->flag & CD_FLAG_IN_MEMORY) { + cdf_layer_add(cdf, layer->type, layer->name, + typeInfo->filesize(cdf, layer->data, totelem)); + } + else { + cdf_free(cdf); + return; /* read failed for a layer! */ + } + } } - customdata_external_filename(filename, id, external); - if(!cdf_write_open(cdf, filename)) + if(!cdf_write_open(cdf, filename)) { + fprintf(stderr, "Failed to open %s for writing.\n", filename); return; + } for(i=0; i<data->totlayer; i++) { layer = &data->layers[i]; @@ -2808,6 +2821,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in } if(i != data->totlayer) { + fprintf(stderr, "Failed to write data to %s.\n", filename); cdf_free(cdf); return; } diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index fa1490620d6..65a0d731beb 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 0d3f8b34918..06b5ba84433 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -34,6 +34,7 @@ #include <string.h> #include <math.h> +#include "ctype.h" #include "MEM_guardedalloc.h" @@ -67,19 +68,19 @@ #endif -void copy_defgroups (ListBase *outbase, ListBase *inbase) +void defgroup_copy_list (ListBase *outbase, ListBase *inbase) { bDeformGroup *defgroup, *defgroupn; outbase->first= outbase->last= 0; for (defgroup = inbase->first; defgroup; defgroup=defgroup->next){ - defgroupn= copy_defgroup(defgroup); + defgroupn= defgroup_duplicate(defgroup); BLI_addtail(outbase, defgroupn); } } -bDeformGroup *copy_defgroup (bDeformGroup *ingroup) +bDeformGroup *defgroup_duplicate (bDeformGroup *ingroup) { bDeformGroup *outgroup; @@ -96,7 +97,108 @@ bDeformGroup *copy_defgroup (bDeformGroup *ingroup) return outgroup; } -bDeformGroup *get_named_vertexgroup (Object *ob, char *name) +/* copy & overwrite weights */ +void defvert_copy (MDeformVert *dvert_r, const MDeformVert *dvert) +{ + if(dvert_r->totweight == dvert->totweight) { + if(dvert->totweight) + memcpy(dvert_r->dw, dvert->dw, dvert->totweight * sizeof(MDeformWeight)); + } + else { + if(dvert_r->dw) + BLI_cellalloc_free(dvert_r->dw); + + if(dvert->totweight) + dvert_r->dw= BLI_cellalloc_dupalloc(dvert->dw); + else + dvert_r->dw= NULL; + + dvert_r->totweight = dvert->totweight; + } +} + +/* only sync over matching weights, don't add or remove groups + * warning, loop within loop. + */ +void defvert_sync (MDeformVert *dvert_r, const MDeformVert *dvert, int use_verify) +{ + if(dvert->totweight && dvert_r->totweight) { + int i; + MDeformWeight *dw; + for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) { + MDeformWeight *dw_r; + if(use_verify) dw_r= defvert_find_index(dvert_r, dw->def_nr); + else dw_r= defvert_verify_index(dvert_r, dw->def_nr); + + if(dw_r) { + dw_r->weight= dw->weight; + } + } + } +} + +/* be sure all flip_map values are valid */ +void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, int *flip_map, int use_verify) +{ + if(dvert->totweight && dvert_r->totweight) { + int i; + MDeformWeight *dw; + for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) { + MDeformWeight *dw_r; + if(use_verify) dw_r= defvert_find_index(dvert_r, flip_map[dw->def_nr]); + else dw_r= defvert_verify_index(dvert_r, flip_map[dw->def_nr]); + + if(dw_r) { + dw_r->weight= dw->weight; + } + } + } +} + +/* be sure all flip_map values are valid */ +void defvert_remap (MDeformVert *dvert, int *map) +{ + MDeformWeight *dw; + int i; + for(i=0, dw=dvert->dw; i<dvert->totweight; i++, dw++) { + dw->def_nr= map[dw->def_nr]; + } +} + +void defvert_normalize (MDeformVert *dvert) +{ + if(dvert->totweight<=0) { + /* nothing */ + } + else if (dvert->totweight==1) { + dvert->dw[0].weight= 1.0f; + } + else { + int i; + float tot= 0.0f; + MDeformWeight *dw; + for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) + tot += dw->weight; + + if(tot > 0.0f) { + for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) + dw->weight /= tot; + } + } +} + +void defvert_flip (MDeformVert *dvert, int *flip_map) +{ + MDeformWeight *dw; + int i; + + for(dw= dvert->dw, i=0; i<dvert->totweight; dw++, i++) + if(flip_map[dw->def_nr] >= 0) + dw->def_nr= flip_map[dw->def_nr]; +} + + +bDeformGroup *defgroup_find_name (Object *ob, char *name) { /* return a pointer to the deform group with this name * or return NULL otherwise. @@ -111,31 +213,35 @@ bDeformGroup *get_named_vertexgroup (Object *ob, char *name) return NULL; } -int get_named_vertexgroup_num (Object *ob, const char *name) +int defgroup_name_index (Object *ob, const char *name) { /* Return the location of the named deform group within the list of - * deform groups. This function is a combination of get_defgroup_num and - * get_named_vertexgroup. The other two could be called instead, but that + * deform groups. This function is a combination of defgroup_find_index and + * defgroup_find_name. The other two could be called instead, but that * require looping over the vertexgroups twice. */ bDeformGroup *curdef; int def_nr; - for (curdef=ob->defbase.first, def_nr=0; curdef; curdef=curdef->next, def_nr++) { - if (!strcmp(curdef->name, name)) - return def_nr; + if(name[0] != '\0') { + for (curdef=ob->defbase.first, def_nr=0; curdef; curdef=curdef->next, def_nr++) { + if (!strcmp(curdef->name, name)) + return def_nr; + } } - + return -1; } -int get_defgroup_num (Object *ob, bDeformGroup *dg) +int defgroup_find_index (Object *ob, bDeformGroup *dg) { /* Fetch the location of this deform group * within the linked list of deform groups. * (this number is stored in the deform * weights of the deform verts to link them * to this deform group). + * + * note: this is zero based, ob->actdef starts at 1. */ bDeformGroup *eg; @@ -168,7 +274,59 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) } -void unique_vertexgroup_name (bDeformGroup *dg, Object *ob) +/* note, must be freed */ +int *defgroup_flip_map(Object *ob, int use_default) +{ + bDeformGroup *dg; + int totdg= BLI_countlist(&ob->defbase); + + if(totdg==0) { + return NULL; + } + else { + char name[sizeof(dg->name)]; + int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), "get_defgroup_flip_map"); + + memset(map, -1, totdg * sizeof(int)); + + for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) { + if(map[i] == -1) { /* may be calculated previously */ + + /* incase no valid value is found, use this */ + if(use_default) + map[i]= i; + + flip_side_name(name, dg->name, 0); + if(strcmp(name, dg->name)) { + flip_num= defgroup_name_index(ob, name); + if(flip_num >= 0) { + map[i]= flip_num; + map[flip_num]= i; /* save an extra lookup */ + } + } + } + } + return map; + } +} + +int defgroup_flip_index(Object *ob, int index, int use_default) +{ + bDeformGroup *dg= BLI_findlink(&ob->defbase, index); + int flip_index = -1; + + if(dg) { + char name[sizeof(dg->name)]; + flip_side_name(name, dg->name, 0); + + if(strcmp(name, dg->name)) + flip_index= defgroup_name_index(ob, name); + } + + return (flip_index==-1 && use_default) ? index : flip_index; +} + +void defgroup_unique_name (bDeformGroup *dg, Object *ob) { bDeformGroup *curdef; int number; @@ -222,27 +380,176 @@ void unique_vertexgroup_name (bDeformGroup *dg, Object *ob) } } -float deformvert_get_weight(const struct MDeformVert *dvert, int group_num) + +/* finds the best possible flipped name. For renaming; check for unique names afterwards */ +/* if strip_number: removes number extensions */ +void flip_side_name (char *name, const char *from_name, int strip_number) { - if(dvert) - { - const MDeformWeight *dw = dvert->dw; - int i; + int len; + char prefix[sizeof((bDeformGroup *)NULL)->name]={""}; /* The part before the facing */ + char suffix[sizeof((bDeformGroup *)NULL)->name]={""}; /* The part after the facing */ + char replace[sizeof((bDeformGroup *)NULL)->name]={""}; /* The replacement string */ + char number[sizeof((bDeformGroup *)NULL)->name]={""}; /* The number extension string */ + char *index=NULL; + + len= strlen(from_name); + if(len<3) return; // we don't do names like .R or .L + + strcpy(name, from_name); + + /* We first check the case with a .### extension, let's find the last period */ + if(isdigit(name[len-1])) { + index= strrchr(name, '.'); // last occurrence + if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! + if(strip_number==0) + strcpy(number, index); + *index= 0; + len= strlen(name); + } + } - for(i=dvert->totweight; i>0; i--, dw++) - if(dw->def_nr == group_num) - return dw->weight; + strcpy (prefix, name); + +#define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') + + /* first case; separator . - _ with extensions r R l L */ + if( IS_SEPARATOR(name[len-2]) ) { + switch(name[len-1]) { + case 'l': + prefix[len-1]= 0; + strcpy(replace, "r"); + break; + case 'r': + prefix[len-1]= 0; + strcpy(replace, "l"); + break; + case 'L': + prefix[len-1]= 0; + strcpy(replace, "R"); + break; + case 'R': + prefix[len-1]= 0; + strcpy(replace, "L"); + break; + } + } + /* case; beginning with r R l L , with separator after it */ + else if( IS_SEPARATOR(name[1]) ) { + switch(name[0]) { + case 'l': + strcpy(replace, "r"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + case 'r': + strcpy(replace, "l"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + case 'L': + strcpy(replace, "R"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + case 'R': + strcpy(replace, "L"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + } + } + else if(len > 5) { + /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */ + index = BLI_strcasestr(prefix, "right"); + if (index==prefix || index==prefix+len-5) { + if(index[0]=='r') + strcpy (replace, "left"); + else { + if(index[1]=='I') + strcpy (replace, "LEFT"); + else + strcpy (replace, "Left"); + } + *index= 0; + strcpy (suffix, index+5); + } + else { + index = BLI_strcasestr(prefix, "left"); + if (index==prefix || index==prefix+len-4) { + if(index[0]=='l') + strcpy (replace, "right"); + else { + if(index[1]=='E') + strcpy (replace, "RIGHT"); + else + strcpy (replace, "Right"); + } + *index= 0; + strcpy (suffix, index+4); + } + } } - /* Not found */ - return 0.0; +#undef IS_SEPARATOR + + sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); } -float vertexgroup_get_vertex_weight(const struct MDeformVert *dvert, int index, int group_num) +float defvert_find_weight(const struct MDeformVert *dvert, int group_num) +{ + MDeformWeight *dw= defvert_find_index(dvert, group_num); + return dw ? dw->weight : 0.0f; +} + +float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num) { if(group_num == -1 || dvert == NULL) - return 1.0; + return 1.0f; + + return defvert_find_weight(dvert+index, group_num); +} + + +MDeformWeight *defvert_find_index(const MDeformVert *dvert, int defgroup) +{ + if(dvert && defgroup >= 0) { + MDeformWeight *dw = dvert->dw; + int i; + + for(i=dvert->totweight; i>0; i--, dw++) + if(dw->def_nr == defgroup) + return dw; + } - return deformvert_get_weight(dvert+index, group_num); + return NULL; } +/* Ensures that mv has a deform weight entry for the specified defweight group */ +/* Note this function is mirrored in editmesh_tools.c, for use for editvertices */ +MDeformWeight *defvert_verify_index(MDeformVert *dv, int defgroup) +{ + MDeformWeight *newdw; + + /* do this check always, this function is used to check for it */ + if(!dv || defgroup<0) + return NULL; + + newdw = defvert_find_index(dv, defgroup); + if(newdw) + return newdw; + + newdw = BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight"); + if(dv->dw) { + memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight); + BLI_cellalloc_free(dv->dw); + } + dv->dw=newdw; + + dv->dw[dv->totweight].weight=0.0f; + dv->dw[dv->totweight].def_nr=defgroup; + /* Group index */ + + dv->totweight++; + + return dv->dw+(dv->totweight-1); +} diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index e664dd01f4d..0c9248c1eb9 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. @@ -29,12 +29,9 @@ #include <string.h> #include <math.h> -#ifdef _WIN32 -#include "BLI_winstuff.h" -#endif - #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_winstuff.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" @@ -809,7 +806,7 @@ DagNode * dag_find_node (DagForest *forest,void * fob) static int ugly_hack_sorry= 1; // prevent type check -/* no checking of existance, use dag_find_node first or dag_get_node */ +/* no checking of existence, use dag_find_node first or dag_get_node */ DagNode * dag_add_node (DagForest *forest, void * fob) { DagNode *node; @@ -2214,6 +2211,50 @@ void DAG_ids_flush_update(int time) DAG_scene_flush_update(sce, lay, time); } +void DAG_on_load_update(void) +{ + Main *bmain= G.main; + Scene *scene, *sce; + Base *base; + Object *ob; + Group *group; + GroupObject *go; + unsigned int lay; + + dag_current_scene_layers(bmain, &scene, &lay); + + if(scene) { + /* derivedmeshes and displists are not saved to file so need to be + remade, tag them so they get remade in the scene update loop, + note armature poses or object matrices are preserved and do not + require updates, so we skip those */ + for(SETLOOPER(scene, base)) { + ob= base->object; + + if(base->lay & lay) { + if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) + ob->recalc |= OB_RECALC_DATA; + if(ob->dup_group) + ob->dup_group->id.flag |= LIB_DOIT; + } + } + + for(group= G.main->group.first; group; group= group->id.next) { + if(group->id.flag & LIB_DOIT) { + for(go= group->gobject.first; go; go= go->next) { + if(ELEM5(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) + go->ob->recalc |= OB_RECALC_DATA; + } + + group->id.flag &= ~LIB_DOIT; + } + } + + /* now tag update flags, to ensure deformers get calculated on redraw */ + DAG_scene_update_flags(scene, lay); + } +} + void DAG_id_flush_update(ID *id, short flag) { Main *bmain= G.main; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index c694422124a..c1fcf4f13f4 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -321,9 +321,9 @@ static Render *fastshade_get_render(Scene *scene) /* XXX ugly global still, but we can't do preview while rendering */ if(G.rendering==0) { - Render *re= RE_GetRender("_Shade View_"); + Render *re= RE_GetRender("_Shade View_", RE_SLOT_DEFAULT); if(re==NULL) { - re= RE_NewRender("_Shade View_"); + re= RE_NewRender("_Shade View_", RE_SLOT_DEFAULT); RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */ } @@ -337,7 +337,7 @@ static Render *fastshade_get_render(Scene *scene) /* called on file reading */ void fastshade_free_render(void) { - Render *re= RE_GetRender("_Shade View_"); + Render *re= RE_GetRender("_Shade View_", RE_SLOT_DEFAULT); if(re) { RE_Database_Free(re); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 0f4d09f82d3..f8193a3a7b0 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -593,7 +593,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin float cfra = eff->scene->r.cfra; int ret = 0; - if(eff->pd->shape==PFIELD_SHAPE_SURFACE && eff->surmd) { + if(eff->pd && eff->pd->shape==PFIELD_SHAPE_SURFACE && eff->surmd) { /* closest point in the object surface is an effector */ float vec[3]; @@ -606,7 +606,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin efd->size = 0.0f; } - else if(eff->pd->shape==PFIELD_SHAPE_POINTS) { + else if(eff->pd && eff->pd->shape==PFIELD_SHAPE_POINTS) { if(eff->ob->derivedFinal) { DerivedMesh *dm = eff->ob->derivedFinal; @@ -658,6 +658,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin Object *ob = eff->ob; Object obcopy = *ob; + /* XXX this is not thread-safe, but used from multiple threads by + particle system */ where_is_object_time(eff->scene, ob, cfra); /* use z-axis as normal*/ @@ -665,7 +667,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin normalize_v3(efd->nor); /* for vortex the shape chooses between old / new force */ - if(eff->pd->shape == PFIELD_SHAPE_PLANE) { + if(eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) { /* efd->loc is closes point on effector xy-plane */ float temp[3]; sub_v3_v3v3(temp, point->loc, ob->obmat[3]); @@ -696,7 +698,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin efd->distance = len_v3(efd->vec_to_point); /* rest length for harmonic effector, will have to see later if this could be extended to other effectors */ - if(eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size) + if(eff->pd && eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size) mul_v3_fl(efd->vec_to_point, (efd->distance-eff->pd->f_size)/efd->distance); if(eff->flag & PE_USE_NORMAL_DATA) { diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index c83a0443356..cc42b0754a5 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -37,6 +37,7 @@ #include <stdlib.h> #include <fcntl.h> #include <string.h> +#include <errno.h> #ifndef _WIN32 #include <unistd.h> @@ -76,8 +77,8 @@ #include "BKE_object.h" #include "BKE_material.h" #include "BKE_exotic.h" +#include "BKE_report.h" -/* #include "BKE_error.h" */ #include "BKE_screen.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" @@ -205,18 +206,31 @@ static void read_stl_mesh_binary(Scene *scene, char *str) unsigned int numfacets = 0, i, j, vertnum; unsigned int maxmeshsize, nummesh, lastmeshsize; unsigned int totvert, totface; + ReportList *reports= NULL; /* XXX */ fpSTL= fopen(str, "rb"); if(fpSTL==NULL) { - //XXX error("Can't read file"); + BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno)); return; } - fseek(fpSTL, 80, SEEK_SET); - fread(&numfacets, 4*sizeof(char), 1, fpSTL); + if(fseek(fpSTL, 80, SEEK_SET) != 0) { + BKE_reportf(reports, RPT_ERROR, "Failed reading file: %s.", strerror(errno)); + fclose(fpSTL); + return; + } + + if(fread(&numfacets, 4*sizeof(char), 1, fpSTL) != 1) { + if(feof(fpSTL)) + BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file."); + else + BKE_reportf(reports, RPT_ERROR, "Failed reading file: %s.", strerror(errno)); + fclose(fpSTL); + return; + } if (ENDIAN_ORDER==B_ENDIAN) { - SWITCH_INT(numfacets); - } + SWITCH_INT(numfacets); + } maxmeshsize = MESH_MAX_VERTS/3; @@ -318,13 +332,14 @@ static void read_stl_mesh_ascii(Scene *scene, char *str) unsigned int numtenthousand, linenum; unsigned int i, vertnum; unsigned int totvert, totface; + ReportList *reports= NULL; /* XXX */ /* ASCII stl sucks ... we don't really know how many faces there are until the file is done, so lets allocate faces 10000 at a time */ fpSTL= fopen(str, "r"); if(fpSTL==NULL) { - //XXX error("Can't read file"); + BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno)); return; } @@ -634,6 +649,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb) int file, filelen, count, lll, face, nr = 0; int skipdata, ok, a, b, tot, first, colnr, coordtype, polytype, *idata; struct DispList *dl; + ReportList *reports= NULL; /* XXX */ ivbase.first= ivbase.last= 0; iv_curcol= 0; @@ -641,7 +657,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb) file= open(str, O_BINARY|O_RDONLY); if(file== -1) { - //XXX error("Can't read file\n"); + BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno)); return; } @@ -652,7 +668,11 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb) } maindata= MEM_mallocN(filelen, "leesInventor"); - read(file, maindata, filelen); + if(read(file, maindata, filelen) < filelen) { + BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file."); + close(file); + return; + } close(file); iv_data_stack= MEM_mallocN(sizeof(float)*IV_MAXSTACK, "ivstack"); @@ -1895,6 +1915,7 @@ void write_stl(Scene *scene, char *str) Base *base; FILE *fpSTL; int numfacets = 0; + ReportList *reports= NULL; /* XXX */ if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0; if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0; @@ -1908,7 +1929,7 @@ void write_stl(Scene *scene, char *str) fpSTL= fopen(str, "wb"); if(fpSTL==NULL) { - //XXX error("Can't write file"); + BKE_reportf(reports, RPT_ERROR, "Can't open file: %s.", strerror(errno)); return; } strcpy(temp_dir, str); @@ -3388,7 +3409,7 @@ static void dxf_read_polyline(Scene *scene, int noob) { /* Blender vars */ Object *ob; Mesh *me; - float vert[3]; + float vert[3] = {0}; MVert *mvert, *vtmp; MFace *mface, *ftmp; @@ -3613,7 +3634,7 @@ static void dxf_read_lwpolyline(Scene *scene, int noob) { /* Blender vars */ Object *ob; Mesh *me; - float vert[3]; + float vert[3] = {0}; MVert *mvert; MFace *mface; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 3ce77c8cb4f..807a723685a 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. @@ -50,7 +50,7 @@ #include "BKE_fcurve.h" #include "BKE_animsys.h" #include "BKE_action.h" - +#include "BKE_armature.h" #include "BKE_curve.h" #include "BKE_global.h" #include "BKE_idprop.h" @@ -284,9 +284,49 @@ int list_find_data_fcurves (ListBase *dst, ListBase *src, const char *dataPrefix return matches; } +FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) +{ + FCurve *fcu= NULL; + + *driven= 0; + + /* there must be some RNA-pointer + property combon */ + if(prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { + AnimData *adt= BKE_animdata_from_id(ptr->id.data); + char *path; + + if(adt) { + if((adt->action && adt->action->curves.first) || (adt->drivers.first)) { + /* XXX this function call can become a performance bottleneck */ + path= RNA_path_from_ID_to_property(ptr, prop); + + if(path) { + /* animation takes priority over drivers */ + if(adt->action && adt->action->curves.first) + fcu= list_find_fcurve(&adt->action->curves, path, rnaindex); + + /* if not animated, check if driven */ + if(!fcu && (adt->drivers.first)) { + fcu= list_find_fcurve(&adt->drivers, path, rnaindex); + + if(fcu) + *driven= 1; + } + + if(fcu && action) + *action= adt->action; + + MEM_freeN(path); + } + } + } + } + + return fcu; +} /* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */ -#define BEZT_BINARYSEARCH_THRESH 0.00001f +#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */ /* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_fcurve) * Returns the index to insert at (data already at that index will be offset if replace is 0) @@ -761,13 +801,19 @@ typedef struct DriverVarTypeInfo { /* ......... */ +static ID *dtar_id_ensure_proxy_from(ID *id) +{ + if (id && GS(id->name)==ID_OB && ((Object *)id)->proxy_from) + return (ID *)(((Object *)id)->proxy_from); + return id; +} + /* Helper function to obtain a value using RNA from the specified source (for evaluating drivers) */ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) { PointerRNA id_ptr, ptr; PropertyRNA *prop; ID *id; - char *path; int index; float value= 0.0f; @@ -775,22 +821,22 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) if ELEM(NULL, driver, dtar) return 0.0f; - /* get RNA-pointer for the ID-block given in target */ - RNA_id_pointer_create(dtar->id, &id_ptr); - id= dtar->id; - path= dtar->rna_path; + id= dtar_id_ensure_proxy_from(dtar->id); /* error check for missing pointer... */ // TODO: tag the specific target too as having issues if (id == NULL) { printf("Error: driver has an invalid target to use \n"); - if (G.f & G_DEBUG) printf("\tpath = %s\n", path); + if (G.f & G_DEBUG) printf("\tpath = %s\n", dtar->rna_path); driver->flag |= DRIVER_FLAG_INVALID; return 0.0f; } + /* get RNA-pointer for the ID-block given in target */ + RNA_id_pointer_create(id, &id_ptr); + /* get property to read from, and get value as appropriate */ - if (RNA_path_resolve_full(&id_ptr, path, &ptr, &prop, &index)) { + if (RNA_path_resolve_full(&id_ptr, dtar->rna_path, &ptr, &prop, &index)) { switch (RNA_property_type(prop)) { case PROP_BOOLEAN: if (RNA_property_array_length(&ptr, prop)) @@ -819,7 +865,7 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) } else { if (G.f & G_DEBUG) - printf("Driver Evaluation Error: cannot resolve target for %s -> %s \n", id->name, path); + printf("Driver Evaluation Error: cannot resolve target for %s -> %s \n", id->name, dtar->rna_path); driver->flag |= DRIVER_FLAG_INVALID; return 0.0f; @@ -831,13 +877,16 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) /* Helper function to obtain a pointer to a Pose Channel (for evaluating drivers) */ static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dtar) { + ID *id; /* sanity check */ if ELEM(NULL, driver, dtar) return NULL; - + + id= dtar_id_ensure_proxy_from(dtar->id); + /* check if the ID here is a valid object */ - if ((dtar->id) && GS(dtar->id->name)) { - Object *ob= (Object *)dtar->id; + if (id && GS(id->name)) { + Object *ob= (Object *)id; /* get pose, and subsequently, posechannel */ return get_pose_channel(ob->pose, dtar->pchan_name); @@ -907,12 +956,12 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) DRIVER_TARGETS_USED_LOOPER(dvar) { /* get pointer to loc values to store in */ - Object *ob= (Object *)dtar->id; + Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id); bPoseChannel *pchan; float tmp_loc[3]; /* check if this target has valid data */ - if ((ob == NULL) || (GS(dtar->id->name) != ID_OB)) { + if ((ob == NULL) || (GS(ob->id.name) != ID_OB)) { /* invalid target, so will not have enough targets */ driver->flag |= DRIVER_FLAG_INVALID; return 0.0f; @@ -967,13 +1016,14 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) { DriverTarget *dtar= &dvar->targets[0]; - Object *ob= (Object *)dtar->id; + Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id); bPoseChannel *pchan; float mat[4][4]; - short rotOrder = 0; + float eul[3] = {0.0f,0.0f,0.0f}; + short useEulers=0, rotOrder=ROT_MODE_EUL; /* check if this target has valid data */ - if ((ob == NULL) || (GS(dtar->id->name) != ID_OB)) { + if ((ob == NULL) || (GS(ob->id.name) != ID_OB)) { /* invalid target, so will not have enough targets */ driver->flag |= DRIVER_FLAG_INVALID; return 0.0f; @@ -985,16 +1035,28 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* check if object or bone, and get transform matrix accordingly */ if (pchan) { /* bone */ - rotOrder= (pchan->rotmode > 0) ? pchan->rotmode : ROT_MODE_EUL; + if (pchan->rotmode > 0) { + VECCOPY(eul, pchan->eul); + rotOrder= pchan->rotmode; + useEulers = 1; + } - if (dtar->flag & DTAR_FLAG_LOCALSPACE) - copy_m4_m4(mat, pchan->chan_mat); + if (dtar->flag & DTAR_FLAG_LOCALSPACE) { + /* specially calculate local matrix, since chan_mat is not valid + * since it stores delta transform of pose_mat so that deforms work + */ + pchan_to_mat4(pchan, mat); + } else mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat); } else { /* object */ - rotOrder= (ob->rotmode > 0) ? ob->rotmode : ROT_MODE_EUL; + if (ob->rotmode > 0) { + VECCOPY(eul, ob->rot); + rotOrder= ob->rotmode; + useEulers = 1; + } if (dtar->flag & DTAR_FLAG_LOCALSPACE) object_to_mat4(ob, mat); @@ -1015,10 +1077,10 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) return scale[dtar->transChan - DTAR_TRANSCHAN_SCALEX]; } else if (dtar->transChan >= DTAR_TRANSCHAN_ROTX) { - /* extract euler rotation, and choose the right axis */ - float eul[3]; + /* extract euler rotation (if needed), and choose the right axis */ + if ((dtar->flag & DTAR_FLAG_LOCALSPACE)==0 || (useEulers == 0)) + mat4_to_eulO(eul, rotOrder, mat); - mat4_to_eulO(eul, rotOrder, mat); return eul[dtar->transChan - DTAR_TRANSCHAN_ROTX]; } else { @@ -1150,7 +1212,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver) /* give the variable a 'unique' name */ strcpy(dvar->name, "var"); - BLI_uniquename(&driver->variables, dvar, "var", '_', offsetof(DriverVar, name), 64); + BLI_uniquename(&driver->variables, dvar, "var", '_', offsetof(DriverVar, name), sizeof(dvar->name)); /* set the default type to 'single prop' */ driver_change_variable_type(dvar, DVAR_TYPE_SINGLE_PROP); @@ -1205,6 +1267,7 @@ ChannelDriver *fcurve_copy_driver (ChannelDriver *driver) /* copy all data */ ndriver= MEM_dupallocN(driver); + ndriver->expr_comp= NULL; /* copy variables */ ndriver->variables.first= ndriver->variables.last= NULL; @@ -1231,20 +1294,23 @@ ChannelDriver *fcurve_copy_driver (ChannelDriver *driver) float driver_get_variable_value (ChannelDriver *driver, DriverVar *dvar) { DriverVarTypeInfo *dvti; - + /* sanity check */ if (ELEM(NULL, driver, dvar)) return 0.0f; /* call the relevant callbacks to get the variable value - * using the variable type info + * using the variable type info, storing the obtained value + * in dvar->curval so that drivers can be debugged */ dvti= get_dvar_typeinfo(dvar->type); if (dvti && dvti->get_value) - return dvti->get_value(driver, dvar); + dvar->curval= dvti->get_value(driver, dvar); else - return 0.0f; + dvar->curval= 0.0f; + + return dvar->curval; } /* Evaluate an Channel-Driver to get a 'time' value to use instead of "evaltime" @@ -1267,12 +1333,12 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) if (driver->variables.first == driver->variables.last) { /* just one target, so just use that */ dvar= driver->variables.first; - return driver_get_variable_value(driver, dvar); + driver->curval= driver_get_variable_value(driver, dvar); } else { /* more than one target, so average the values of the targets */ - int tot = 0; float value = 0.0f; + int tot = 0; /* loop through targets, adding (hopefully we don't get any overflow!) */ for (dvar= driver->variables.first; dvar; dvar=dvar->next) { @@ -1282,10 +1348,9 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) /* perform operations on the total if appropriate */ if (driver->type == DRIVER_TYPE_AVERAGE) - return (value / (float)tot); + driver->curval= (value / (float)tot); else - return value; - + driver->curval= value; } } break; @@ -1319,6 +1384,9 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) value= tmp_val; } } + + /* store value in driver */ + driver->curval= value; } break; @@ -1329,13 +1397,15 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) if ( (driver->expression[0] == '\0') || (driver->flag & DRIVER_FLAG_INVALID) ) { - return 0.0f; + driver->curval= 0.0f; + } + else + { + /* this evaluates the expression using Python,and returns its result: + * - on errors it reports, then returns 0.0f + */ + driver->curval= BPY_pydriver_eval(driver); } - - /* this evaluates the expression using Python,and returns its result: - * - on errors it reports, then returns 0.0f - */ - return BPY_pydriver_eval(driver); #endif /* DISABLE_PYTHON*/ } break; @@ -1346,12 +1416,11 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) * This is currently used as the mechanism which allows animated settings to be able * to be changed via the UI. */ - return driver->curval; } } - /* return 0.0f, as couldn't find relevant data to use */ - return 0.0f; + /* return value for driver */ + return driver->curval; } /* ***************************** Curve Calculations ********************************* */ @@ -1658,9 +1727,13 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim { /* evaltime occurs somewhere in the middle of the curve */ for (a=0; prevbezt && bezt && (a < fcu->totvert-1); a++, prevbezt=bezt, bezt++) - { + { + /* use if the key is directly on the frame, rare cases this is needed else we get 0.0 instead. */ + if(fabs(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) { + cvalue= bezt->vec[1][1]; + } /* evaltime occurs within the interval defined by these two keyframes */ - if ((prevbezt->vec[1][0] <= evaltime) && (bezt->vec[1][0] >= evaltime)) + else if ((prevbezt->vec[1][0] <= evaltime) && (bezt->vec[1][0] >= evaltime)) { /* value depends on interpolation mode */ if ((prevbezt->ipo == BEZT_IPO_CONST) || (fcu->flag & FCURVE_DISCRETE_VALUES)) diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index cd452b3baef..592119ce099 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. @@ -433,7 +433,7 @@ DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifie } BLI_convertstringcode(targetDir, G.sce); - BLI_convertstringframe(targetDir, curFrame); // fixed #frame-no + BLI_convertstringframe(targetDir, curFrame, 0); // fixed #frame-no strcpy(targetFile,targetDir); strcat(targetFile, ".bobj.gz"); @@ -563,6 +563,12 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], int i; float vec[3]; + if(totvert == 0) { + zero_v3(start); + zero_v3(size); + return; + } + VECCOPY(vec, mvert[0].co); mul_m4_v3(obmat, vec); bbsx = vec[0]; bbsy = vec[1]; bbsz = vec[2]; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 3be9d0133fe..cee6d59488f 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 41e5178d6cb..36bb031744e 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 8a933ba5289..c65961d0953 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender @@ -194,7 +194,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) /* auto-name */ sprintf(gpl->info, "GP_Layer"); - BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), 128); + BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info)); /* make this one the active one */ gpencil_layer_setactive(gpd, gpl); diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index f35a0a96bb4..4f768bbad23 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -57,13 +57,13 @@ #include <config.h> #endif -void free_group_object(GroupObject *go) +static void free_group_object(GroupObject *go) { MEM_freeN(go); } -void free_group(Group *group) +void free_group_objects(Group *group) { /* don't free group itself */ GroupObject *go; @@ -130,7 +130,7 @@ void unlink_group(Group *group) } /* group stays in library, but no members */ - free_group(group); + free_group_objects(group); group->id.us= 0; } diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index b9e3c593ddf..1f22e8c1e3f 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2006-2007 Blender Foundation. * All rights reserved. @@ -49,6 +49,7 @@ #include "BKE_icons.h" #include "BKE_utildefines.h" +#include "BKE_global.h" /* only for G.background test */ #include "BLO_sys_types.h" // for intptr_t support @@ -217,7 +218,7 @@ void BKE_icon_changed(int id) { Icon* icon = 0; - if (!id) return; + if (!id || G.background) return; icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(id)); @@ -239,7 +240,7 @@ int BKE_icon_getid(struct ID* id) { Icon* new_icon = 0; - if (!id) + if (!id || G.background) return 0; if (id->icon_id) diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index ddfb28437a9..37aee8fb4aa 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -385,6 +385,49 @@ IDProperty *IDP_CopyGroup(IDProperty *prop) return newp; } +/* use for syncing proxies. + * When values name and types match, copy the values, else ignore */ +void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) +{ + IDProperty *loop, *prop; + for (prop=src->data.group.first; prop; prop=prop->next) { + for (loop=dest->data.group.first; loop; loop=loop->next) { + if (BSTR_EQ(loop->name, prop->name)) { + int copy_done= 0; + + if(prop->type==loop->type) { + + switch (prop->type) { + case IDP_INT: + case IDP_FLOAT: + case IDP_DOUBLE: + loop->data= prop->data; + copy_done= 1; + break; + case IDP_GROUP: + IDP_SyncGroupValues(loop, prop); + copy_done= 1; + break; + default: + { + IDProperty *tmp= loop; + IDProperty *copy= IDP_CopyProperty(prop); + + BLI_insertlinkafter(&dest->data.group, loop, copy); + BLI_remlink(&dest->data.group, tmp); + loop = copy; + + IDP_FreeProperty(tmp); + MEM_freeN(tmp); + } + } + } + break; + } + } + } +} + /* replaces all properties with the same name in a destination group from a source group. */ @@ -392,12 +435,11 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) { IDProperty *loop, *prop; for (prop=src->data.group.first; prop; prop=prop->next) { - IDProperty *copy = IDP_CopyProperty(prop); - for (loop=dest->data.group.first; loop; loop=loop->next) { if (BSTR_EQ(loop->name, prop->name)) { - if (loop->next) BLI_insertlinkbefore(&dest->data.group, loop->next, copy); - else BLI_addtail(&dest->data.group, copy); + IDProperty *copy = IDP_CopyProperty(prop); + + BLI_insertlink(&dest->data.group, loop, copy); BLI_remlink(&dest->data.group, loop); IDP_FreeProperty(loop); @@ -406,8 +448,12 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) } } - dest->len++; - BLI_addtail(&dest->data.group, copy); + /* only add at end if not added yet */ + if (loop == NULL) { + IDProperty *copy = IDP_CopyProperty(prop); + dest->len++; + BLI_addtail(&dest->data.group, copy); + } } } /* @@ -419,8 +465,7 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) IDProperty *loop; for (loop=group->data.group.first; loop; loop=loop->next) { if (BSTR_EQ(loop->name, prop->name)) { - if (loop->next) BLI_insertlinkbefore(&group->data.group, loop->next, prop); - else BLI_addtail(&group->data.group, prop); + BLI_insertlink(&group->data.group, loop, prop); BLI_remlink(&group->data.group, loop); IDP_FreeProperty(loop); @@ -513,14 +558,12 @@ void IDP_FreeIterBeforeEnd(void *vself) direct data.*/ static void IDP_FreeGroup(IDProperty *prop) { - IDProperty *loop, *next; - for (loop=prop->data.group.first; loop; loop=next) + IDProperty *loop; + for (loop=prop->data.group.first; loop; loop=loop->next) { - next = loop->next; - BLI_remlink(&prop->data.group, loop); IDP_FreeProperty(loop); - MEM_freeN(loop); } + BLI_freelistN(&prop->data.group); } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f7edb2bd146..accadb3d434 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -392,7 +392,6 @@ Image *BKE_add_image_file(const char *name, int frame) BLI_strncpy(str, name, sizeof(str)); BLI_convertstringcode(str, G.sce); - BLI_convertstringframe(str, frame); /* exists? */ file= open(str, O_BINARY|O_RDONLY); @@ -404,7 +403,6 @@ Image *BKE_add_image_file(const char *name, int frame) if(ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) { BLI_strncpy(strtest, ima->name, sizeof(ima->name)); BLI_convertstringcode(strtest, G.sce); - BLI_convertstringframe(strtest, frame); if( strcmp(strtest, str)==0 ) { if(ima->anim==NULL || ima->id.us==0) { @@ -725,17 +723,6 @@ void BKE_image_print_memlist(void) } } -/* frees all ibufs used by any image datablocks */ -void BKE_image_free_image_ibufs(void) -{ - Image *ima; - - for(ima= G.main->image.first; ima; ima= ima->id.next) { - image_free_buffers(ima); - } - -} - void BKE_image_free_all_textures(void) { Tex *tex; @@ -1024,9 +1011,9 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } if (scene->r.stamp & R_STAMP_MARKER) { - TimeMarker *marker = NULL; // XXX get_frame_marker(scene->r.cfra); + char *name = scene_find_last_marker_name(scene, CFRA); - if (marker) strcpy(text, marker->name); + if (name) strcpy(text, name); else strcpy(text, "<none>"); if (do_prefix) sprintf(stamp_data->marker, "Marker %s", text); @@ -1101,7 +1088,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } { - Render *re= RE_GetRender(scene->id.name); + Render *re= RE_GetRender(scene->id.name, RE_SLOT_RENDERING); RenderStats *stats= re ? RE_GetStats(re):NULL; if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { @@ -1423,15 +1410,9 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_ext) { if (string==NULL) return; - BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ - - /* if we dont have any #'s to insert numbers into, use 4 numbers by default */ - if (strchr(string, '#')==NULL) - strcat(string, "####"); /* 4 numbers */ - BLI_convertstringcode(string, G.sce); - BLI_convertstringframe(string, frame); + BLI_convertstringframe(string, frame, 4); if(use_ext) BKE_add_image_extension(string, imtype); @@ -1449,7 +1430,10 @@ struct anim *openanim(char *name, int flags) ibuf = IMB_anim_absolute(anim, 0); if (ibuf == NULL) { - printf("not an anim; %s\n", name); + if(BLI_exists(name)) + printf("not an anim: %s\n", name); + else + printf("anim file doesn't exist: %s\n", name); IMB_free_anim(anim); return(0); } @@ -1480,7 +1464,7 @@ struct anim *openanim(char *name, int flags) */ -/* forces existance of 1 Image for renderout or nodes, returns Image */ +/* forces existence of 1 Image for renderout or nodes, returns Image */ /* name is only for default, when making new one */ Image *BKE_image_verify_viewer(int type, const char *name) { @@ -1615,7 +1599,7 @@ RenderResult *BKE_image_acquire_renderresult(struct Scene *scene, Image *ima) if(ima->rr) return ima->rr; else if(ima->type==IMA_TYPE_R_RESULT) - return RE_AcquireResultRead(RE_GetRender(scene->id.name)); + return RE_AcquireResultRead(RE_GetRender(scene->id.name, RE_SLOT_VIEW)); return NULL; } @@ -1623,7 +1607,7 @@ void BKE_image_release_renderresult(struct Scene *scene, Image *ima) { if(ima->rr); else if(ima->type==IMA_TYPE_R_RESULT) - RE_ReleaseResult(RE_GetRender(scene->id.name)); + RE_ReleaseResult(RE_GetRender(scene->id.name, RE_SLOT_VIEW)); } /* after imbuf load, openexr type can return with a exrhandle open */ @@ -1672,6 +1656,10 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) unsigned short numlen; char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX]; + /* XXX temp stuff? */ + if(ima->lastframe != frame) + ima->tpageflag |= IMA_TPAGE_REFRESH; + ima->lastframe= frame; BLI_stringdec(ima->name, head, tail, &numlen); @@ -1683,8 +1671,6 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) else BLI_convertstringcode(name, G.sce); - BLI_convertstringframe(name, frame); /* TODO - should this be here? */ - /* read ibuf */ ibuf = IMB_loadiffname(name, IB_rect|IB_multilayer); if(G.f & G_DEBUG) printf("loaded %s\n", name); @@ -1846,7 +1832,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) else BLI_convertstringcode(str, G.sce); - BLI_convertstringframe(str, cfra); + BLI_convertstringframe(str, cfra, 0); /* read ibuf */ ibuf = IMB_loadiffname(str, IB_rect|IB_multilayer|IB_imginfo); @@ -1937,7 +1923,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ return NULL; if(iuser && iuser->scene) { - re= RE_GetRender(iuser->scene->id.name); + re= RE_GetRender(iuser->scene->id.name, RE_SLOT_VIEW); rr= RE_AcquireResultRead(re); /* release is done in BKE_image_release_ibuf using lock_r */ @@ -1961,7 +1947,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ } else { RenderResult rres; - float *rectf; + float *rectf, *rectz; unsigned int *rect; float dither; int channels, layer, pass; @@ -1971,9 +1957,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ pass= (iuser)? iuser->pass: 0; /* this gives active layer, composite or seqence result */ - RE_AcquireResultImage(RE_GetRender(iuser->scene->id.name), &rres); + RE_AcquireResultImage(RE_GetRender(iuser->scene->id.name, RE_SLOT_VIEW), &rres); rect= (unsigned int *)rres.rect32; rectf= rres.rectf; + rectz= rres.rectz; dither= iuser->scene->r.dither_intensity; /* get compo/seq result by default */ @@ -1981,18 +1968,24 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ else if(rr->layers.first) { RenderLayer *rl= BLI_findlink(&rr->layers, layer-(rr->rectf?1:0)); if(rl) { + RenderPass *rpass; + /* there's no combined pass, is in renderlayer itself */ if(pass==0) { rectf= rl->rectf; } else { - RenderPass *rpass= BLI_findlink(&rl->passes, pass-1); + rpass= BLI_findlink(&rl->passes, pass-1); if(rpass) { channels= rpass->channels; rectf= rpass->rect; dither= 0.0f; /* don't dither passes */ } } + + for(rpass= rl->passes.first; rpass; rpass= rpass->next) + if(rpass->passtype == SCE_PASS_Z) + rectz= rpass->rect; } } @@ -2015,7 +2008,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->rect_float= rectf; ibuf->flags |= IB_rectfloat; ibuf->channels= channels; - ibuf->zbuf_float= rres.rectz; + ibuf->zbuf_float= rectz; ibuf->flags |= IB_zbuffloat; ibuf->dither= dither; @@ -2040,11 +2033,20 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame if(ima->source==IMA_SRC_MOVIE) { frame= iuser?iuser->framenr:ima->lastframe; ibuf= image_get_ibuf(ima, 0, frame); + /* XXX temp stuff? */ + if(ima->lastframe != frame) + ima->tpageflag |= IMA_TPAGE_REFRESH; + ima->lastframe = frame; } else if(ima->source==IMA_SRC_SEQUENCE) { if(ima->type==IMA_TYPE_IMAGE) { frame= iuser?iuser->framenr:ima->lastframe; ibuf= image_get_ibuf(ima, 0, frame); + + /* XXX temp stuff? */ + if(ima->lastframe != frame) + ima->tpageflag |= IMA_TPAGE_REFRESH; + ima->lastframe = frame; } else if(ima->type==IMA_TYPE_MULTILAYER) { frame= iuser?iuser->framenr:ima->lastframe; @@ -2211,7 +2213,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) return BKE_image_acquire_ibuf(ima, iuser, NULL); } -void BKE_image_user_calc_imanr(ImageUser *iuser, int cfra, int fieldnr) +void BKE_image_user_calc_frame(ImageUser *iuser, int cfra, int fieldnr) { int imanr, len; @@ -2258,104 +2260,3 @@ void BKE_image_user_calc_imanr(ImageUser *iuser, int cfra, int fieldnr) if(iuser->ok==0) iuser->ok= 1; } } - -/* - Produce image export path. - - Fails returning 0 if image filename is empty or if destination path - matches image path (i.e. both are the same file). - - Trailing slash in dest_dir is optional. - - Logic: - - - if an image is "below" current .blend file directory, rebuild the - same dir structure in dest_dir - - For example //textures/foo/bar.png becomes - [dest_dir]/textures/foo/bar.png. - - - if an image is not "below" current .blend file directory, - disregard it's path and copy it in the same directory where 3D file - goes. - - For example //../foo/bar.png becomes [dest_dir]/bar.png. - - This logic will help ensure that all image paths are relative and - that a user gets his images in one place. It'll also provide - consistent behaviour across exporters. - */ -int BKE_get_image_export_path(struct Image *im, const char *dest_dir, char *abs, int abs_size, char *rel, int rel_size) -{ - char path[FILE_MAX]; - char dir[FILE_MAX]; - char base[FILE_MAX]; - char blend_dir[FILE_MAX]; /* directory, where current .blend file resides */ - char dest_path[FILE_MAX]; - char rel_dir[FILE_MAX]; - int len; - - if (abs) - abs[0]= 0; - - if (rel) - rel[0]= 0; - - BLI_split_dirfile_basic(G.sce, blend_dir, NULL); - - if (!strlen(im->name)) { - if (G.f & G_DEBUG) printf("Invalid image type.\n"); - return 0; - } - - BLI_strncpy(path, im->name, sizeof(path)); - - /* expand "//" in filename and get absolute path */ - BLI_convertstringcode(path, G.sce); - - /* get the directory part */ - BLI_split_dirfile_basic(path, dir, base); - - len= strlen(blend_dir); - - rel_dir[0] = 0; - - /* if image is "below" current .blend file directory */ - if (!strncmp(path, blend_dir, len)) { - - /* if image is _in_ current .blend file directory */ - if (!strcmp(dir, blend_dir)) { - BLI_join_dirfile(dest_path, dest_dir, base); - } - /* "below" */ - else { - /* rel = image_path_dir - blend_dir */ - BLI_strncpy(rel_dir, dir + len, sizeof(rel_dir)); - - BLI_join_dirfile(dest_path, dest_dir, rel_dir); - BLI_join_dirfile(dest_path, dest_path, base); - } - - } - /* image is out of current directory */ - else { - BLI_join_dirfile(dest_path, dest_dir, base); - } - - if (abs) - BLI_strncpy(abs, dest_path, abs_size); - - if (rel) { - strncat(rel, rel_dir, rel_size); - strncat(rel, base, rel_size); - } - - /* return 2 if src=dest */ - if (!strcmp(path, dest_path)) { - if (G.f & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path); - return 2; - } - - return 1; -} - diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index f2b737fa3c2..6912a65886a 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. @@ -1408,19 +1408,29 @@ typedef struct HairGridVert { float velocity[3]; float density; } HairGridVert; +#define HAIR_GRID_INDEX(vec, min, max, axis) (int)( (vec[axis] - min[axis]) / (max[axis] - min[axis]) * 9.99f ); /* Smoothing of hair velocities: * adapted from Volumetric Methods for Simulation and Rendering of Hair by Lena Petrovic, Mark Henne and John Anderson * Pixar Technical Memo #06-08, Pixar Animation Studios */ -static void hair_velocity_smoothing(float smoothfac, lfVector *lF, lfVector *lX, lfVector *lV, int numverts) +static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVector *lV, int numverts) { - /* TODO: this is an initial implementation and should be made much better in due time */ + /* TODO: This is an initial implementation and should be made much better in due time. + * What should at least be implemented is a grid size parameter and a smoothing kernel + * for bigger grids. + */ /* 10x10x10 grid gives nice initial results */ HairGridVert grid[10][10][10]; + HairGridVert colg[10][10][10]; + ListBase *colliders = get_collider_cache(clmd->scene, NULL); + ColliderCache *col = NULL; float gmin[3], gmax[3], density; + /* 2.0f is an experimental value that seems to give good results */ + float smoothfac = 2.0f * clmd->sim_parms->velocity_smooth; + float collfac = 2.0f * clmd->sim_parms->collider_friction; int v = 0; int i = 0; int j = 0; @@ -1439,15 +1449,20 @@ static void hair_velocity_smoothing(float smoothfac, lfVector *lF, lfVector *lX, grid[i][j][k].velocity[1] = 0.0f; grid[i][j][k].velocity[2] = 0.0f; grid[i][j][k].density = 0.0f; + + colg[i][j][k].velocity[0] = 0.0f; + colg[i][j][k].velocity[1] = 0.0f; + colg[i][j][k].velocity[2] = 0.0f; + colg[i][j][k].density = 0.0f; } } } /* gather velocities & density */ - for(v = 0; v < numverts; v++) { - i = (int)( (lX[v][0] - gmin[0]) / (gmax[0] - gmin[0]) * 9.99f ); - j = (int)( (lX[v][1] - gmin[1]) / (gmax[1] - gmin[1]) * 9.99f ); - k = (int)( (lX[v][2] - gmin[2]) / (gmax[2] - gmin[2]) * 9.99f ); + if(smoothfac > 0.0f) for(v = 0; v < numverts; v++) { + i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0); + j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1); + k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2); grid[i][j][k].velocity[0] += lV[v][0]; grid[i][j][k].velocity[1] += lV[v][1]; @@ -1455,6 +1470,36 @@ static void hair_velocity_smoothing(float smoothfac, lfVector *lF, lfVector *lX, grid[i][j][k].density += 1.0f; } + /* gather colliders */ + if(colliders && collfac > 0.0f) for(col = colliders->first; col; col = col->next) + { + MVert *loc0 = col->collmd->x; + MVert *loc1 = col->collmd->xnew; + float vel[3]; + + for(v=0; v<col->collmd->numverts; v++, loc0++, loc1++) { + i = HAIR_GRID_INDEX(loc1->co, gmin, gmax, 0); + + if(i>=0 && i<10) { + j = HAIR_GRID_INDEX(loc1->co, gmin, gmax, 1); + + if(j>=0 && j<10) { + k = HAIR_GRID_INDEX(loc1->co, gmin, gmax, 2); + + if(k>=0 && k<10) { + VECSUB(vel, loc1->co, loc0->co); + + colg[i][j][k].velocity[0] += vel[0]; + colg[i][j][k].velocity[1] += vel[1]; + colg[i][j][k].velocity[2] += vel[2]; + colg[i][j][k].density += 1.0; + } + } + } + } + } + + /* divide velocity with density */ for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { @@ -1465,21 +1510,35 @@ static void hair_velocity_smoothing(float smoothfac, lfVector *lF, lfVector *lX, grid[i][j][k].velocity[1] /= density; grid[i][j][k].velocity[2] /= density; } + + density = colg[i][j][k].density; + if(density > 0.0f) { + colg[i][j][k].velocity[0] /= density; + colg[i][j][k].velocity[1] /= density; + colg[i][j][k].velocity[2] /= density; + } } } } /* calculate forces */ for(v = 0; v < numverts; v++) { - i = (int)( (lX[v][0] - gmin[0]) / (gmax[0] - gmin[0]) * 9.99f ); - j = (int)( (lX[v][1] - gmin[1]) / (gmax[1] - gmin[1]) * 9.99f ); - k = (int)( (lX[v][2] - gmin[2]) / (gmax[2] - gmin[2]) * 9.99f ); - - /* 2.0f is an experimental value that seems to give good results */ - lF[v][0] += 2.0f * smoothfac * (grid[i][j][k].velocity[0] - lV[v][0]); - lF[v][1] += 2.0f * smoothfac * (grid[i][j][k].velocity[1] - lV[v][1]); - lF[v][2] += 2.0f * smoothfac * (grid[i][j][k].velocity[2] - lV[v][2]); + i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0); + j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1); + k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2); + + lF[v][0] += smoothfac * (grid[i][j][k].velocity[0] - lV[v][0]); + lF[v][1] += smoothfac * (grid[i][j][k].velocity[1] - lV[v][1]); + lF[v][2] += smoothfac * (grid[i][j][k].velocity[2] - lV[v][2]); + + if(colg[i][j][k].density > 0.0f) { + lF[v][0] += collfac * (colg[i][j][k].velocity[0] - lV[v][0]); + lF[v][1] += collfac * (colg[i][j][k].velocity[1] - lV[v][1]); + lF[v][2] += collfac * (colg[i][j][k].velocity[2] - lV[v][2]); + } } + + free_collider_cache(&colliders); } static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M) { @@ -1508,8 +1567,8 @@ static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, init_lfvector(lF, gravity, numverts); - if(clmd->sim_parms->velocity_smooth > 0.0f) - hair_velocity_smoothing(clmd->sim_parms->velocity_smooth, lF, lX, lV, numverts); + if(clmd->sim_parms->velocity_smooth > 0.0f || clmd->sim_parms->collider_friction > 0.0f) + hair_velocity_smoothing(clmd, lF, lX, lV, numverts); /* multiply lF with mass matrix // force = mass * acceleration (in this case: gravity) @@ -1579,6 +1638,36 @@ static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor); } } + + /* Hair has only edges */ + if(cloth->numfaces == 0) { + ClothSpring *spring; + float edgevec[3]={0,0,0}; //edge vector + float edgeunnormal[3]={0,0,0}; // not-normalized-edge normal + float tmp[3]={0,0,0}; + float factor = 0.01; + + search = cloth->springs; + while(search) { + spring = search->link; + + if(spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) { + VECSUB(edgevec, (float*)lX[spring->ij], (float*)lX[spring->kl]); + + project_v3_v3v3(tmp, winvec[spring->ij], edgevec); + VECSUB(edgeunnormal, winvec[spring->ij], tmp); + /* hair doesn't stretch too much so we can use restlen pretty safely */ + VECADDS(lF[spring->ij], lF[spring->ij], edgeunnormal, spring->restlen * factor); + + project_v3_v3v3(tmp, winvec[spring->kl], edgevec); + VECSUB(edgeunnormal, winvec[spring->kl], tmp); + VECADDS(lF[spring->kl], lF[spring->kl], edgeunnormal, spring->restlen * factor); + } + + search = search->next; + } + } + del_lfvector(winvec); } @@ -1689,8 +1778,8 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase VECCOPY(verts[i].txold, id->X[i]); } - - if(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) + + if(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) { float temp = clmd->sim_parms->stepsPerFrame; /* not too nice hack, but collisions need this correction -jahka */ diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index feb7fc3e382..dbde6403226 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -865,12 +865,15 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co case ID_SO: /* sound */ propname= sound_adrcodes_to_paths(adrcode, &dummy_index); + break; case ID_WO: /* world */ propname= world_adrcodes_to_paths(adrcode, &dummy_index); + break; case ID_PA: /* particle */ propname= particle_adrcodes_to_paths(adrcode, &dummy_index); + break; /* XXX problematic blocktypes */ case ID_CU: /* curve */ @@ -1069,7 +1072,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) /* Add F-Curve to the correct list * - grpname is needed to be used as group name where relevant, and is usually derived from actname */ -static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, char *grpname) +static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo) { /* If we're adding to an action, we will have groups to write to... */ if (groups && grpname) { @@ -1096,10 +1099,12 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); agrp->flag = AGRP_SELECTED; - BLI_snprintf(agrp->name, 64, grpname); + if(muteipo) agrp->flag |= AGRP_MUTED; + + strncpy(agrp->name, grpname, sizeof(agrp->name)); BLI_addtail(&tmp_act.groups, agrp); - BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), 64); + BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name)); } } @@ -1107,6 +1112,9 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c /* WARNING: this func should only need to look at the stuff we initialised, if not, things may crash */ action_groups_add_channel(&tmp_act, agrp, fcu); + if(agrp->flag & AGRP_MUTED) /* flush down */ + fcu->flag |= FCURVE_MUTED; + /* set the output lists based on the ones in the temp action */ groups->first= tmp_act.groups.first; groups->last= tmp_act.groups.last; @@ -1124,7 +1132,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to */ -static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname) +static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, int muteipo) { AdrBit2Path *abp; FCurve *fcu; @@ -1240,7 +1248,7 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha } /* add new F-Curve to list */ - fcurve_add_to_list(groups, list, fcurve, actname); + fcurve_add_to_list(groups, list, fcurve, actname, muteipo); } } else { @@ -1275,8 +1283,10 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha /* 'hide' flag is now used for keytype - only 'keyframes' existed before */ dst->hide= BEZT_KEYTYPE_KEYFRAME; - /* correct values for euler rotation curves - they were degrees/10 */ - // XXX for now, just make them into radians as RNA sets/reads directly in that form + /* correct values for euler rotation curves + * - they were degrees/10 + * - we need radians for RNA to do the right thing + */ if ( ((icu->blocktype == ID_OB) && ELEM3(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) || ((icu->blocktype == ID_PO) && ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) ) { @@ -1312,7 +1322,7 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha } /* add new F-Curve to list */ - fcurve_add_to_list(groups, list, fcu, actname); + fcurve_add_to_list(groups, list, fcu, actname, muteipo); } } @@ -1353,7 +1363,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase if (icu->driver) { /* Blender 2.4x allowed empty drivers, but we don't now, since they cause more trouble than they're worth */ if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) { - icu_to_fcurves(NULL, drivers, icu, actname, constname); + icu_to_fcurves(NULL, drivers, icu, actname, constname, ipo->muteipo); } else { MEM_freeN(icu->driver); @@ -1361,7 +1371,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase } } else - icu_to_fcurves(animgroups, anim, icu, actname, constname); + icu_to_fcurves(animgroups, anim, icu, actname, constname, ipo->muteipo); } /* if this IPO block doesn't have any users after this one, free... */ @@ -1793,18 +1803,36 @@ void do_versions_ipos_to_animato(Main *main) } } + /* worlds */ + for (id= main->world.first; id; id= id->next) { + World *wo= (World *)id; + + if (G.f & G_DEBUG) printf("\tconverting world %s \n", id->name+2); + + /* we're only interested in the IPO */ + if (wo->ipo) { + /* Add AnimData block */ + adt= BKE_id_add_animdata(id); + + /* Convert World data... */ + ipo_to_animdata(id, wo->ipo, NULL, NULL); + wo->ipo->id.us--; + wo->ipo= NULL; + } + } + /* sequence strips */ for(scene = main->scene.first; scene; scene = scene->id.next) { if(scene->ed && scene->ed->seqbasep) { Sequence * seq; - + for(seq = scene->ed->seqbasep->first; seq; seq = seq->next) { short adrcode = SEQ_FAC1; - + if (G.f & G_DEBUG) printf("\tconverting sequence strip %s \n", seq->name+2); - + if (!seq->ipo || !seq->ipo->curve.first) { seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 77dfb7bafb4..c32b2d81513 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -52,6 +52,7 @@ #include "BKE_action.h" #include "BKE_blender.h" #include "BKE_curve.h" +#include "BKE_customdata.h" #include "BKE_global.h" #include "BKE_key.h" #include "BKE_lattice.h" @@ -1046,6 +1047,9 @@ static float *get_weights_array(Object *ob, char *vgroup) { bDeformGroup *curdef; MDeformVert *dvert= NULL; + BMEditMesh *em= NULL; + BMIter iter; + BMVert *eve; int totvert= 0, index= 0; /* no vgroup string set? */ @@ -1056,6 +1060,9 @@ static float *get_weights_array(Object *ob, char *vgroup) Mesh *me= ob->data; dvert= me->dvert; totvert= me->totvert; + + if(me->edit_btmesh && me->edit_btmesh->bm->totvert == totvert) + em= me->edit_btmesh; } else if(ob->type==OB_LATTICE) { Lattice *lt= ob->data; @@ -1075,15 +1082,33 @@ static float *get_weights_array(Object *ob, char *vgroup) int i, j; weights= MEM_callocN(totvert*sizeof(float), "weights"); - - for (i=0; i < totvert; i++, dvert++) { - for(j=0; j<dvert->totweight; j++) { - if (dvert->dw[j].def_nr == index) { - weights[i]= dvert->dw[j].weight; - break; + + if(em) { + eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL); + for (i=0; eve; eve=BMIter_Step(&iter), i++) { + dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + + if(dvert) { + for(j=0; j<dvert->totweight; j++) { + if(dvert->dw[j].def_nr == index) { + weights[i]= dvert->dw[j].weight; + break; + } + } } } } + else { + for(i=0; i < totvert; i++, dvert++) { + for(j=0; j<dvert->totweight; j++) { + if(dvert->dw[j].def_nr == index) { + weights[i]= dvert->dw[j].weight; + break; + } + } + } + } + return weights; } return NULL; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index d2f17292df8..211f3d07cf4 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 579ec115c43..a7cafd1e0b4 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -117,6 +117,7 @@ #include "BKE_idprop.h" #include "BKE_particle.h" #include "BKE_gpencil.h" +#include "BKE_fcurve.h" #define MAX_IDPUP 60 /* was 24 */ @@ -652,7 +653,17 @@ static void id_copy_animdata(ID *id) } } -/* used everywhere in blenkernel and text.c */ +/* material nodes use this since they are not treated as libdata */ +void copy_libblock_data(ID *id, const ID *id_from) +{ + if (id_from->properties) + id->properties = IDP_CopyProperty(id_from->properties); + + /* the duplicate should get a copy of the animdata */ + id_copy_animdata(id); +} + +/* used everywhere in blenkernel */ void *copy_libblock(void *rt) { ID *idn, *id; @@ -678,10 +689,8 @@ void *copy_libblock(void *rt) id->newid= idn; idn->flag |= LIB_NEW; - if (id->properties) idn->properties = IDP_CopyProperty(id->properties); - - /* the duplicate should get a copy of the animdata */ - id_copy_animdata(idn); + + copy_libblock_data(idn, id); return idn; } @@ -698,6 +707,30 @@ void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) ) free_windowmanager_cb= func; } +void animdata_dtar_clear_cb(ID *id, AnimData *adt, void *userdata) +{ + ChannelDriver *driver; + FCurve *fcu; + + /* find the driver this belongs to and update it */ + for (fcu=adt->drivers.first; fcu; fcu=fcu->next) { + driver= fcu->driver; + + if (driver) { + DriverVar *dvar; + for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + DRIVER_TARGETS_USED_LOOPER(dvar) + { + if (dtar->id == userdata) + dtar->id= NULL; + } + DRIVER_TARGETS_LOOPER_END + } + } + } +} + + /* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */ void free_libblock(ListBase *lb, void *idv) { @@ -768,7 +801,7 @@ void free_libblock(ListBase *lb, void *idv) sound_free((bSound*)id); break; case ID_GR: - free_group((Group *)id); + free_group_objects((Group *)id); break; case ID_AR: free_armature((bArmature *)id); @@ -798,9 +831,13 @@ void free_libblock(ListBase *lb, void *idv) IDP_FreeProperty(id->properties); MEM_freeN(id->properties); } + BLI_remlink(lb, id); - MEM_freeN(id); + /* this ID may be a driver target! */ + BKE_animdata_main_cb(G.main, animdata_dtar_clear_cb, (void *)id); + + MEM_freeN(id); } void free_libblock_us(ListBase *lb, void *idv) /* test users */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 3567c061f04..27b46c40d28 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -112,7 +112,7 @@ void init_material(Material *ma) ma->specr= ma->specg= ma->specb= 1.0; ma->mirr= ma->mirg= ma->mirb= 1.0; ma->spectra= 1.0; - ma->amb= 0.5; + ma->amb= 1.0; ma->alpha= 1.0; ma->spec= ma->hasize= 0.5; ma->har= 50; @@ -189,7 +189,7 @@ void init_material(Material *ma) ma->vol.ms_intensity = 1.f; ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP; - + ma->shade_flag= MA_APPROX_OCCLUSION; ma->preview = NULL; } @@ -216,7 +216,6 @@ Material *copy_material(Material *ma) #endif // XXX old animation system id_us_plus((ID *)man->group); - for(a=0; a<MAX_MTEX; a++) { if(ma->mtex[a]) { man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial"); @@ -1240,4 +1239,110 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } } +/* copy/paste buffer, if we had a propper py api that would be better */ +Material matcopybuf; +// MTex mtexcopybuf; +static short matcopied=0; + +void clear_matcopybuf(void) +{ + memset(&matcopybuf, 0, sizeof(Material)); +} + +void free_matcopybuf(void) +{ +// extern MTex mtexcopybuf; /* buttons.c */ + int a; + + for(a=0; a<MAX_MTEX; a++) { + if(matcopybuf.mtex[a]) { + MEM_freeN(matcopybuf.mtex[a]); + matcopybuf.mtex[a]= NULL; + } + } + + if(matcopybuf.ramp_col) MEM_freeN(matcopybuf.ramp_col); + if(matcopybuf.ramp_spec) MEM_freeN(matcopybuf.ramp_spec); + + matcopybuf.ramp_col= NULL; + matcopybuf.ramp_spec= NULL; + + if(matcopybuf.nodetree) { + ntreeFreeTree(matcopybuf.nodetree); + MEM_freeN(matcopybuf.nodetree); + matcopybuf.nodetree= NULL; + } +// default_mtex(&mtexcopybuf); +} + +void copy_matcopybuf(Material *ma) +{ + int a; + MTex *mtex; + + if(matcopied) + free_matcopybuf(); + + memcpy(&matcopybuf, ma, sizeof(Material)); + if(matcopybuf.ramp_col) matcopybuf.ramp_col= MEM_dupallocN(matcopybuf.ramp_col); + if(matcopybuf.ramp_spec) matcopybuf.ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec); + + for(a=0; a<MAX_MTEX; a++) { + mtex= matcopybuf.mtex[a]; + if(mtex) { + matcopybuf.mtex[a]= MEM_dupallocN(mtex); + } + } + matcopybuf.nodetree= ntreeCopyTree(ma->nodetree, 0); + matcopybuf.preview= NULL; + matcopybuf.gpumaterial.first= matcopybuf.gpumaterial.last= NULL; + matcopied= 1; +} + +void paste_matcopybuf(Material *ma) +{ + int a; + MTex *mtex; + ID id; + + if(matcopied==0) + return; + /* free current mat */ + if(ma->ramp_col) MEM_freeN(ma->ramp_col); + if(ma->ramp_spec) MEM_freeN(ma->ramp_spec); + for(a=0; a<MAX_MTEX; a++) { + mtex= ma->mtex[a]; + if(mtex && mtex->tex) mtex->tex->id.us--; + if(mtex) MEM_freeN(mtex); + } + + if(ma->nodetree) { + ntreeFreeTree(ma->nodetree); + MEM_freeN(ma->nodetree); + } + + GPU_materials_free(ma); + + id= (ma->id); + memcpy(ma, &matcopybuf, sizeof(Material)); + (ma->id)= id; + + if(matcopybuf.ramp_col) ma->ramp_col= MEM_dupallocN(matcopybuf.ramp_col); + if(matcopybuf.ramp_spec) ma->ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec); + for(a=0; a<MAX_MTEX; a++) { + mtex= ma->mtex[a]; + if(mtex) { + ma->mtex[a]= MEM_dupallocN(mtex); + if(mtex->tex) id_us_plus((ID *)mtex->tex); + } + } + + ma->nodetree= ntreeCopyTree(matcopybuf.nodetree, 0); + + /* + BIF_preview_changed(ID_MA); + BIF_undo_push("Paste material settings"); + scrarea_queue_winredraw(curarea); + */ +} diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index d731ab4230b..24eeb1ab43f 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -22,7 +22,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a7df7a44475..c7b76941793 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c0446375acd..d5696dd03d4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2005 by the Blender Foundation. * All rights reserved. @@ -40,7 +40,6 @@ #include "stdarg.h" #include "math.h" #include "float.h" -#include "ctype.h" #include "BLI_math.h" #include "BLI_blenlib.h" @@ -106,6 +105,7 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_scene.h" #include "BKE_smoke.h" #include "BKE_softbody.h" #include "BKE_subsurf.h" @@ -358,15 +358,14 @@ static void latticeModifier_updateDepgraph(ModifierData *md, DagForest *forest, static void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3]) { - md= md->next; - if(md) { - if(md->type==eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - if(amd->multi) - amd->prevCos= MEM_dupallocN(vertexCos); - } - /* lattice/mesh modifier too */ + while((md=md->next) && md->type==eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData*) md; + if(amd->multi && amd->prevCos==NULL) + amd->prevCos= MEM_dupallocN(vertexCos); + else + break; } + /* lattice/mesh modifier too */ } @@ -433,8 +432,9 @@ static void subsurfModifier_freeData(ModifierData *md) static int subsurfModifier_isDisabled(ModifierData *md, int useRenderParams) { SubsurfModifierData *smd = (SubsurfModifierData*) md; + int levels= (useRenderParams)? smd->renderLevels: smd->levels; - return (useRenderParams)? (smd->renderLevels == 0): (smd->levels == 0); + return get_render_subsurf_level(&md->scene->r, levels) == 0; } static DerivedMesh *subsurfModifier_applyModifier( @@ -872,23 +872,7 @@ static DerivedMesh *maskModifier_applyModifier(ModifierData *md, Object *ob, } else /* --- Using Nominated VertexGroup only --- */ { - int defgrp_index = -1; - - /* get index of vertex group */ - if (mmd->vgroup[0]) - { - bDeformGroup *def; - - /* find index by comparing names - SLOW... */ - for (i = 0, def = ob->defbase.first; def; def = def->next, i++) - { - if (!strcmp(def->name, mmd->vgroup)) - { - defgrp_index = i; - break; - } - } - } + int defgrp_index = defgroup_name_index(ob, mmd->vgroup); /* get dverts */ if (defgrp_index >= 0) @@ -1820,118 +1804,6 @@ static void mirrorModifier_updateDepgraph(ModifierData *md, DagForest *forest, S } } -/* finds the best possible flipped name. For renaming; check for unique names afterwards */ -/* if strip_number: removes number extensions */ -static void vertgroup_flip_name (char *name, int strip_number) -{ - int len; - char prefix[128]={""}; /* The part before the facing */ - char suffix[128]={""}; /* The part after the facing */ - char replace[128]={""}; /* The replacement string */ - char number[128]={""}; /* The number extension string */ - char *index=NULL; - - len= strlen(name); - if(len<3) return; // we don't do names like .R or .L - - /* We first check the case with a .### extension, let's find the last period */ - if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrance - if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! - if(strip_number==0) - strcpy(number, index); - *index= 0; - len= strlen(name); - } - } - - strcpy (prefix, name); - -#define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') - - /* first case; separator . - _ with extensions r R l L */ - if( IS_SEPARATOR(name[len-2]) ) { - switch(name[len-1]) { - case 'l': - prefix[len-1]= 0; - strcpy(replace, "r"); - break; - case 'r': - prefix[len-1]= 0; - strcpy(replace, "l"); - break; - case 'L': - prefix[len-1]= 0; - strcpy(replace, "R"); - break; - case 'R': - prefix[len-1]= 0; - strcpy(replace, "L"); - break; - } - } - /* case; beginning with r R l L , with separator after it */ - else if( IS_SEPARATOR(name[1]) ) { - switch(name[0]) { - case 'l': - strcpy(replace, "r"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'r': - strcpy(replace, "l"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'L': - strcpy(replace, "R"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'R': - strcpy(replace, "L"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - } - } - else if(len > 5) { - /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */ - index = BLI_strcasestr(prefix, "right"); - if (index==prefix || index==prefix+len-5) { - if(index[0]=='r') - strcpy (replace, "left"); - else { - if(index[1]=='I') - strcpy (replace, "LEFT"); - else - strcpy (replace, "Left"); - } - *index= 0; - strcpy (suffix, index+5); - } - else { - index = BLI_strcasestr(prefix, "left"); - if (index==prefix || index==prefix+len-4) { - if(index[0]=='l') - strcpy (replace, "right"); - else { - if(index[1]=='E') - strcpy (replace, "RIGHT"); - else - strcpy (replace, "Right"); - } - *index= 0; - strcpy (suffix, index+4); - } - } - } - -#undef IS_SEPARATOR - - sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); -} - #if 0 static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, Object *ob, @@ -1946,9 +1818,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, int maxVerts = dm->getNumVerts(dm); int maxEdges = dm->getNumEdges(dm); int maxFaces = dm->getNumTessFaces(dm); - int vector_size=0, j, a, b; - bDeformGroup *def, *defb; - bDeformGroup **vector_def = NULL; + int *flip_map= NULL; + int do_vgroup_mirr= (mmd->flag & MOD_MIR_VGROUP); int (*indexMap)[2]; float mtx[4][4], imtx[4][4]; @@ -1959,18 +1830,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, result = CDDM_from_template(dm, maxVerts * 2, maxEdges * 2, maxFaces * 2, 0, 0); - if (mmd->flag & MOD_MIR_VGROUP) { - /* calculate the number of deformedGroups */ - for(vector_size = 0, def = ob->defbase.first; def; - def = def->next, vector_size++); - - /* load the deformedGroups for fast access */ - vector_def = - (bDeformGroup **)MEM_mallocN(sizeof(bDeformGroup*) * vector_size, - "group_index"); - for(a = 0, def = ob->defbase.first; def; def = def->next, a++) { - vector_def[a] = def; - } + if (do_vgroup_mirr) { + flip_map= defgroup_flip_map(ob, 0); + if(flip_map == NULL) + do_vgroup_mirr= 0; } if (mmd->mirror_ob) { @@ -2017,7 +1880,6 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, mv->flag |= ME_VERT_MERGED; } else { MVert *mv2 = CDDM_get_vert(result, numVerts); - MDeformVert *dvert = NULL; DM_copy_vert_data(dm, result, i, numVerts, 1); *mv2 = *mv; @@ -2028,36 +1890,13 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, } copy_v3_v3(mv2->co, co); - if (mmd->flag & MOD_MIR_VGROUP){ - dvert = DM_get_vert_data(result, numVerts, CD_MDEFORMVERT); - - if (dvert) - { - for(j = 0; j < dvert[0].totweight; ++j) - { - char tmpname[32]; - - if(dvert->dw[j].def_nr < 0 || - dvert->dw[j].def_nr >= vector_size) - continue; - - def = vector_def[dvert->dw[j].def_nr]; - strcpy(tmpname, def->name); - vertgroup_flip_name(tmpname,0); - - for(b = 0, defb = ob->defbase.first; defb; - defb = defb->next, b++) - { - if(!strcmp(defb->name, tmpname)) - { - dvert->dw[j].def_nr = b; - break; - } - } - } + if (do_vgroup_mirr) { + MDeformVert *dvert= DM_get_vert_data(result, numVerts, CD_MDEFORMVERT); + if(dvert) { + defvert_flip(dvert, flip_map); } } - + numVerts++; } } @@ -2142,7 +1981,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, } } - if (vector_def) MEM_freeN(vector_def); + if (flip_map) MEM_freeN(flip_map); MEM_freeN(indexMap); @@ -2289,7 +2128,7 @@ BM_INLINE VertUser *new_vuser(MemBase *base) BM_INLINE MemBase *new_membase(void) { MemBase *b = MEM_callocN(sizeof(MemBase), "MemBase for edgesplit in modifier.c"); - b->vertuserpool = BLI_mempool_create(sizeof(VertUser), 1, 2048); + b->vertuserpool = BLI_mempool_create(sizeof(VertUser), 1, 2048, 1); return b; } @@ -2650,17 +2489,12 @@ static DerivedMesh *bevelModifier_applyModifier( options = bmd->flags|bmd->val_flags|bmd->lim_flags|bmd->e_flags; - //~ if ((options & BME_BEVEL_VWEIGHT) && bmd->defgrp_name[0]) { - //~ for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { - //~ if (!strcmp(def->name, bmd->defgrp_name)) { - //~ defgrp_index = i; - //~ break; - //~ } - //~ } - //~ if (defgrp_index < 0) { - //~ options &= ~BME_BEVEL_VWEIGHT; - //~ } - //~ } + /*if ((options & BME_BEVEL_VWEIGHT) && bmd->defgrp_name[0]) { + defgrp_index = defgroup_name_index(ob, bmd->defgrp_name); + if (defgrp_index < 0) { + options &= ~BME_BEVEL_VWEIGHT; + } + }*/ bm = BME_derivedmesh_to_bmesh(derivedData); BME_bevel(bm,bmd->value,bmd->res,options,defgrp_index,bmd->bevel_angle,NULL); @@ -2810,7 +2644,7 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, /* UVs need special handling, since they come from faces */ if(texmapping == MOD_DISP_MAP_UV) { - if(dm->getTessFaceDataArray(dm, CD_MTFACE)) { + if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) { MFace *mface = dm->getTessFaceArray(dm); MFace *mf; char *done = MEM_callocN(sizeof(*done) * numVerts, @@ -2892,8 +2726,8 @@ static void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) * if the texture didn't give an RGB value, copy the intensity across */ if(result_type & TEX_RGB) - texres->tin = (0.35 * texres->tr + 0.45 * texres->tg - + 0.2 * texres->tb); + texres->tin = (0.35f * texres->tr + 0.45f * texres->tg + + 0.2f * texres->tb); else texres->tr = texres->tg = texres->tb = texres->tin; } @@ -2911,17 +2745,7 @@ static void displaceModifier_do( if(!dmd->texture) return; - defgrp_index = -1; - - if(dmd->defgrp_name[0]) { - bDeformGroup *def; - for(i = 0, def = ob->defbase.first; def; def = def->next, i++) { - if(!strcmp(def->name, dmd->defgrp_name)) { - defgrp_index = i; - break; - } - } - } + defgrp_index = defgroup_name_index(ob, dmd->defgrp_name); mvert = CDDM_get_verts(dm); if(defgrp_index >= 0) @@ -3117,7 +2941,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, if(num_projectors == 0) return dm; /* make sure there are UV layers available */ - if(!dm->getTessFaceDataArray(dm, CD_MTFACE)) return dm; + if(!CustomData_has_layer(&dm->faceData, CD_MTFACE)) return dm; /* make sure we're using an existing layer */ validate_layer_name(&dm->faceData, CD_MTFACE, umd->uvlayer_name, uvname); @@ -3537,18 +3361,7 @@ static void smoothModifier_do( medges = dm->getEdgeArray(dm); numDMEdges = dm->getNumEdges(dm); - defgrp_index = -1; - - if (smd->defgrp_name[0]) { - bDeformGroup *def; - - for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { - if (!strcmp(def->name, smd->defgrp_name)) { - defgrp_index = i; - break; - } - } - } + defgrp_index = defgroup_name_index(ob, smd->defgrp_name); if (defgrp_index >= 0) dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); @@ -3761,7 +3574,7 @@ static void castModifier_sphere_do( Object *ctrl_ob = NULL; - int i, defgrp_index = -1; + int i, defgrp_index; int has_radius = 0; short flag, type; float fac, facm, len = 0.0f; @@ -3803,16 +3616,7 @@ static void castModifier_sphere_do( /* 3) if we were given a vertex group name, * only those vertices should be affected */ - if (cmd->defgrp_name[0]) { - bDeformGroup *def; - - for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { - if (!strcmp(def->name, cmd->defgrp_name)) { - defgrp_index = i; - break; - } - } - } + defgrp_index = defgroup_name_index(ob, cmd->defgrp_name); if ((ob->type == OB_MESH) && dm && defgrp_index >= 0) dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); @@ -3946,7 +3750,7 @@ static void castModifier_cuboid_do( MDeformVert *dvert = NULL; Object *ctrl_ob = NULL; - int i, defgrp_index = -1; + int i, defgrp_index; int has_radius = 0; short flag; float fac, facm; @@ -3970,16 +3774,7 @@ static void castModifier_cuboid_do( /* 3) if we were given a vertex group name, * only those vertices should be affected */ - if (cmd->defgrp_name[0]) { - bDeformGroup *def; - - for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { - if (!strcmp(def->name, cmd->defgrp_name)) { - defgrp_index = i; - break; - } - } - } + defgrp_index = defgroup_name_index(ob, cmd->defgrp_name); if ((ob->type == OB_MESH) && dm && defgrp_index >= 0) dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); @@ -4223,9 +4018,15 @@ static void castModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { - DerivedMesh *dm = get_dm(md->scene, ob, NULL, derivedData, NULL, 0); + DerivedMesh *dm = NULL; CastModifierData *cmd = (CastModifierData *)md; + if (ob->type == OB_MESH) { + /* DerivedMesh is used only in case object is MESH */ + /* so we could optimize modifier applying by skipping DM creation */ + dm = get_dm(md->scene, ob, NULL, derivedData, NULL, 0); + } + if (cmd->type == MOD_CAST_TYPE_CUBOID) { castModifier_cuboid_do(cmd, ob, dm, vertexCos, numVerts); } else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */ @@ -4379,7 +4180,7 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, /* UVs need special handling, since they come from faces */ if(texmapping == MOD_WAV_MAP_UV) { - if(dm->getTessFaceDataArray(dm, CD_MTFACE)) { + if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) { MFace *mface = dm->getTessFaceArray(dm); MFace *mf; char *done = MEM_callocN(sizeof(*done) * numVerts, @@ -4477,18 +4278,7 @@ static void waveModifier_do(WaveModifierData *md, } /* get the index of the deform group */ - defgrp_index = -1; - - if(wmd->defgrp_name[0]) { - int i; - bDeformGroup *def; - for(i = 0, def = ob->defbase.first; def; def = def->next, i++) { - if(!strcmp(def->name, wmd->defgrp_name)) { - defgrp_index = i; - break; - } - } - } + defgrp_index = defgroup_name_index(ob, wmd->defgrp_name); if(defgrp_index >= 0){ dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); @@ -4916,50 +4706,46 @@ static void hookModifier_deformVerts( } } else if(hmd->name[0]) { /* vertex group hook */ - bDeformGroup *curdef; Mesh *me = ob->data; - int index = 0; - int use_dverts; + int use_dverts = 0; int maxVerts = 0; - - /* find the group (weak loop-in-loop) */ - for(curdef = ob->defbase.first; curdef; curdef = curdef->next, index++) - if(!strcmp(curdef->name, hmd->name)) break; + int defgrp_index = defgroup_name_index(ob, hmd->name); - if(dm) + if(dm) { if(dm->getVertData(dm, 0, CD_MDEFORMVERT)) { - use_dverts = 1; - maxVerts = dm->getNumVerts(dm); - } else use_dverts = 0; - else if(me->dvert) { + maxVerts = dm->getNumVerts(dm); use_dverts = 1; - maxVerts = me->totvert; - } else use_dverts = 0; - - if(curdef && use_dverts) { - MDeformVert *dvert = me->dvert; - int i, j; - - for(i = 0; i < maxVerts; i++, dvert++) { - if(dm) dvert = dm->getVertData(dm, i, CD_MDEFORMVERT); - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == index) { - float fac = hmd->force*dvert->dw[j].weight; - float *co = vertexCos[i]; - - if(hmd->falloff != 0.0) { - float len = len_v3v3(co, hmd->cent); - if(len > hmd->falloff) fac = 0.0; - else if(len > 0.0) - fac *= sqrt(1.0 - len / hmd->falloff); - } - - mul_v3_m4v3(vec, mat, co); - interp_v3_v3v3(co, co, vec, fac); + } + } + else if(me->dvert) { + maxVerts = me->totvert; + use_dverts = 1; + } + + if(defgrp_index >= 0 && use_dverts) { + MDeformVert *dvert = me->dvert; + int i, j; + + for(i = 0; i < maxVerts; i++, dvert++) { + if(dm) dvert = dm->getVertData(dm, i, CD_MDEFORMVERT); + for(j = 0; j < dvert->totweight; j++) { + if(dvert->dw[j].def_nr == defgrp_index) { + float fac = hmd->force*dvert->dw[j].weight; + float *co = vertexCos[i]; + + if(hmd->falloff != 0.0) { + float len = len_v3v3(co, hmd->cent); + if(len > hmd->falloff) fac = 0.0; + else if(len > 0.0) + fac *= sqrt(1.0 - len / hmd->falloff); } + + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } + } } } @@ -5122,7 +4908,7 @@ static void solidifyModifier_copyData(ModifierData *md, ModifierData *target) tsmd->crease_inner = smd->crease_inner; tsmd->crease_outer = smd->crease_outer; tsmd->crease_rim = smd->crease_rim; - strcpy(tsmd->vgroup, smd->vgroup); + strcpy(tsmd->defgrp_name, smd->defgrp_name); } static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, @@ -5991,7 +5777,6 @@ static DerivedMesh *booleanModifier_applyModifier( ModifierData *md, Object *ob, DerivedMesh *derivedData, int useRenderParams, int isFinalCalc) { - // XXX doesn't handle derived data BooleanModifierData *bmd = (BooleanModifierData*) md; DerivedMesh *dm = bmd->object->derivedFinal; @@ -6001,20 +5786,14 @@ static DerivedMesh *booleanModifier_applyModifier( DerivedMesh *result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, 1 + bmd->operation); - if(dm) - dm->release(dm); - /* if new mesh returned, return it; otherwise there was * an error, so delete the modifier object */ if(result) return result; else - bmd->object = NULL; + modifier_setError(md, "Can't execute boolean operation."); } - if(dm) - dm->release(dm); - return derivedData; } @@ -6162,14 +5941,14 @@ static void particleSystemModifier_deformVerts( psmd->totdmvert= psmd->dm->getNumVerts(psmd->dm); psmd->totdmedge= psmd->dm->getNumEdges(psmd->dm); psmd->totdmface= psmd->dm->getNumTessFaces(psmd->dm); - } + } - if(psys){ - psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(md->scene, ob, psys); - psmd->flag |= eParticleSystemFlag_psys_updated; - psmd->flag &= ~eParticleSystemFlag_DM_changed; - } + if(psys) { + psmd->flag &= ~eParticleSystemFlag_psys_updated; + particle_system_update(md->scene, ob, psys); + psmd->flag |= eParticleSystemFlag_psys_updated; + psmd->flag &= ~eParticleSystemFlag_DM_changed; + } } /* disabled particles in editmode for now, until support for proper derivedmesh @@ -6538,7 +6317,7 @@ static void explodeModifier_createFacepa(ExplodeModifierData *emd, for(i=0; i<totvert; i++){ val = BLI_frand(); val = (1.0f-emd->protect)*val + emd->protect*0.5f; - if(val < deformvert_get_weight(dvert+i,emd->vgroup-1)) + if(val < defvert_find_weight(dvert+i,emd->vgroup-1)) vertpa[i] = -1; } } @@ -7580,21 +7359,10 @@ static void meshdeformModifier_do( VECCOPY(dco[a], co) } - defgrp_index = -1; - - if(mmd->defgrp_name[0]) { - bDeformGroup *def; - - for(a=0, def=ob->defbase.first; def; def=def->next, a++) { - if(!strcmp(def->name, mmd->defgrp_name)) { - defgrp_index= a; - break; - } - } + defgrp_index = defgroup_name_index(ob, mmd->defgrp_name); - if (defgrp_index >= 0) - dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT); - } + if (defgrp_index >= 0) + dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT); /* do deformation */ fac= 1.0f; @@ -8524,10 +8292,12 @@ void modifier_copyData(ModifierData *md, ModifierData *target) mti->copyData(md, target); } -int modifier_couldBeCage(ModifierData *md) +int modifier_couldBeCage(Scene *scene, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + md->scene= scene; + return ( (md->mode & eModifierMode_Realtime) && (md->mode & eModifierMode_Editmode) && (!mti->isDisabled || !mti->isDisabled(md, 0)) && @@ -8562,7 +8332,7 @@ void modifier_setError(ModifierData *md, char *format, ...) * also used in transform_conversion.c, to detect CrazySpace [tm] (2nd arg * then is NULL) */ -int modifiers_getCageIndex(Object *ob, int *lastPossibleCageIndex_r, int virtual_) +int modifiers_getCageIndex(Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) { ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first; int i, cageIndex = -1; @@ -8571,6 +8341,8 @@ int modifiers_getCageIndex(Object *ob, int *lastPossibleCageIndex_r, int virtual for (i=0; md; i++,md=md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + md->scene= scene; + if (!(md->mode & eModifierMode_Realtime)) continue; if (!(md->mode & eModifierMode_Editmode)) continue; if (mti->isDisabled && mti->isDisabled(md, 0)) continue; @@ -8610,10 +8382,12 @@ int modifiers_isParticleEnabled(Object *ob) return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)); } -int modifier_isEnabled(ModifierData *md, int required_mode) +int modifier_isEnabled(Scene *scene, ModifierData *md, int required_mode) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + md->scene= scene; + if((md->mode & required_mode) != required_mode) return 0; if(mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0; if(md->mode & eModifierMode_DisableTemporary) return 0; @@ -8623,7 +8397,7 @@ int modifier_isEnabled(ModifierData *md, int required_mode) return 1; } -LinkNode *modifiers_calcDataMasks(Object *ob, ModifierData *md, CustomDataMask dataMask, int required_mode) +LinkNode *modifiers_calcDataMasks(Scene *scene, Object *ob, ModifierData *md, CustomDataMask dataMask, int required_mode) { LinkNode *dataMasks = NULL; LinkNode *curr, *prev; @@ -8633,7 +8407,7 @@ LinkNode *modifiers_calcDataMasks(Object *ob, ModifierData *md, CustomDataMask d ModifierTypeInfo *mti = modifierType_getInfo(md->type); CustomDataMask mask = 0; - if(modifier_isEnabled(md, required_mode)) + if(modifier_isEnabled(scene, md, required_mode)) if(mti->requiredDataMask) mask = mti->requiredDataMask(ob, md); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index b1f2a9d90f2..83f04db9cd7 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 by Nicholas Bishop * All rights reserved. @@ -50,6 +50,7 @@ #include "BKE_modifier.h" #include "BKE_multires.h" #include "BKE_object.h" +#include "BKE_scene.h" #include "BKE_subsurf.h" #include "BKE_utildefines.h" @@ -84,27 +85,22 @@ MultiresModifierData *find_multires_modifier(Object *ob) static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) { if(render) - return mmd->renderlvl; + return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl): mmd->renderlvl; else if(ob->mode == OB_MODE_SCULPT) return mmd->sculptlvl; else - return mmd->lvl; + return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl): mmd->lvl; } static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) { mmd->totlvl = lvl; - if(ob->mode != OB_MODE_SCULPT) { - mmd->lvl = MAX2(mmd->lvl, lvl); - CLAMP(mmd->lvl, 0, mmd->totlvl); - } - - mmd->sculptlvl = MAX2(mmd->sculptlvl, lvl); - CLAMP(mmd->sculptlvl, 0, mmd->totlvl); + if(ob->mode != OB_MODE_SCULPT) + mmd->lvl = CLAMPIS(MAX2(mmd->lvl, lvl), 0, mmd->totlvl); - mmd->renderlvl = MAX2(mmd->renderlvl, lvl); - CLAMP(mmd->renderlvl, 0, mmd->totlvl); + mmd->sculptlvl = CLAMPIS(MAX2(mmd->sculptlvl, lvl), 0, mmd->totlvl); + mmd->renderlvl = CLAMPIS(MAX2(mmd->renderlvl, lvl), 0, mmd->totlvl); } static void multires_dm_mark_as_modified(DerivedMesh *dm) @@ -121,6 +117,7 @@ void multires_mark_as_modified(Object *ob) void multires_force_update(Object *ob) { + if(ob && ob->derivedFinal) { ob->derivedFinal->needsFree =1; ob->derivedFinal->release(ob->derivedFinal); @@ -128,6 +125,12 @@ void multires_force_update(Object *ob) } } +void multires_force_render_update(Object *ob) +{ + if(ob && (ob->mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires)) + multires_force_update(ob); +} + /* XXX */ #if 0 void multiresModifier_join(Object *ob) diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 3979586fb19..bbef2b3e0db 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. @@ -258,8 +258,8 @@ NlaTrack *add_nlatrack (AnimData *adt, NlaTrack *prev) BKE_nlatrack_set_active(&adt->nla_tracks, nlt); /* must have unique name, but we need to seed this */ - sprintf(nlt->name, "NlaTrack"); - BLI_uniquename(&adt->nla_tracks, nlt, "NlaTrack", '.', offsetof(NlaTrack, name), 64); + strcpy(nlt->name, "NlaTrack"); + BLI_uniquename(&adt->nla_tracks, nlt, "NlaTrack", '.', offsetof(NlaTrack, name), sizeof(nlt->name)); /* return the new track */ return nlt; @@ -369,14 +369,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short return strip->end - scale*(cframe - strip->actstart); } else if (mode == NLATIME_CONVERT_UNMAP) { - int repeatsNum = (int)((cframe - strip->start) / (actlength * scale)); - - /* this method doesn't clip the values to lie within the action range only - * - the '(repeatsNum * actlength * scale)' compensates for the fmod(...) - * - the fmod(...) works in the same way as for eval - */ - return strip->actend - (repeatsNum * actlength * scale) - - (fmod(cframe - strip->start, actlength*scale) / scale); + return strip->actend - (strip->end - cframe) / scale; } else /* if (mode == NLATIME_CONVERT_EVAL) */{ if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, ((int)strip->repeat))) { @@ -399,14 +392,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short return strip->start + scale*(cframe - strip->actstart); } else if (mode == NLATIME_CONVERT_UNMAP) { - int repeatsNum = (int)((cframe - strip->start) / (actlength * scale)); - - /* this method doesn't clip the values to lie within the action range only - * - the '(repeatsNum * actlength * scale)' compensates for the fmod(...) - * - the fmod(...) works in the same way as for eval - */ - return strip->actstart + (repeatsNum * actlength * scale) - + (fmod(cframe - strip->start, actlength*scale) / scale); + return strip->actstart + (cframe - strip->start) / scale; } else /* if (mode == NLATIME_CONVERT_EVAL) */{ if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, ((int)strip->repeat))) { @@ -1049,6 +1035,31 @@ short BKE_nlastrip_within_bounds (NlaStrip *strip, float min, float max) return 1; } +/* Recalculate the start and end frames for the current strip, after changing + * the extents of the action or the mapping (repeats or scale factor) info + */ +void BKE_nlastrip_recalculate_bounds (NlaStrip *strip) +{ + float actlen, mapping; + + /* sanity checks + * - must have a strip + * - can only be done for action clips + */ + if ((strip == NULL) || (strip->type != NLASTRIP_TYPE_CLIP)) + return; + + /* calculate new length factors */ + actlen= strip->actend - strip->actstart; + if (IS_EQ(actlen, 0.0f)) actlen= 1.0f; + + mapping= strip->scale * strip->repeat; + + /* adjust endpoint of strip in response to this */ + if (IS_EQ(mapping, 0.0f) == 0) + strip->end = (actlen * mapping) + strip->start; +} + /* Is the given NLA-strip the first one to occur for the given AnimData block */ // TODO: make this an api method if necesary, but need to add prefix first static short nlastrip_is_first (AnimData *adt, NlaStrip *strip) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index a316a313cfd..ced88b7e818 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2005 Blender Foundation. * All rights reserved. @@ -35,6 +35,7 @@ #include <stddef.h> #include <string.h> +#include "DNA_anim_types.h" #include "DNA_ID.h" #include "DNA_image_types.h" #include "DNA_node_types.h" @@ -43,8 +44,11 @@ #include "DNA_text_types.h" #include "DNA_scene_types.h" +#include "RNA_access.h" + #include "BKE_blender.h" #include "BKE_colortools.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_library.h" @@ -53,6 +57,7 @@ #include "BKE_texture.h" #include "BKE_text.h" #include "BKE_utildefines.h" +#include "BKE_animsys.h" /* BKE_free_animdata only */ #include "BLI_math.h" #include "BLI_blenlib.h" @@ -904,7 +909,7 @@ void nodeAddSockets(bNode *node, bNodeType *ntype) /* Find the first available, non-duplicate name for a given node */ void nodeUniqueName(bNodeTree *ntree, bNode *node) { - BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), 32); + BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), sizeof(node->name)); } bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) @@ -1100,10 +1105,12 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) /* is ntree part of library? */ for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next) if(newtree==ntree) break; - if(newtree) + if(newtree) { newtree= copy_libblock(ntree); - else + } else { newtree= MEM_dupallocN(ntree); + copy_libblock_data(&newtree->id, &ntree->id); /* copy animdata and ID props */ + } newtree->nodes.first= newtree->nodes.last= NULL; newtree->links.first= newtree->links.last= NULL; } @@ -1339,6 +1346,8 @@ void ntreeFreeTree(bNodeTree *ntree) ntreeEndExecTree(ntree); /* checks for if it is still initialized */ + BKE_free_animdata((ID *)ntree); + BLI_freelistN(&ntree->links); /* do first, then unlink_node goes fast */ for(node= ntree->nodes.first; node; node= next) { @@ -1947,7 +1956,7 @@ static void composit_begin_exec(bNodeTree *ntree, int is_group) } } /* cannot initialize them while using in threads */ - if(ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB)) { + if(ELEM4(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) { curvemapping_initialize(node->storage); if(node->type==CMP_NODE_CURVE_RGB) curvemapping_premultiply(node->storage, 0); @@ -2865,6 +2874,54 @@ void ntreeCompositTagRender(Scene *curscene) } } +static int node_animation_properties(bNodeTree *ntree, bNode *node) +{ + bNodeSocket *sock; + const ListBase *lb; + Link *link; + PointerRNA ptr; + PropertyRNA *prop; + + /* check to see if any of the node's properties have fcurves */ + RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr); + lb = RNA_struct_defined_properties(ptr.type); + + for (link=lb->first; link; link=link->next) { + int driven, len=1, index; + prop = (PropertyRNA *)link; + + if (RNA_property_array_check(&ptr, prop)) + len = RNA_property_array_length(&ptr, prop); + + for (index=0; index<len; index++) { + if (rna_get_fcurve(&ptr, prop, index, NULL, &driven)) { + NodeTagChanged(ntree, node); + return 1; + } + } + } + + /* now check node sockets */ + for (sock = node->inputs.first; sock; sock=sock->next) { + int driven, len=1, index; + + RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr); + prop = RNA_struct_find_property(&ptr, "default_value"); + + if (RNA_property_array_check(&ptr, prop)) + len = RNA_property_array_length(&ptr, prop); + + for (index=0; index<len; index++) { + if (rna_get_fcurve(&ptr, prop, index, NULL, &driven)) { + NodeTagChanged(ntree, node); + return 1; + } + } + } + + return 0; +} + /* tags nodes that have animation capabilities */ int ntreeCompositTagAnimated(bNodeTree *ntree) { @@ -2874,6 +2931,10 @@ int ntreeCompositTagAnimated(bNodeTree *ntree) if(ntree==NULL) return 0; for(node= ntree->nodes.first; node; node= node->next) { + + tagged = node_animation_properties(ntree, node); + + /* otherwise always tag these node types */ if(node->type==CMP_NODE_IMAGE) { Image *ima= (Image *)node->id; if(ima && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { @@ -2983,6 +3044,8 @@ static void registerCompositNodes(ListBase *ntypelist) nodeRegisterType(ntypelist, &cmp_node_invert); nodeRegisterType(ntypelist, &cmp_node_alphaover); nodeRegisterType(ntypelist, &cmp_node_zcombine); + nodeRegisterType(ntypelist, &cmp_node_colorbalance); + nodeRegisterType(ntypelist, &cmp_node_huecorrect); nodeRegisterType(ntypelist, &cmp_node_normal); nodeRegisterType(ntypelist, &cmp_node_curve_vec); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 687c9b8c7bf..a83997f1e70 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -580,6 +580,7 @@ void unlink_object(Scene *scene, Object *ob) if(sce->id.lib==NULL) { if(sce->camera==ob) sce->camera= NULL; if(sce->toolsettings->skgen_template==ob) sce->toolsettings->skgen_template = NULL; + if(sce->toolsettings->particle.object==ob) sce->toolsettings->particle.object= NULL; #ifdef DURIAN_CAMERA_SWITCH { @@ -1146,8 +1147,8 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) } if(psys->clmd) { - ClothModifierData *nclmd = (ClothModifierData *)modifier_new(eModifierType_Cloth); - modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)nclmd); + psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth); + modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)psysn->clmd); psys->hair_in_dm = psys->hair_out_dm = NULL; } @@ -1165,6 +1166,12 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) psysn->pointcache= BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); + /* XXX - from reading existing code this seems correct but intended usage of + * pointcache should /w cloth should be added in 'ParticleSystem' - campbell */ + if(psysn->clmd) { + psysn->clmd->point_cache= psysn->pointcache; + } + id_us_plus((ID *)psysn->part); return psysn; @@ -1287,7 +1294,7 @@ Object *copy_object(Object *ob) if(ob->type==OB_ARMATURE) armature_rebuild_pose(obn, obn->data); } - copy_defgroups(&obn->defbase, &ob->defbase); + defgroup_copy_list(&obn->defbase, &ob->defbase); copy_constraints(&obn->constraints, &ob->constraints); obn->mode = 0; @@ -1430,9 +1437,9 @@ int object_is_libdata(Object *ob) int object_data_is_libdata(Object *ob) { if(!ob) return 0; - if(ob->proxy) return 0; + if(ob->proxy && (ob->data==NULL || ((ID *)ob->data)->lib==NULL)) return 0; if(ob->id.lib) return 1; - if(!ob->data) return 0; + if(ob->data==NULL) return 0; if(((ID *)ob->data)->lib) return 1; return 0; @@ -1454,6 +1461,38 @@ static void armature_set_id_extern(Object *ob) } +void 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_id_add_animdata(&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) + { + if ((Object *)dtar->id == target) + dtar->id= (ID *)ob; + else + id_lib_extern((ID *)dtar->id); + } + DRIVER_TARGETS_LOOPER_END + } + } + } +} + /* proxy rule: lib_object->proxy_from == the one we borrow from, set temporally while object_update */ /* local_object->proxy == pointer to library object, saved in files and read */ /* local_object->proxy_group == pointer to group dupli-object, saved in files and read */ @@ -1490,33 +1529,8 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) copy_m4_m4(ob->parentinv, target->parentinv); /* copy animdata stuff - drivers only for now... */ - if ((target->adt) && (target->adt->drivers.first)) { - FCurve *fcu; - - /* add new animdata block */ - ob->adt= BKE_id_add_animdata(&ob->id); - - /* make a copy of all the drivers (for now), then correct any links that need fixing */ - 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) - { - if ((Object *)dtar->id == target) - dtar->id= (ID *)ob; - else - id_lib_extern((ID *)dtar->id); - } - DRIVER_TARGETS_LOOPER_END - } - } - } - + object_copy_proxy_drivers(ob, target); + /* skip constraints? */ // FIXME: this is considered by many as a bug @@ -1669,6 +1683,7 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) } } +/* see pchan_apply_mat4() for the equivalent 'pchan' function */ void object_apply_mat4(Object *ob, float mat[][4]) { float mat3[3][3]; @@ -1842,17 +1857,16 @@ static void give_parvert(Object *par, int nr, float *vec) DerivedMesh *dm = par->derivedFinal; if(dm) { - int i, count = 0, vindex, numVerts = dm->getNumVerts(dm); + MVert *mvert= dm->getVertArray(dm); int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); - float co[3]; + int i, count = 0, vindex, numVerts = dm->getNumVerts(dm); /* get the average of all verts with (original index == nr) */ - for(i = 0; i < numVerts; ++i) { - vindex= (index)? *index: i; + for(i = 0; i < numVerts; i++) { + vindex= (index)? index[i]: i; if(vindex == nr) { - dm->getVertCo(dm, i, co); - add_v3_v3v3(vec, vec, co); + add_v3_v3v3(vec, vec, mvert[i].co); count++; } } @@ -1977,9 +1991,8 @@ void set_no_parent_ipo(int val) void where_is_object_time(Scene *scene, Object *ob, float ctime) { float *fp1, *fp2, slowmat[4][4] = MAT4_UNITY; - float stime=ctime, fac1, fac2, vec[3]; + float stime=ctime, fac1, fac2; int a; - int pop; /* new version: correct parent+vertexparent and track+parent */ /* this one only calculates direct attached parent and track */ @@ -1998,21 +2011,19 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) /* hurms, code below conflicts with depgraph... (ton) */ /* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */ - pop= 0; if(no_parent_ipo==0 && stime != par->ctime) { // only for ipo systems? - pushdata(par, sizeof(Object)); - pop= 1; + Object tmp= *par; if(par->proxy_from); // was a copied matrix, no where_is! bad... else where_is_object_time(scene, par, ctime); + + solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); + + *par= tmp; } - - solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); - - if(pop) { - poplast(par); - } + else + solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); if(ob->partype & PARSLOW) { // include framerate @@ -2038,7 +2049,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } /* solve constraints */ - if (ob->constraints.first) { + if (ob->constraints.first && !(ob->flag & OB_NO_CONSTRAINTS)) { bConstraintOb *cob; cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); @@ -2050,9 +2061,8 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } /* set negative scale flag in object */ - cross_v3_v3v3(vec, ob->obmat[0], ob->obmat[1]); - if( dot_v3v3(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE; - else ob->transflag &= ~OB_NEG_SCALE; + if(is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; + else ob->transflag &= ~OB_NEG_SCALE; } static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul) @@ -2366,27 +2376,97 @@ void minmax_object(Object *ob, float *min, float *max) } } -/* TODO - use dupli objects bounding boxes */ -void minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max) +int minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max) { + int ok= 0; if ((ob->transflag & OB_DUPLI)==0) { - return; + return ok; } else { ListBase *lb; DupliObject *dob; lb= object_duplilist(scene, ob); for(dob= lb->first; dob; dob= dob->next) { - if(dob->no_draw); - else { - /* should really use bound box of dup object */ - DO_MINMAX(dob->mat[3], min, max); + if(dob->no_draw == 0) { + BoundBox *bb= object_get_boundbox(dob->ob); + + if(bb) { + int i; + for(i=0; i<8; i++) { + float vec[3]; + mul_v3_m4v3(vec, dob->mat, bb->vec[i]); + DO_MINMAX(vec, min, max); + } + + ok= 1; + } } } free_object_duplilist(lb); /* does restore */ } -} + return ok; +} + +/* copied from DNA_object_types.h */ +typedef struct ObTfmBack { + float loc[3], dloc[3], orig[3]; + float size[3], dsize[3]; /* scale and delta scale */ + float rot[3], drot[3]; /* euler rotation */ + float quat[4], dquat[4]; /* quaternion rotation */ + float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */ + float rotAngle, drotAngle; /* axis angle rotation - angle part */ + float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */ + float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */ + float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */ + float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */ +} ObTfmBack; + +void *object_tfm_backup(Object *ob) +{ + ObTfmBack *obtfm= MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack"); + copy_v3_v3(obtfm->loc, ob->loc); + copy_v3_v3(obtfm->dloc, ob->dloc); + copy_v3_v3(obtfm->orig, ob->orig); + copy_v3_v3(obtfm->size, ob->size); + copy_v3_v3(obtfm->dsize, ob->dsize); + copy_v3_v3(obtfm->rot, ob->rot); + copy_v3_v3(obtfm->drot, ob->drot); + copy_qt_qt(obtfm->quat, ob->quat); + copy_qt_qt(obtfm->dquat, ob->dquat); + copy_v3_v3(obtfm->rotAxis, ob->rotAxis); + copy_v3_v3(obtfm->drotAxis, ob->drotAxis); + obtfm->rotAngle= ob->rotAngle; + obtfm->drotAngle= ob->drotAngle; + copy_m4_m4(obtfm->obmat, ob->obmat); + copy_m4_m4(obtfm->parentinv, ob->parentinv); + copy_m4_m4(obtfm->constinv, ob->constinv); + copy_m4_m4(obtfm->imat, ob->imat); + + return (void *)obtfm; +} + +void object_tfm_restore(Object *ob, void *obtfm_pt) +{ + ObTfmBack *obtfm= (ObTfmBack *)obtfm_pt; + copy_v3_v3(ob->loc, obtfm->loc); + copy_v3_v3(ob->dloc, obtfm->dloc); + copy_v3_v3(ob->orig, obtfm->orig); + copy_v3_v3(ob->size, obtfm->size); + copy_v3_v3(ob->dsize, obtfm->dsize); + copy_v3_v3(ob->rot, obtfm->rot); + copy_v3_v3(ob->drot, obtfm->drot); + copy_qt_qt(ob->quat, obtfm->quat); + copy_qt_qt(ob->dquat, obtfm->dquat); + copy_v3_v3(ob->rotAxis, obtfm->rotAxis); + copy_v3_v3(ob->drotAxis, obtfm->drotAxis); + ob->rotAngle= obtfm->rotAngle; + ob->drotAngle= obtfm->drotAngle; + copy_m4_m4(ob->obmat, obtfm->obmat); + copy_m4_m4(ob->parentinv, obtfm->parentinv); + copy_m4_m4(ob->constinv, obtfm->constinv); + copy_m4_m4(ob->imat, obtfm->imat); +} /* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */ /* local_object->proxy == pointer to library object, saved in files and read */ diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 036cadebbe8..55f09eede91 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 4fe63a966be..5728c7a1fe0 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 by Nicholas Bishop * All rights reserved. diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index c07163bb074..7cee4b1d7bb 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 by Janne Karhu. * All rights reserved. @@ -61,6 +61,7 @@ #include "BLI_cellalloc.h" #include "BKE_anim.h" +#include "BKE_animsys.h" #include "BKE_boids.h" #include "BKE_cloth.h" @@ -255,7 +256,7 @@ void psys_enable_all(Object *ob) } int psys_in_edit_mode(Scene *scene, ParticleSystem *psys) { - return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit)); + return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit) && !psys->renderdata); } static void psys_create_frand(ParticleSystem *psys) { @@ -371,6 +372,7 @@ int psys_uses_gravity(ParticleSimulationData *sim) /************************************************/ void psys_free_settings(ParticleSettings *part) { + BKE_free_animdata(&part->id); free_partdeflect(part->pd); free_partdeflect(part->pd2); @@ -1001,12 +1003,7 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4, return value; } -static void weighted_particle_vector(float *v1, float *v2, float *v3, float *v4, float *weights, float *vec) -{ - vec[0]= weights[0]*v1[0] + weights[1]*v2[0] + weights[2]*v3[0] + weights[3]*v4[0]; - vec[1]= weights[0]*v1[1] + weights[1]*v2[1] + weights[2]*v3[1] + weights[3]*v4[1]; - vec[2]= weights[0]*v1[2] + weights[1]*v2[2] + weights[2]*v3[2] + weights[3]*v4[2]; -} + void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, int velocity) { float t[4]; @@ -1017,19 +1014,19 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic else { key_curve_position_weights(dt, t, type); - weighted_particle_vector(keys[0].co, keys[1].co, keys[2].co, keys[3].co, t, result->co); + interp_v3_v3v3v3v3(result->co, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); if(velocity){ float temp[3]; if(dt>0.999f){ key_curve_position_weights(dt-0.001f, t, type); - weighted_particle_vector(keys[0].co, keys[1].co, keys[2].co, keys[3].co, t, temp); + interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); VECSUB(result->vel, result->co, temp); } else{ key_curve_position_weights(dt+0.001f, t, type); - weighted_particle_vector(keys[0].co, keys[1].co, keys[2].co, keys[3].co, t, temp); + interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); VECSUB(result->vel, temp, result->co); } } @@ -1311,46 +1308,33 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or float tuv[4][2]; float *o1, *o2, *o3, *o4; - v1= (mvert+mface->v1)->co; - v2= (mvert+mface->v2)->co; - v3= (mvert+mface->v3)->co; - VECCOPY(n1,(mvert+mface->v1)->no); - VECCOPY(n2,(mvert+mface->v2)->no); - VECCOPY(n3,(mvert+mface->v3)->no); - normalize_v3(n1); - normalize_v3(n2); - normalize_v3(n3); + v1= mvert[mface->v1].co; + v2= mvert[mface->v2].co; + v3= mvert[mface->v3].co; + + normal_short_to_float_v3(n1, mvert[mface->v1].no); + normal_short_to_float_v3(n2, mvert[mface->v2].no); + normal_short_to_float_v3(n3, mvert[mface->v3].no); if(mface->v4) { - v4= (mvert+mface->v4)->co; - VECCOPY(n4,(mvert+mface->v4)->no); - normalize_v3(n4); + v4= mvert[mface->v4].co; + normal_short_to_float_v3(n4, mvert[mface->v4].no); - vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0] + w[3]*v4[0]; - vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1] + w[3]*v4[1]; - vec[2]= w[0]*v1[2] + w[1]*v2[2] + w[2]*v3[2] + w[3]*v4[2]; + interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w); if(nor){ - if(mface->flag & ME_SMOOTH){ - nor[0]= w[0]*n1[0] + w[1]*n2[0] + w[2]*n3[0] + w[3]*n4[0]; - nor[1]= w[0]*n1[1] + w[1]*n2[1] + w[2]*n3[1] + w[3]*n4[1]; - nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2] + w[3]*n4[2]; - } + if(mface->flag & ME_SMOOTH) + interp_v3_v3v3v3v3(nor, n1, n2, n3, n4, w); else normal_quad_v3(nor,v1,v2,v3,v4); } } else { - vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0]; - vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1]; - vec[2]= w[0]*v1[2] + w[1]*v2[2] + w[2]*v3[2]; - + interp_v3_v3v3v3(vec, v1, v2, v3, w); + if(nor){ - if(mface->flag & ME_SMOOTH){ - nor[0]= w[0]*n1[0] + w[1]*n2[0] + w[2]*n3[0]; - nor[1]= w[0]*n1[1] + w[1]*n2[1] + w[2]*n3[1]; - nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2]; - } + if(mface->flag & ME_SMOOTH) + interp_v3_v3v3v3(nor, n1, n2, n3, w); else normal_tri_v3(nor,v1,v2,v3); } @@ -1411,17 +1395,14 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or if(mface->v4) { o4= orcodata[mface->v4]; - orco[0]= w[0]*o1[0] + w[1]*o2[0] + w[2]*o3[0] + w[3]*o4[0]; - orco[1]= w[0]*o1[1] + w[1]*o2[1] + w[2]*o3[1] + w[3]*o4[1]; - orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2] + w[3]*o4[2]; + + interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w); if(ornor) normal_quad_v3( ornor,o1, o2, o3, o4); } else { - orco[0]= w[0]*o1[0] + w[1]*o2[0] + w[2]*o3[0]; - orco[1]= w[0]*o1[1] + w[1]*o2[1] + w[2]*o3[1]; - orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2]; + interp_v3_v3v3v3(orco, o1, o2, o3, w); if(ornor) normal_tri_v3( ornor,o1, o2, o3); @@ -2848,7 +2829,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, &result); /* dynamic hair is in object space */ - /* keyed and baked are allready in global space */ + /* keyed and baked are already in global space */ if(hair_dm) mul_m4_v3(sim->ob->obmat, result.co); else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) @@ -2989,12 +2970,21 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; - sel_col[0] = (float)edit->sel_col[0] / 255.0f; - sel_col[1] = (float)edit->sel_col[1] / 255.0f; - sel_col[2] = (float)edit->sel_col[2] / 255.0f; - nosel_col[0] = (float)edit->nosel_col[0] / 255.0f; - nosel_col[1] = (float)edit->nosel_col[1] / 255.0f; - nosel_col[2] = (float)edit->nosel_col[2] / 255.0f; + if(pset->brushtype == PE_BRUSH_WEIGHT){ + /* use weight painting colors now... */ +#if 0 + sel_col[0] = sel_col[1] = sel_col[2] = 1.0f; + nosel_col[0] = nosel_col[1] = nosel_col[2] = 0.0f; +#endif + } + else{ + sel_col[0] = (float)edit->sel_col[0] / 255.0f; + sel_col[1] = (float)edit->sel_col[1] / 255.0f; + sel_col[2] = (float)edit->sel_col[2] / 255.0f; + nosel_col[0] = (float)edit->nosel_col[0] / 255.0f; + nosel_col[1] = (float)edit->nosel_col[1] / 255.0f; + nosel_col[2] = (float)edit->nosel_col[2] / 255.0f; + } /*---first main loop: create all actual particles' paths---*/ for(i=0; i<totpart; i++, pa+=pa?1:0, point++){ @@ -3009,6 +2999,14 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf pind.bspline = psys ? (psys->part->flag & PART_HAIR_BSPLINE) : 0; pind.dm = NULL; + + /* should init_particle_interpolation set this ? */ + if(pset->brushtype==PE_BRUSH_WEIGHT){ + pind.hkey[0] = NULL; + pind.hkey[1] = pa->hair; + } + + memset(cache[i], 0, sizeof(*cache[i])*(steps+1)); cache[i]->steps = steps; @@ -3041,7 +3039,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); - /* non-hair points are allready in global space */ + /* non-hair points are already in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, result.co); @@ -3097,22 +3095,37 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf ca->vel[1] = 1.0f; /* selection coloring in edit mode */ - if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ - VECCOPY(ca->col, sel_col); - } - else{ - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); - } + if(pset->brushtype==PE_BRUSH_WEIGHT){ + if(k==0) + weight_to_rgb(pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); + else if(k >= steps - 1) + weight_to_rgb(pind.hkey[0]->weight, ca->col, ca->col+1, ca->col+2); + else + weight_to_rgb((1.0f - keytime) * pind.hkey[0]->weight + keytime * pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); + + /* at the moment this is only used for weight painting. + * will need to move out of this check if its used elsewhere. */ + pind.hkey[0] = pind.hkey[1]; + pind.hkey[1]++; } - else{ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); + else { + if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ + if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ + VECCOPY(ca->col, sel_col); + } + else{ + keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); + } } else{ - VECCOPY(ca->col, nosel_col); + if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ + keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); + } + else{ + VECCOPY(ca->col, nosel_col); + } } } @@ -3857,7 +3870,9 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * pind.cache = cached ? psys->pointcache : NULL; pind.epoint = NULL; pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE); - pind.dm = psys->hair_out_dm; + /* pind.dm disabled in editmode means we dont get effectors taken into + * account when subdividing for instance */ + pind.dm = psys_in_edit_mode(sim->scene, psys) ? NULL : psys->hair_out_dm; init_particle_interpolation(sim->ob, psys, pa, &pind); do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, state); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 6b2b220cca2..b057976e3b5 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 by Janne Karhu. * All rights reserved. @@ -172,12 +172,6 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) PARTICLE_P; int totpart, totsaved = 0; - if(psys->edit && psys->free_edit) { - psys->free_edit(psys->edit); - psys->edit = NULL; - psys->free_edit = NULL; - } - if(new_totpart<0) { if(part->distr==PART_DISTR_GRID && part->from != PART_FROM_VERT) { totpart= part->grid_res; @@ -190,6 +184,12 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) totpart=new_totpart; if(totpart && totpart != psys->totpart) { + if(psys->edit && psys->free_edit) { + psys->free_edit(psys->edit); + psys->edit = NULL; + psys->free_edit = NULL; + } + newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); if(psys->part->phystype == PART_PHYS_BOIDS) newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles"); @@ -247,12 +247,12 @@ static int get_psys_child_number(struct Scene *scene, ParticleSystem *psys) if(!psys->part->childtype) return 0; - if(psys->renderdata) { + if(psys->renderdata) nbr= psys->part->ren_child_nbr; - return get_render_child_particle_number(&scene->r, nbr); - } else - return psys->part->child_nbr; + nbr= psys->part->child_nbr; + + return get_render_child_particle_number(&scene->r, nbr); } static int get_psys_tot_child(struct Scene *scene, ParticleSystem *psys) @@ -263,6 +263,12 @@ static int get_psys_tot_child(struct Scene *scene, ParticleSystem *psys) static void alloc_child_particles(ParticleSystem *psys, int tot) { if(psys->child){ + /* only re-allocate if we have to */ + if(psys->part->childtype && psys->totchild == tot) { + memset(psys->child, 0, tot*sizeof(ChildParticle)); + return; + } + MEM_freeN(psys->child); psys->child=0; psys->totchild=0; @@ -1050,6 +1056,8 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, cpa->num=-1; } } + /* dmcache must be updated for parent particles if children from faces is used */ + psys_calc_dmcache(ob, finaldm, psys); return 0; } @@ -1814,8 +1822,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, project_v3_v3v3(dvec, r_vel, pa->state.ave); sub_v3_v3v3(mat[0], pa->state.ave, dvec); normalize_v3(mat[0]); - VECCOPY(mat[2], r_vel); - mul_v3_fl(mat[2], -1.0f); + negate_v3_v3(mat[2], r_vel); normalize_v3(mat[2]); cross_v3_v3v3(mat[1], mat[2], mat[0]); @@ -3071,10 +3078,8 @@ static void do_hair_dynamics(ParticleSimulationData *sim) dvert->dw = MEM_callocN (sizeof(MDeformWeight), "deformWeight"); dvert->totweight = 1; } - - /* no special reason for the 0.5 */ - /* just seems like a nice value from experiments */ - dvert->dw->weight = k ? 0.5f : 1.0f; + /* roots should be 1.0, the rest can be anything from 0.0 to 1.0 */ + dvert->dw->weight = key->weight; dvert++; } } @@ -3309,6 +3314,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) if(pa->alive==PARS_UNBORN && (part->flag & PART_UNBORN || cfra + psys->pointcache->step > pa->time)) reset_particle(sim, pa, dtime, cfra); + else if(part->phystype == PART_PHYS_NO) + reset_particle(sim, pa, dtime, cfra); if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ switch(part->phystype){ @@ -3561,7 +3568,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int cfra) strcpy(filename, fss->surfdataPath); strcat(filename, suffix); BLI_convertstringcode(filename, G.sce); - BLI_convertstringframe(filename, curFrame); // fixed #frame-no + BLI_convertstringframe(filename, curFrame, 0); // fixed #frame-no strcat(filename, suffix2); gzf = gzopen(filename, "rb"); @@ -3801,7 +3808,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) pa->alive = PARS_ALIVE; } } - else if(cfra != startframe && (sim->ob->id.lib || (cache->flag & PTCACHE_BAKED))) { + else if(cfra != startframe && ( /*sim->ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED))) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ psys_reset(psys, PSYS_RESET_CACHE_MISS); psys->cfra=cfra; psys->recalc = 0; @@ -3921,6 +3928,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(!sim.psmd->dm) return; + /* execute drivers only, as animation has already been done */ + BKE_animsys_evaluate_animdata(&psys->part->id, psys->part->adt, cfra, ADT_RECALC_DRIVERS); + if(psys->recalc & PSYS_RECALC_TYPE) psys_changed_type(&sim); else if(psys->recalc & PSYS_RECALC_PHYS) @@ -3938,6 +3948,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) for(i=0; i<=psys->part->hair_step; i++){ hcfra=100.0f*(float)i/(float)psys->part->hair_step; + BKE_animsys_evaluate_animdata(&psys->part->id, psys->part->adt, hcfra, ADT_RECALC_ANIM); system_step(&sim, hcfra); save_hair(&sim, hcfra); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7b2cf72e311..b1319a81f5d 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -42,7 +42,13 @@ #include "DNA_smoke_types.h" #include "BLI_blenlib.h" +#include "BLI_threads.h" +#include "PIL_time.h" + +#include "WM_api.h" + +#include "BKE_blender.h" #include "BKE_cloth.h" #include "BKE_depsgraph.h" #include "BKE_global.h" @@ -58,8 +64,6 @@ #include "BKE_utildefines.h" #include "BIK_api.h" -#include "BLI_blenlib.h" - /* both in intern */ #include "smoke_API.h" @@ -84,6 +88,13 @@ #include "BLI_winstuff.h" #endif +#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) +/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */ +#include <pthread.h> +extern pthread_key_t gomp_tls_key; +static void *thread_tls_data; +#endif + #define PTCACHE_DATA_FROM(data, type, from) if(data[type]) { memcpy(data[type], from, ptcache_data_size[type]); } #define PTCACHE_DATA_TO(data, type, index, to) if(data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); } @@ -192,9 +203,9 @@ static int ptcache_write_particle(int index, void *psys_v, void **data) ParticleData *pa = psys->particles + index; BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; float times[3] = {pa->time, pa->dietime, pa->lifetime}; + int step = psys->pointcache->step; if(data[BPHYS_DATA_INDEX]) { - int step = psys->pointcache->step; /* No need to store unborn or died particles */ if(pa->time - step > pa->state.time || pa->dietime + step < pa->state.time) return 0; @@ -211,7 +222,8 @@ static int ptcache_write_particle(int index, void *psys_v, void **data) if(boid) PTCACHE_DATA_FROM(data, BPHYS_DATA_BOIDS, &boid->data); - return 1; + /* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */ + return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time); } void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, float time) { @@ -238,6 +250,10 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr BKE_ptcache_make_particle_key(&pa->state, 0, data, cfra); + /* set frames cached before birth to birth time */ + if(cfra < pa->time) + pa->state.time = pa->time; + if(data[BPHYS_DATA_SIZE]) PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size); @@ -710,7 +726,9 @@ static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) unsigned char *obstacles; unsigned int in_len = sizeof(float)*(unsigned int)res; unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); - int mode = res >= 1000000 ? 2 : 1; + //int mode = res >= 1000000 ? 2 : 1; + int mode=1; // light + if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles); @@ -753,7 +771,10 @@ static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v) smoke_turbulence_get_res(sds->wt, res_big_array); res_big = res_big_array[0]*res_big_array[1]*res_big_array[2]; - mode = res_big >= 1000000 ? 2 : 1; + //mode = res_big >= 1000000 ? 2 : 1; + mode = 1; // light + if (sds->cache_high_comp == SM_CACHE_HEAVY) mode=2; // heavy + in_len_big = sizeof(float) * (unsigned int)res_big; smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); @@ -1132,6 +1153,9 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) } else if (mode==PTCACHE_FILE_WRITE) { BLI_make_existing_file(filename); /* will create the dir if needs be, same as //textures is created */ fp = fopen(filename, "wb"); + } else if (mode==PTCACHE_FILE_UPDATE) { + BLI_make_existing_file(filename); + fp = fopen(filename, "rb+"); } if (!fp) @@ -1237,6 +1261,18 @@ static void ptcache_file_init_pointers(PTCacheFile *pf) pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<<BPHYS_DATA_BOIDS) ? &pf->data.boids : NULL; } +static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) +{ + int i, size=0; + int data_types = pf->data_types; + + for(i=0; i<BPHYS_TOT_DATA; i++) + size += pf->data_types & (1<<i) ? ptcache_data_size[i] : 0; + + ptcache_file_init_pointers(pf); + /* size of default header + data up to index */ + fseek(pf->fp, 8 + 3*sizeof(int) + index * size, SEEK_SET); +} void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) { int data_types = pm->data_types; @@ -1255,6 +1291,14 @@ void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) pm->cur[i] = (char*)pm->cur[i] + ptcache_data_size[i]; } } +void BKE_ptcache_mem_seek_pointers(int index, PTCacheMem *pm) +{ + int data_types = pm->data_types; + int i; + + for(i=0; i<BPHYS_TOT_DATA; i++) + pm->cur[i] = data_types & (1<<i) ? (char*)pm->data[i] + index * ptcache_data_size[i] : NULL; +} static void ptcache_alloc_data(PTCacheMem *pm) { int data_types = pm->data_types; @@ -1437,7 +1481,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else if(pid->read_header(pf2)) { ptcache_file_init_pointers(pf2); totpoint2 = pf2->totpoint; - index2 = pf->data_types & BPHYS_DATA_INDEX ? &pf2->data.index : &i; + index2 = pf2->data_types & BPHYS_DATA_INDEX ? &pf2->data.index : &i; } } else { @@ -1447,7 +1491,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) } } - /* don't read old cache if allready simulated past cached frame */ + /* don't read old cache if already simulated past cached frame */ if(!pm && !pf && cfra1 && cfra1 <= pid->cache->simframe) error = 1; if(cfra1 && cfra1==cfra2) @@ -1599,7 +1643,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) { PointCache *cache = pid->cache; - PTCacheFile *pf= NULL; + PTCacheFile *pf= NULL, *pf2= NULL; int i; int totpoint = pid->totpoint(pid->calldata); int add = 0, overwrite = 0; @@ -1609,7 +1653,7 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) return 0; if(cache->flag & PTCACHE_DISK_CACHE) { - int efra = cache->endframe; + int ofra, efra = cache->endframe; if(cfra==0) add = 1; @@ -1620,7 +1664,6 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) add = 1; } else { - int ofra; /* find last cached frame */ while(efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra)) efra--; @@ -1663,11 +1706,36 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) } else for(i=0; i<totpoint; i++) { - if(pid->write_elem && pid->write_elem(i, pid->calldata, pf->cur)) - if(!ptcache_file_write_data(pf)) { - ptcache_file_close(pf); - return 0; + if(pid->write_elem) { + int write = pid->write_elem(i, pid->calldata, pf->cur); + if(write) { + if(!ptcache_file_write_data(pf)) { + ptcache_file_close(pf); + if(pf2) ptcache_file_close(pf2); + return 0; + } + /* newly born particles have to be copied to previous cached frame */ + else if(overwrite && write == 2) { + if(!pf2) { + pf2 = ptcache_file_open(pid, PTCACHE_FILE_UPDATE, ofra); + if(!pf2) { + ptcache_file_close(pf); + return 0; + } + pf2->type = pid->type; + pf2->totpoint = totpoint; + pf2->data_types = pid->data_types; + } + ptcache_file_seek_pointers(i, pf2); + pid->write_elem(i, pid->calldata, pf2->cur); + if(!ptcache_file_write_data(pf2)) { + ptcache_file_close(pf); + ptcache_file_close(pf2); + return 0; + } + } } + } } } } @@ -1712,8 +1780,19 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) BKE_ptcache_mem_init_pointers(pm); for(i=0; i<totpoint; i++) { - if(pid->write_elem && pid->write_elem(i, pid->calldata, pm->cur)) - BKE_ptcache_mem_incr_pointers(pm); + if(pid->write_elem) { + int write = pid->write_elem(i, pid->calldata, pm->cur); + if(write) { + BKE_ptcache_mem_incr_pointers(pm); + + /* newly born particles have to be copied to previous cached frame */ + if(overwrite && write == 2) { + pm2 = cache->mem_cache.last; + BKE_ptcache_mem_seek_pointers(i, pm2); + pid->write_elem(i, pid->calldata, pm2->cur); + } + } + } } //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); @@ -1732,8 +1811,9 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) cache->flag |= PTCACHE_FRAMES_SKIPPED; } - if(pf) - ptcache_file_close(pf); + if(pf) ptcache_file_close(pf); + + if(pf2) ptcache_file_close(pf2); BKE_ptcache_update_info(pid); @@ -2242,6 +2322,32 @@ void BKE_ptcache_quick_cache_all(Scene *scene) BKE_ptcache_make_cache(&baker); } +/* Simulation thread, no need for interlocks as data written in both threads + are only unitary integers (I/O assumed to be atomic for them) */ +typedef struct { + int break_operation; + int thread_ended; + int endframe; + int step; + int *cfra_ptr; + Scene *scene; +} ptcache_make_cache_data; + +static void *ptcache_make_cache_thread(void *ptr) { + ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr; + +#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) + // Workaround for Apple gcc 4.2.1 omp vs background thread bug + pthread_setspecific (gomp_tls_key, thread_tls_data); +#endif + + for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) + scene_update_for_newframe(data->scene, data->scene->lay); + + data->thread_ended = TRUE; + return NULL; +} + /* if bake is not given run simulations to current frame */ void BKE_ptcache_make_cache(PTCacheBaker* baker) { @@ -2253,10 +2359,16 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) float frameleno = scene->r.framelen; int cfrao = CFRA; int startframe = MAXFRAME; - int endframe = baker->anim_init ? scene->r.sfra : CFRA; int bake = baker->bake; int render = baker->render; - int step = baker->quick_step; + ListBase threads; + ptcache_make_cache_data thread_data; + int progress, old_progress; + + thread_data.endframe = baker->anim_init ? scene->r.sfra : CFRA; + thread_data.step = baker->quick_step; + thread_data.cfra_ptr = &CFRA; + thread_data.scene = baker->scene; G.afbreek = 0; @@ -2294,11 +2406,11 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) startframe = MAX2(cache->last_exact, cache->startframe); if(bake) { - endframe = cache->endframe; + thread_data.endframe = cache->endframe; cache->flag |= PTCACHE_BAKING; } else { - endframe = MIN2(endframe, cache->endframe); + thread_data.endframe = MIN2(thread_data.endframe, cache->endframe); } cache->flag &= ~PTCACHE_BAKED; @@ -2330,7 +2442,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache->flag |= PTCACHE_BAKING; if(bake) - endframe = MAX2(endframe, cache->endframe); + thread_data.endframe = MAX2(thread_data.endframe, cache->endframe); } cache->flag &= ~PTCACHE_BAKED; @@ -2340,30 +2452,45 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) BLI_freelistN(&pidlist); } - CFRA= startframe; + CFRA = startframe; scene->r.framelen = 1.0; - - for(; CFRA <= endframe; CFRA+=step) { - int prog; + thread_data.break_operation = FALSE; + thread_data.thread_ended = FALSE; + old_progress = -1; + +#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) + // Workaround for Apple gcc 4.2.1 omp vs background thread bug + thread_tls_data = pthread_getspecific(gomp_tls_key); +#endif + BLI_init_threads(&threads, ptcache_make_cache_thread, 1); + BLI_insert_thread(&threads, (void*)&thread_data); + + while (thread_data.thread_ended == FALSE) { if(bake) - prog = (int)(100.0f * (float)(CFRA - startframe)/(float)(endframe-startframe)); + progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe)); else - prog = CFRA; + progress = CFRA; /* NOTE: baking should not redraw whole ui as this slows things down */ - if(baker->progressbar) - baker->progressbar(baker->progresscontext, prog); + if ((baker->progressbar) && (progress != old_progress)) { + baker->progressbar(baker->progresscontext, progress); + old_progress = progress; + } - scene_update_for_newframe(scene, scene->lay); + /* Delay to lessen CPU load from UI thread */ + PIL_sleep_ms(200); /* NOTE: breaking baking should leave calculated frames in cache, not clear it */ - if(baker->break_test && baker->break_test(baker->break_data)) - break; + if(blender_test_break() && !thread_data.break_operation) { + thread_data.break_operation = TRUE; + if (baker->progressend) + baker->progressend(baker->progresscontext); + WM_cursor_wait(1); + } } - if (baker->progressend) - baker->progressend(baker->progresscontext); + BLI_end_threads(&threads); /* clear baking flag */ if(pid) { @@ -2386,7 +2513,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache = pid->cache; - if(step > 1) + if(thread_data.step > 1) cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED); else cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED); @@ -2408,6 +2535,11 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) if(bake) /* already on cfra unless baking */ scene_update_for_newframe(scene, scene->lay); + if (thread_data.break_operation) + WM_cursor_wait(0); + else if (baker->progressend) + baker->progressend(baker->progresscontext); + /* TODO: call redraw all windows somehow */ } /* Helpers */ diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index 5cae527957b..d65e3391f04 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index e524359d2bc..a2a44ca53a7 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 5cd554725ff..1c727ee1596 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -139,7 +139,7 @@ void init_sensor(bSensor *sens) break; case SENS_MOUSE: ms=sens->data= MEM_callocN(sizeof(bMouseSensor), "mousesens"); - //XXX ms->type= LEFTMOUSE; + ms->type= 1; // LEFTMOUSE workaround because Mouse Sensor types enum starts in 1 break; case SENS_COLLISION: sens->data= MEM_callocN(sizeof(bCollisionSensor), "colsens"); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f17d11c40ce..77b1202aa20 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -83,6 +83,7 @@ #include "BKE_sequencer.h" #include "BKE_world.h" #include "BKE_utildefines.h" +#include "BKE_sound.h" //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" @@ -158,6 +159,7 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) scen->obedit= NULL; scen->toolsettings= MEM_dupallocN(sce->toolsettings); scen->stats= NULL; + scen->fps_info= NULL; ts= scen->toolsettings; if(ts) { @@ -233,6 +235,8 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) } } + sound_create_scene(scen); + return scen; } @@ -315,6 +319,10 @@ void free_scene(Scene *sce) if(sce->stats) MEM_freeN(sce->stats); + if(sce->fps_info) + MEM_freeN(sce->fps_info); + + sound_destroy_scene(sce); } Scene *add_scene(char *name) @@ -356,6 +364,7 @@ Scene *add_scene(char *name) sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION; sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_SCENE|R_STAMP_CAMERA|R_STAMP_RENDERTIME; + sce->r.stamp_font_id= 12; sce->r.threads= 1; @@ -367,6 +376,11 @@ Scene *add_scene(char *name) sce->r.cineonblack= 95; sce->r.cineonwhite= 685; sce->r.cineongamma= 1.7f; + + sce->r.border.xmin= 0.0f; + sce->r.border.ymin= 0.0f; + sce->r.border.xmax= 1.0f; + sce->r.border.ymax= 1.0f; sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings),"Tool Settings Struct"); sce->toolsettings->cornertype=1; @@ -475,6 +489,8 @@ Scene *add_scene(char *name) sce->gm.flag = GAME_DISPLAY_LISTS; sce->gm.matmode = GAME_MAT_MULTITEX; + sound_create_scene(sce); + return sce; } @@ -714,7 +730,7 @@ Object *scene_find_camera_switch(Scene *scene) Object *camera= NULL; for (m= scene->markers.first; m; m= m->next) { - if(m->camera && (m->frame <= cfra) && (m->frame > frame)) { + if(m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER)==0 && (m->frame <= cfra) && (m->frame > frame)) { camera= m->camera; frame= m->frame; @@ -727,26 +743,47 @@ Object *scene_find_camera_switch(Scene *scene) } #endif -static char *get_cfra_marker_name(Scene *scene) +char *scene_find_marker_name(Scene *scene, int frame) { ListBase *markers= &scene->markers; TimeMarker *m1, *m2; /* search through markers for match */ for (m1=markers->first, m2=markers->last; m1 && m2; m1=m1->next, m2=m2->prev) { - if (m1->frame==CFRA) + if (m1->frame==frame) return m1->name; if (m1 == m2) break; - if (m2->frame==CFRA) + if (m2->frame==frame) return m2->name; } return NULL; } +/* return the current marker for this frame, +we can have more then 1 marker per frame, this just returns the first :/ */ +char *scene_find_last_marker_name(Scene *scene, int frame) +{ + TimeMarker *marker, *best_marker = NULL; + int best_frame = -MAXFRAME*2; + for (marker= scene->markers.first; marker; marker= marker->next) { + if (marker->frame==frame) { + return marker->name; + } + + if ( marker->frame > best_frame && marker->frame < frame) { + best_marker = marker; + best_frame = marker->frame; + } + } + + return best_marker ? best_marker->name : NULL; +} + + Base *scene_add_base(Scene *sce, Object *ob) { Base *b= MEM_callocN(sizeof(*b), "scene_add_base"); @@ -826,20 +863,6 @@ static void scene_update_newframe(Scene *sce, unsigned int lay) { Base *base; Object *ob; - float ctime = frame_to_float(sce, sce->r.cfra); - - if(sce->theDag==NULL) - DAG_scene_sort(sce); - - DAG_scene_update_flags(sce, lay); // only stuff that moves or needs display still - - /* All 'standard' (i.e. without any dependencies) animation is handled here, - * with an 'local' to 'macro' order of evaluation. This should ensure that - * settings stored nestled within a hierarchy (i.e. settings in a Texture block - * can be overridden by settings from Scene, which owns the Texture through a hierarchy - * such as Scene->World->MTex/Texture) can still get correctly overridden. - */ - BKE_animsys_evaluate_all_animation(G.main, ctime); for(base= sce->base.first; base; base= base->next) { ob= base->object; @@ -892,16 +915,37 @@ void scene_update_tagged(Scene *scene) /* applies changes right away, does all sets too */ void scene_update_for_newframe(Scene *sce, unsigned int lay) { - Scene *scene= sce; + float ctime = frame_to_float(sce, sce->r.cfra); + Scene *sce_iter; /* clear animation overrides */ // XXX TODO... - + + for(sce_iter= sce; sce_iter; sce_iter= sce_iter->set) { + if(sce_iter->theDag==NULL) + DAG_scene_sort(sce_iter); + } + + + /* Following 2 functions are recursive + * so dont call within 'scene_update_newframe' */ + DAG_scene_update_flags(sce, lay); // only stuff that moves or needs display still + + /* All 'standard' (i.e. without any dependencies) animation is handled here, + * with an 'local' to 'macro' order of evaluation. This should ensure that + * settings stored nestled within a hierarchy (i.e. settings in a Texture block + * can be overridden by settings from Scene, which owns the Texture through a hierarchy + * such as Scene->World->MTex/Texture) can still get correctly overridden. + */ + BKE_animsys_evaluate_all_animation(G.main, ctime); + /*...done with recusrive funcs */ + + /* sets first, we allow per definition current scene to have dependencies on sets */ - for(sce= sce->set; sce; sce= sce->set) - scene_update_newframe(sce, lay); + for(sce_iter= sce->set; sce_iter; sce_iter= sce_iter->set) + scene_update_newframe(sce_iter, lay); - scene_update_newframe(scene, lay); + scene_update_newframe(sce, lay); } /* return default layer, also used to patch old files */ @@ -911,8 +955,8 @@ void scene_add_render_layer(Scene *sce) // int tot= 1 + BLI_countlist(&sce->r.layers); srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer"); - sprintf(srl->name, "RenderLayer"); - BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), 32); + strcpy(srl->name, "RenderLayer"); + BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), sizeof(srl->name)); BLI_addtail(&sce->r.layers, srl); /* note, this is also in render, pipeline.c, to make layer when scenedata doesnt have it */ @@ -925,7 +969,7 @@ void scene_add_render_layer(Scene *sce) int get_render_subsurf_level(RenderData *r, int lvl) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY)) + if(r->mode & R_SIMPLIFY) return MIN2(r->simplify_subsurf, lvl); else return lvl; @@ -933,7 +977,7 @@ int get_render_subsurf_level(RenderData *r, int lvl) int get_render_child_particle_number(RenderData *r, int num) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY)) + if(r->mode & R_SIMPLIFY) return (int)(r->simplify_particles*num); else return num; @@ -941,7 +985,7 @@ int get_render_child_particle_number(RenderData *r, int num) int get_render_shadow_samples(RenderData *r, int samples) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY) && samples > 0) + if((r->mode & R_SIMPLIFY) && samples > 0) return MIN2(r->simplify_shadowsamples, samples); else return samples; @@ -949,7 +993,7 @@ int get_render_shadow_samples(RenderData *r, int samples) float get_render_aosss_error(RenderData *r, float error) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY)) + if(r->mode & R_SIMPLIFY) return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error; else return error; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 0dc6bf359f6..6d0057ca298 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -336,3 +336,19 @@ unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene) return layer; } +/* ***************** Utilities ********************** */ + +/* Find a region of the specified type from the given area */ +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; + } + } + return NULL; +} + diff --git a/source/blender/blenkernel/intern/script.c b/source/blender/blenkernel/intern/script.c index 98298950c19..424067a7046 100644 --- a/source/blender/blenkernel/intern/script.c +++ b/source/blender/blenkernel/intern/script.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 2c532bfed1c..770bcddfffd 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 36c6e074d4e..98dbf83f032 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -233,8 +233,8 @@ void seq_free_sequence(Scene *scene, Sequence *seq) if (ed->act_seq==seq) ed->act_seq= NULL; - if(seq->sound_handle) - sound_delete_handle(scene, seq->sound_handle); + if(seq->scene_sound) + sound_remove_scene_sound(scene, seq->scene_sound); } MEM_freeN(seq); @@ -484,7 +484,7 @@ void build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int *totseq, } -void calc_sequence_disp(Sequence *seq) +void calc_sequence_disp(Scene *scene, Sequence *seq) { if(seq->startofs && seq->startstill) seq->startstill= 0; if(seq->endofs && seq->endstill) seq->endstill= 0; @@ -500,10 +500,10 @@ void calc_sequence_disp(Sequence *seq) seq->handsize= (float)((seq->enddisp-seq->startdisp)/25); } - seq_update_sound(seq); + seq_update_sound(scene, seq); } -void calc_sequence(Sequence *seq) +void calc_sequence(Scene *scene, Sequence *seq) { Sequence *seqm; int min, max; @@ -511,7 +511,7 @@ void calc_sequence(Sequence *seq) /* check all metas recursively */ seqm= seq->seqbase.first; while(seqm) { - if(seqm->seqbase.first) calc_sequence(seqm); + if(seqm->seqbase.first) calc_sequence(scene, seqm); seqm= seqm->next; } @@ -534,7 +534,7 @@ void calc_sequence(Sequence *seq) seq->enddisp= MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp); seq->len= seq->enddisp - seq->startdisp; } else { - calc_sequence_disp(seq); + calc_sequence_disp(scene, seq); } if(seq->strip && seq->len!=seq->strip->len) { @@ -563,7 +563,7 @@ void calc_sequence(Sequence *seq) } } } - calc_sequence_disp(seq); + calc_sequence_disp(scene, seq); } } @@ -583,8 +583,6 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) seq->type != SEQ_IMAGE) { BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); BLI_convertstringcode(str, G.sce); - BLI_convertstringframe(str, scene->r.cfra); - } if (seq->type == SEQ_IMAGE) { @@ -616,7 +614,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } seq->strip->len = seq->len; } else if (seq->type == SEQ_SOUND) { - seq->len = AUD_getInfo(seq->sound->handle).length * FPS; + seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS); seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { @@ -642,7 +640,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } BLI_strncpy(seq->name+2, sce->id.name + 2, SEQ_NAME_MAXSTR-2); - seqUniqueName(scene->ed->seqbasep, seq); + seqbase_unique_name_recursive(&scene->ed->seqbase, seq); seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1; seq->len -= seq->anim_startofs; @@ -655,7 +653,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) free_proxy_seq(seq); - calc_sequence(seq); + calc_sequence(scene, seq); } void sort_seq(Scene *scene) @@ -722,6 +720,62 @@ void clear_scene_in_allseqs(Scene *scene) } } +typedef struct SeqUniqueInfo { + Sequence *seq; + char name_src[32]; + char name_dest[32]; + int count; + int match; +} SeqUniqueInfo; + +/* +static void seqbase_unique_name(ListBase *seqbasep, Sequence *seq) +{ + BLI_uniquename(seqbasep, seq, "Sequence", '.', offsetof(Sequence, name), SEQ_NAME_MAXSTR); +}*/ + +static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) +{ + Sequence *seq; + for(seq=seqbasep->first; seq; seq= seq->next) { + if (sui->seq != seq && strcmp(sui->name_dest, seq->name+2)==0) { + sprintf(sui->name_dest, "%.18s.%03d", sui->name_src, sui->count++); + sui->match= 1; /* be sure to re-scan */ + } + } +} + +static int seqbase_unique_name_recursive_cb(Sequence *seq, void *arg_pt) +{ + if(seq->seqbase.first) + seqbase_unique_name(&seq->seqbase, (SeqUniqueInfo *)arg_pt); + return 1; +} + +void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq) +{ + SeqUniqueInfo sui; + char *dot; + sui.seq= seq; + strcpy(sui.name_src, seq->name+2); + strcpy(sui.name_dest, seq->name+2); + + /* Strip off the suffix */ + if ((dot=strrchr(sui.name_src, '.'))) + *dot= '\0'; + + sui.count= 1; + sui.match= 1; /* assume the worst to start the loop */ + + while(sui.match) { + sui.match= 0; + seqbase_unique_name(seqbasep, &sui); + seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_cb, &sui); + } + + strcpy(seq->name+2, sui.name_dest); +} + static char *give_seqname_by_type(int type) { switch(type) { @@ -1066,17 +1120,19 @@ static TStripElem *give_tstripelem(Sequence *seq, int cfra) StripElem *give_stripelem(Sequence *seq, int cfra) { - StripElem *se; - int nr; - - se = seq->strip->stripdata; - nr = give_stripelem_index(seq, cfra); + StripElem *se= seq->strip->stripdata; - if (nr == -1) return 0; - if (se == 0) return 0; + if(seq->type == SEQ_MOVIE) { + /* use the first */ + } + else { + int nr = give_stripelem_index(seq, cfra); - se += nr + seq->anim_startofs; + if (nr == -1) return 0; + if (se == 0) return 0; + se += nr + seq->anim_startofs; + } return se; } @@ -1188,7 +1244,6 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { BLI_join_dirfile(name, dir, seq->strip->proxy->file); BLI_convertstringcode(name, G.sce); - BLI_convertstringframe(name, cfra); return TRUE; } @@ -1218,8 +1273,8 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na } BLI_convertstringcode(name, G.sce); - BLI_convertstringframe(name, frameno); - + BLI_convertstringframe(name, frameno, 0); + strcat(name, ".jpg"); @@ -1986,7 +2041,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int StripElem * s_elem = give_stripelem(seq, cfra); BLI_join_dirfile(name, seq->strip->dir, s_elem->name); BLI_convertstringcode(name, G.sce); - BLI_convertstringframe(name, scene->r.cfra); if (!build_proxy_run) { se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); } @@ -2021,7 +2075,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if(seq->anim==0) { BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); BLI_convertstringcode(name, G.sce); - BLI_convertstringframe(name, scene->r.cfra); seq->anim = openanim( name, IB_rect | @@ -2052,7 +2105,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int Scene *sce= seq->scene;// *oldsce= scene; Render *re; RenderResult rres; - char scenename[64]; int have_seq= FALSE; int sce_valid= FALSE; @@ -2096,11 +2148,10 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int oldcfra = seq->scene->r.cfra; - if(rendering) { - BLI_strncpy(scenename, sce->id.name+2, 64); - strcpy(sce->id.name+2, " do_build_seq_ibuf"); - } - re= RE_NewRender(sce->id.name); + if(rendering) + re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); + else + re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); /* prevent eternal loop */ doseq= scene->r.scemode & R_DOSEQ; @@ -2109,9 +2160,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int RE_BlenderFrame(re, sce, NULL, seq->sfra+se->nr+seq->anim_startofs); - if(rendering) - BLI_strncpy(sce->id.name+2, scenename, 64); - RE_AcquireResultImage(re, &rres); if(rres.rectf) { @@ -2506,14 +2554,18 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, TStripElem* se2 = give_tstripelem(seq_arr[i], cfra); float facf = seq->blend_opacity / 100.0; - + int early_out = sh.early_out(seq, facf, facf); + switch (early_out) { case 0: { int x= se2->ibuf->x; int y= se2->ibuf->y; int swap_input = FALSE; + if(se1->ibuf_comp == NULL) + continue; + if (se1->ibuf_comp->rect_float || se2->ibuf->rect_float) { se2->ibuf_comp = IMB_allocImBuf( @@ -2576,7 +2628,8 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, } case 1: { se2->ibuf_comp = se1->ibuf; - IMB_refImBuf(se2->ibuf_comp); + if(se2->ibuf_comp) + IMB_refImBuf(se2->ibuf_comp); break; } @@ -3192,7 +3245,7 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan } if(len_change) - calc_sequence(seq); + calc_sequence(scene, seq); } return free_imbuf; @@ -3242,23 +3295,6 @@ static void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo) } #endif -static int seq_sound_reload_cb(Sequence *seq, void *arg_pt) -{ - if (seq->type==SEQ_SOUND && seq->sound) { - Scene *scene= (Scene *)arg_pt; - if(seq->sound_handle) - sound_delete_handle(scene, seq->sound_handle); - - seq->sound_handle = sound_new_handle(scene, seq->sound, seq->start, seq->start + seq->strip->len, 0); - return 0; - } - return 1; /* recurse meta's */ -} -void seqbase_sound_reload(Scene *scene, ListBase *seqbase) -{ - seqbase_recursive_apply(seqbase, seq_sound_reload_cb, (void *)scene); -} - /* seq funcs's for transforming internally notice the difference between start/end and left/right. @@ -3466,7 +3502,7 @@ static void seq_translate(Scene *evil_scene, Sequence *seq, int delta) } } - calc_sequence_disp(seq); + calc_sequence_disp(evil_scene, seq); } /* return 0 if there werent enough space */ @@ -3474,13 +3510,13 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene) { int orig_machine= test->machine; test->machine++; - calc_sequence(test); + calc_sequence(evil_scene, test); while( seq_test_overlap(seqbasep, test) ) { if(test->machine >= MAXSEQ) { break; } test->machine++; - calc_sequence(test); // XXX - I dont think this is needed since were only moving vertically, Campbell. + calc_sequence(evil_scene, test); // XXX - I dont think this is needed since were only moving vertically, Campbell. } @@ -3500,7 +3536,7 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene) new_frame = new_frame + (test->start-test->startdisp); /* adjust by the startdisp */ seq_translate(evil_scene, test, new_frame - test->start); - calc_sequence(test); + calc_sequence(evil_scene, test); return 0; } else { return 1; @@ -3529,7 +3565,7 @@ static int shuffle_seq_time_offset_test(ListBase * seqbasep, char dir) return offset; } -static int shuffle_seq_time_offset(ListBase * seqbasep, char dir) +static int shuffle_seq_time_offset(Scene* scene, ListBase * seqbasep, char dir) { int ofs= 0; int tot_ofs= 0; @@ -3548,7 +3584,7 @@ static int shuffle_seq_time_offset(ListBase * seqbasep, char dir) for(seq= seqbasep->first; seq; seq= seq->next) { if(seq->tmp) - calc_sequence_disp(seq); /* corrects dummy startdisp/enddisp values */ + calc_sequence_disp(scene, seq); /* corrects dummy startdisp/enddisp values */ } return tot_ofs; @@ -3560,8 +3596,8 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene) Sequence *seq; - int offset_l = shuffle_seq_time_offset(seqbasep, 'L'); - int offset_r = shuffle_seq_time_offset(seqbasep, 'R'); + int offset_l = shuffle_seq_time_offset(evil_scene, seqbasep, 'L'); + int offset_r = shuffle_seq_time_offset(evil_scene, seqbasep, 'R'); int offset = (-offset_l < offset_r) ? offset_l:offset_r; if(offset) { @@ -3576,19 +3612,16 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene) return offset? 0:1; } -void seq_update_sound(Sequence *seq) +void seq_update_sound(Scene* scene, Sequence *seq) { - if(seq->type == SEQ_SOUND && seq->sound_handle) + if(seq->scene_sound) { - seq->sound_handle->startframe = seq->startdisp; - seq->sound_handle->endframe = seq->enddisp; - seq->sound_handle->frameskip = seq->startofs + seq->anim_startofs; - seq->sound_handle->changed = -1; + sound_move_scene_sound(scene, seq->scene_sound, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); /* mute is set in seq_update_muting_recursive */ } } -static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute) +static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequence *metaseq, int mute) { Sequence *seq; int seqmute; @@ -3604,27 +3637,26 @@ static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, i if(seq == metaseq) seqmute= 0; - seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute); + seq_update_muting_recursive(scene, &seq->seqbase, metaseq, seqmute); } else if(seq->type == SEQ_SOUND) { - if(seq->sound_handle && seqmute != seq->sound_handle->mute) { - seq->sound_handle->mute = seqmute; - seq->sound_handle->changed = -1; + if(seq->scene_sound) { + sound_mute_scene_sound(scene, seq->scene_sound, seqmute); } } } } -void seq_update_muting(Editing *ed) +void seq_update_muting(Scene *scene, Editing *ed) { if(ed) { /* mute all sounds up to current metastack list */ MetaStack *ms= ed->metastack.last; if(ms) - seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1); + seq_update_muting_recursive(scene, &ed->seqbase, ms->parseq, 1); else - seq_update_muting_recursive(&ed->seqbase, NULL, 0); + seq_update_muting_recursive(scene, &ed->seqbase, NULL, 0); } } @@ -3709,7 +3741,7 @@ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) { if(seq) { strcpy(seq->name, seq_load->name); - seqUniqueName(scene->ed->seqbasep, seq); + seqbase_unique_name_recursive(&scene->ed->seqbase, seq); if(seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) { seq_load->start_frame += (seq->enddisp - seq->startdisp); @@ -3747,16 +3779,12 @@ Sequence *alloc_sequence(ListBase *lb, int cfra, int machine) seq->machine= machine; seq->mul= 1.0; seq->blend_opacity = 100.0; + seq->volume = 1.0f; return seq; } -void seqUniqueName(ListBase *seqbasep, Sequence *seq) -{ - BLI_uniquename(seqbasep, seq, "Sequence", '.', offsetof(Sequence, name), SEQ_NAME_MAXSTR); -} - -/* NOTE: this function doesn't fill in iamge names */ +/* NOTE: this function doesn't fill in image names */ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load) { Scene *scene= CTX_data_scene(C); /* only for active seq */ @@ -3767,7 +3795,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel); seq->type= SEQ_IMAGE; BLI_strncpy(seq->name+2, "Image", SEQ_NAME_MAXSTR-2); - seqUniqueName(seqbasep, seq); + seqbase_unique_name_recursive(&scene->ed->seqbase, seq); /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); @@ -3796,13 +3824,13 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo sound = sound_new_file(CTX_data_main(C), seq_load->path); - if (sound==NULL || sound->handle == NULL) { + if (sound==NULL || sound->playback_handle == NULL) { //if(op) // BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return NULL; } - info = AUD_getInfo(sound->handle); + info = AUD_getInfo(sound->playback_handle); if (info.specs.channels == AUD_CHANNELS_INVALID) { sound_delete(C, sound); @@ -3816,20 +3844,20 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq->type= SEQ_SOUND; seq->sound= sound; BLI_strncpy(seq->name+2, "Sound", SEQ_NAME_MAXSTR-2); - seqUniqueName(seqbasep, seq); + seqbase_unique_name_recursive(&scene->ed->seqbase, seq); /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = (int) (info.length * FPS); + strip->len = seq->len = ceil(info.length * FPS); strip->us= 1; strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); - seq->sound_handle = sound_new_handle(scene, sound, seq_load->start_frame, seq_load->start_frame + strip->len, 0); + seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + strip->len, 0); - calc_sequence_disp(seq); + calc_sequence_disp(scene, seq); /* last active name */ strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); @@ -3860,7 +3888,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq->anim= an; seq->anim_preseek = IMB_anim_get_preseek(an); BLI_strncpy(seq->name+2, "Movie", SEQ_NAME_MAXSTR-2); - seqUniqueName(seqbasep, seq); + seqbase_unique_name_recursive(&scene->ed->seqbase, seq); /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); @@ -3871,7 +3899,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); - calc_sequence_disp(seq); + calc_sequence_disp(scene, seq); if(seq_load->flag & SEQ_LOAD_MOVIE_SOUND) { diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 1c9e65eae73..d15b5fd95e2 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. @@ -185,7 +185,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) { float *co = calc->vertexCos[i]; float tmp_co[3]; - float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); + float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); if(weight == 0.0f) continue; @@ -357,7 +357,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S { float *co = calc->vertexCos[i]; float tmp_co[3], tmp_no[3]; - float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); + float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); if(weight == 0.0f) continue; @@ -448,7 +448,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) { float *co = calc->vertexCos[i]; float tmp_co[3]; - float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); + float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); if(weight == 0.0f) continue; //Convert the vertex to tree coordinates @@ -520,7 +520,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object calc.vertexCos = vertexCos; //DeformVertex - calc.vgroup = get_named_vertexgroup_num(calc.ob, calc.smd->vgroup_name); + calc.vgroup = defgroup_name_index(calc.ob, calc.smd->vgroup_name); if(dm) { calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); @@ -546,7 +546,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object - calc.vgroup = get_named_vertexgroup_num(calc.ob, smd->vgroup_name); + calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name); if(dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) { diff --git a/source/blender/blenkernel/intern/simple_deform.c b/source/blender/blenkernel/intern/simple_deform.c index b2920615f5a..f3984eb1c8b 100644 --- a/source/blender/blenkernel/intern/simple_deform.c +++ b/source/blender/blenkernel/intern/simple_deform.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. @@ -149,7 +149,7 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s float smd_limit[2], smd_factor; SpaceTransform *transf = NULL, tmp_transf; void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; //Mode callback - int vgroup = get_named_vertexgroup_num(ob, smd->vgroup_name); + int vgroup = defgroup_name_index(ob, smd->vgroup_name); MDeformVert *dvert = NULL; //Safe-check @@ -227,7 +227,7 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s for(i=0; i<numVerts; i++) { - float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup); + float weight = defvert_array_find_weight_safe(dvert, i, vgroup); if(weight != 0.0f) { diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index a41c7747b1a..ecafd0881ad 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Contributor(s): none yet. * diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index e53707bd6eb..dd25bfe4ec4 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation. * All rights reserved. @@ -872,11 +872,13 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) heat[index] = sfs->temp; density[index] = sfs->density; - /* + + // Uses particle velocity as initial velocity for smoke + if(smd->domain->flags & MOD_SMOKE_INITVELOCITY) { velocity_x[index] = pa->state.vel[0]; velocity_y[index] = pa->state.vel[1]; velocity_z[index] = pa->state.vel[2]; - */ + } // obstacle[index] |= 2; // we need different handling for the high-res feature @@ -1396,8 +1398,9 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct) { - int x, y, z; + int z; float bv[6]; + int slabsize=res[0]*res[1]; memset(result, -1, sizeof(float)*res[0]*res[1]*res[2]); // x bv[0] = p0[0]; @@ -1409,19 +1412,20 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa bv[4] = p0[2]; bv[5] = p1[2]; -#pragma omp parallel for schedule(static) private(y, z) - for(x = 0; x < res[0]; x++) +#pragma omp parallel for schedule(static,1) + for(z = 0; z < res[2]; z++) + { + size_t index = z*slabsize; + int x,y; + for(y = 0; y < res[1]; y++) - for(z = 0; z < res[2]; z++) + for(x = 0; x < res[0]; x++, index++) { float voxelCenter[3]; - size_t index; float pos[3]; int cell[3]; float tRay = 1.0; - index = smoke_get_index(x, res[0], y, res[1], z); - if(result[index] >= 0.0f) continue; voxelCenter[0] = p0[0] + dx * x + dx * 0.5; @@ -1446,5 +1450,6 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa // #pragma omp critical result[index] = tRay; } + } } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 65c9841a46b..8ca8feead90 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. @@ -1270,7 +1270,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa normalize_v3(d_nvect); if ( /* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || - we did that edge allready */ + we did that edge already */ isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ Vec3PlusStVec(force,-0.5f,d_nvect); @@ -2865,7 +2865,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* or heun ~ 2nd order runge-kutta steps, mode 1,2 */ SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; - float dx[3],dv[3],aabbmin[3],aabbmax[3],cm[3]={0.0f,0.0f,0.0f}; + float dx[3]={0},dv[3],aabbmin[3],aabbmax[3],cm[3]={0.0f,0.0f,0.0f}; float timeovermass/*,freezeloc=0.00001f,freezeforce=0.00000000001f*/; float maxerrpos= 0.0f,maxerrvel = 0.0f; int a,fuzzy=0; @@ -3268,7 +3268,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) if (sb->namedVG_Mass[0]) { - int grp= get_named_vertexgroup_num (ob,sb->namedVG_Mass); + int grp= defgroup_name_index (ob,sb->namedVG_Mass); /* printf("VGN %s %d \n",sb->namedVG_Mass,grp); */ if(grp > -1){ get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->mass); @@ -3282,7 +3282,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) if (sb->namedVG_Spring_K[0]) { - int grp= get_named_vertexgroup_num (ob,sb->namedVG_Spring_K); + int grp= defgroup_name_index (ob,sb->namedVG_Spring_K); //printf("VGN %s %d \n",sb->namedVG_Spring_K,grp); if(grp > -1){ get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->springweight); @@ -3487,7 +3487,9 @@ static void lattice_to_softbody(Scene *scene, Object *ob) sb= ob->soft; /* can be created in renew_softbody() */ /* weights from bpoints, same code used as for mesh vertices */ - if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { + /* if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { 2.4x one*/ + /* new! take the weights from lattice vertex anyhow */ + if(ob->softflag & OB_SB_GOAL){ BodyPoint *bp= sb->bpoint; BPoint *bpnt= lt->def; float goalfac= ABS(sb->maxgoal - sb->mingoal); @@ -3539,7 +3541,9 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) bs= sb->bspring; /* weights from bpoints, same code used as for mesh vertices */ - if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) + /* if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/ + /* new! take the weights from curve vertex anyhow */ + if(ob->softflag & OB_SB_GOAL) setgoal= 1; for(nu= cu->nurb.first; nu; nu= nu->next) { diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 3232e2677b5..e014b209e07 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -11,7 +11,9 @@ #include "BLI_blenlib.h" +#include "DNA_anim_types.h" #include "DNA_scene_types.h" +#include "DNA_sequence_types.h" #include "DNA_sound_types.h" #include "DNA_packedFile_types.h" #include "DNA_screen_types.h" @@ -26,19 +28,57 @@ #include "BKE_context.h" #include "BKE_library.h" #include "BKE_packedFile.h" +#include "BKE_fcurve.h" +#include "BKE_animsys.h" + +#include "RNA_access.h" #ifdef HAVE_CONFIG_H #include <config.h> #endif -static int sound_disabled = 0; +static int force_device = -1; + +static void sound_sync_callback(void* data, int mode, float time) +{ + struct Main* bmain = (struct Main*)data; + struct Scene* scene; + + scene = bmain->scene.first; + while(scene) + { + if(scene->audio.flag & AUDIO_SYNC) + { + if(mode) + sound_play_scene(scene); + else + sound_stop_scene(scene); + AUD_seek(scene->sound_scene_handle, time); + } + scene = scene->id.next; + } +} + +int sound_define_from_str(char *str) +{ + if (BLI_strcaseeq(str, "NULL")) + return AUD_NULL_DEVICE; + if (BLI_strcaseeq(str, "SDL")) + return AUD_SDL_DEVICE; + if (BLI_strcaseeq(str, "OPENAL")) + return AUD_OPENAL_DEVICE; + if (BLI_strcaseeq(str, "JACK")) + return AUD_JACK_DEVICE; + + return -1; +} -void sound_disable() +void sound_force_device(int device) { - sound_disabled = 1; + force_device = device; } -void sound_init() +void sound_init(struct Main *bmain) { AUD_DeviceSpecs specs; int device, buffersize; @@ -49,8 +89,8 @@ void sound_init() specs.format = U.audioformat; specs.rate = U.audiorate; - if (sound_disabled) - device = 0; + if(force_device >= 0) + device = force_device; if(buffersize < 128) buffersize = AUD_DEFAULT_BUFFER_SIZE; @@ -66,6 +106,10 @@ void sound_init() if(!AUD_init(device, specs, buffersize)) AUD_init(AUD_NULL_DEVICE, specs, buffersize); + +#ifdef WITH_JACK + AUD_setSyncCallback(sound_sync_callback, bmain); +#endif } void sound_exit() @@ -73,7 +117,7 @@ void sound_exit() AUD_exit(); } -struct bSound* sound_new_file(struct Main *main, char* filename) +struct bSound* sound_new_file(struct Main *bmain, char* filename) { bSound* sound = NULL; @@ -81,21 +125,21 @@ struct bSound* sound_new_file(struct Main *main, char* filename) int len; strcpy(str, filename); - BLI_convertstringcode(str, main->name); + BLI_convertstringcode(str, bmain->name); len = strlen(filename); while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') len--; - sound = alloc_libblock(&main->sound, ID_SO, filename+len); - strcpy(sound->name, filename); + sound = alloc_libblock(&bmain->sound, ID_SO, filename+len); + BLI_strncpy(sound->name, filename, FILE_MAX); // XXX unused currently sound->type = SOUND_TYPE_FILE; - sound_load(main, sound); + sound_load(bmain, sound); - if(!sound->handle) + if(!sound->playback_handle) { - free_libblock(&main->sound, sound); + free_libblock(&bmain->sound, sound); sound = NULL; } @@ -119,7 +163,7 @@ struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) sound_load(CTX_data_main(C), sound); - if(!sound->handle) + if(!sound->playback_handle) { free_libblock(&CTX_data_main(C)->sound, sound); sound = NULL; @@ -145,7 +189,7 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa sound_load(CTX_data_main(C), sound); - if(!sound->handle) + if(!sound->playback_handle) { free_libblock(&CTX_data_main(C)->sound, sound); sound = NULL; @@ -161,8 +205,6 @@ void sound_delete(struct bContext *C, struct bSound* sound) { sound_free(sound); - sound_unlink(C, sound); - free_libblock(&CTX_data_main(C)->sound, sound); } } @@ -173,7 +215,7 @@ void sound_cache(struct bSound* sound, int ignore) AUD_unload(sound->cache); sound->cache = AUD_bufferSound(sound->handle); - sound->changed++; + sound->playback_handle = sound->cache; } void sound_delete_cache(struct bSound* sound) @@ -182,10 +224,11 @@ void sound_delete_cache(struct bSound* sound) { AUD_unload(sound->cache); sound->cache = NULL; + sound->playback_handle = sound->handle; } } -void sound_load(struct Main *main, struct bSound* sound) +void sound_load(struct Main *bmain, struct bSound* sound) { if(sound) { @@ -193,6 +236,7 @@ void sound_load(struct Main *main, struct bSound* sound) { AUD_unload(sound->handle); sound->handle = NULL; + sound->playback_handle = NULL; } // XXX unused currently @@ -214,7 +258,7 @@ void sound_load(struct Main *main, struct bSound* sound) if(sound->id.lib) path = sound->id.lib->filename; else - path = main ? main->name : G.sce; + path = bmain ? bmain->name : G.sce; BLI_convertstringcode(fullpath, path); @@ -239,7 +283,10 @@ void sound_load(struct Main *main, struct bSound* sound) break; } #endif - sound->changed++; + if(sound->cache) + sound->playback_handle = sound->cache; + else + sound->playback_handle = sound->handle; } } @@ -255,243 +302,166 @@ void sound_free(struct bSound* sound) { AUD_unload(sound->handle); sound->handle = NULL; + sound->playback_handle = NULL; } } -void sound_unlink(struct bContext *C, struct bSound* sound) +static float sound_get_volume(Scene* scene, Sequence* sequence, float time) { - Scene *scene; - SoundHandle *handle; - -// XXX unused currently -#if 0 - bSound *snd; - for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next) - { - if(snd->child_sound == sound) - { - snd->child_sound = NULL; - if(snd->handle) - { - AUD_unload(sound->handle); - snd->handle = NULL; - } - - sound_unlink(C, snd); - } - } -#endif - - for(scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) - { - for(handle = scene->sound_handles.first; handle; handle = handle->next) - { - if(handle->source == sound) - { - handle->source = NULL; - if(handle->handle) - AUD_stop(handle->handle); - } - } - } + AnimData *adt= BKE_animdata_from_id(&scene->id); + FCurve *fcu = NULL; + char buf[64]; + + /* NOTE: this manually constructed path needs to be used here to avoid problems with RNA crashes */ + sprintf(buf, "sequence_editor.sequences_all[\"%s\"].volume", sequence->name+2); + if (adt && adt->action && adt->action->curves.first) + fcu= list_find_fcurve(&adt->action->curves, buf, 0); + + if(fcu) + return evaluate_fcurve(fcu, time * FPS); + else + return sequence->volume; } -struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip) +AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume) { - ListBase* handles = &scene->sound_handles; + AUD_Device* mixdown = AUD_openReadDevice(specs); - SoundHandle* handle = MEM_callocN(sizeof(SoundHandle), "sound_handle"); - handle->source = sound; - handle->startframe = startframe; - handle->endframe = endframe; - handle->frameskip = frameskip; - handle->state = AUD_STATUS_INVALID; - handle->volume = 1.0f; + AUD_setDeviceVolume(mixdown, volume); - BLI_addtail(handles, handle); + AUD_playDevice(mixdown, scene->sound_scene, start / FPS); - return handle; + return mixdown; } -void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle) +void sound_create_scene(struct Scene *scene) { - if(handle == NULL) - return; + scene->sound_scene = AUD_createSequencer(scene, (AUD_volumeFunction)&sound_get_volume); +} - if(handle->handle) - AUD_stop(handle->handle); +void sound_destroy_scene(struct Scene *scene) +{ + if(scene->sound_scene_handle) + AUD_stop(scene->sound_scene_handle); + if(scene->sound_scene) + AUD_destroySequencer(scene->sound_scene); +} - BLI_freelinkN(&scene->sound_handles, handle); +void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) +{ + return AUD_addSequencer(scene->sound_scene, &(sequence->sound->playback_handle), startframe / FPS, endframe / FPS, frameskip / FPS, sequence); } -void sound_stop_all(struct bContext *C) +void sound_remove_scene_sound(struct Scene *scene, void* handle) { - SoundHandle *handle; + AUD_removeSequencer(scene->sound_scene, handle); +} - for(handle = CTX_data_scene(C)->sound_handles.first; handle; handle = handle->next) - { - if(handle->state == AUD_STATUS_PLAYING) - { - AUD_pause(handle->handle); - handle->state = AUD_STATUS_PAUSED; - } - } +void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute) +{ + AUD_muteSequencer(scene->sound_scene, handle, mute); +} + +void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip) +{ + AUD_moveSequencer(scene->sound_scene, handle, startframe / FPS, endframe / FPS, frameskip / FPS); } -void sound_update_playing(struct bContext *C) +void sound_start_play_scene(struct Scene *scene) { - SoundHandle *handle; - Scene* scene = CTX_data_scene(C); - int cfra = CFRA; - float fps = FPS; - int action; + AUD_Sound* sound; + sound = AUD_loopSound(scene->sound_scene); + scene->sound_scene_handle = AUD_play(sound, 1); + AUD_unload(sound); +} +void sound_play_scene(struct Scene *scene) +{ + AUD_Status status; AUD_lock(); - for(handle = scene->sound_handles.first; handle; handle = handle->next) + status = AUD_getStatus(scene->sound_scene_handle); + + if(status == AUD_STATUS_INVALID) + sound_start_play_scene(scene); + + AUD_setLoop(scene->sound_scene_handle, -1, -1); + + if(status != AUD_STATUS_PLAYING) { - if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute || (scene->audio.flag & AUDIO_MUTE)) - { - if(handle->state == AUD_STATUS_PLAYING) - { - AUD_pause(handle->handle); - handle->state = AUD_STATUS_PAUSED; - } - } - else - { - action = 0; - - if(handle->changed != handle->source->changed) - { - handle->changed = handle->source->changed; - action = 3; - if(handle->state != AUD_STATUS_INVALID) - { - AUD_stop(handle->handle); - handle->state = AUD_STATUS_INVALID; - } - } - else - { - if(handle->state != AUD_STATUS_PLAYING) - action = 3; - else - { - handle->state = AUD_getStatus(handle->handle); - if(handle->state != AUD_STATUS_PLAYING) - action = 3; - else - { - float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe; - if(diff < 0.0) - diff = -diff; - if(diff > FPS/2.0) - { - action = 2; - } - } - } - } - - AUD_setSoundVolume(handle->handle, handle->volume); - - if(action & 1) - { - if(handle->state == AUD_STATUS_INVALID) - { - if(handle->source && handle->source->handle) - { - AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps); - handle->handle = AUD_play(limiter, 1); - AUD_unload(limiter); - if(handle->handle) - handle->state = AUD_STATUS_PLAYING; - if(cfra == handle->startframe) - action &= ~2; - } - } - else - if(AUD_resume(handle->handle)) - handle->state = AUD_STATUS_PLAYING; - else - handle->state = AUD_STATUS_INVALID; - } - - if(action & 2) - AUD_seek(handle->handle, (cfra - handle->startframe) / fps); - } + AUD_seek(scene->sound_scene_handle, CFRA / FPS); + AUD_resume(scene->sound_scene_handle); } + if(scene->audio.flag & AUDIO_SYNC) + AUD_startPlayback(); + AUD_unlock(); } -void sound_scrub(struct bContext *C) +void sound_stop_scene(struct Scene *scene) { - SoundHandle *handle; - Scene* scene = CTX_data_scene(C); - int cfra = CFRA; - float fps = FPS; - - if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) - { - AUD_lock(); + AUD_pause(scene->sound_scene_handle); - for(handle = scene->sound_handles.first; handle; handle = handle->next) - { - if(cfra >= handle->startframe && cfra < handle->endframe && !handle->mute) - { - if(handle->source && handle->source->handle) - { - int frameskip = handle->frameskip + cfra - handle->startframe; - AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, frameskip / fps, (frameskip + 1)/fps); - AUD_play(limiter, 0); - AUD_unload(limiter); - } - } - } - - AUD_unlock(); - } + if(scene->audio.flag & AUDIO_SYNC) + AUD_stopPlayback(); } -AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, int end, float volume) +void sound_seek_scene(struct bContext *C) { - AUD_Device* mixdown = AUD_openReadDevice(specs); - SoundHandle *handle; - float fps = FPS; - AUD_Sound *limiter, *delayer; - int frameskip, s, e; + struct Scene *scene = CTX_data_scene(C); + AUD_Status status; - end++; + AUD_lock(); - AUD_setDeviceVolume(mixdown, volume); + status = AUD_getStatus(scene->sound_scene_handle); + + if(status == AUD_STATUS_INVALID) + { + sound_start_play_scene(scene); + AUD_pause(scene->sound_scene_handle); + } - for(handle = scene->sound_handles.first; handle; handle = handle->next) + if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) { - if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->handle) + AUD_setLoop(scene->sound_scene_handle, -1, 1 / FPS); + if(scene->audio.flag & AUDIO_SYNC) + AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS); + else + AUD_seek(scene->sound_scene_handle, CFRA / FPS); + AUD_resume(scene->sound_scene_handle); + } + else + { + if(scene->audio.flag & AUDIO_SYNC) + AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS); + else { - frameskip = handle->frameskip; - s = handle->startframe - start; - e = handle->frameskip + AUD_MIN(handle->endframe, end) - handle->startframe; - - if(s < 0) - { - frameskip -= s; - s = 0; - } - - AUD_setSoundVolume(handle->handle, handle->volume); - - limiter = AUD_limitSound(handle->source->handle, frameskip / fps, e / fps); - delayer = AUD_delaySound(limiter, s / fps); - - AUD_playDevice(mixdown, delayer); - - AUD_unload(delayer); - AUD_unload(limiter); + if(status == AUD_STATUS_PLAYING) + AUD_seek(scene->sound_scene_handle, CFRA / FPS); } } - return mixdown; + AUD_unlock(); +} + +float sound_sync_scene(struct Scene *scene) +{ + if(scene->audio.flag & AUDIO_SYNC) + return AUD_getSequencerPosition(scene->sound_scene_handle); + else + return AUD_getPosition(scene->sound_scene_handle); +} + +int sound_scene_playing(struct Scene *scene) +{ + if(scene->audio.flag & AUDIO_SYNC) + return AUD_doesPlayback(); + else + return -1; +} + +int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length) +{ + return AUD_readSound(sound->cache, buffer, length); } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 991d9f548b0..4c73e60f741 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2005 Blender Foundation. * All rights reserved. @@ -1256,8 +1256,8 @@ static void cgdm_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) if(faceFlags) { mf->flag = faceFlags[i*2]; mf->mat_nr = faceFlags[i*2+1]; - } else - mf->flag = ME_SMOOTH; + } + else mf->flag = ME_SMOOTH; } static void cgdm_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) @@ -1308,7 +1308,6 @@ static void cgdm_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for(x = 1; x < edgeSize - 1; x++, i++) { vd= ccgSubSurf_getEdgeData(ss, e, x); copy_v3_v3(mvert[i].co, vd->co); - /* TODO CCGSubsurf does not set these */ normal_float_to_short_v3(mvert[i].no, vd->no); } } @@ -1872,6 +1871,21 @@ void ccgDM_glNormalFast(float *a, float *b, float *c, float *d) glNormal3fv(no); } +static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) +{ + if(ccgdm->pbvh) { + CCGFace **faces; + int totface; + + BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface); + if(totface) { + ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface); + ccgSubSurf_updateNormals(ccgdm->ss, faces, totface); + MEM_freeN(faces); + } + } +} + /* Only used by non-editmesh types */ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, int (*setMaterial)(int, void *attribs)) { CCGDerivedMesh *cgdm = (CCGDerivedMesh*) dm; @@ -1881,24 +1895,17 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) char *faceFlags = cgdm->faceFlags; int step = (fast)? gridSize-1: 1; + ccgdm_pbvh_update(cgdm); if(cgdm->pbvh && cgdm->multires.mmd && !fast) { - CCGFace **faces; - int totface; - - BLI_pbvh_get_grid_updates(cgdm->pbvh, 1, (void***)&faces, &totface); - if(totface) { - ccgSubSurf_updateFromFaces(ss, 0, faces, totface); - ccgSubSurf_updateNormals(ss, faces, totface); - MEM_freeN(faces); - } + if(dm->numFaceData) { + /* should be per face */ + if(!setMaterial(faceFlags[1]+1, NULL)) + return; - /* should be per face */ - if(faceFlags && faceFlags[0] & ME_SMOOTH) - glShadeModel(GL_SMOOTH); - - BLI_pbvh_draw(cgdm->pbvh, partial_redraw_planes, NULL); - - glShadeModel(GL_FLAT); + glShadeModel((faceFlags[0] & ME_SMOOTH)? GL_SMOOTH: GL_FLAT); + BLI_pbvh_draw(cgdm->pbvh, partial_redraw_planes, NULL); + glShadeModel(GL_FLAT); + } return; } @@ -1982,6 +1989,8 @@ static void cgdm_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo char *faceFlags = cgdm->faceFlags; int a, b, i, doDraw, numVerts, matnr, new_matnr, totface; + ccgdm_pbvh_update(cgdm); + doDraw = 0; numVerts = 0; matnr = -1; @@ -2136,6 +2145,8 @@ static void cgdm_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha unsigned char *cp1, *cp2; int useTwoSide=1; + ccgdm_pbvh_update(cgdm); + cp1= col1; if(col2) { cp2= col2; @@ -2206,6 +2217,8 @@ static void cgdm_drawFacesTex_common(DerivedMesh *dm, int i, totface, flag, gridSize = ccgSubSurf_getGridSize(ss); int gridFaces = gridSize - 1; + ccgdm_pbvh_update(cgdm); + if(!mcol) mcol = dm->getTessFaceDataArray(dm, CD_MCOL); @@ -3322,7 +3335,9 @@ struct DerivedMesh *subsurf_make_derived_from_derived( CCGDerivedMesh *result = NULL; if(editMode) { - smd->emCache = _getSubSurf(smd->emCache, smd->levels, useAging, 0, + int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels; + + smd->emCache = _getSubSurf(smd->emCache, levels, useAging, 0, useSimple); ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple); @@ -3332,9 +3347,8 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } else if(useRenderParams) { /* Do not use cache in render mode. */ CCGSubSurf *ss; - int levels; - - levels= smd->renderLevels; // XXX get_render_subsurf_level(&scene->r, smd->renderLevels); + int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels): smd->renderLevels; + if(levels == 0) return dm; @@ -3349,6 +3363,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } else { int useIncremental = 1; //(smd->flags & eSubsurfModifierFlag_Incremental); int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr; + int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels; CCGSubSurf *ss; /* It is quite possible there is a much better place to do this. It @@ -3365,7 +3380,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } if(useIncremental && isFinalCalc) { - smd->mCache = ss = _getSubSurf(smd->mCache, smd->levels, + smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging, 0, useSimple); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); @@ -3379,7 +3394,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( smd->mCache = NULL; } - ss = _getSubSurf(NULL, smd->levels, 0, 1, useSimple); + ss = _getSubSurf(NULL, levels, 0, 1, useSimple); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm); diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index dee33656332..59635d4d344 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008, Blender Foundation * All rights reserved. diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index c5c23c8b6c7..4dcc26827d0 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -150,6 +150,13 @@ int txt_get_undostate(void) return undoing; } +static void init_undo_text(Text *text) +{ + text->undo_pos= -1; + text->undo_len= TXT_INIT_UNDO; + text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); +} + void free_text(Text *text) { TextLine *tmp; @@ -180,12 +187,10 @@ Text *add_empty_text(char *name) ta->name= NULL; - ta->undo_pos= -1; - ta->undo_len= TXT_INIT_UNDO; - ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf"); - + init_undo_text(ta); + ta->nlines=1; - ta->flags= TXT_ISDIRTY | TXT_ISMEM; + ta->flags= TXT_ISDIRTY | TXT_ISMEM | TXT_TABSTOSPACES; ta->lines.first= ta->lines.last= NULL; ta->markers.first= ta->markers.last= NULL; @@ -259,9 +264,7 @@ int reopen_text(Text *text) /* clear undo buffer */ MEM_freeN(text->undo_buf); - text->undo_pos= -1; - text->undo_len= TXT_INIT_UNDO; - text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); + init_undo_text(text); fseek(fp, 0L, SEEK_END); len= ftell(fp); @@ -352,6 +355,8 @@ Text *add_text(char *file, const char *relpath) ta->markers.first= ta->markers.last= NULL; ta->curl= ta->sell= NULL; + ta->flags= TXT_TABSTOSPACES; + fseek(fp, 0L, SEEK_END); len= ftell(fp); fseek(fp, 0L, SEEK_SET); @@ -359,9 +364,7 @@ Text *add_text(char *file, const char *relpath) ta->name= MEM_mallocN(strlen(file)+1, "text_name"); strcpy(ta->name, file); - ta->undo_pos= -1; - ta->undo_len= TXT_INIT_UNDO; - ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf"); + init_undo_text(ta); buffer= MEM_mallocN(len, "text_buffer"); // under windows fread can return less then len bytes because @@ -428,9 +431,15 @@ Text *copy_text(Text *ta) tan= copy_libblock(ta); - tan->name= MEM_mallocN(strlen(ta->name)+1, "text_name"); - strcpy(tan->name, ta->name); - + /* file name can be NULL */ + if(ta->name) { + tan->name= MEM_mallocN(strlen(ta->name)+1, "text_name"); + strcpy(tan->name, ta->name); + } + else { + tan->name= NULL; + } + tan->flags = ta->flags | TXT_ISDIRTY; tan->lines.first= tan->lines.last= NULL; @@ -458,6 +467,8 @@ Text *copy_text(Text *ta) tan->curl= tan->sell= tan->lines.first; tan->curc= tan->selc= 0; + init_undo_text(tan); + return tan; } @@ -1399,9 +1410,7 @@ static int max_undo_test(Text *text, int x) if(text->undo_len*2 > TXT_MAX_UNDO) { /* XXX error("Undo limit reached, buffer cleared\n"); */ MEM_freeN(text->undo_buf); - text->undo_len= TXT_INIT_UNDO; - text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); - text->undo_pos=-1; + init_undo_text(text); return 0; } else { void *tmp= text->undo_buf; @@ -2361,7 +2370,11 @@ static char tab_to_spaces[] = " "; static void txt_convert_tab_to_spaces (Text *text) { - char *sb = &tab_to_spaces[text->curl->len % TXT_TABSIZE]; + /* sb aims to pad adjust the tab-width needed so that the right number of spaces + * is added so that the indention of the line is the right width (i.e. aligned + * to multiples of TXT_TABSIZE) + */ + char *sb = &tab_to_spaces[text->curc % TXT_TABSIZE]; txt_insert_buf(text, sb); } @@ -2380,7 +2393,7 @@ int txt_add_char (Text *text, char add) } /* insert spaces rather then tabs */ - if (add == '\t') { + if (add == '\t' && text->flags & TXT_TABSTOSPACES) { txt_convert_tab_to_spaces(text); return 1; } @@ -2460,13 +2473,18 @@ void indent(Text *text) { int len, num; char *tmp; - /* char *addtab = "\t"; - int tablen = 1; */ + + char *add = "\t"; + int indentlen = 1; + /* hardcoded: TXT_TABSIZE = 4 spaces: */ int spaceslen = TXT_TABSIZE; - /* hardcoded: use spaces: */ - char *add = tab_to_spaces; - int indentlen = spaceslen; + + /* insert spaces rather then tabs */ + if (text->flags & TXT_TABSTOSPACES){ + add = tab_to_spaces; + indentlen = spaceslen; + } if (!text) return; if (!text->curl) return; @@ -2517,11 +2535,17 @@ void indent(Text *text) void unindent(Text *text) { int num = 0; - /* char *rmtab = "\t"; */ - char *remove = tab_to_spaces; - /* int indenttab = 1; */ - int indentspaces = TXT_TABSIZE; - int indent = indentspaces; + char *remove = "\t"; + int indent = 1; + + /* hardcoded: TXT_TABSIZE = 4 spaces: */ + int spaceslen = TXT_TABSIZE; + + /* insert spaces rather then tabs */ + if (text->flags & TXT_TABSTOSPACES){ + remove = tab_to_spaces; + indent = spaceslen; + } if (!text) return; if (!text->curl) return; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index c60001db314..10fdbc7fa14 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -420,6 +420,7 @@ void free_texture(Tex *tex) if(tex->env) BKE_free_envmap(tex->env); if(tex->pd) BKE_free_pointdensity(tex->pd); if(tex->vd) BKE_free_voxeldata(tex->vd); + BKE_free_animdata((struct ID *)tex); BKE_previewimg_free(&tex->preview); BKE_icon_delete((struct ID*)tex); tex->id.icon_id = 0; @@ -858,6 +859,14 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex) } } +bNode *give_current_material_texture_node(Material *ma) +{ + if(ma && ma->use_nodes && ma->nodetree) + return nodeGetActiveID(ma->nodetree, ID_TE); + + return NULL; +} + Tex *give_current_material_texture(Material *ma) { MTex *mtex= NULL; @@ -865,6 +874,9 @@ Tex *give_current_material_texture(Material *ma) bNode *node; if(ma && ma->use_nodes && ma->nodetree) { + /* first check texture, then material, this works together + with a hack that clears the active ID flag for textures on + making a material node active */ node= nodeGetActiveID(ma->nodetree, ID_TE); if(node) { @@ -877,6 +889,7 @@ Tex *give_current_material_texture(Material *ma) ma= (Material*)node->id; } } + if(ma) { mtex= ma->mtex[(int)(ma->texact)]; if(mtex) tex= mtex->tex; @@ -1095,7 +1108,6 @@ PointDensity *BKE_add_pointdensity(void) pd->coba = add_colorband(1); pd->speed_scale = 1.0f; pd->totpoints = 0; - pd->coba = add_colorband(1); pd->object = NULL; pd->psys = 0; return pd; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 1f72c894cc8..87424dda04d 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -14,29 +14,29 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Contributor(s): Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ - #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <string.h> +#ifdef WIN32 +#define _USE_MATH_DEFINES +#endif #include <math.h> -#if defined(WIN32) && (!(defined snprintf)) -#define snprintf _snprintf -#endif +#include "BLI_winstuff.h" #define TEMP_STR_SIZE 256 #define SEP_CHR '#' #define SEP_STR "#" -#define EUL 0.000001 +#define EPS 0.000001 /* define a single unit */ @@ -119,11 +119,18 @@ static struct bUnitDef buNaturalTimeDef[] = { }; static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buNaturalRotDef[] = { + {"degree", "degrees", "°", NULL, "Degrees", M_PI/180.0, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; + #define UNIT_SYSTEM_MAX 3 static struct bUnitCollection *bUnitSystems[][8] = { - {0,0,0,0,0,0,0,0}, - {0,&buMetricLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* metric */ - {0,&buImperialLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* imperial */ + {0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0}, + {0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */ + {0,&buImperialLenCollecton, 0,0,0,&buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* imperial */ {0,0,0,0,0,0,0,0} }; @@ -148,7 +155,7 @@ static bUnitDef *unit_best_fit(double value, bUnitCollection *usys, bUnitDef *un if(suppress && (unit->flag & B_UNIT_DEF_SUPPRESS)) continue; - if (value_abs >= unit->scalar*(1.0-EUL)) /* scale down scalar so 1cm doesnt convert to 10mm because of float error */ + if (value_abs >= unit->scalar*(1.0-EPS)) /* scale down scalar so 1cm doesnt convert to 10mm because of float error */ return unit; } @@ -163,7 +170,7 @@ static void unit_dual_convert(double value, bUnitCollection *usys, { bUnitDef *unit= unit_best_fit(value, usys, NULL, 1); - *value_a= floor(value/unit->scalar) * unit->scalar; + *value_a= (value < 0.0 ? ceil:floor)(value/unit->scalar) * unit->scalar; *value_b= value - (*value_a); *unit_a= unit; @@ -451,23 +458,25 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre bUnitCollection *usys_iter; int system_iter; - for(system_iter= 1; system_iter<UNIT_SYSTEM_MAX; system_iter++) { + for(system_iter= 0; system_iter<UNIT_SYSTEM_MAX; system_iter++) { if (system_iter != system) { usys_iter= unit_get_system(system_iter, type); - for(unit= usys_iter->units; unit->name; unit++) { - - if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { - int ofs = 0; - /* incase there are multiple instances */ - while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) - change= 1; + if (usys_iter) { + for(unit= usys_iter->units; unit->name; unit++) { + + if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { + int ofs = 0; + /* incase there are multiple instances */ + while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) + change= 1; + } } } } } } unit= NULL; - + if(change==0) { /* no units given so infer a unit from the previous string or default */ if(str_prev) { @@ -482,9 +491,10 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre } } - if(unit==NULL) + if(unit==NULL || unit->name == NULL) unit= unit_default(usys); + /* add the unit prefix and re-run, use brackets incase there was an expression given */ if(snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) { strncpy(str, str_tmp, len_max); @@ -530,7 +540,6 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre } } - // printf("replace %s\n", str); return change; } diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index b5f8bc81b81..fff0a08136b 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -102,6 +102,9 @@ World *add_world(char *name) wrld->aodist= 10.0f; wrld->aosamp= 5; wrld->aoenergy= 1.0f; + wrld->ao_env_energy= 1.0f; + wrld->ao_indirect_energy= 1.0f; + wrld->ao_indirect_bounces= 1; wrld->aobias= 0.05f; wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; wrld->ao_approx_error= 0.25f; diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 9ff5ee00bfb..d67a79154d2 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -121,18 +121,16 @@ static int sframe; static void filepath_avi (char *string, RenderData *rd) { - char txt[64]; - - if (string==0) return; + if (string==NULL) return; strcpy(string, rd->pic); BLI_convertstringcode(string, G.sce); BLI_make_existing_file(string); - if (BLI_strcasecmp(string + strlen(string) - 4, ".avi")) { - sprintf(txt, "%04d_%04d.avi", (rd->sfra) , (rd->efra) ); - strcat(string, txt); + if (!BLI_testextensie(string, ".avi")) { + BLI_convertstringframe_range(string, rd->sfra, rd->efra, 4); + strcat(string, ".avi"); } } diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 920ff255bcc..6e94602c0c9 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -15,7 +15,6 @@ * */ - #ifdef WITH_FFMPEG #include <string.h> #include <stdio.h> @@ -78,11 +77,10 @@ extern void do_init_ffmpeg(); static int ffmpeg_type = 0; static int ffmpeg_codec = CODEC_ID_MPEG4; -static int ffmpeg_audio_codec = CODEC_ID_MP2; +static int ffmpeg_audio_codec = CODEC_ID_NONE; static int ffmpeg_video_bitrate = 1150; static int ffmpeg_audio_bitrate = 128; static int ffmpeg_gop_size = 12; -static int ffmpeg_multiplex_audio = 1; static int ffmpeg_autosplit = 0; static int ffmpeg_autosplit_count = 0; @@ -96,9 +94,10 @@ static uint8_t* video_buffer = 0; static int video_buffersize = 0; static uint8_t* audio_input_buffer = 0; -static int audio_input_frame_size = 0; +static int audio_input_samples = 0; static uint8_t* audio_output_buffer = 0; static int audio_outbuf_size = 0; +static double audio_time = 0.0f; static AUD_Device* audio_mixdown_device = 0; @@ -133,27 +132,39 @@ static int write_audio_frame(void) c = get_codec_from_stream(audio_stream); - if(audio_mixdown_device) - AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_frame_size); - av_init_packet(&pkt); + pkt.size = 0; + + AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_samples); + audio_time += (double) audio_input_samples / (double) c->sample_rate; pkt.size = avcodec_encode_audio(c, audio_output_buffer, - audio_outbuf_size, + audio_outbuf_size, (short*) audio_input_buffer); + + if(pkt.size < 0) + { + // XXX error("Error writing audio packet"); + return -1; + } + pkt.data = audio_output_buffer; + + if(c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) + { #ifdef FFMPEG_CODEC_TIME_BASE - pkt.pts = av_rescale_q(c->coded_frame->pts, - c->time_base, audio_stream->time_base); + pkt.pts = av_rescale_q(c->coded_frame->pts, + c->time_base, audio_stream->time_base); #else - pkt.pts = c->coded_frame->pts; + pkt.pts = c->coded_frame->pts; #endif - fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts); + fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts); + } pkt.stream_index = audio_stream->index; pkt.flags |= PKT_FLAG_KEY; if (av_interleaved_write_frame(outfile, &pkt) != 0) { - //XXX error("Error writing audio packet"); + // XXX error("Error writing audio packet"); return -1; } return 0; @@ -233,6 +244,14 @@ static const char** get_file_extensions(int format) static const char * rv[] = { ".ogg", ".ogv", NULL }; return rv; } + case FFMPEG_MP3: { + static const char * rv[] = { ".mp3", NULL }; + return rv; + } + case FFMPEG_WAV: { + static const char * rv[] = { ".wav", NULL }; + return rv; + } default: return NULL; } @@ -563,6 +582,7 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex c->sample_rate = rd->ffcodecdata.audio_mixrate; c->bit_rate = ffmpeg_audio_bitrate*1000; + c->sample_fmt = SAMPLE_FMT_S16; c->channels = 2; codec = avcodec_find_encoder(c->codec_id); if (!codec) { @@ -577,40 +597,26 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex return NULL; } - /* FIXME: Should be user configurable */ - if (ffmpeg_type == FFMPEG_DV) { - /* this is a hack around the poor ffmpeg dv multiplexer. */ - /* only fixes PAL for now - (NTSC is a lot more complicated here...)! */ - audio_outbuf_size = 7680; - } else { - audio_outbuf_size = 10000; + audio_outbuf_size = FF_MIN_BUFFER_SIZE; + + if((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD)) + audio_input_samples = audio_outbuf_size * 8 / c->bits_per_coded_sample / c->channels; + else + { + audio_input_samples = c->frame_size; + if(c->frame_size * c->channels * sizeof(int16_t) * 4 > audio_outbuf_size) + audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4; } + audio_output_buffer = (uint8_t*)MEM_mallocN( audio_outbuf_size, "FFMPEG audio encoder input buffer"); - /* ugly hack for PCM codecs */ - - if (c->frame_size <= 1) { - audio_input_frame_size = audio_outbuf_size / c->channels; - switch(c->codec_id) { - case CODEC_ID_PCM_S16LE: - case CODEC_ID_PCM_S16BE: - case CODEC_ID_PCM_U16LE: - case CODEC_ID_PCM_U16BE: - audio_input_frame_size >>= 1; - break; - default: - break; - } - } else { - audio_input_frame_size = c->frame_size; - } - audio_input_buffer = (uint8_t*)MEM_mallocN( - audio_input_frame_size * sizeof(short) * c->channels, + audio_input_samples * c->channels * sizeof(int16_t), "FFMPEG audio encoder output buffer"); + audio_time = 0.0f; + return st; } /* essential functions -- start, append, end */ @@ -629,8 +635,6 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report ffmpeg_video_bitrate = rd->ffcodecdata.video_bitrate; ffmpeg_audio_bitrate = rd->ffcodecdata.audio_bitrate; ffmpeg_gop_size = rd->ffcodecdata.gop_size; - ffmpeg_multiplex_audio = rd->ffcodecdata.flags - & FFMPEG_MULTIPLEX_AUDIO; ffmpeg_autosplit = rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT; @@ -641,12 +645,11 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report fprintf(stderr, "Starting output to %s(ffmpeg)...\n" " Using type=%d, codec=%d, audio_codec=%d,\n" " video_bitrate=%d, audio_bitrate=%d,\n" - " gop_size=%d, multiplex=%d, autosplit=%d\n" + " gop_size=%d, autosplit=%d\n" " render width=%d, render height=%d\n", name, ffmpeg_type, ffmpeg_codec, ffmpeg_audio_codec, ffmpeg_video_bitrate, ffmpeg_audio_bitrate, - ffmpeg_gop_size, ffmpeg_multiplex_audio, - ffmpeg_autosplit, rectx, recty); + ffmpeg_gop_size, ffmpeg_autosplit, rectx, recty); exts = get_file_extensions(ffmpeg_type); if (!exts) { @@ -667,7 +670,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report of->oformat = fmt; of->packet_size= rd->ffcodecdata.mux_packet_size; - if (ffmpeg_multiplex_audio) { + if (ffmpeg_audio_codec != CODEC_ID_NONE) { of->mux_rate = rd->ffcodecdata.mux_rate; } else { of->mux_rate = 0; @@ -676,6 +679,8 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report of->preload = (int)(0.5*AV_TIME_BASE); of->max_delay = (int)(0.7*AV_TIME_BASE); + fmt->audio_codec = ffmpeg_audio_codec; + snprintf(of->filename, sizeof(of->filename), "%s", name); /* set the codec to the user's selection */ switch(ffmpeg_type) { @@ -703,6 +708,11 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report case FFMPEG_FLV: fmt->video_codec = CODEC_ID_FLV1; break; + case FFMPEG_MP3: + fmt->audio_codec = CODEC_ID_MP3; + case FFMPEG_WAV: + fmt->video_codec = CODEC_ID_NONE; + break; case FFMPEG_MPEG4: default: fmt->video_codec = CODEC_ID_MPEG4; @@ -723,30 +733,29 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report } } - fmt->audio_codec = ffmpeg_audio_codec; - if (ffmpeg_type == FFMPEG_DV) { fmt->audio_codec = CODEC_ID_PCM_S16LE; - if (ffmpeg_multiplex_audio && rd->ffcodecdata.audio_mixrate != 48000) { + if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000) { BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!"); return 0; } } - video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty); - printf("alloc video stream %p\n", video_stream); - if (!video_stream) { - BKE_report(reports, RPT_ERROR, "Error initializing video stream."); - return 0; + if (fmt->video_codec != CODEC_ID_NONE) { + video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty); + printf("alloc video stream %p\n", video_stream); + if (!video_stream) { + BKE_report(reports, RPT_ERROR, "Error initializing video stream."); + return 0; + } } - - if (ffmpeg_multiplex_audio) { + + if (ffmpeg_audio_codec != CODEC_ID_NONE) { audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of); if (!audio_stream) { BKE_report(reports, RPT_ERROR, "Error initializing audio stream."); return 0; } - //XXX audiostream_play(SFRA, 0, 1); } if (av_set_parameters(of, NULL) < 0) { BKE_report(reports, RPT_ERROR, "Error setting output parameters."); @@ -772,15 +781,6 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report /* Get the output filename-- similar to the other output formats */ void filepath_ffmpeg(char* string, RenderData* rd) { - - // XXX quick define, solve! -#define FILE_MAXDIR 256 -#define FILE_MAXFILE 126 - - char txt[FILE_MAXDIR+FILE_MAXFILE]; - // XXX -#undef FILE_MAXDIR -#undef FILE_MAXFILE char autosplit[20]; const char ** exts = get_file_extensions(rd->ffcodecdata.type); @@ -790,7 +790,6 @@ void filepath_ffmpeg(char* string, RenderData* rd) { strcpy(string, rd->pic); BLI_convertstringcode(string, G.sce); - BLI_convertstringframe(string, rd->cfra); BLI_make_existing_file(string); @@ -810,9 +809,9 @@ void filepath_ffmpeg(char* string, RenderData* rd) { if (!*fe) { strcat(string, autosplit); - sprintf(txt, "%04d_%04d%s", (rd->sfra), - (rd->efra), *exts); - strcat(string, txt); + + BLI_convertstringframe_range(string, rd->sfra, rd->efra, 4); + strcat(string, *exts); } else { *(string + strlen(string) - strlen(*fe)) = 0; strcat(string, autosplit); @@ -828,14 +827,14 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo success = start_ffmpeg_impl(rd, rectx, recty, reports); - if(ffmpeg_multiplex_audio && audio_stream) + if(audio_stream) { AVCodecContext* c = get_codec_from_stream(audio_stream); AUD_DeviceSpecs specs; specs.channels = c->channels; specs.format = AUD_FORMAT_S16; specs.rate = rd->ffcodecdata.audio_mixrate; - audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->efra, rd->ffcodecdata.audio_volume); + audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume); } return success; @@ -843,21 +842,13 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo void end_ffmpeg(void); -static void write_audio_frames() +static void write_audio_frames(double to_pts) { int finished = 0; - while (ffmpeg_multiplex_audio && !finished) { - double a_pts = ((double)audio_stream->pts.val - * audio_stream->time_base.num - / audio_stream->time_base.den); - double v_pts = ((double)video_stream->pts.val - * video_stream->time_base.num - / video_stream->time_base.den); - - if (a_pts < v_pts) { - write_audio_frame(); - } else { + while (audio_stream && !finished) { + if((audio_time >= to_pts) || + (write_audio_frame())) { finished = 1; } } @@ -866,25 +857,31 @@ static void write_audio_frames() int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty, ReportList *reports) { AVFrame* avframe; - int success; + int success = 1; fprintf(stderr, "Writing frame %i, " "render width=%d, render height=%d\n", frame, rectx, recty); - write_audio_frames(); - - avframe= generate_video_frame((unsigned char*) pixels, reports); - success= (avframe && write_video_frame(rd, avframe, reports)); +// why is this done before writing the video frame and again at end_ffmpeg? +// write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base)); - if (ffmpeg_autosplit) { - if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) { - end_ffmpeg(); - ffmpeg_autosplit_count++; - success &= start_ffmpeg_impl(rd, rectx, recty, reports); + if(video_stream) + { + avframe= generate_video_frame((unsigned char*) pixels, reports); + success= (avframe && write_video_frame(rd, avframe, reports)); + + if (ffmpeg_autosplit) { + if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) { + end_ffmpeg(); + ffmpeg_autosplit_count++; + success &= start_ffmpeg_impl(rd, rectx, recty, reports); + } } } + write_audio_frames((frame - rd->sfra) / (((double)rd->frs_sec) / rd->frs_sec_base)); + return success; } @@ -895,9 +892,9 @@ void end_ffmpeg(void) fprintf(stderr, "Closing ffmpeg...\n"); - if (audio_stream && video_stream) { +/* if (audio_stream) { SEE UPPER write_audio_frames(); - } + }*/ if(audio_mixdown_device) { @@ -1269,8 +1266,8 @@ void ffmpeg_verify_image_type(RenderData *rd) } } - if(audio && rd->ffcodecdata.audio_codec <= 0) { - rd->ffcodecdata.audio_codec = CODEC_ID_MP2; + if(audio && rd->ffcodecdata.audio_codec < 0) { + rd->ffcodecdata.audio_codec = CODEC_ID_NONE; rd->ffcodecdata.audio_bitrate = 128; } } diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h index ec0f31e3dc9..ebacfa82b11 100644 --- a/source/blender/blenkernel/nla_private.h +++ b/source/blender/blenkernel/nla_private.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. |