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:
authorJoseph Eagar <joeedh@gmail.com>2009-11-29 03:53:23 +0300
committerJoseph Eagar <joeedh@gmail.com>2009-11-29 03:53:23 +0300
commitabd16aac5af56a37a3435b94039d77b74223abab (patch)
tree47ba926d0e8e2c3a903a5d2f1b8290d274cb381c /source/blender/blenkernel
parent3d0db91f820a509bc6c93718499ffe8ff49515d3 (diff)
parentd459c9c9abd2ad0819e5c096f6e3e5a93a02a219 (diff)
ok, apparently didn't commit this either. apparently includes a merge with trunk/2.5 at r24811 I thought I'd committed but did not, yeek.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h5
-rw-r--r--source/blender/blenkernel/BKE_action.h6
-rw-r--r--source/blender/blenkernel/BKE_constraint.h9
-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_node.h1
-rw-r--r--source/blender/blenkernel/BKE_paint.h3
-rw-r--r--source/blender/blenkernel/BKE_sequence.h38
-rw-r--r--source/blender/blenkernel/BKE_softbody.h3
-rw-r--r--source/blender/blenkernel/BKE_tessmesh.h5
-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.c46
-rw-r--r--source/blender/blenkernel/intern/anim.c20
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c4
-rw-r--r--source/blender/blenkernel/intern/armature.c140
-rw-r--r--source/blender/blenkernel/intern/brush.c20
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c5
-rw-r--r--source/blender/blenkernel/intern/cloth.c17
-rw-r--r--source/blender/blenkernel/intern/collision.c4
-rw-r--r--source/blender/blenkernel/intern/constraint.c145
-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/displist.c2
-rw-r--r--source/blender/blenkernel/intern/fcurve.c60
-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/implicit.c4
-rw-r--r--source/blender/blenkernel/intern/ipo.c4
-rw-r--r--source/blender/blenkernel/intern/key.c60
-rw-r--r--source/blender/blenkernel/intern/modifier.c14
-rw-r--r--source/blender/blenkernel/intern/node.c20
-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.c369
-rw-r--r--source/blender/blenkernel/intern/softbody.c252
-rw-r--r--source/blender/blenkernel/intern/sound.c6
-rw-r--r--source/blender/blenkernel/intern/text.c52
45 files changed, 1373 insertions, 323 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index ec7998cc064..c1fe8f0452e 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -95,6 +95,7 @@ struct Object;
struct Scene;
struct Mesh;
struct BMEditMesh;
+struct KeyBlock;
struct ModifierData;
struct MCol;
struct ColorBand;
@@ -432,6 +433,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..e0b65c1996f 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.
*/
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index f957c5e17d4..a8ccc84a7c3 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -108,7 +108,6 @@ bConstraintTypeInfo *get_constraint_typeinfo(int type);
/* Constraint Target Macros */
#define VALID_CONS_TARGET(ct) ((ct) && (ct->tar))
-
/* ---------------------------------------------------------------------------- */
/* Constraint function prototypes */
@@ -119,7 +118,15 @@ void copy_constraints(struct ListBase *dst, 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_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 22ce89dcb81..56738d882c3 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -61,7 +61,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 89ac993d71a..a05df810ca4 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -282,6 +282,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_node.h b/source/blender/blenkernel/BKE_node.h
index 4c872fb247c..f9130e24a08 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -162,6 +162,7 @@ void nodeVerifyType(struct bNodeTree *ntree, struct bNode *node);
void nodeAddToPreview(struct bNode *, float *, int, int);
void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
+void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
void nodeAddSockets(struct bNode *node, struct bNodeType *ntype);
struct bNode *nodeAddNodeType(struct bNodeTree *ntree, int type, struct bNodeTree *ngroup, struct ID *id);
void nodeRegisterType(struct ListBase *typelist, const struct bNodeType *ntype) ;
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index ba42aca1872..b532b0820d7 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -68,6 +68,9 @@ typedef struct SculptSession {
struct MFace *mface;
int totvert, totface;
float *face_normals;
+
+ 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/BKE_tessmesh.h b/source/blender/blenkernel/BKE_tessmesh.h
index 1045295ae92..7d9516fd4e9 100644
--- a/source/blender/blenkernel/BKE_tessmesh.h
+++ b/source/blender/blenkernel/BKE_tessmesh.h
@@ -1,3 +1,6 @@
+#ifndef _BKE_TESSMESH_H
+#define _BKE_TESSMESH_H
+
#include "bmesh.h"
struct BMesh;
@@ -61,3 +64,5 @@ BMEditMesh *BMEdit_Create(BMesh *bm);
BMEditMesh *BMEdit_Copy(BMEditMesh *tm);
void BMEdit_Free(BMEditMesh *em);
void BMEdit_UpdateLinkedCustomData(BMEditMesh *em);
+
+#endif /* _BKE_TESSMESH_H */ \ No newline at end of file
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 43e50bb4f1f..38f541ff7e8 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -17,7 +17,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 a3569298fde..cda035046f6 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(CCFace *f, int lvl, int S, int x, int y, float *no, int leve
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;
@@ -1934,7 +1937,7 @@ static void CCS__sync(CSubSurf *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;
@@ -1993,7 +1996,7 @@ static void CCS__sync(CSubSurf *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 cf4b9e8e0b7..4585a56675a 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -436,6 +436,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..af3c4719e32 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"
@@ -516,17 +518,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 +571,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,7 +634,7 @@ 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;
}
@@ -868,7 +886,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 +1063,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 a3946946e6c..9d50be3af53 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -251,17 +251,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;
@@ -703,7 +699,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
if(par->transflag & OB_DUPLIFACES_SCALE) {
float size= v4? area_quad_v3(v1, v2, v3, v4): area_tri_v3(v1, v2, v3);
size= sqrt(size) * par->dupfacesca;
- mul_m3_fl(mat[0], size);
+ mul_m3_fl(mat, size);
}
copy_m3_m3(mat3, mat);
@@ -940,7 +936,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
- mul_mat3_m4_fl((float *)tmat, size*scale);
+ mul_mat3_m4_fl(tmat, size*scale);
if(par_space_mat)
mul_m4_m4m4(mat, tmat, par_space_mat);
else
@@ -962,7 +958,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
copy_m4_m4(mat, pamat);
mul_m4_m4m4(tmat, obmat, mat);
- mul_mat3_m4_fl((float *)tmat, size*scale);
+ mul_mat3_m4_fl(tmat, size*scale);
if(part->draw & PART_DRAW_GLOBAL_OB)
VECADD(tmat[3], tmat[3], vec);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index e2849825862..5ebcec63cd4 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)
{
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index a53ab493171..75ee27a73af 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -814,7 +814,7 @@ static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonem
else
copy_m3_m4(wmat, pchan->chan_mat);
- mul_m3_fl((float*)wmat, weight);
+ mul_m3_fl(wmat, weight);
add_m3_m3m3(mat, mat, wmat);
}
@@ -1014,7 +1014,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
vec= sumvec;
if(defMats) {
- zero_m3((float*)summat);
+ zero_m3(summat);
smat = summat;
}
}
@@ -1124,7 +1124,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
copy_m3_m3(tmpmat, defMats[i]);
if(!use_quaternion) /* quaternion already is scale corrected */
- mul_m3_fl((float*)smat, armature_weight/contrib);
+ mul_m3_fl(smat, armature_weight/contrib);
mul_serie_m3(defMats[i], tmpmat, pre, smat, post,
NULL, NULL, NULL, NULL);
@@ -1531,8 +1531,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;
@@ -1587,9 +1586,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);
}
}
@@ -1633,7 +1630,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];
@@ -1662,6 +1659,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...
@@ -1708,7 +1720,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
@@ -1801,7 +1813,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);
}
}
@@ -1812,9 +1824,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);
@@ -1822,24 +1832,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
@@ -1878,7 +1905,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
@@ -1889,20 +1916,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 */
@@ -1916,11 +1935,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 ccee5a266f2..a9d72d93091 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -83,7 +83,7 @@ Brush *add_brush(const char *name)
brush->clone.alpha= 0.5;
brush->sculpt_tool = SCULPT_TOOL_DRAW;
- brush_curve_preset(brush, BRUSH_PRESET_SHARP);
+ brush_curve_preset(brush, BRUSH_PRESET_SMOOTH);
/* enable fake user by default */
brush->id.flag |= LIB_FAKEUSER;
@@ -252,7 +252,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;
@@ -271,16 +271,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/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 9701bc41175..6a3c416bbab 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -492,8 +492,9 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co,
t0 = vert[ edge->v1 ].co;
t1 = vert[ edge->v2 ].co;
- closest_to_line_segment_v3(nearest_tmp, co, t0, t1);
- dist = len_v3v3(nearest_tmp, co);
+ // NOTE: casts to "float*" here are due to co being "const float*"
+ closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1);
+ dist = len_v3v3(nearest_tmp, (float*)co);
if(dist < nearest->dist)
{
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 43d66e899e8..a3517404c2b 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -132,6 +132,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;
@@ -451,6 +452,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
@@ -469,7 +482,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;
@@ -504,7 +517,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/collision.c b/source/blender/blenkernel/intern/collision.c
index 3d995d7b6e8..2ea54ac1f03 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -726,6 +726,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap
return collpair;
}
+#if 0
static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end )
{
int result = 0;
@@ -834,6 +835,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo
}
return result;
}
+#endif
static float projectPointOntoLine(float *p, float *a, float *b)
{
@@ -1065,6 +1067,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
return 0;
}
+#if 0
static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair )
{
EdgeCollPair edgecollpair;
@@ -1292,6 +1295,7 @@ static int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierDa
return 1;
}
+#endif
// return all collision objects in scene
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index c15d0dc59c1..8d750e73459 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1927,7 +1927,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);
@@ -1935,7 +1935,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 {
@@ -1947,7 +1947,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);
@@ -1961,9 +1961,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);
@@ -3638,6 +3642,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)
{
@@ -3668,6 +3787,8 @@ void relink_constraints (ListBase *conlist)
}
}
+/* ......... */
+
/* duplicate all of the constraints in a constraint stack */
void copy_constraints (ListBase *dst, ListBase *src)
{
@@ -3682,6 +3803,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 */
@@ -3690,6 +3812,8 @@ void copy_constraints (ListBase *dst, ListBase *src)
}
}
+/* ......... */
+
/* finds the 'active' constraint in a constraint stack */
bConstraint *constraints_get_active (ListBase *list)
{
@@ -3707,6 +3831,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/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/displist.c b/source/blender/blenkernel/intern/displist.c
index 7efd07511e2..3d8fbe248bf 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -479,7 +479,7 @@ static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, floa
invert_m4_m4(tmat, mat);
copy_m3_m4(imat, tmat);
- if(ob->transflag & OB_NEG_SCALE) mul_m3_fl((float *)imat, -1.0);
+ if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0);
if (need_orco_r) *need_orco_r= 0;
for(a=0; a<ob->totcol; a++) {
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index a1e6570608f..c451168a005 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)
{
@@ -801,8 +846,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 +881,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 +974,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 dcb3bf47068..d4dde0fed5d 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/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 073b4e80ae7..f2b737fa3c2 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -297,6 +297,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
///////////////////////////
// 3x3 matrix
///////////////////////////
+#if 0
/* printf 3x3 matrix on console: for debug output */
static void print_fmatrix(float m3[3][3])
{
@@ -304,6 +305,7 @@ static void print_fmatrix(float m3[3][3])
printf("%f\t%f\t%f\n",m3[1][0],m3[1][1],m3[1][2]);
printf("%f\t%f\t%f\n\n",m3[2][0],m3[2][1],m3[2][2]);
}
+#endif
/* copy 3x3 matrix */
DO_INLINE void cp_fmatrix(float to[3][3], float from[3][3])
@@ -972,6 +974,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
}
}
+#if 0
/*
// version 1.3
static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv)
@@ -1143,6 +1146,7 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
return iterations<conjgrad_looplimit;
}
+#endif
// outer product is NOT cross product!!!
DO_INLINE void dfdx_spring_type1(float to[3][3], float extent[3], float length, float L, float dot, float k)
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 81ad0ef6658..e83c494ba79 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1239,11 +1239,11 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot)
#endif // XXX old animation system
flag= setkeys(ctime, &key->block, k, t, 0);
-
+
if(flag==0)
- ; /* do_key(a, a+step, tot, (char *)out, key, k, t, 0); */
+ do_key(a, a+step, tot, (char *)out, key, actkb, k, t, 0);
else
- ; /* cp_key(a, a+step, tot, (char *)out, key, k[2],0); */
+ cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, 0);
}
}
else {
@@ -1442,6 +1442,50 @@ 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;
+ kb->uid = key->uidgen++;
+
+ 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)
{
@@ -1455,6 +1499,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 c34abd3ef8b..e26d084c1d1 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -3167,7 +3167,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
unit_m4(offsetmat);
- mul_mat3_m4_fl(offsetmat[0], 0.5);
+ mul_mat3_m4_fl(offsetmat, 0.5);
offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5;
if (cam) {
@@ -5202,7 +5202,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;
}
@@ -5233,7 +5233,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;
@@ -5283,7 +5283,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
@@ -8121,6 +8121,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 9f635acc931..9efbf7699c6 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -32,6 +32,7 @@
#endif
#include <stdlib.h>
+#include <stddef.h>
#include <string.h>
#include "DNA_ID.h"
@@ -903,7 +904,11 @@ void nodeAddSockets(bNode *node, bNodeType *ntype)
}
}
}
-
+/* Find the first available, non-duplicate name for a given node */
+void nodeUniqueName(bNodeTree *ntree, bNode *node)
+{
+ BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), 32);
+}
bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id)
{
@@ -937,6 +942,9 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id)
}
else
BLI_strncpy(node->name, ntype->name, NODE_MAXSTR);
+
+ nodeUniqueName(ntree, node);
+
node->type= ntype->type;
node->flag= NODE_SELECT|ntype->flag;
node->width= ntype->width;
@@ -989,6 +997,8 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal)
bNodeSocket *sock, *oldsock;
*nnode= *node;
+ nodeUniqueName(ntree, nnode);
+
BLI_addtail(&ntree->nodes, nnode);
BLI_duplicatelist(&nnode->inputs, &node->inputs);
@@ -1062,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;
@@ -1093,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) {
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1bcb060d3f6..a8acdf36461 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -623,7 +623,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 3dfe3966e2f..27fcfa8b9cb 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 1ab085f5fa8..07969704521 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"
@@ -63,8 +69,8 @@
/* **** XXX ******** */
static int seqrectx= 0; /* bad bad global! */
static int seqrecty= 0;
-static void waitcursor(int val) {}
-static int blender_test_break() {return 0;}
+//static void waitcursor(int val) {}
+//static int blender_test_break() {return 0;}
/* **** XXX ******** */
@@ -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 */
@@ -1230,6 +1237,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in
}
}
+#if 0
static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra,
int build_proxy_run, int render_size);
@@ -1360,6 +1368,7 @@ static void seq_proxy_rebuild(Scene *scene, Sequence * seq)
}
waitcursor(0);
}
+#endif
/* **********************************************************************
@@ -1561,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;
}
@@ -1651,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;
}
@@ -2010,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;
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);
@@ -2039,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");
@@ -2061,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);
@@ -2090,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);
@@ -2116,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) {
@@ -2134,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:
@@ -2224,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];
@@ -2385,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);
@@ -2411,20 +2395,9 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
sh = get_sequence_blend(seq);
- seq->facf0 = seq->facf1 = 1.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;
+ facf = seq->blend_opacity / 100.0;
- 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:
@@ -2481,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;
@@ -2530,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);
}
@@ -2631,6 +2606,7 @@ ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown
return i;
}
+#if 0
/* check used when we need to change seq->blend_mode but not to effect or audio strips */
static int seq_can_blend(Sequence *seq)
{
@@ -2640,6 +2616,7 @@ static int seq_can_blend(Sequence *seq)
return 0;
}
}
+#endif
/* *********************** threading api ******************* */
@@ -2651,8 +2628,8 @@ static pthread_mutex_t queue_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t wakeup_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t wakeup_cond = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER;
+//static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER;
+//static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t frame_done_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t frame_done_cond = PTHREAD_COND_INITIALIZER;
@@ -2685,6 +2662,7 @@ typedef struct PrefetchQueueElem {
struct ImBuf * ibuf;
} PrefetchQueueElem;
+#if 0
static void *seq_prefetch_thread(void * This_)
{
PrefetchThread * This = This_;
@@ -2833,6 +2811,7 @@ static void seq_stop_threads()
/* deinit malloc mutex */
BLI_end_threads(0);
}
+#endif
void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown,
int render_size)
@@ -2859,6 +2838,7 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown,
pthread_mutex_unlock(&wakeup_lock);
}
+#if 0
static void seq_wait_for_prefetch_ready()
{
PrefetchThread *tslot;
@@ -2887,6 +2867,7 @@ static void seq_wait_for_prefetch_ready()
fprintf(stderr, "SEQ-THREAD: prefetch done\n");
}
+#endif
ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
{
@@ -2993,6 +2974,7 @@ static void free_anim_seq(Sequence *seq)
}
}
+#if 0
static void free_imbuf_seq_except(Scene *scene, int cfra)
{
Editing *ed= seq_give_editing(scene, FALSE);
@@ -3042,8 +3024,9 @@ static void free_imbuf_seq_except(Scene *scene, int cfra)
}
SEQ_END
}
+#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;
@@ -3101,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,
@@ -3154,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);
}
}
@@ -3187,6 +3170,7 @@ void free_imbuf_seq()
}
#endif
+#if 0 // XXX old animation system
static void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo)
{
/* force update of all sequences with this ipo, on ipo changes */
@@ -3206,6 +3190,7 @@ static void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo)
}
SEQ_END
}
+#endif
/* seq funcs's for transforming internally
notice the difference between start/end and left/right.
@@ -3498,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 2e4bef26df4..e3a66b33ca3 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -109,6 +109,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 {
@@ -118,6 +128,7 @@ typedef struct SBScratch {
BodyFace *bodyface;
int totface;
float aabbmin[3],aabbmax[3];
+ ReferenceState Ref;
}SBScratch;
typedef struct SB_thread_context {
@@ -594,7 +605,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
if (ob->soft){
int nofquads;
- float s_shear = ob->soft->shearstiff*ob->soft->shearstiff;
+ //float s_shear = ob->soft->shearstiff*ob->soft->shearstiff;
nofquads = count_mesh_quads(me);
if (nofquads) {
@@ -883,6 +894,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;
}
@@ -3333,6 +3347,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
@@ -3570,16 +3605,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 */
+ }
}
}
@@ -3593,6 +3631,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 *************** */
@@ -3714,6 +3753,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;
@@ -3751,6 +3962,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);
@@ -3933,7 +4145,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) {
@@ -3968,22 +4179,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 */
@@ -3999,6 +4211,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;
@@ -4036,7 +4251,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);