Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-11-25 20:51:16 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-11-25 20:51:16 +0300
commit55d2a56d6020a5d286d5d44f7d2d8a8d0bc9bf58 (patch)
tree959cb7abcf1ab92caa28fa5a5156520f08f9936d /source/blender/blenkernel
parent077edbb384e3845f27cc06618046a08c7101cc4c (diff)
parentf1fa79a59554cb36ebee0a569a7b0f442fef6646 (diff)
Sculpt:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24483:24889
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h5
-rw-r--r--source/blender/blenkernel/BKE_action.h12
-rw-r--r--source/blender/blenkernel/BKE_constraint.h11
-rw-r--r--source/blender/blenkernel/BKE_context.h2
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h7
-rw-r--r--source/blender/blenkernel/BKE_group.h4
-rw-r--r--source/blender/blenkernel/BKE_idprop.h2
-rw-r--r--source/blender/blenkernel/BKE_key.h2
-rw-r--r--source/blender/blenkernel/BKE_modifier.h1
-rw-r--r--source/blender/blenkernel/BKE_paint.h1
-rw-r--r--source/blender/blenkernel/BKE_sequence.h38
-rw-r--r--source/blender/blenkernel/BKE_softbody.h3
-rw-r--r--source/blender/blenkernel/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/SConscript2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c11
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c20
-rw-r--r--source/blender/blenkernel/intern/action.c89
-rw-r--r--source/blender/blenkernel/intern/anim.c14
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c40
-rw-r--r--source/blender/blenkernel/intern/armature.c134
-rw-r--r--source/blender/blenkernel/intern/brush.c18
-rw-r--r--source/blender/blenkernel/intern/cloth.c17
-rw-r--r--source/blender/blenkernel/intern/constraint.c147
-rw-r--r--source/blender/blenkernel/intern/context.c4
-rw-r--r--source/blender/blenkernel/intern/curve.c62
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c2
-rw-r--r--source/blender/blenkernel/intern/fcurve.c63
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c109
-rw-r--r--source/blender/blenkernel/intern/group.c52
-rw-r--r--source/blender/blenkernel/intern/idprop.c2
-rw-r--r--source/blender/blenkernel/intern/ipo.c4
-rw-r--r--source/blender/blenkernel/intern/key.c53
-rw-r--r--source/blender/blenkernel/intern/modifier.c12
-rw-r--r--source/blender/blenkernel/intern/node.c12
-rw-r--r--source/blender/blenkernel/intern/object.c2
-rw-r--r--source/blender/blenkernel/intern/paint.c2
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c100
-rw-r--r--source/blender/blenkernel/intern/sequence.c351
-rw-r--r--source/blender/blenkernel/intern/softbody.c250
-rw-r--r--source/blender/blenkernel/intern/sound.c6
-rw-r--r--source/blender/blenkernel/intern/text.c52
41 files changed, 1396 insertions, 324 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index bb14ac7e803..bcafc4c48b2 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -54,6 +54,7 @@ struct Object;
struct Scene;
struct Mesh;
struct EditMesh;
+struct KeyBlock;
struct ModifierData;
struct MCol;
struct ColorBand;
@@ -345,6 +346,10 @@ int DM_release(DerivedMesh *dm);
*/
void DM_to_mesh(DerivedMesh *dm, struct Mesh *me);
+/* utility function to convert a DerivedMesh to a shape key block
+ */
+void DM_to_meshkey(DerivedMesh *dm, struct Mesh *me, struct KeyBlock *kb);
+
/* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
* zero for the layer type, so only layer types specified by the mask
* will be copied
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 17b56864d1e..6029ce01794 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -118,6 +118,12 @@ struct bActionGroup *action_groups_find_named(struct bAction *act, const char na
/* Pose API ----------------- */
/**
+ * Deallocates a pose channel.
+ * Does not free the pose channel itself.
+ */
+void free_pose_channel(struct bPoseChannel *pchan);
+
+/**
* Removes and deallocates all channels from a pose.
* Does not free the pose itself.
*/
@@ -134,7 +140,11 @@ void free_pose(struct bPose *pose);
*/
void copy_pose(struct bPose **dst, struct bPose *src, int copyconstraints);
-
+/**
+ * Copy the internal members of each pose channel including constraints
+ * and ID-Props, used when duplicating bones in editmode.
+ */
+void duplicate_pose_channel_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
/**
* Return a pointer to the pose channel of the given name
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index f957c5e17d4..e9110b99098 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -108,18 +108,25 @@ bConstraintTypeInfo *get_constraint_typeinfo(int type);
/* Constraint Target Macros */
#define VALID_CONS_TARGET(ct) ((ct) && (ct->tar))
-
/* ---------------------------------------------------------------------------- */
/* Constraint function prototypes */
void unique_constraint_name(struct bConstraint *con, struct ListBase *list);
void free_constraints(struct ListBase *list);
-void copy_constraints(struct ListBase *dst, struct ListBase *src);
+void copy_constraints(struct ListBase *dst, const struct ListBase *src);
void relink_constraints(struct ListBase *list);
void free_constraint_data(struct bConstraint *con);
+/* Constraint API function prototypes */
struct bConstraint *constraints_get_active(struct ListBase *list);
+void constraints_set_active(ListBase *list, struct bConstraint *con);
+
+struct bConstraint *add_ob_constraint(struct Object *ob, const char *name, short type);
+struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type);
+
+int remove_constraint(ListBase *list, struct bConstraint *con);
+int remove_constraint_index(ListBase *list, int index);
/* 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 7f64538b10d..947ec914fa4 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -248,7 +248,7 @@ int CTX_data_selected_editable_bones(const bContext *C, ListBase *list);
int CTX_data_visible_bones(const bContext *C, ListBase *list);
int CTX_data_editable_bones(const bContext *C, ListBase *list);
-struct bPoseChannel *CTX_data_active_pchan(const bContext *C);
+struct bPoseChannel *CTX_data_active_pose_bone(const bContext *C);
int CTX_data_selected_pchans(const bContext *C, ListBase *list);
int CTX_data_visible_pchans(const bContext *C, ListBase *list);
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 6e273c81e39..5888c6d7530 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -34,6 +34,7 @@ struct ChannelDriver;
struct DriverTarget;
struct BezTriple;
+struct StructRNA;
#include "DNA_curve_types.h"
@@ -129,7 +130,8 @@ FModifierTypeInfo *get_fmodifier_typeinfo(int type);
struct FModifier *add_fmodifier(ListBase *modifiers, int type);
void copy_fmodifiers(ListBase *dst, ListBase *src);
-void remove_fmodifier(ListBase *modifiers, struct FModifier *fcm);
+int remove_fmodifier(ListBase *modifiers, struct FModifier *fcm);
+int remove_fmodifier_index(ListBase *modifiers, int index);
void free_fmodifiers(ListBase *modifiers);
struct FModifier *find_active_fmodifier(ListBase *modifiers);
@@ -155,6 +157,9 @@ void copy_fcurves(ListBase *dst, ListBase *src);
/* find matching F-Curve in the given list of F-Curves */
struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index);
+/* high level function to get an fcurve from C without having the rna */
+struct FCurve *id_data_find_fcurve(ID* id, void *data, struct StructRNA *type, char *prop_name, int index);
+
/* 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_group.h b/source/blender/blenkernel/BKE_group.h
index b66ddf13527..877e09b037f 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -42,8 +42,8 @@ void free_group(struct Group *group);
void unlink_group(struct Group *group);
struct Group *add_group(char *name);
struct Group *copy_group(struct Group *group);
-void add_to_group(struct Group *group, struct Object *ob);
-int rem_from_group(struct Group *group, struct Object *ob);
+int add_to_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
+int rem_from_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
struct Group *find_group(struct Object *ob, struct Group *group);
int object_in_group(struct Object *ob, struct Group *group);
int group_is_animated(struct Object *parent, struct Group *group);
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 1980ba78c86..9c7460851cb 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -117,7 +117,7 @@ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
*/
void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop);
-IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, char *name);
+IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name);
/*Get an iterator to iterate over the members of an id property group.
Note that this will automatically free the iterator once iteration is complete;
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index b70801a9edd..d5bae00d32e 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -59,7 +59,9 @@ void key_curve_normal_weights(float t, float *data, int type);
float *do_ob_key(struct Scene *scene, struct Object *ob);
struct Key *ob_get_key(struct Object *ob);
+struct KeyBlock *add_keyblock(struct Scene *scene, struct Key *key);
struct KeyBlock *ob_get_keyblock(struct Object *ob);
+struct KeyBlock *ob_get_reference_keyblock(struct Object *ob);
struct KeyBlock *key_get_keyblock(struct Key *key, int index);
struct KeyBlock *key_get_named_keyblock(struct Key *key, const char name[]);
char *key_get_curValue_rnaPath(struct Key *key, struct KeyBlock *kb);
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 3018f89178e..6fe6a683130 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -281,6 +281,7 @@ int modifier_dependsOnTime(struct ModifierData *md);
int modifier_supportsMapping(struct ModifierData *md);
int modifier_couldBeCage(struct ModifierData *md);
int modifier_isDeformer(struct ModifierData *md);
+int modifier_sameTopology(ModifierData *md);
int modifier_isEnabled(struct ModifierData *md, int required_mode);
void modifier_setError(struct ModifierData *md, char *format, ...);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 2b4fb9d938d..1688ecb3492 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -71,6 +71,7 @@ typedef struct SculptSession {
float *face_normals;
struct PBVH *tree;
struct Object *ob;
+ struct KeyBlock *kb, *refkb;
/* Mesh connectivity */
struct ListBase *fmap;
diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h
index fb3c282b090..2f7526d524c 100644
--- a/source/blender/blenkernel/BKE_sequence.h
+++ b/source/blender/blenkernel/BKE_sequence.h
@@ -163,7 +163,7 @@ void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_s
/* seqeffects.c */
// intern?
struct SeqEffectHandle get_sequence_blend(struct Sequence *seq);
-void sequence_effect_speed_rebuild_map(struct Sequence *seq, int force);
+void sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq, int force);
// extern
struct SeqEffectHandle get_sequence_effect(struct Sequence *seq);
@@ -183,10 +183,44 @@ void fix_single_seq(struct Sequence *seq);
int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test);
int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test);
int shuffle_seq_time(ListBase * seqbasep);
-void free_imbuf_seq(struct ListBase * seqbasep, int check_mem_usage);
+void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage);
void seq_update_sound(struct Sequence *seq);
void clear_scene_in_allseqs(struct Scene *sce);
+struct Sequence *active_seq_get(struct Scene *scene);
+void active_seq_set(struct Scene *scene, struct Sequence *seq);
+
+/* api for adding new sequence strips */
+typedef struct SeqLoadInfo {
+ int start_frame;
+ int channel;
+ int flag; /* use sound, replace sel */
+ int type;
+ int tot_success;
+ int tot_error;
+ int len; /* only for image strips */
+ char path[512];
+ char name[32];
+} SeqLoadInfo;
+
+/* SeqLoadInfo.flag */
+#define SEQ_LOAD_REPLACE_SEL 1<<0
+#define SEQ_LOAD_FRAME_ADVANCE 1<<1
+#define SEQ_LOAD_MOVIE_SOUND 1<<2
+#define SEQ_LOAD_SOUND_CACHE 1<<3
+
+/* use as an api function */
+typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *);
+
+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);
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index d8053281ceb..92cb5542ad1 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -68,5 +68,8 @@ extern void sbObjectToSoftbody(struct Object *ob);
/* pass NULL to unlink again */
extern void sbSetInterruptCallBack(int (*f)(void));
+extern void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscale[3][3]);
+
+
#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index f60cade61ed..7bd6314097b 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -37,6 +37,8 @@ SET(INC
${ZLIB_INC}
)
+ADD_DEFINITIONS(-DGLEW_STATIC)
+
IF(WITH_BULLET)
SET(INC ${INC} ../../../extern/bullet2/src)
ADD_DEFINITIONS(-DUSE_BULLET)
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index 63631ddc40f..81b74cc9c42 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -16,7 +16,7 @@ incs += ' #/intern/audaspace/intern'
incs += ' ' + env['BF_OPENGL_INC']
incs += ' ' + env['BF_ZLIB_INC']
-defs = []
+defs = [ 'GLEW_STATIC' ]
if not env['WITH_BF_PYTHON']:
defs.append('DISABLE_PYTHON')
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 86595dea8fb..7c2c6d4d99e 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -3,12 +3,15 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
-#include <float.h>
#include "CCGSubSurf.h"
#include "BLO_sys_types.h" // for intptr_t support
+/* used for normalize_v3 in BLI_math_vector
+ * float.h's FLT_EPSILON causes trouble with subsurf normals - campbell */
+#define EPSILON (1.0e-35f)
+
/***/
typedef unsigned char byte;
@@ -593,7 +596,7 @@ void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int lev
length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
- if (length>FLT_EPSILON) {
+ if (length>EPSILON) {
float invLength = 1.f/length;
no[0] *= invLength;
@@ -1232,7 +1235,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
- if (length>FLT_EPSILON) {
+ if (length>EPSILON) {
float invLength = 1.0f/length;
no[0] *= invLength;
no[1] *= invLength;
@@ -1291,7 +1294,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
float *no = FACE_getIFNo(f, lvl, S, x, y);
float length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
- if (length>FLT_EPSILON) {
+ if (length>EPSILON) {
float invLength = 1.0f/length;
no[0] *= invLength;
no[1] *= invLength;
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index b715b1531de..c2921a17bef 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -277,6 +277,26 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me)
*me = tmp;
}
+void DM_to_meshkey(DerivedMesh *dm, Mesh *me, KeyBlock *kb)
+{
+ int a, totvert = dm->getNumVerts(dm);
+ float *fp;
+ MVert *mvert;
+
+ if(totvert==0 || me->totvert==0 || me->totvert!=totvert) return;
+
+ if(kb->data) MEM_freeN(kb->data);
+ kb->data= MEM_callocN(me->key->elemsize*me->totvert, "kb->data");
+ kb->totelem= totvert;
+
+ fp= kb->data;
+ mvert=dm->getVertDataArray(dm, CD_MVERT);
+
+ for(a=0; a<kb->totelem; a++, fp+=3, mvert++) {
+ VECCOPY(fp, mvert->co);
+ }
+}
+
void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask)
{
CustomData_set_only_copy(&dm->vertData, mask);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 358a482c3cf..cb6fef0bc30 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -62,6 +62,8 @@
#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
+#include "BKE_idprop.h"
+
#include "BIK_api.h"
#include "BLI_math.h"
@@ -151,7 +153,6 @@ void make_local_action(bAction *act)
}
}
-
void free_action (bAction *act)
{
/* sanity check */
@@ -516,17 +517,22 @@ void copy_pose (bPose **dst, bPose *src, int copycon)
outPose->ikdata = NULL;
outPose->ikparam = MEM_dupallocN(src->ikparam);
- // TODO: rename this argument...
- if (copycon) {
- for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) {
+ for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) {
+ // TODO: rename this argument...
+ if (copycon) {
copy_constraints(&listb, &pchan->constraints); // copy_constraints NULLs listb
pchan->constraints= listb;
pchan->path= NULL;
}
- /* for now, duplicate Bone Groups too when doing this */
- BLI_duplicatelist(&outPose->agroups, &src->agroups);
+ if(pchan->prop) {
+ pchan->prop= IDP_CopyProperty(pchan->prop);
+ }
}
+
+ /* for now, duplicate Bone Groups too when doing this */
+ if(copycon)
+ BLI_duplicatelist(&outPose->agroups, &src->agroups);
*dst=outPose;
}
@@ -564,16 +570,27 @@ void init_pose_ikparam(bPose *pose)
}
}
+void free_pose_channel(bPoseChannel *pchan)
+{
+ if (pchan->path)
+ MEM_freeN(pchan->path);
+
+ free_constraints(&pchan->constraints);
+
+ if(pchan->prop) {
+ IDP_FreeProperty(pchan->prop);
+ MEM_freeN(pchan->prop);
+ }
+}
+
void free_pose_channels(bPose *pose)
{
bPoseChannel *pchan;
if (pose->chanbase.first) {
- for (pchan = pose->chanbase.first; pchan; pchan=pchan->next){
- if (pchan->path)
- MEM_freeN(pchan->path);
- free_constraints(&pchan->constraints);
- }
+ for (pchan = pose->chanbase.first; pchan; pchan=pchan->next)
+ free_pose_channel(pchan);
+
BLI_freelistN(&pose->chanbase);
}
}
@@ -616,12 +633,54 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
pchan->flag= chan->flag;
con= chan->constraints.first;
- for(pcon= pchan->constraints.first; pcon; pcon= pcon->next, con= con->next) {
+ for(pcon= pchan->constraints.first; pcon && con; pcon= pcon->next, con= con->next) {
pcon->enforce= con->enforce;
pcon->headtail= con->headtail;
}
}
+/* makes copies of internal data, unlike copy_pose_channel_data which only
+ * copies the pose state.
+ * hint: use when copying bones in editmode (on returned value from verify_pose_channel) */
+void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_from)
+{
+ /* copy transform locks */
+ pchan->protectflag = pchan_from->protectflag;
+
+ /* copy rotation mode */
+ pchan->rotmode = pchan_from->rotmode;
+
+ /* copy bone group */
+ pchan->agrp_index= pchan_from->agrp_index;
+
+ /* ik (dof) settings */
+ pchan->ikflag = pchan_from->ikflag;
+ VECCOPY(pchan->limitmin, pchan_from->limitmin);
+ VECCOPY(pchan->limitmax, pchan_from->limitmax);
+ VECCOPY(pchan->stiffness, pchan_from->stiffness);
+ pchan->ikstretch= pchan_from->ikstretch;
+ pchan->ikrotweight= pchan_from->ikrotweight;
+ pchan->iklinweight= pchan_from->iklinweight;
+
+ /* constraints */
+ copy_constraints(&pchan->constraints, &pchan_from->constraints);
+
+ /* id-properties */
+ if(pchan->prop) {
+ /* unlikely but possible it exists */
+ IDP_FreeProperty(pchan->prop);
+ MEM_freeN(pchan->prop);
+ pchan->prop= NULL;
+ }
+ if(pchan_from->prop) {
+ pchan->prop= IDP_CopyProperty(pchan_from->prop);
+ }
+
+ /* custom shape */
+ pchan->custom= pchan_from->custom;
+}
+
+
/* checks for IK constraint, Spline IK, and also for Follow-Path constraint.
* can do more constraints flags later
*/
@@ -868,7 +927,7 @@ short action_get_item_transforms (bAction *act, Object *ob, bPoseChannel *pchan,
/* build PointerRNA from provided data to obtain the paths to use */
if (pchan)
- RNA_pointer_create((ID *)ob, &RNA_PoseChannel, pchan, &ptr);
+ RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
else if (ob)
RNA_id_pointer_create((ID *)ob, &ptr);
else
@@ -1045,7 +1104,9 @@ void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose,
copy_m4_m4(workob->constinv, ob->constinv);
workob->parent= ob->parent;
workob->track= ob->track;
-
+
+ workob->rotmode= ob->rotmode;
+
workob->trackflag= ob->trackflag;
workob->upflag= ob->upflag;
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index a1b138b9a74..6b8b604cb94 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -250,17 +250,13 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat,
/* note, commented out for follow constraint */
//if(cu->flag & CU_FOLLOW) {
-
+
key_curve_tangent_weights(1.0f-fac, data, KEY_BSPLINE);
-
- dir[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ;
- dir[1]= data[0]*p0->vec[1] + data[1]*p1->vec[1] + data[2]*p2->vec[1] + data[3]*p3->vec[1] ;
- dir[2]= data[0]*p0->vec[2] + data[1]*p1->vec[2] + data[2]*p2->vec[2] + data[3]*p3->vec[2] ;
-
+
+ interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data);
+
/* make compatible with vectoquat */
- dir[0]= -dir[0];
- dir[1]= -dir[1];
- dir[2]= -dir[2];
+ negate_v3(dir);
//}
nu= cu->nurb.first;
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index e2849825862..a6f733708c7 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -353,7 +353,7 @@ static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char *oldName
/* Fix all RNA-Paths in the AnimData block used by the given ID block
* NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
- * i.e. pose.pose_channels["Bone"]
+ * i.e. pose.bones["Bone"]
*/
void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, char *oldName, char *newName)
{
@@ -388,7 +388,7 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, c
/* 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.pose_channels["Bone"]
+ * i.e. pose.bones["Bone"]
*/
void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newName)
{
@@ -697,20 +697,26 @@ 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))
- RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value);
+ 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);
+ }
else
RNA_property_boolean_set(&new_ptr, prop, (int)value);
break;
case PROP_INT:
- if (RNA_property_array_length(&new_ptr, prop))
- RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
+ 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);
+ }
else
RNA_property_int_set(&new_ptr, prop, (int)value);
break;
case PROP_FLOAT:
- if (RNA_property_array_length(&new_ptr, prop))
- RNA_property_float_set_index(&new_ptr, prop, array_index, value);
+ 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);
+ }
else
RNA_property_float_set(&new_ptr, prop, value);
break;
@@ -1434,20 +1440,26 @@ void nladata_flush_channels (ListBase *channels)
switch (RNA_property_type(prop))
{
case PROP_BOOLEAN:
- if (RNA_property_array_length(ptr, prop))
- RNA_property_boolean_set_index(ptr, prop, array_index, (int)value);
+ 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);
+ }
else
RNA_property_boolean_set(ptr, prop, (int)value);
break;
case PROP_INT:
- if (RNA_property_array_length(ptr, prop))
- RNA_property_int_set_index(ptr, prop, array_index, (int)value);
+ 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);
+ }
else
RNA_property_int_set(ptr, prop, (int)value);
break;
case PROP_FLOAT:
- if (RNA_property_array_length(ptr, prop))
- RNA_property_float_set_index(ptr, prop, array_index, value);
+ 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);
+ }
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 798c3a87846..7a1a2eec95b 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1530,8 +1530,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
}
/* free stuff from current channel */
- if (pchan->path) MEM_freeN(pchan->path);
- free_constraints(&pchan->constraints);
+ free_pose_channel(pchan);
/* the final copy */
*pchan= pchanw;
@@ -1586,9 +1585,7 @@ void armature_rebuild_pose(Object *ob, bArmature *arm)
for(pchan= pose->chanbase.first; pchan; pchan= next) {
next= pchan->next;
if(pchan->bone==NULL) {
- if(pchan->path)
- MEM_freeN(pchan->path);
- free_constraints(&pchan->constraints);
+ free_pose_channel(pchan);
BLI_freelinkN(&pose->chanbase, pchan);
}
}
@@ -1632,7 +1629,7 @@ typedef struct tSplineIK_Tree {
/* ----------- */
/* Tag the bones in the chain formed by the given bone for IK */
-static void splineik_init_tree_from_pchan(Object *ob, bPoseChannel *pchan_tip)
+static void splineik_init_tree_from_pchan(Scene *scene, Object *ob, bPoseChannel *pchan_tip)
{
bPoseChannel *pchan, *pchanRoot=NULL;
bPoseChannel *pchanChain[255];
@@ -1661,6 +1658,21 @@ static void splineik_init_tree_from_pchan(Object *ob, bPoseChannel *pchan_tip)
}
if (con == NULL)
return;
+
+ /* make sure that the constraint targets are ok
+ * - this is a workaround for a depsgraph bug...
+ */
+ if (ikData->tar) {
+ Curve *cu= ikData->tar->data;
+
+ /* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
+ * currently for paths to work it needs to go through the bevlist/displist system (ton)
+ */
+
+ /* only happens on reload file, but violates depsgraph still... fix! */
+ if ((cu->path==NULL) || (cu->path->data==NULL))
+ makeDispListCurveTypes(scene, ikData->tar, 0);
+ }
/* find the root bone and the chain of bones from the root to the tip
* NOTE: this assumes that the bones are connected, but that may not be true...
@@ -1707,7 +1719,7 @@ static void splineik_init_tree_from_pchan(Object *ob, bPoseChannel *pchan_tip)
*/
if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) {
/* 1) equi-spaced joints */
- ikData->points[i]= segmentLen;
+ ikData->points[i]= ikData->points[i-1] - segmentLen;
}
else {
/* 2) to find this point on the curve, we take a step from the previous joint
@@ -1800,7 +1812,7 @@ static void splineik_init_tree(Scene *scene, Object *ob, float ctime)
/* find the tips of Spline IK chains, which are simply the bones which have been tagged as such */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if (pchan->constflag & PCHAN_HAS_SPLINEIK)
- splineik_init_tree_from_pchan(ob, pchan);
+ splineik_init_tree_from_pchan(scene, ob, pchan);
}
}
@@ -1811,9 +1823,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
{
bSplineIKConstraint *ikData= tree->ikData;
float poseHead[3], poseTail[3], poseMat[4][4];
- float splineVec[3], scaleFac;
- float rad, radius=1.0f;
- float vec[4], dir[3];
+ 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);
@@ -1821,24 +1831,41 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
VECCOPY(poseHead, pchan->pose_head);
VECCOPY(poseTail, pchan->pose_tail);
- /* step 1a: get xyz positions for the tail endpoint of the bone */
- if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) {
- /* convert the position to pose-space, then store it */
- mul_m4_v3(ob->imat, vec);
- VECCOPY(poseTail, vec);
+ /* step 1: determine the positions for the endpoints of the bone */
+ {
+ float vec[4], dir[3], rad;
+ float tailBlendFac= 1.0f;
+
+ /* determine if the bone should still be affected by SplineIK */
+ if (tree->points[index+1] >= 1.0f) {
+ /* spline doesn't affect the bone anymore, so done... */
+ pchan->flag |= POSE_DONE;
+ return;
+ }
+ else if ((tree->points[index] >= 1.0f) && (tree->points[index+1] < 1.0f)) {
+ /* blending factor depends on the amount of the bone still left on the chain */
+ tailBlendFac= (1.0f - tree->points[index+1]) / (tree->points[index] - tree->points[index+1]);
+ }
- /* set the new radius */
- radius= rad;
- }
-
- /* step 1b: get xyz positions for the head endpoint of the bone */
- if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) {
- /* store the position, and convert it to pose space */
- mul_m4_v3(ob->imat, vec);
- VECCOPY(poseHead, vec);
+ /* tail endpoint */
+ if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) {
+ /* convert the position to pose-space, then store it */
+ mul_m4_v3(ob->imat, vec);
+ interp_v3_v3v3(poseTail, pchan->pose_tail, vec, tailBlendFac);
+
+ /* set the new radius */
+ radius= rad;
+ }
- /* set the new radius (it should be the average value) */
- radius = (radius+rad) / 2;
+ /* head endpoint */
+ if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) {
+ /* store the position, and convert it to pose space */
+ mul_m4_v3(ob->imat, vec);
+ VECCOPY(poseHead, vec);
+
+ /* set the new radius (it should be the average value) */
+ radius = (radius+rad) / 2;
+ }
}
/* step 2: determine the implied transform from these endpoints
@@ -1877,7 +1904,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* construct rotation matrix from the axis-angle rotation found above
* - this call takes care to make sure that the axis provided is a unit vector first
*/
- axis_angle_to_mat3( dmat,raxis, rangle);
+ axis_angle_to_mat3(dmat, raxis, rangle);
/* combine these rotations so that the y-axis of the bone is now aligned as the spline dictates,
* while still maintaining roll control from the existing bone animation
@@ -1888,20 +1915,12 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
}
/* step 4: set the scaling factors for the axes */
- // TODO: include a no-scale option?
{
/* only multiply the y-axis by the scaling factor to get nice volume-preservation */
mul_v3_fl(poseMat[1], scaleFac);
/* set the scaling factors of the x and z axes from... */
switch (ikData->xzScaleMode) {
- case CONSTRAINT_SPLINEIK_XZS_RADIUS:
- {
- /* radius of curve */
- mul_v3_fl(poseMat[0], radius);
- mul_v3_fl(poseMat[2], radius);
- }
- break;
case CONSTRAINT_SPLINEIK_XZS_ORIGINAL:
{
/* original scales get used */
@@ -1915,11 +1934,50 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
mul_v3_fl(poseMat[2], scale);
}
break;
+ case CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC:
+ {
+ /* 'volume preservation' */
+ float scale;
+
+ /* calculate volume preservation factor which is
+ * basically the inverse of the y-scaling factor
+ */
+ if (fabs(scaleFac) != 0.0f) {
+ scale= 1.0 / fabs(scaleFac);
+
+ /* we need to clamp this within sensible values */
+ // NOTE: these should be fine for now, but should get sanitised in future
+ scale= MIN2( MAX2(scale, 0.0001) , 100000);
+ }
+ else
+ scale= 1.0f;
+
+ /* apply the scaling */
+ mul_v3_fl(poseMat[0], scale);
+ mul_v3_fl(poseMat[2], scale);
+ }
+ break;
+ }
+
+ /* finally, multiply the x and z scaling by the radius of the curve too,
+ * to allow automatic scales to get tweaked still
+ */
+ if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_CURVERAD) == 0) {
+ mul_v3_fl(poseMat[0], radius);
+ mul_v3_fl(poseMat[2], radius);
}
}
- /* step 5: set the location of the bone in the matrix */
- VECCOPY(poseMat[3], poseHead);
+ /* step 5: set the location of the bone in the matrix
+ * - when the 'no-root' option is affected, the chain can retain
+ * the shape but be moved elsewhere
+ */
+ if (ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) {
+ VECCOPY(poseMat[3], pchan->pose_head);
+ }
+ else {
+ VECCOPY(poseMat[3], poseHead);
+ }
/* finally, store the new transform */
copy_m4_m4(pchan->pose_mat, poseMat);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 2923853d6a7..09d73f20b9a 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -253,7 +253,7 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
if(preset == BRUSH_PRESET_SHARP)
cm->totpoint= 3;
if(preset == BRUSH_PRESET_SMOOTH)
- cm->totpoint= 6;
+ cm->totpoint= 4;
if(preset == BRUSH_PRESET_MAX)
cm->totpoint= 2;
@@ -272,16 +272,12 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
else if(preset == BRUSH_PRESET_SMOOTH) {
cm->curve[0].x= 0;
cm->curve[0].y= 1;
- cm->curve[1].x= 0.1;
- cm->curve[1].y= 0.97553;
- cm->curve[2].x= 0.3;
- cm->curve[2].y= 0.79389;
- cm->curve[3].x= 0.9;
- cm->curve[3].y= 0.02447;
- cm->curve[4].x= 0.7;
- cm->curve[4].y= 0.20611;
- cm->curve[5].x= 1;
- cm->curve[5].y= 0;
+ cm->curve[1].x= 0.25;
+ cm->curve[1].y= 0.92;
+ cm->curve[2].x= 0.75;
+ cm->curve[2].y= 0.08;
+ cm->curve[3].x= 1;
+ cm->curve[3].y= 0;
}
else if(preset == BRUSH_PRESET_MAX) {
cm->curve[0].x= 0;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 4a9cb237c01..6c4c7daea7f 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -131,6 +131,7 @@ void cloth_init ( ClothModifierData *clmd )
clmd->sim_parms->avg_spring_len = 0.0;
clmd->sim_parms->presets = 2; /* cotton as start setting */
clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
+ clmd->sim_parms->reset = 0;
clmd->coll_parms->self_friction = 5.0;
clmd->coll_parms->friction = 5.0;
@@ -450,6 +451,18 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
cache->last_exact= 0;
return dm;
}
+
+ if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll)))
+ {
+ clmd->sim_parms->reset = 0;
+ cache->flag |= PTCACHE_REDO_NEEDED;
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
+ cache->simframe= 0;
+ cache->last_exact= 0;
+ cache->flag |= PTCACHE_SIMULATION_VALID;
+ cache->flag &= ~PTCACHE_REDO_NEEDED;
+ return result;
+ }
/* verify we still have the same number of vertices, if not do nothing.
* note that this should only happen if the number of vertices changes
@@ -468,7 +481,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
/* handle continuous simulation with the play button */
- if(BKE_ptcache_get_continue_physics()) {
+ if(BKE_ptcache_get_continue_physics() || ((clmd->sim_parms->preroll > 0) && (framenr > startframe - clmd->sim_parms->preroll) && (framenr < startframe))) {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
cache->last_exact= 0;
@@ -503,7 +516,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
if(!do_init_cloth(ob, clmd, result, framenr))
return result;
- if(framenr == startframe) {
+ if((framenr == startframe) && (clmd->sim_parms->preroll == 0)) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
do_init_cloth(ob, clmd, result, framenr);
cache->simframe= framenr;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index c38e61d269a..aff3bf058fd 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1924,7 +1924,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
*/
if (data->type < 10) {
/* extract rotation (is in whatever space target should be in) */
- mat4_to_eul( vec,tempmat);
+ mat4_to_eul(vec, tempmat);
vec[0] *= (float)(180.0/M_PI);
vec[1] *= (float)(180.0/M_PI);
vec[2] *= (float)(180.0/M_PI);
@@ -1932,7 +1932,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
}
else if (data->type < 20) {
/* extract scaling (is in whatever space target should be in) */
- mat4_to_size( vec,tempmat);
+ mat4_to_size(vec, tempmat);
axis= data->type - 10;
}
else {
@@ -1944,7 +1944,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
/* Target defines the animation */
s = (vec[axis]-data->min) / (data->max-data->min);
CLAMP(s, 0, 1);
- t = ( s * (data->end-data->start)) + data->start;
+ t = (s * (data->end-data->start)) + data->start;
if (G.f & G_DEBUG)
printf("do Action Constraint %s - Ob %s Pchan %s \n", con->name, cob->ob->id.name+2, (cob->pchan)?cob->pchan->name:NULL);
@@ -1958,9 +1958,13 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
/* make a temporary pose and evaluate using that */
pose = MEM_callocN(sizeof(bPose), "pose");
- /* make a copy of the bone of interest in the temp pose before evaluating action, so that it can get set */
+ /* make a copy of the bone of interest in the temp pose before evaluating action, so that it can get set
+ * - we need to manually copy over a few settings, including rotation order, otherwise this fails
+ */
pchan = cob->pchan;
+
tchan= verify_pose_channel(pose, pchan->name);
+ tchan->rotmode= pchan->rotmode;
/* evaluate action using workob (it will only set the PoseChannel in question) */
what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t);
@@ -3635,6 +3639,121 @@ void free_constraints (ListBase *list)
BLI_freelistN(list);
}
+
+/* Remove the specified constraint from the given constraint stack */
+int remove_constraint (ListBase *list, bConstraint *con)
+{
+ if (con) {
+ free_constraint_data(con);
+ BLI_freelinkN(list, con);
+ return 1;
+ }
+ else
+ return 0;
+}
+
+/* Remove the nth constraint from the given constraint stack */
+int remove_constraint_index (ListBase *list, int index)
+{
+ bConstraint *con= BLI_findlink(list, index);
+
+ if (con)
+ return remove_constraint(list, con);
+ else
+ return 0;
+}
+
+/* ......... */
+
+/* Creates a new constraint, initialises its data, and returns it */
+static bConstraint *add_new_constraint_internal (const char *name, short type)
+{
+ bConstraint *con= MEM_callocN(sizeof(bConstraint), "Constraint");
+ bConstraintTypeInfo *cti= get_constraint_typeinfo(type);
+ const char *newName;
+
+ /* Set up a generic constraint datablock */
+ con->type = type;
+ con->flag |= CONSTRAINT_EXPAND;
+ con->enforce = 1.0f;
+
+ /* Determine a basic name, and info */
+ if (cti) {
+ /* initialise constraint data */
+ con->data = MEM_callocN(cti->size, cti->structName);
+
+ /* only constraints that change any settings need this */
+ if (cti->new_data)
+ cti->new_data(con->data);
+
+ /* if no name is provided, use the type of the constraint as the name */
+ newName= (name && name[0]) ? name : cti->name;
+ }
+ else {
+ /* if no name is provided, use the generic "Const" name */
+ // NOTE: any constraint type that gets here really shouldn't get added...
+ newName= (name && name[0]) ? name : "Const";
+ }
+
+ /* copy the name */
+ BLI_strncpy(con->name, newName, sizeof(con->name));
+
+ /* return the new constraint */
+ return con;
+}
+
+/* if pchan is not NULL then assume we're adding a pose constraint */
+static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type)
+{
+ bConstraint *con;
+ ListBase *list;
+
+ /* add the constraint */
+ con= add_new_constraint_internal(name, type);
+
+ /* find the constraint stack - bone or object? */
+ list = (pchan) ? (&pchan->constraints) : (&ob->constraints);
+
+ if (list) {
+ /* add new constraint to end of list of constraints before ensuring that it has a unique name
+ * (otherwise unique-naming code will fail, since it assumes element exists in list)
+ */
+ BLI_addtail(list, con);
+ unique_constraint_name(con, list);
+
+ /* if the target list is a list on some PoseChannel belonging to a proxy-protected
+ * Armature layer, we must tag newly added constraints with a flag which allows them
+ * to persist after proxy syncing has been done
+ */
+ if (proxylocked_constraints_owner(ob, pchan))
+ con->flag |= CONSTRAINT_PROXY_LOCAL;
+
+ /* make this constraint the active one */
+ constraints_set_active(list, con);
+ }
+
+ return con;
+}
+
+/* ......... */
+
+/* Add new constraint for the given bone */
+bConstraint *add_pose_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type)
+{
+ if (pchan == NULL)
+ return NULL;
+
+ return add_new_constraint(ob, pchan, name, type);
+}
+
+/* Add new constraint for the given object */
+bConstraint *add_ob_constraint(Object *ob, const char *name, short type)
+{
+ return add_new_constraint(ob, NULL, name, type);
+}
+
+/* ......... */
+
/* Reassign links that constraints have to other data (called during file loading?) */
void relink_constraints (ListBase *conlist)
{
@@ -3665,8 +3784,10 @@ void relink_constraints (ListBase *conlist)
}
}
+/* ......... */
+
/* duplicate all of the constraints in a constraint stack */
-void copy_constraints (ListBase *dst, ListBase *src)
+void copy_constraints (ListBase *dst, const ListBase *src)
{
bConstraint *con, *srccon;
@@ -3679,6 +3800,7 @@ void copy_constraints (ListBase *dst, 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 */
@@ -3687,6 +3809,8 @@ void copy_constraints (ListBase *dst, ListBase *src)
}
}
+/* ......... */
+
/* finds the 'active' constraint in a constraint stack */
bConstraint *constraints_get_active (ListBase *list)
{
@@ -3704,6 +3828,19 @@ bConstraint *constraints_get_active (ListBase *list)
return NULL;
}
+/* Set the given constraint as the active one (clearing all the others) */
+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;
+ }
+}
+
/* -------- Constraints and Proxies ------- */
/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 21549f6b147..164e7a23d92 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -878,9 +878,9 @@ int CTX_data_editable_bones(const bContext *C, ListBase *list)
return ctx_data_collection_get(C, "editable_bones", list);
}
-struct bPoseChannel *CTX_data_active_pchan(const bContext *C)
+struct bPoseChannel *CTX_data_active_pose_bone(const bContext *C)
{
- return ctx_data_pointer_get(C, "active_pchan");
+ return ctx_data_pointer_get(C, "active_pose_bone");
}
int CTX_data_selected_pchans(const bContext *C, ListBase *list)
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 83e2e0c29d9..75759733cad 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -1569,7 +1569,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
/* correct non-cyclic cases by copying direction and rotation
* values onto the first & last end-points */
-static void bevel_list_cyclic_fix(BevList *bl)
+static void bevel_list_cyclic_fix_3D(BevList *bl)
{
BevPoint *bevp, *bevp1;
@@ -1837,7 +1837,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
bevel_list_calc_bisect(bl);
if(bl->poly== -1) /* check its not cyclic */
- bevel_list_cyclic_fix(bl); // XXX - run this now so tangents will be right before doing the flipping
+ bevel_list_cyclic_fix_3D(bl); // XXX - run this now so tangents will be right before doing the flipping
bevel_list_flip_tangents(bl);
/* correct the tangents */
@@ -1896,7 +1896,7 @@ static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
}
if(bl->poly== -1) /* check its not cyclic */
- bevel_list_cyclic_fix(bl);
+ bevel_list_cyclic_fix_3D(bl);
if(smooth_iter)
bevel_list_smooth(bl, smooth_iter);
@@ -1906,6 +1906,29 @@ static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
+/* only for 2 points */
+static void make_bevel_list_segment_3D(BevList *bl)
+{
+ float q[4];
+
+ BevPoint *bevp2= (BevPoint *)(bl+1);
+ BevPoint *bevp1= bevp2+1;
+
+ /* simple quat/dir */
+ sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec);
+ normalize_v3(bevp1->dir);
+
+ vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
+
+ axis_angle_to_quat(q, bevp1->dir, bevp1->alfa);
+ mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
+ normalize_qt(bevp1->quat);
+ VECCOPY(bevp2->dir, bevp1->dir);
+ QUATCOPY(bevp2->quat, bevp1->quat);
+}
+
+
+
void makeBevelList(Object *ob)
{
/*
@@ -2213,7 +2236,9 @@ void makeBevelList(Object *ob)
}
/* STEP 4: 2D-COSINES or 3D ORIENTATION */
- if((cu->flag & CU_3D)==0) { /* 3D */
+ if((cu->flag & CU_3D)==0) {
+ /* note: bevp->dir and bevp->quat are not needed for beveling but are
+ * used when making a path from a 2D curve, therefor they need to be set - Campbell */
bl= cu->bev.first;
while(bl) {
@@ -2230,6 +2255,9 @@ void makeBevelList(Object *ob)
calc_bevel_sin_cos(x1, y1, -x1, -y1, &(bevp1->sina), &(bevp1->cosa));
bevp2->sina= bevp1->sina;
bevp2->cosa= bevp1->cosa;
+
+ /* fill in dir & quat */
+ make_bevel_list_segment_3D(bl);
}
else {
bevp2= (BevPoint *)(bl+1);
@@ -2245,6 +2273,12 @@ void makeBevelList(Object *ob)
calc_bevel_sin_cos(x1, y1, x2, y2, &(bevp1->sina), &(bevp1->cosa));
+ /* from: make_bevel_list_3D_zup, could call but avoid a second loop.
+ * no need for tricky tilt calculation as with 3D curves */
+ bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
+ vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
+ /* done with inline make_bevel_list_3D_zup */
+
bevp0= bevp1;
bevp1= bevp2;
bevp2++;
@@ -2261,6 +2295,9 @@ void makeBevelList(Object *ob)
bevp1= bevp-1;
bevp->sina= bevp1->sina;
bevp->cosa= bevp1->cosa;
+
+ /* correct for the dir/quat, see above why its needed */
+ bevel_list_cyclic_fix_3D(bl);
}
}
bl= bl->next;
@@ -2274,22 +2311,7 @@ void makeBevelList(Object *ob)
/* do nothing */
}
else if(bl->nr==2) { /* 2 pnt, treat separate */
- float q[4];
-
- bevp2= (BevPoint *)(bl+1);
- bevp1= bevp2+1;
-
- /* simple quat/dir */
- sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec);
- normalize_v3(bevp1->dir);
-
- vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
-
- axis_angle_to_quat(q, bevp1->dir, bevp1->alfa);
- mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
- normalize_qt(bevp1->quat);
- VECCOPY(bevp2->dir, bevp1->dir);
- QUATCOPY(bevp2->quat, bevp1->quat);
+ make_bevel_list_segment_3D(bl);
}
else {
make_bevel_list_3D(bl, (int)(resolu*cu->twist_smooth), cu->twist_mode);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 8b848ac5371..302b81f2a04 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -327,7 +327,7 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
node1 = dag_get_node(dag, dtar->id);
/* check if bone... */
- if ((ob->type==OB_ARMATURE) && dtar->rna_path && strstr(dtar->rna_path, "pose.pose_channels["))
+ if ((ob->type==OB_ARMATURE) && dtar->rna_path && strstr(dtar->rna_path, "pose.bones["))
dag_add_relation(dag, node1, node, isdata?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver");
/* check if ob data */
else if (dtar->rna_path && strstr(dtar->rna_path, "data."))
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index a1e6570608f..e90fccf6b29 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -47,6 +47,8 @@
#include "BLI_noise.h"
#include "BKE_fcurve.h"
+#include "BKE_animsys.h"
+
#include "BKE_curve.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
@@ -177,6 +179,49 @@ void copy_fcurves (ListBase *dst, ListBase *src)
/* --------------------- Finding -------------------------- */
+FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index)
+{
+ /* anim vars */
+ AnimData *adt;
+ FCurve *fcu= NULL;
+
+ /* rna vars */
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ char *path;
+
+ adt= BKE_animdata_from_id(id);
+
+ /* only use the current action ??? */
+ if(adt==NULL || adt->action==NULL)
+ return NULL;
+
+ RNA_pointer_create(id, type, data, &ptr);
+ prop = RNA_struct_find_property(&ptr, prop_name);
+
+ if(prop) {
+ 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, index);
+
+ /* if not animated, check if driven */
+#if 0
+ if(!fcu && (adt->drivers.first)) {
+ fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex);
+ }
+#endif
+
+ MEM_freeN(path);
+ }
+ }
+
+ return fcu;
+}
+
+
/* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */
FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array_index)
{
@@ -686,6 +731,9 @@ DriverTarget *driver_add_new_target (ChannelDriver *driver)
dtar= MEM_callocN(sizeof(DriverTarget), "DriverTarget");
BLI_addtail(&driver->targets, dtar);
+ /* make the default ID-type ID_OB, since most driver targets refer to objects */
+ dtar->idtype= ID_OB;
+
/* give the target a 'unique' name */
strcpy(dtar->name, "var");
BLI_uniquename(&driver->targets, dtar, "var", '_', offsetof(DriverTarget, name), 64);
@@ -801,8 +849,13 @@ float driver_get_target_value (ChannelDriver *driver, DriverTarget *dtar)
break;
}
}
- else if (G.f & G_DEBUG)
- printf("Driver Evaluation Error: cannot resolve target for %s -> %s \n", id->name, path);
+ else {
+ if (G.f & G_DEBUG)
+ printf("Driver Evaluation Error: cannot resolve target for %s -> %s \n", id->name, path);
+
+ driver->flag |= DRIVER_FLAG_INVALID;
+ return 0.0f;
+ }
return value;
}
@@ -831,7 +884,7 @@ static void driver_get_target_pchans2 (ChannelDriver *driver, bPoseChannel **pch
/* resolve path so that we have pointer to the right posechannel */
if (RNA_path_resolve(&id_ptr, dtar->rna_path, &ptr, &prop)) {
/* is pointer valid (i.e. pointing to an actual posechannel */
- if ((ptr.type == &RNA_PoseChannel) && (ptr.data)) {
+ if ((ptr.type == &RNA_PoseBone) && (ptr.data)) {
/* first or second target? */
if (i)
*pchan1= ptr.data;
@@ -924,8 +977,8 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
}
/* use the final posed locations */
- mat4_to_quat( q1,pchan->pose_mat);
- mat4_to_quat( q2,pchan2->pose_mat);
+ mat4_to_quat(q1, pchan->pose_mat);
+ mat4_to_quat(q2, pchan2->pose_mat);
invert_qt(q1);
mul_qt_qtqt(quat, q1, q2);
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index f70de4983e3..877c6d6b62e 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -53,6 +53,8 @@
#include "RNA_access.h"
#include "RNA_types.h"
+#include "AUD_C-API.h"
+
#ifndef DISABLE_PYTHON
#include "BPY_extern.h" /* for BPY_pydriver_eval() */
#endif
@@ -871,6 +873,96 @@ static FModifierTypeInfo FMI_LIMITS = {
fcm_limits_evaluate /* evaluate */
};
+/* Sound F-Curve Modifier --------------------------- */
+
+static void fcm_sound_new_data (void *mdata)
+{
+ FMod_Sound *data= (FMod_Sound *)mdata;
+
+ /* defaults */
+ data->strength= 1.0f;
+ data->delay = 0.0f;
+ data->modification = FCM_SOUND_MODIF_REPLACE;
+ data->sound = NULL;
+}
+
+static void fcm_sound_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
+{
+ FMod_Sound *data= (FMod_Sound *)fcm->data;
+ float amplitude;
+
+ AUD_Device *device;
+ AUD_Sound *limiter;
+ AUD_SoundInfo info;
+
+ // XXX fixme - need to get in terms of time instead of frames to be really useful
+// evaltime = FRA2TIME(evaltime);
+ evaltime -= data->delay;
+
+ /* sound-system cannot cope with negative times/frames */
+ if (evaltime < 0.0f)
+ return;
+ /* must have a sound with a cache so that this can be used */
+ if (ELEM(NULL, data->sound, data->sound->cache))
+ return;
+
+ /* examine this snippet of the wave, and extract the amplitude from it */
+ info = AUD_getInfo(data->sound->cache);
+ info.specs.channels = 1;
+ info.specs.format = AUD_FORMAT_FLOAT32;
+ device = AUD_openReadDevice(info.specs);
+ limiter = AUD_limitSound(data->sound->cache, evaltime, evaltime + 1);
+ AUD_playDevice(device, limiter);
+ AUD_unload(limiter);
+ AUD_readDevice(device, (sample_t*)&amplitude, 1);
+ AUD_closeReadDevice(device);
+
+ /* combine the amplitude with existing motion data */
+ switch (data->modification) {
+ case FCM_SOUND_MODIF_ADD:
+ *cvalue= *cvalue + amplitude * data->strength;
+ break;
+ case FCM_SOUND_MODIF_SUBTRACT:
+ *cvalue= *cvalue - amplitude * data->strength;
+ break;
+ case FCM_SOUND_MODIF_MULTIPLY:
+ *cvalue= *cvalue * amplitude * data->strength;
+ break;
+ case FCM_SOUND_MODIF_REPLACE:
+ default:
+ *cvalue= *cvalue + amplitude * data->strength;
+ break;
+ }
+}
+
+static float fcm_sound_time (FCurve *fcu, FModifier *fcm, float cvalue, float evaltime)
+{
+ FMod_Sound *data= (FMod_Sound *)fcm->data;
+
+ /* check for the time delay */
+// evaltime = FRA2TIME(evaltime);
+ if(evaltime < data->delay)
+ return data->delay;
+
+ /* modifier doesn't change time */
+ return evaltime;
+}
+
+static FModifierTypeInfo FMI_SOUND = {
+ FMODIFIER_TYPE_SOUND, /* type */
+ sizeof(FMod_Sound), /* size */
+ FMI_TYPE_REPLACE_VALUES, /* action type */
+ 0, /* requirements */
+ "Sound", /* name */
+ "FMod_Sound", /* struct name */
+ NULL, /* free data */
+ NULL, /* copy data */
+ fcm_sound_new_data, /* new data */
+ NULL, /* verify */
+ fcm_sound_time, /* evaluate time */
+ fcm_sound_evaluate /* evaluate */
+};
+
/* F-Curve Modifier API --------------------------- */
/* All of the F-Curve Modifier api functions use FModifierTypeInfo structs to carry out
* and operations that involve F-Curve modifier specific code.
@@ -892,6 +984,7 @@ static void fmods_init_typeinfo ()
fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */
fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */
+ fmodifiersTypeInfo[9]= &FMI_SOUND; /* Sound F-Curve Modifier */
}
/* This function should be used for getting the appropriate type-info when only
@@ -992,13 +1085,13 @@ void copy_fmodifiers (ListBase *dst, ListBase *src)
}
/* Remove and free the given F-Modifier from the given stack */
-void remove_fmodifier (ListBase *modifiers, FModifier *fcm)
+int remove_fmodifier (ListBase *modifiers, FModifier *fcm)
{
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
/* sanity check */
if (fcm == NULL)
- return;
+ return 0;
/* free modifier's special data (stored inside fcm->data) */
if (fcm->data) {
@@ -1010,15 +1103,25 @@ void remove_fmodifier (ListBase *modifiers, FModifier *fcm)
}
/* remove modifier from stack */
- if (modifiers)
+ if (modifiers) {
BLI_freelinkN(modifiers, fcm);
+ return 1;
+ }
else {
// XXX this case can probably be removed some day, as it shouldn't happen...
printf("remove_fmodifier() - no modifier stack given \n");
MEM_freeN(fcm);
+ return 0;
}
}
+/* Remove and free the nth F-Modifier from the given stack */
+int remove_fmodifier_index (ListBase *modifiers, int index)
+{
+ FModifier *fcm= BLI_findlink(modifiers, index);
+ return remove_fmodifier(modifiers, fcm);
+}
+
/* Remove all of a given F-Curve's modifiers */
void free_fmodifiers (ListBase *modifiers)
{
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 6bb47bc0f0f..3ab02a576d0 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -51,6 +51,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_object.h"
+#include "BKE_scene.h" /* object_in_scene */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -95,7 +96,7 @@ void unlink_group(Group *group)
/* ensure objects are not in this group */
for(; base; base= base->next) {
- if(rem_from_group(group, base->object) && find_group(base->object, NULL)==NULL) {
+ if(rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL)==NULL) {
base->object->flag &= ~OB_FROMGROUP;
base->flag &= ~OB_FROMGROUP;
}
@@ -153,15 +154,15 @@ Group *copy_group(Group *group)
}
/* external */
-void add_to_group(Group *group, Object *ob)
+static int add_to_group_internal(Group *group, Object *ob)
{
GroupObject *go;
- if(group==NULL || ob==NULL) return;
+ if(group==NULL || ob==NULL) return 0;
/* check if the object has been added already */
for(go= group->gobject.first; go; go= go->next) {
- if(go->ob==ob) return;
+ if(go->ob==ob) return 0;
}
go= MEM_callocN(sizeof(GroupObject), "groupobject");
@@ -169,10 +170,31 @@ void add_to_group(Group *group, Object *ob)
go->ob= ob;
+ return 1;
+}
+
+int add_to_group(Group *group, Object *object, Scene *scene, Base *base)
+{
+ if(add_to_group_internal(group, object)) {
+ if((object->flag & OB_FROMGROUP)==0) {
+
+ if(scene && base==NULL)
+ base= object_in_scene(object, scene);
+
+ object->flag |= OB_FROMGROUP;
+
+ if(base)
+ base->flag |= OB_FROMGROUP;
+ }
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
/* also used for ob==NULL */
-int rem_from_group(Group *group, Object *ob)
+static int rem_from_group_internal(Group *group, Object *ob)
{
GroupObject *go, *gon;
int removed = 0;
@@ -192,6 +214,26 @@ int rem_from_group(Group *group, Object *ob)
return removed;
}
+int rem_from_group(Group *group, Object *object, Scene *scene, Base *base)
+{
+ if(rem_from_group_internal(group, object)) {
+
+ if(find_group(object, NULL) == NULL) {
+ if(scene && base==NULL)
+ base= object_in_scene(object, scene);
+
+ object->flag &= ~OB_FROMGROUP;
+
+ if(base)
+ base->flag &= ~OB_FROMGROUP;
+ }
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
int object_in_group(Object *ob, Group *group)
{
GroupObject *go;
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 3cff82f522a..7e081982f24 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -442,7 +442,7 @@ void IDP_RemFromGroup(IDProperty *group, IDProperty *prop)
BLI_remlink(&group->data.group, prop);
}
-IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, char *name)
+IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
{
IDProperty *loop;
for (loop=prop->data.group.first; loop; loop=loop->next) {
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 9e9a1719952..18a8210c68d 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -919,11 +919,11 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
/* append preceeding bits to path */
if ((actname && actname[0]) && (constname && constname[0])) {
/* Constraint in Pose-Channel */
- sprintf(buf, "pose.pose_channels[\"%s\"].constraints[\"%s\"]", actname, constname);
+ sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname);
}
else if (actname && actname[0]) {
/* Pose-Channel */
- sprintf(buf, "pose.pose_channels[\"%s\"]", actname);
+ sprintf(buf, "pose.bones[\"%s\"]", actname);
}
else if (constname && constname[0]) {
/* Constraint in Object */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 0b067c6ef7b..c7b79756263 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1395,6 +1395,49 @@ Key *ob_get_key(Object *ob)
return NULL;
}
+KeyBlock *add_keyblock(Scene *scene, Key *key)
+{
+ KeyBlock *kb;
+ float curpos= -0.1;
+ int tot;
+
+ kb= key->block.last;
+ if(kb) curpos= kb->pos;
+
+ kb= MEM_callocN(sizeof(KeyBlock), "Keyblock");
+ BLI_addtail(&key->block, kb);
+ kb->type= KEY_CARDINAL;
+
+ tot= BLI_countlist(&key->block);
+ if(tot==1) strcpy(kb->name, "Basis");
+ else sprintf(kb->name, "Key %d", tot-1);
+
+ // XXX this is old anim system stuff? (i.e. the 'index' of the shapekey)
+ kb->adrcode= tot-1;
+
+ key->totkey++;
+ if(key->totkey==1) key->refkey= kb;
+
+ kb->slidermin= 0.0f;
+ kb->slidermax= 1.0f;
+
+ // XXX kb->pos is the confusing old horizontal-line RVK crap in old IPO Editor...
+ if(key->type == KEY_RELATIVE)
+ kb->pos= curpos+0.1;
+ else {
+#if 0 // XXX old animation system
+ curpos= bsystem_time(scene, 0, (float)CFRA, 0.0);
+ if(calc_ipo_spec(key->ipo, KEY_SPEED, &curpos)==0) {
+ curpos /= 100.0;
+ }
+ kb->pos= curpos;
+
+ sort_keys(key);
+#endif // XXX old animation system
+ }
+ return kb;
+}
+
/* only the active keyblock */
KeyBlock *ob_get_keyblock(Object *ob)
{
@@ -1408,6 +1451,16 @@ KeyBlock *ob_get_keyblock(Object *ob)
return NULL;
}
+KeyBlock *ob_get_reference_keyblock(Object *ob)
+{
+ Key *key= ob_get_key(ob);
+
+ if (key)
+ return key->refkey;
+
+ return NULL;
+}
+
/* get the appropriate KeyBlock given an index */
KeyBlock *key_get_keyblock(Key *key, int index)
{
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index d8c05c30cfe..31849ace99d 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -6020,7 +6020,7 @@ static void collisionModifier_initData(ModifierData *md)
collmd->current_x = NULL;
collmd->current_xnew = NULL;
collmd->current_v = NULL;
- collmd->time = -1;
+ collmd->time = -1000;
collmd->numverts = 0;
collmd->bvhtree = NULL;
}
@@ -6051,7 +6051,7 @@ static void collisionModifier_freeData(ModifierData *md)
collmd->current_x = NULL;
collmd->current_xnew = NULL;
collmd->current_v = NULL;
- collmd->time = -1;
+ collmd->time = -1000;
collmd->numverts = 0;
collmd->bvhtree = NULL;
collmd->mfaces = NULL;
@@ -6101,7 +6101,7 @@ static void collisionModifier_deformVerts(
if(collmd->x && (numverts != collmd->numverts))
collisionModifier_freeData((ModifierData *)collmd);
- if(collmd->time == -1) // first time
+ if(collmd->time == -1000) // first time
{
collmd->x = dm->dupVertArray(dm); // frame start position
@@ -8929,6 +8929,12 @@ int modifier_couldBeCage(ModifierData *md)
modifier_supportsMapping(md));
}
+int modifier_sameTopology(ModifierData *md)
+{
+ ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ return ( mti->type == eModifierTypeType_OnlyDeform || mti->type == eModifierTypeType_Nonconstructive);
+}
+
void modifier_setError(ModifierData *md, char *format, ...)
{
char buffer[2048];
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 1b0f1f28d2c..a27c3b6494b 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1072,6 +1072,11 @@ bNodeTree *ntreeAddTree(int type)
return ntree;
}
+/* Warning: this function gets called during some rather unexpected times
+ * - internal_select is only 1 when used for duplicating selected nodes (i.e. Shift-D duplicate operator)
+ * - this gets called when executing compositing updates (for threaded previews)
+ * - when the nodetree datablock needs to be copied (i.e. when users get copied)
+ */
bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
{
bNodeTree *newtree;
@@ -1103,10 +1108,9 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
if(internal_select==0 || (node->flag & NODE_SELECT)) {
nnode= nodeCopyNode(newtree, node, internal_select); /* sets node->new */
if(internal_select) {
- node->flag &= ~NODE_SELECT;
+ node->flag &= ~(NODE_SELECT|NODE_ACTIVE);
nnode->flag |= NODE_SELECT;
}
- node->flag &= ~NODE_ACTIVE;
/* deselect original sockets */
for(sock= node->inputs.first; sock; sock= sock->next) {
@@ -1671,7 +1675,9 @@ void ntreeSocketUseFlags(bNodeTree *ntree)
/* tag all thats in use */
for(link= ntree->links.first; link; link= link->next) {
- link->fromsock->flag |= SOCK_IN_USE;
+
+ if(link->fromsock) // FIXME, see below
+ link->fromsock->flag |= SOCK_IN_USE;
if(link->tosock) // FIXME This can be NULL, when dragging a new link in the UI, should probably copy the node tree for preview render - campbell
link->tosock->flag |= SOCK_IN_USE;
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 27bfd6f36a3..660d5222f3a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -614,7 +614,7 @@ void unlink_object(Scene *scene, Object *ob)
/* groups */
group= G.main->group.first;
while(group) {
- rem_from_group(group, ob);
+ rem_from_group(group, ob, NULL, NULL);
group= group->id.next;
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 5cc2190c088..4fe63a966be 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -161,7 +161,7 @@ void paint_brush_slot_remove(Paint *p)
int paint_facesel_test(Object *ob)
{
- return (ob && ob->data && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)));
+ return (ob && ob->type==OB_MESH && ob->data && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)));
}
void paint_init(Paint *p, const char col[3])
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index a175ddf975a..a1f81bf6166 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -36,11 +36,13 @@
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
+#include "DNA_anim_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BKE_global.h"
+#include "BKE_fcurve.h"
#include "BKE_plugin_types.h"
#include "BKE_sequence.h"
#include "BKE_texture.h"
@@ -49,6 +51,8 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "RNA_access.h"
+
/* **** XXX **** */
static void error() {}
@@ -242,7 +246,6 @@ static void do_plugin_effect(Sequence * seq,int cfra,
if(seq->plugin->cfra)
*(seq->plugin->cfra)= cfra;
-// XXX *(seq->plugin->cfra)= frame_to_float(scene, cfra);
cp = PIL_dynlib_find_symbol(
seq->plugin->handle, "seqname");
@@ -2777,14 +2780,13 @@ static void store_icu_yrange_speed(struct Sequence * seq,
}
}
}
-
-void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
+void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
{
- float facf0 = seq->facf0;
- //float ctime, div;
+ float ctime, div;
int cfra;
float fallback_fac;
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
+ FCurve *fcu= NULL;
/* if not already done, load / initialize data */
get_sequence_effect(seq);
@@ -2797,6 +2799,11 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
return;
}
+ /* XXX - new in 2.5x. should we use the animation system this way?
+ * The fcurve is needed because many frames need evaluating at once - campbell */
+ fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_fader", 0);
+
+
if (!v->frameMap || v->length != seq->len) {
if (v->frameMap) MEM_freeN(v->frameMap);
@@ -2811,8 +2818,7 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
/* if there is no IPO, try to make retiming easy by stretching the
strip */
// XXX old animation system - seq
- if (/*!seq->ipo &&*/ seq->seq1->enddisp != seq->seq1->start
- && seq->seq1->len != 0) {
+ if (!fcu && seq->seq1->enddisp != seq->seq1->start && seq->seq1->len != 0) {
fallback_fac = (float) seq->seq1->len /
(float) (seq->seq1->enddisp - seq->seq1->start);
/* FIXME: this strip stretching gets screwed by stripdata
@@ -2829,32 +2835,29 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
if ((v->flags & SEQ_SPEED_INTEGRATE) != 0) {
float cursor = 0;
+ float facf;
v->frameMap[0] = 0;
v->lastValidFrame = 0;
for (cfra = 1; cfra < v->length; cfra++) {
-#if 0 // XXX old animation system
- if(seq->ipo) {
- if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
- ctime = frame_to_float(scene, seq->startdisp + cfra);
- div = 1.0;
- } else {
- ctime= frame_to_float(scene, cfra);
- div= v->length / 100.0f;
- if(div==0.0) return;
- }
-
- calc_ipo(seq->ipo, ctime/div);
- execute_ipo((ID *)seq, seq->ipo);
- } else
-#endif // XXX old animation system
- {
- seq->facf0 = fallback_fac;
+ if(fcu) {
+ if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
+ ctime = seq->startdisp + cfra;
+ div = 1.0;
+ } else {
+ ctime= cfra;
+ div= v->length / 100.0f;
+ if(div==0.0) return;
+ }
+
+ facf = evaluate_fcurve(fcu, ctime/div);
+ } else {
+ facf = fallback_fac;
}
- seq->facf0 *= v->globalSpeed;
+ facf *= v->globalSpeed;
- cursor += seq->facf0;
+ cursor += facf;
if (cursor >= v->length) {
v->frameMap[cfra] = v->length - 1;
@@ -2864,40 +2867,39 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
}
}
} else {
+ float facf;
+
v->lastValidFrame = 0;
for (cfra = 0; cfra < v->length; cfra++) {
-#if 0 // XXX old animation system
- if(seq->ipo) {
- if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
- ctime = frame_to_float(scene, seq->startdisp + cfra);
- div = 1.0;
- } else {
- ctime= frame_to_float(scene, cfra);
- div= v->length / 100.0f;
- if(div==0.0) return;
- }
+
+ if(fcu) {
+ if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
+ ctime = seq->startdisp + cfra;
+ div = 1.0;
+ } else {
+ ctime= cfra;
+ div= v->length / 100.0f;
+ if(div==0.0) return;
+ }
- calc_ipo(seq->ipo, ctime/div);
- execute_ipo((ID *)seq, seq->ipo);
+ facf = evaluate_fcurve(fcu, ctime / div);
+ if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
+ facf *= v->length;
+ }
}
-#endif // XXX old animation system
- if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
- seq->facf0 *= v->length;
- }
- if (/*!seq->ipo*/ 1) { // XXX old animation system - seq
- seq->facf0 = (float) cfra * fallback_fac;
+ if (!fcu) {
+ facf = (float) cfra * fallback_fac;
}
- seq->facf0 *= v->globalSpeed;
- if (seq->facf0 >= v->length) {
- seq->facf0 = v->length - 1;
+ facf *= v->globalSpeed;
+ if (facf >= v->length) {
+ facf = v->length - 1;
} else {
v->lastValidFrame = cfra;
}
- v->frameMap[cfra] = seq->facf0;
+ v->frameMap[cfra] = facf;
}
}
- seq->facf0 = facf0;
}
/*
diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c
index a986e9d7a94..1920e82b4ab 100644
--- a/source/blender/blenkernel/intern/sequence.c
+++ b/source/blender/blenkernel/intern/sequence.c
@@ -27,6 +27,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -37,14 +38,19 @@
#include "DNA_listBase.h"
#include "DNA_sequence_types.h"
#include "DNA_scene_types.h"
+#include "DNA_anim_types.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_sequence.h"
+#include "BKE_fcurve.h"
#include "BKE_utildefines.h"
+#include "RNA_access.h"
+#include "RE_pipeline.h"
#include "BLI_blenlib.h"
+#include "BLI_util.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -602,9 +608,9 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq)
sce = seq->scene;
}
- strncpy(seq->name + 2, sce->id.name + 2,
- sizeof(seq->name) - 2);
-
+ BLI_strncpy(seq->name+2, sce->id.name + 2, SEQ_NAME_MAXSTR-2);
+ seqUniqueName(scene->ed->seqbasep, seq);
+
seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1;
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
@@ -807,25 +813,26 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se)
int x, y;
int early_out;
struct SeqEffectHandle sh = get_sequence_effect(seq);
+ FCurve *fcu= NULL;
if (!sh.execute) { /* effect not supported in this version... */
make_black_ibuf(se->ibuf);
return;
}
-#if 0 // XXX old animation system
- if(seq->ipo && seq->ipo->curve.first) {
- do_seq_ipo(scene, seq, cfra);
- fac= seq->facf0;
- facf= seq->facf1;
- } else
-#endif // XXX old animation system
- {
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence,
+ "effect_fader", 0);
+
+ if (!fcu) {
sh.get_default_fac(seq, cfra, &fac, &facf);
+ if( scene->r.mode & R_FIELDS ); else facf= fac;
+ } else {
+ fac = facf = evaluate_fcurve(fcu, cfra);
+ if( scene->r.mode & R_FIELDS ) {
+ facf = evaluate_fcurve(fcu, cfra + 0.5);
+ }
}
- if( !(scene->r.mode & R_FIELDS) ) facf = fac;
-
early_out = sh.early_out(seq, fac, facf);
if (early_out == -1) { /* no input needed */
@@ -1563,12 +1570,6 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se
if(seq->blend_mode == SEQ_BLEND_REPLACE &&
!(seq->type & SEQ_EFFECT)) {
-#if 0 // XXX old animation system
- if (seq->ipo && seq->ipo->curve.first) {
- do_seq_ipo(scene, seq, cfra);
- mul *= seq->facf0;
- }
-#endif // XXX old animation system
mul *= seq->blend_opacity / 100.0;
}
@@ -1653,12 +1654,6 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf
mul = seq->mul;
if(seq->blend_mode == SEQ_BLEND_REPLACE) {
-#if 0 // XXX old animation system
- if (seq->ipo && seq->ipo->curve.first) {
- do_seq_ipo(scene, seq, cfra);
- mul *= seq->facf0;
- }
-#endif // XXX old animation system
mul *= seq->blend_opacity / 100.0;
}
@@ -2012,14 +2007,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
}
}
} else if(seq->type == SEQ_SCENE) { // scene can be NULL after deletions
-#if 0
- /* XXX move entirely to render? */
- int oldcfra = CFRA;
- Sequence * oldseq = get_last_seq();
- Scene *sce= seq->scene, *oldsce= scene;
+ Scene *sce= seq->scene;// *oldsce= scene;
Render *re;
RenderResult rres;
- int doseq, rendering= G.rendering;
char scenename[64];
int have_seq= (sce->r.scemode & R_DOSEQ) && sce->ed && sce->ed->seqbase.first;
int sce_valid =sce && (sce->camera || have_seq);
@@ -2041,18 +2031,24 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
if (!sce_valid) {
se->ok = STRIPELEM_FAILED;
} else if (se->ibuf==NULL && sce_valid) {
- /* no need to display a waitcursor on sequencer
- scene strips */
- if (!have_seq)
- waitcursor(1);
-
+ int oldcfra;
/* Hack! This function can be called from do_render_seq(), in that case
the seq->scene can already have a Render initialized with same name,
so we have to use a default name. (compositor uses scene name to
find render).
However, when called from within the UI (image preview in sequencer)
we do want to use scene Render, that way the render result is defined
- for display in render/imagewindow */
+ for display in render/imagewindow
+
+ Hmm, don't see, why we can't do that all the time,
+ and since G.rendering is uhm, gone... (Peter)
+ */
+
+ int rendering = 1;
+ int doseq;
+
+ oldcfra = seq->scene->r.cfra;
+
if(rendering) {
BLI_strncpy(scenename, sce->id.name+2, 64);
strcpy(sce->id.name+2, " do_build_seq_ibuf");
@@ -2063,16 +2059,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
doseq= scene->r.scemode & R_DOSEQ;
scene->r.scemode &= ~R_DOSEQ;
- BIF_init_render_callbacks(re, 0); /* 0= no display callbacks */
-
- /* XXX hrms, set_scene still needed? work on that... */
- if(sce!=oldsce) set_scene_bg(sce);
RE_BlenderFrame(re, sce,
seq->sfra+se->nr+seq->anim_startofs);
- if(sce!=oldsce) set_scene_bg(oldsce);
- /* UGLY WARNING, it is set to zero in RE_BlenderFrame */
- G.rendering= rendering;
if(rendering)
BLI_strncpy(sce->id.name+2, scenename, 64);
@@ -2092,20 +2081,12 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
RE_ReleaseResultImage(re);
- BIF_end_render_callbacks();
+ // BIF_end_render_callbacks();
/* restore */
scene->r.scemode |= doseq;
-
- // XXX
-#if 0
- if((G.f & G_PLAYANIM)==0 /* bad, is set on do_render_seq */
- && !have_seq
- && !build_proxy_run)
-#endif
-
- CFRA = oldcfra;
- set_last_seq(oldseq);
+
+ seq->scene->r.cfra = oldcfra;
copy_to_ibuf_still(seq, se);
@@ -2118,7 +2099,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
}
}
-#endif
}
if (!build_proxy_run) {
if (se->ibuf && use_limiter) {
@@ -2136,24 +2116,25 @@ static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *s
float fac, facf;
struct SeqEffectHandle sh = get_sequence_effect(seq);
int early_out;
+ FCurve *fcu= NULL;
se->se1 = 0;
se->se2 = 0;
se->se3 = 0;
-#if 0 // XXX old animation system
- if(seq->ipo && seq->ipo->curve.first) {
- do_seq_ipo(scene, seq, cfra);
- fac= seq->facf0;
- facf= seq->facf1;
- } else
-#endif // XXX old animation system
- {
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence,
+ "effect_fader", 0);
+
+ if (!fcu) {
sh.get_default_fac(seq, cfra, &fac, &facf);
- }
+ if( scene->r.mode & R_FIELDS ); else facf= fac;
+ } else {
+ fac = facf = evaluate_fcurve(fcu, cfra);
+ if( scene->r.mode & R_FIELDS ) {
+ facf = evaluate_fcurve(fcu, cfra + 0.5);
+ }
+ }
- if( scene->r.mode & R_FIELDS ); else facf= fac;
-
early_out = sh.early_out(seq, fac, facf);
switch (early_out) {
case -1:
@@ -2226,7 +2207,7 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra
TStripElem * se1 = 0;
TStripElem * se2 = 0;
- sequence_effect_speed_rebuild_map(seq, 0);
+ sequence_effect_speed_rebuild_map(scene, seq, 0);
f_cfra = seq->start + s->frameMap[nr];
@@ -2387,6 +2368,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
int early_out;
Sequence * seq = seq_arr[i];
struct SeqEffectHandle sh;
+ float facf;
se = give_tstripelem(seq, cfra);
@@ -2413,20 +2395,9 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
sh = get_sequence_blend(seq);
- seq->facf0 = seq->facf1 = 1.0;
+ facf = seq->blend_opacity / 100.0;
-#if 0 // XXX old animation system
- if(seq->ipo && seq->ipo->curve.first) {
- do_seq_ipo(scene, seq, cfra);
- }
-#endif
-
- if( scene->r.mode & R_FIELDS ); else seq->facf0 = seq->facf1;
-
- seq->facf0 *= seq->blend_opacity / 100.0;
- seq->facf1 *= seq->blend_opacity / 100.0;
-
- early_out = sh.early_out(seq, seq->facf0, seq->facf1);
+ early_out = sh.early_out(seq, facf, facf);
switch (early_out) {
case -1:
@@ -2483,8 +2454,10 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
struct SeqEffectHandle sh = get_sequence_blend(seq);
TStripElem* se1 = give_tstripelem(seq_arr[i-1], cfra);
TStripElem* se2 = give_tstripelem(seq_arr[i], cfra);
+
+ float facf = seq->blend_opacity / 100.0;
- int early_out = sh.early_out(seq, seq->facf0, seq->facf1);
+ int early_out = sh.early_out(seq, facf, facf);
switch (early_out) {
case 0: {
int x= se2->ibuf->x;
@@ -2532,12 +2505,12 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
if (swap_input) {
sh.execute(seq, cfra,
- seq->facf0, seq->facf1, x, y,
+ facf, facf, x, y,
se2->ibuf, se1->ibuf_comp, 0,
se2->ibuf_comp);
} else {
sh.execute(seq, cfra,
- seq->facf0, seq->facf1, x, y,
+ facf, facf, x, y,
se1->ibuf_comp, se2->ibuf, 0,
se2->ibuf_comp);
}
@@ -3053,7 +3026,7 @@ static void free_imbuf_seq_except(Scene *scene, int cfra)
}
#endif
-void free_imbuf_seq(ListBase * seqbase, int check_mem_usage)
+void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage)
{
Sequence *seq;
TStripElem *se;
@@ -3111,11 +3084,11 @@ void free_imbuf_seq(ListBase * seqbase, int check_mem_usage)
if(seq->type==SEQ_MOVIE)
free_anim_seq(seq);
if(seq->type==SEQ_SPEED) {
- sequence_effect_speed_rebuild_map(seq, 1);
+ sequence_effect_speed_rebuild_map(scene, seq, 1);
}
}
if(seq->type==SEQ_META) {
- free_imbuf_seq(&seq->seqbase, FALSE);
+ free_imbuf_seq(scene, &seq->seqbase, FALSE);
}
if(seq->type==SEQ_SCENE) {
/* FIXME: recurs downwards,
@@ -3164,7 +3137,7 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan
if(seq->type == SEQ_MOVIE)
free_anim_seq(seq);
if(seq->type == SEQ_SPEED) {
- sequence_effect_speed_rebuild_map(seq, 1);
+ sequence_effect_speed_rebuild_map(scene, seq, 1);
}
}
@@ -3510,3 +3483,205 @@ void seq_update_sound(struct Sequence *seq)
seq->sound_handle->changed = -1;
}
}
+
+Sequence *active_seq_get(Scene *scene)
+{
+ Editing *ed= seq_give_editing(scene, FALSE);
+ if(ed==NULL) return NULL;
+ return ed->act_seq;
+}
+
+void active_seq_set(Scene *scene, Sequence *seq)
+{
+ Editing *ed= seq_give_editing(scene, FALSE);
+ if(ed==NULL) return;
+
+ ed->act_seq= seq;
+}
+
+/* api like funcs for adding */
+
+void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
+{
+ if(seq) {
+ strcpy(seq->name, seq_load->name);
+ seqUniqueName(scene->ed->seqbasep, seq);
+
+ if(seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
+ seq_load->start_frame += (seq->enddisp - seq->startdisp);
+ }
+
+ if(seq_load->flag & SEQ_LOAD_REPLACE_SEL) {
+ seq_load->flag |= 1; /* SELECT */
+ active_seq_set(scene, seq);
+ }
+
+ if(seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
+ if(seq->sound)
+ sound_cache(seq->sound, 0);
+ }
+
+ seq_load->tot_success++;
+ }
+ else {
+ seq_load->tot_error++;
+ }
+}
+
+Sequence *alloc_sequence(ListBase *lb, int cfra, int machine)
+{
+ Sequence *seq;
+
+ seq= MEM_callocN( sizeof(Sequence), "addseq");
+ BLI_addtail(lb, seq);
+
+ *( (short *)seq->name )= ID_SEQ;
+ seq->name[2]= 0;
+
+ seq->flag= 1; /* SELECT */
+ seq->start= cfra;
+ seq->machine= machine;
+ seq->mul= 1.0;
+ seq->blend_opacity = 100.0;
+
+ 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 */
+Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ Scene *scene= CTX_data_scene(C); /* only for active seq */
+ Sequence *seq;
+ Strip *strip;
+ StripElem *se;
+
+ 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);
+
+ /* basic defaults */
+ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
+
+ strip->len = seq->len = seq_load->len ? seq_load->len : 1;
+ 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_load_apply(scene, seq, seq_load);
+
+ return seq;
+}
+
+Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ Scene *scene= CTX_data_scene(C); /* only for sound */
+ Editing *ed= seq_give_editing(scene, TRUE);
+ bSound *sound;
+
+ Sequence *seq; /* generic strip vars */
+ Strip *strip;
+ StripElem *se;
+
+ AUD_SoundInfo info;
+
+ sound = sound_new_file(CTX_data_main(C), seq_load->path);
+
+ if (sound==NULL || sound->handle == NULL) {
+ //if(op)
+ // BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
+ return NULL;
+ }
+
+ info = AUD_getInfo(sound->handle);
+
+ if (info.specs.format == AUD_FORMAT_INVALID) {
+ sound_delete(C, sound);
+ //if(op)
+ // BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
+ return NULL;
+ }
+
+ seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
+
+ seq->type= SEQ_SOUND;
+ seq->sound= sound;
+ BLI_strncpy(seq->name+2, "Sound", SEQ_NAME_MAXSTR-2);
+ seqUniqueName(seqbasep, seq);
+
+ /* basic defaults */
+ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
+ strip->len = seq->len = (int) (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);
+
+ calc_sequence_disp(seq);
+
+ /* last active name */
+ strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1);
+
+ seq_load_apply(scene, seq, seq_load);
+
+ return seq;
+}
+
+Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ Scene *scene= CTX_data_scene(C); /* only for sound */
+
+ Sequence *seq, *soundseq; /* generic strip vars */
+ Strip *strip;
+ StripElem *se;
+
+ struct anim *an;
+
+ an = openanim(seq_load->path, IB_rect);
+
+ if(an==NULL)
+ return NULL;
+
+ seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
+
+ seq->type= SEQ_MOVIE;
+ seq->anim= an;
+ seq->anim_preseek = IMB_anim_get_preseek(an);
+ BLI_strncpy(seq->name+2, "Movie", SEQ_NAME_MAXSTR-2);
+ seqUniqueName(seqbasep, seq);
+
+ /* basic defaults */
+ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
+ strip->len = seq->len = IMB_anim_get_duration( an );
+ strip->us= 1;
+
+ strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+
+ BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
+
+ calc_sequence_disp(seq);
+
+
+ if(seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
+ int start_frame_back= seq_load->start_frame;
+ seq_load->channel++;
+
+ soundseq = sequencer_add_sound_strip(C, seqbasep, seq_load);
+
+ seq_load->start_frame= start_frame_back;
+ seq_load->channel--;
+ }
+
+ /* can be NULL */
+ seq_load_apply(scene, seq, seq_load);
+
+ return seq;
+}
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 34071b0034c..557f326e951 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -108,6 +108,16 @@ typedef struct BodyFace {
short flag;
} BodyFace;
+typedef struct ReferenceVert {
+ float pos[3]; /* position relative to com */
+ float mass; /* node mass */
+} ReferenceVert;
+
+typedef struct ReferenceState {
+ float com[3]; /* center of mass*/
+ ReferenceVert *ivert; /* list of intial values */
+}ReferenceState ;
+
/*private scratch pad for caching and other data only needed when alive*/
typedef struct SBScratch {
@@ -117,6 +127,7 @@ typedef struct SBScratch {
BodyFace *bodyface;
int totface;
float aabbmin[3],aabbmax[3];
+ ReferenceState Ref;
}SBScratch;
typedef struct SB_thread_context {
@@ -882,6 +893,9 @@ static void free_scratch(SoftBody *sb)
if (sb->scratch->bodyface){
MEM_freeN(sb->scratch->bodyface);
}
+ if (sb->scratch->Ref.ivert){
+ MEM_freeN(sb->scratch->Ref.ivert);
+ }
MEM_freeN(sb->scratch);
sb->scratch = NULL;
}
@@ -3332,6 +3346,27 @@ static void mesh_faces_to_scratch(Object *ob)
}
sb->scratch->totface = me->totface;
}
+static void reference_to_scratch(Object *ob)
+{
+ SoftBody *sb= ob->soft;
+ ReferenceVert *rp;
+ BodyPoint *bp;
+ float accu_pos[3] ={0.f,0.f,0.f};
+ float accu_mass = 0.f;
+ int a;
+
+ sb->scratch->Ref.ivert = MEM_mallocN(sizeof(ReferenceVert)*sb->totpoint,"SB_Reference");
+ bp= ob->soft->bpoint;
+ rp= sb->scratch->Ref.ivert;
+ for(a=0; a<sb->totpoint; a++, rp++, bp++) {
+ VECCOPY(rp->pos,bp->pos);
+ VECADD(accu_pos,accu_pos,bp->pos);
+ accu_mass += bp-> mass;
+ }
+ mul_v3_fl(accu_pos,1.0f/accu_mass);
+ VECCOPY(sb->scratch->Ref.com,accu_pos);
+ /* printf("reference_to_scratch \n"); */
+}
/*
helper function to get proper spring length
@@ -3569,16 +3604,19 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
/* copies softbody result back in object */
static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int local)
{
- BodyPoint *bp= ob->soft->bpoint;
- int a;
-
- /* inverse matrix is not uptodate... */
- invert_m4_m4(ob->imat, ob->obmat);
-
- for(a=0; a<numVerts; a++, bp++) {
- VECCOPY(vertexCos[a], bp->pos);
- if(local==0)
- mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */
+ SoftBody *sb= ob->soft;
+ if(sb){
+ BodyPoint *bp= sb->bpoint;
+ int a;
+ if(sb->solverflags & SBSO_MONITOR ||sb->solverflags & SBSO_ESTIMATEIPO){SB_estimate_transform(ob,sb->lcom,sb->lrot,sb->lscale);}
+ /* inverse matrix is not uptodate... */
+ invert_m4_m4(ob->imat, ob->obmat);
+
+ for(a=0; a<numVerts; a++, bp++) {
+ VECCOPY(vertexCos[a], bp->pos);
+ if(local==0)
+ mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */
+ }
}
}
@@ -3592,6 +3630,7 @@ static void sb_new_scratch(SoftBody *sb)
sb->scratch->totface = 0;
sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f;
sb->scratch->aabbmin[0]=sb->scratch->aabbmin[1]=sb->scratch->aabbmin[2] = -1.0e30f;
+ sb->scratch->Ref.ivert = NULL;
}
/* --- ************ maintaining scratch *************** */
@@ -3713,6 +3752,178 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo
}
}
+/* void SB_estimate_transform */
+/* input Object *ob out (says any object that can do SB like mesh,lattice,curve )
+ output float lloc[3],float lrot[3][3],float lscale[3][3]
+ that is:
+ a precise position vector denoting the motion of the center of mass
+ give a rotation/scale matrix using averaging method, that's why estimate and not calculate
+ see: this is kind of reverse engeneering: having to states of a point cloud and recover what happend
+ our advantage here we know the identity of the vertex
+ there are others methods giving other results.
+ lloc,lrot,lscale are allowed to be NULL, just in case you don't need it.
+ should be pretty useful for pythoneers :)
+ not! velocity .. 2nd order stuff
+ */
+
+/* can't believe there is none in math utils */
+float _det_m3(float m2[3][3])
+{
+ float det = 0.f;
+ if (m2){
+ det= m2[0][0]* (m2[1][1]*m2[2][2] - m2[1][2]*m2[2][1])
+ -m2[1][0]* (m2[0][1]*m2[2][2] - m2[0][2]*m2[2][1])
+ +m2[2][0]* (m2[0][1]*m2[1][2] - m2[0][2]*m2[1][1]);
+ }
+ return det;
+}
+
+void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscale[3][3])
+{
+ BodyPoint *bp;
+ ReferenceVert *rp;
+ float accu_pos[3] = {0.0f,0.0f,0.0f};
+ float com[3],va[3],vb[3],rcom[3];
+ float accu_mass = 0.0f,la = 0.0f,lb = 0.0f,eps = 0.000001f;
+ SoftBody *sb = 0;
+ int a,i=0,imax=16;
+ int _localdebug;
+
+ if (lloc) zero_v3(lloc);
+ if (lrot) zero_m3(lrot);
+ if (lscale) zero_m3(lscale);
+
+
+ if(!ob ||!ob->soft) return; /* why did we get here ? */
+ sb= ob->soft;
+ /*for threading there should be a lock */
+ /* sb-> lock; */
+ /* calculate center of mass */
+ if(!sb || !sb->bpoint) return;
+ _localdebug=sb->solverflags & SBSO_MONITOR; /* turn this on/off if you (don't) want to see progress on console */
+ for(a=0,bp=sb->bpoint; a<sb->totpoint; a++, bp++) {
+ VECADD(accu_pos,accu_pos,bp->pos);
+ accu_mass += bp->mass;
+ }
+ VECCOPY(com,accu_pos);
+ mul_v3_fl(com,1.0f/accu_mass);
+ /* center of mass done*/
+ if (sb->scratch){
+ float dcom[3],stunt[3];
+ float m[3][3],mr[3][3],q[3][3],qi[3][3];
+ float odet,ndet;
+ zero_m3(m);
+ zero_m3(mr);
+ VECSUB(dcom,com,sb->scratch->Ref.com);
+ VECCOPY(rcom,sb->scratch->Ref.com);
+ if (_localdebug) {
+ printf("DCOM %f %f %f\n",dcom[0],dcom[1],dcom[2]);
+ }
+ if (lloc) VECCOPY(lloc,dcom);
+ VECCOPY(sb->lcom,dcom);
+ /* build 'projection' matrix */
+ for(a=0, bp=sb->bpoint, rp=sb->scratch->Ref.ivert; a<sb->totpoint; a++, bp++, rp++) {
+ VECSUB(va,rp->pos,rcom);
+ la += len_v3(va);
+ /* mul_v3_fl(va,bp->mass); mass needs renormalzation here ?? */
+ VECSUB(vb,bp->pos,com);
+ lb += len_v3(vb);
+ /* mul_v3_fl(va,rp->mass); */
+ m[0][0] += va[0] * vb[0];
+ m[0][1] += va[0] * vb[1];
+ m[0][2] += va[0] * vb[2];
+
+ m[1][0] += va[1] * vb[0];
+ m[1][1] += va[1] * vb[1];
+ m[1][2] += va[1] * vb[2];
+
+ m[2][0] += va[2] * vb[0];
+ m[2][1] += va[2] * vb[1];
+ m[2][2] += va[2] * vb[2];
+
+ /* building the referenc matrix on the fly
+ needed to scale properly later*/
+
+ mr[0][0] += va[0] * va[0];
+ mr[0][1] += va[0] * va[1];
+ mr[0][2] += va[0] * va[2];
+
+ mr[1][0] += va[1] * va[0];
+ mr[1][1] += va[1] * va[1];
+ mr[1][2] += va[1] * va[2];
+
+ mr[2][0] += va[2] * va[0];
+ mr[2][1] += va[2] * va[1];
+ mr[2][2] += va[2] * va[2];
+ }
+ /* we are pretty much set up here and we could return that raw mess containing essential information
+ but being nice fellows we proceed:
+ knowing we did split off the tanslational part to the center of mass (com) part
+ however let's do some more reverse engeneering and see if we can split
+ rotation from scale ->Polardecompose
+ */
+ copy_m3_m3(q,m);
+ stunt[0] = q[0][0]; stunt[1] = q[1][1]; stunt[2] = q[2][2];
+ /* nothing to see here but renormalizing works nicely
+ printf("lenght stunt %5.3f a %5.3f b %5.3f %5.3f\n",len_v3(stunt),la,lb,sqrt(la*lb));
+ */
+ mul_m3_fl(q,1.f/len_v3(stunt));
+ /* not too much to see here
+ if(_localdebug){
+ printf("q0 %5.3f %5.3f %5.3f\n",q[0][0],q[0][1],q[0][2]);
+ printf("q1 %5.3f %5.3f %5.3f\n",q[1][0],q[1][1],q[1][2]);
+ printf("q2 %5.3f %5.3f %5.3f\n",q[2][0],q[2][1],q[2][2]);
+ }
+ */
+ /* this is pretty much Polardecompose 'inline' the algo based on Higham's thesis */
+ /* without the far case !!! but seems to work here pretty neat */
+ odet = 0.f;
+ ndet = _det_m3(q);
+ while((odet-ndet)*(odet-ndet) > eps && i<imax){
+ invert_m3_m3(qi,q);
+ transpose_m3(qi);
+ add_m3_m3m3(q,q,qi);
+ mul_m3_fl(q,0.5f);
+ odet =ndet;
+ ndet =_det_m3(q);
+ i++;
+ }
+ if (i){
+ float scale[3][3];
+ float irot[3][3];
+ if(lrot) copy_m3_m3(lrot,q);
+ copy_m3_m3(sb->lrot,q);
+ if(_localdebug){
+ printf("Rot .. i %d\n",i);
+ printf("!q0 %5.3f %5.3f %5.3f\n",q[0][0],q[0][1],q[0][2]);
+ printf("!q1 %5.3f %5.3f %5.3f\n",q[1][0],q[1][1],q[1][2]);
+ printf("!q2 %5.3f %5.3f %5.3f\n",q[2][0],q[2][1],q[2][2]);
+ }
+ invert_m3_m3(irot,q);
+ /* now that's where we need mr to get scaling right */
+ invert_m3_m3(qi,mr);
+ mul_m3_m3m3(q,m,qi);
+
+ //mul_m3_m3m3(scale,q,irot);
+ mul_m3_m3m3(scale,irot,q); /* i always have a problem with this C functions left/right operator applies first*/
+ mul_m3_fl(scale,lb/la); /* 0 order scale was normalized away so put it back here dunno if that is needed here ???*/
+
+ if(lscale) copy_m3_m3(lscale,scale);
+ copy_m3_m3(sb->lscale,scale);
+ if(_localdebug){
+ printf("Scale .. \n");
+ printf("!s0 %5.3f %5.3f %5.3f\n",scale[0][0],scale[0][1],scale[0][2]);
+ printf("!s1 %5.3f %5.3f %5.3f\n",scale[1][0],scale[1][1],scale[1][2]);
+ printf("!s2 %5.3f %5.3f %5.3f\n",scale[2][0],scale[2][1],scale[2][2]);
+ }
+
+
+ }
+ }
+ /*for threading there should be a unlock */
+ /* sb-> unlock; */
+}
+
static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int numVerts)
{
BodyPoint *bp;
@@ -3750,6 +3961,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
sb->scratch->needstobuildcollider=1;
/* copy some info to scratch */
+ if (1) reference_to_scratch(ob); /* wa only need that if we want to reconstruct IPO */
switch(ob->type) {
case OB_MESH:
if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
@@ -3932,7 +4144,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
//cache->last_exact= 0;
-
return;
}
else if(framenr > endframe) {
@@ -3967,22 +4178,23 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
if(BKE_ptcache_get_continue_physics()) {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
-
/* do simulation */
dtime = timescale;
-
softbody_update_positions(ob, sb, vertexCos, numVerts);
softbody_step(scene, ob, sb, dtime);
+ if(sb->solverflags & SBSO_MONITOR ){
+ printf("Picked from cache continue_physics %d\n",framenr);
+ }
softbody_to_object(ob, vertexCos, numVerts, 0);
-
return;
}
/* still no points? go away */
- if(sb->totpoint==0) return;
-
- if(framenr == startframe) {
+ if(sb->totpoint==0) {
+ return;
+ }
+ if(framenr == startframe) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
/* first frame, no simulation to do, just set the positions */
@@ -3998,6 +4210,9 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
cache_result = BKE_ptcache_read_cache(&pid, framenr, scene->r.frs_sec);
if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
+ if(sb->solverflags & SBSO_MONITOR ){
+ printf("Picked from cache at frame %d\n",framenr);
+ }
softbody_to_object(ob, vertexCos, numVerts, sb->local);
cache->simframe= framenr;
@@ -4035,7 +4250,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
-
BKE_ptcache_write_cache(&pid, framenr);
}
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 6ac9b020f21..d8950c7dace 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -384,6 +384,8 @@ void sound_update_playing(struct bContext *C)
}
}
+ AUD_setSoundVolume(handle->handle, handle->volume);
+
if(action & 1)
{
if(handle->state == AUD_STATUS_INVALID)
@@ -468,7 +470,9 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e
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);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 8bf0f6b8bdf..c5c23c8b6c7 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2354,6 +2354,17 @@ void txt_backspace_word (Text *text)
txt_delete_sel(text);
}
+/* Max spaces to replace a tab with, currently hardcoded to TXT_TABSIZE = 4.
+ * Used by txt_convert_tab_to_spaces, indent and unintent.
+ * Remember to change this string according to max tab size */
+static char tab_to_spaces[] = " ";
+
+static void txt_convert_tab_to_spaces (Text *text)
+{
+ char *sb = &tab_to_spaces[text->curl->len % TXT_TABSIZE];
+ txt_insert_buf(text, sb);
+}
+
int txt_add_char (Text *text, char add)
{
int len, lineno;
@@ -2368,6 +2379,12 @@ int txt_add_char (Text *text, char add)
return 1;
}
+ /* insert spaces rather then tabs */
+ if (add == '\t') {
+ txt_convert_tab_to_spaces(text);
+ return 1;
+ }
+
txt_delete_sel(text);
mrk= txt_find_marker_region(text, text->curl, text->curc-1, text->curl->len, 0, 0);
@@ -2443,7 +2460,13 @@ void indent(Text *text)
{
int len, num;
char *tmp;
- char add = '\t';
+ /* char *addtab = "\t";
+ int tablen = 1; */
+ /* hardcoded: TXT_TABSIZE = 4 spaces: */
+ int spaceslen = TXT_TABSIZE;
+ /* hardcoded: use spaces: */
+ char *add = tab_to_spaces;
+ int indentlen = spaceslen;
if (!text) return;
if (!text->curl) return;
@@ -2452,19 +2475,19 @@ void indent(Text *text)
num = 0;
while (TRUE)
{
- tmp= MEM_mallocN(text->curl->len+2, "textline_string");
+ tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string");
text->curc = 0;
- if(text->curc) memcpy(tmp, text->curl->line, text->curc);
- tmp[text->curc]= add;
+ if(text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */
+ memcpy(tmp+text->curc, add, indentlen);
len= text->curl->len - text->curc;
- if(len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len);
- tmp[text->curl->len+1]=0;
+ if(len>0) memcpy(tmp+text->curc+indentlen, text->curl->line+text->curc, len);
+ tmp[text->curl->len+indentlen]= 0;
make_new_line(text->curl, tmp);
- text->curc++;
+ text->curc+= indentlen;
txt_make_dirty(text);
txt_clean_text(text);
@@ -2494,8 +2517,12 @@ void indent(Text *text)
void unindent(Text *text)
{
int num = 0;
- char remove = '\t';
-
+ /* char *rmtab = "\t"; */
+ char *remove = tab_to_spaces;
+ /* int indenttab = 1; */
+ int indentspaces = TXT_TABSIZE;
+ int indent = indentspaces;
+
if (!text) return;
if (!text->curl) return;
if (!text->sell) return;
@@ -2504,15 +2531,14 @@ void unindent(Text *text)
{
int i = 0;
- if (text->curl->line[i] == remove)
+ if (BLI_strncasecmp(text->curl->line, remove, indent) == 0)
{
while(i< text->curl->len) {
- text->curl->line[i]= text->curl->line[i+1];
+ text->curl->line[i]= text->curl->line[i+indent];
i++;
}
- text->curl->len--;
+ text->curl->len-= indent;
}
-
txt_make_dirty(text);
txt_clean_text(text);