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
path: root/source
diff options
context:
space:
mode:
authorChris Want <cwant@ualberta.ca>2004-01-03 02:29:34 +0300
committerChris Want <cwant@ualberta.ca>2004-01-03 02:29:34 +0300
commita5a01ed549b837596790a917d11983e93f381c1b (patch)
tree968eac00a3e5268faaa770c4613604883cface6a /source
parent251c11cca15cc1ae2736546167edd47bd30a2485 (diff)
Armature speed ups, Part I
-------------------------- Major speed up for armatures during times when you aren't posing a figure. Background: the calculation of poses generated by actions and the calculation of displists were getting somewhat out of sync. This was being remedied by 'clearing the constraint done flag' of the pose channels and recalculating the displists every time the 3d view was redrawn, making life slow and unpleasant. Commenting out the code that was doing this, then reinserting the 'clearing the constraint done flag' at the right times made things a bit more perky.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_action.h4
-rw-r--r--source/blender/include/BIF_editconstraint.h3
-rw-r--r--source/blender/src/buttons_object.c2
-rw-r--r--source/blender/src/drawobject.c3
-rw-r--r--source/blender/src/drawview.c34
-rw-r--r--source/blender/src/editconstraint.c55
-rw-r--r--source/blender/src/editobject.c97
-rw-r--r--source/blender/src/headerbuttons.c9
8 files changed, 197 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 0a187450c79..6942a426d8f 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -170,8 +170,8 @@ enum {
POSE_UNUSED5 = 0x00000080,
POSE_OBMAT = 0x00000100,
POSE_PARMAT = 0x00000200,
- PCHAN_DONE = 0x00000400
-
+ PCHAN_DONE = 0x00000400,
+ PCHAN_TRANS_UPDATE = 0x00000800
};
#endif
diff --git a/source/blender/include/BIF_editconstraint.h b/source/blender/include/BIF_editconstraint.h
index 2982abd5ec8..963b9fb4e08 100644
--- a/source/blender/include/BIF_editconstraint.h
+++ b/source/blender/include/BIF_editconstraint.h
@@ -56,8 +56,7 @@ struct ListBase *get_constraint_client_channels (int forcevalid);
struct ListBase *get_constraint_client(char *name, short *clienttype, void** clientdata);
int test_constraints (struct Object *owner, const char *substring, int disable);
void test_scene_constraints (void);
-
-/* void unique_constraint_name (struct bConstraint *con, struct ListBase *list); */
+struct Object *get_con_target(struct bConstraint *constraint);
#endif
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 311966f7f73..54afa9caf66 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -731,6 +731,8 @@ static uiBlock *add_constraintmenu(void *arg_unused)
void do_constraintbuts(unsigned short event)
{
+ clear_object_constraint_status(OBACT);
+
switch(event) {
case B_CONSTRAINT_CHANGENAME:
break;
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index a305fda18b0..92646ec0c5c 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -3551,7 +3551,8 @@ void draw_object(Base *base)
case OB_MESH:
me= ob->data;
-#if 1
+#if 0
+ /* this is a source of great slowness */
#ifdef __NLA
/* Force a refresh of the display list if the parent is an armature */
if (ob->parent && ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL){
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index 559ca9443bd..bfe4506de92 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -1572,10 +1572,16 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
}
}
+#if 0
+ /* Lets be a little more selective about when and where we do this,
+ * or else armatures/poses/displists get recalculated all of the
+ * time
+ */
/* Clear the constraint "done" flags */
for (base = G.scene->base.first; base; base=base->next){
clear_object_constraint_status(base->object);
}
+#endif
/* draw set first */
if(G.scene->set) {
@@ -1780,6 +1786,12 @@ void drawview3d_render(struct View3D *v3d)
/* abuse! to make sure it doesnt draw the helpstuff */
G.f |= G_SIMULATION;
+ /* Clear the constraint "done" flags -- this must be done
+ * before displists are calculated for objects that are
+ * deformed by armatures */
+ for (base = G.scene->base.first; base; base=base->next){
+ clear_object_constraint_status(base->object);
+ }
do_all_ipos();
BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
do_all_keys();
@@ -2244,7 +2256,8 @@ void inner_play_anim_loop(int init, int mode)
static ScrArea *oldsa;
static double swaptime;
static int curmode;
-
+ Base *base;
+
/* init */
if(init) {
oldsa= curarea;
@@ -2258,6 +2271,13 @@ void inner_play_anim_loop(int init, int mode)
}
set_timecursor(CFRA);
+
+ /* Clear the constraint "done" flags -- this must be done
+ * before displists are calculated for objects that are
+ * deformed by armatures */
+ for (base = G.scene->base.first; base; base=base->next){
+ clear_object_constraint_status(base->object);
+ }
do_all_ipos();
BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
do_all_keys();
@@ -2307,7 +2327,8 @@ int play_anim(int mode)
int cfraont;
unsigned short event=0;
short val;
-
+ Base *base;
+
/* patch for very very old scenes */
if(SFRA==0) SFRA= 1;
if(EFRA==0) EFRA= 250;
@@ -2356,7 +2377,14 @@ int play_anim(int mode)
if(event==SPACEKEY);
else CFRA= cfraont;
-
+
+ /* Clear the constraint "done" flags -- this must be done
+ * before displists are calculated for objects that are
+ * deformed by armatures */
+ for (base = G.scene->base.first; base; base=base->next){
+ clear_object_constraint_status(base->object);
+ }
+
do_all_ipos();
do_all_keys();
do_all_actions();
diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c
index 999a4d5f444..702e6a82573 100644
--- a/source/blender/src/editconstraint.c
+++ b/source/blender/src/editconstraint.c
@@ -774,3 +774,58 @@ bConstraintChannel *add_new_constraint_channel(const char* name)
void add_influence_key_to_constraint (bConstraint *con){
printf("doesn't do anything yet\n");
}
+
+Object *get_con_target(bConstraint *constraint)
+{
+ /*
+ * If the target for this constraint is target, return a pointer
+ * to the name for this constraints subtarget ... NULL otherwise
+ */
+ switch (constraint->type) {
+
+ case CONSTRAINT_TYPE_ACTION:
+ {
+ bActionConstraint *data = constraint->data;
+ return data->tar;
+ }
+ break;
+ case CONSTRAINT_TYPE_LOCLIKE:
+ {
+ bLocateLikeConstraint *data = constraint->data;
+ return data->tar;
+ }
+ break;
+ case CONSTRAINT_TYPE_ROTLIKE:
+ {
+ bRotateLikeConstraint *data = constraint->data;
+ return data->tar;
+ }
+ break;
+ case CONSTRAINT_TYPE_KINEMATIC:
+ {
+ bKinematicConstraint *data = constraint->data;
+ return data->tar;
+ }
+ break;
+ case CONSTRAINT_TYPE_TRACKTO:
+ {
+ bTrackToConstraint *data = constraint->data;
+ return data->tar;
+ }
+ break;
+ case CONSTRAINT_TYPE_LOCKTRACK:
+ {
+ bLockTrackConstraint *data = constraint->data;
+ return data->tar;
+ }
+ break;
+ case CONSTRAINT_TYPE_FOLLOWPATH:
+ {
+ bFollowPathConstraint *data = constraint->data;
+ return data->tar;
+ }
+ break;
+ }
+
+ return NULL;
+}
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 71b3c4ec844..4f002f94670 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -447,6 +447,7 @@ void clear_object(char mode)
case OB_ARMATURE:
clear_armature (G.obpose, mode);
#if 1
+ clear_pose_constraint_status(G.obpose);
make_displists_by_armature (G.obpose);
#endif
break;
@@ -2589,6 +2590,88 @@ static Object *is_a_parent_selected(Object *ob) {
return res;
}
+/*** POSE FIGURIN' -- START ***/
+
+static void clear_pose_update_flag(Object *ob) {
+ /* Clear the flag for each pose channel that indicates that
+ * pose should be updated on every redraw
+ */
+ bPoseChannel *chan;
+
+ if (ob->pose) {
+ for (chan = ob->pose->chanbase.first; chan;
+ chan=chan->next){
+ chan->flag &= ~PCHAN_TRANS_UPDATE;
+ }
+ }
+}
+
+static void pose_flags_reset_done(Object *ob) {
+ /* Clear the constraint done status for every pose channe;
+ * that has been flagged as needing constant updating
+ */
+ bPoseChannel *chan;
+
+ if (ob->pose) {
+ for (chan = ob->pose->chanbase.first; chan; chan=chan->next){
+ if (chan->flag & PCHAN_TRANS_UPDATE) {
+ chan->flag &= ~PCHAN_DONE;
+ }
+
+ }
+ }
+
+}
+
+static int is_ob_constraint_target(Object *ob, ListBase *conlist) {
+ /* Is this object the target of a constraint in this list?
+ */
+
+ bConstraint *con;
+
+ for (con=conlist->first; con; con=con->next)
+ {
+ if (get_con_target(con) == ob)
+ return 1;
+ }
+ return 0;
+
+}
+
+static int pose_do_update_flag(Object *ob) {
+ /* Figure out which pose channels need constant updating.
+ */
+ Base *base;
+ bPoseChannel *chan;
+ int do_update = 0;
+
+ if (ob->pose) {
+ for (chan = ob->pose->chanbase.first; chan; chan=chan->next){
+ if (chan->constraints.first) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (is_ob_constraint_target(base->object,
+ &chan->constraints)) {
+ if( (base->flag & SELECT) || (ob->flag & SELECT)) {
+ /* If this armature is selected, or if the
+ * object that is the target of a constraint
+ * is selected, then lets constantly update
+ * this pose channel.
+ */
+ chan->flag |= PCHAN_TRANS_UPDATE;
+ do_update = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return do_update;
+}
+
+/*** POSE FIGURIN' -- END ***/
+
+
static void setbaseflags_for_editing(int mode) /* 0,'g','r','s' */
{
/*
@@ -2624,7 +2707,10 @@ static void setbaseflags_for_editing(int mode) /* 0,'g','r','s' */
if(ob->track && TESTBASE(ob->track) && (base->flag & SELECT)==0)
base->flag |= BA_PARSEL;
}
-
+
+ if (pose_do_update_flag(base->object))
+ base->flag |= BA_WHERE_UPDATE;
+
/* updates? */
if(ob->type==OB_IKA) {
Ika *ika= ob->data;
@@ -2681,6 +2767,8 @@ void clearbaseflags_for_editing()
base->flag &= ~(BA_PARSEL+BA_WASSEL);
base->flag &= ~(BA_DISP_UPDATE+BA_WHERE_UPDATE+BA_DO_IPO);
+
+ clear_pose_update_flag(base->object);
base= base->next;
}
@@ -3278,6 +3366,10 @@ void special_trans_update(int keyflags)
base->object->partype |= PARSLOW;
}
else if(base->flag & BA_WHERE_UPDATE) {
+ /* deal with the armature case */
+ pose_flags_reset_done(base->object);
+ make_displists_by_armature(base->object);
+
where_is_object(base->object);
if(base->object->type==OB_IKA) {
itterate_ika(base->object);
@@ -3298,8 +3390,9 @@ void special_trans_update(int keyflags)
}
-#if 0
+#if 1
if (G.obpose && G.obpose->type == OB_ARMATURE)
+ clear_pose_constraint_status(G.obpose);
make_displists_by_armature(G.obpose);
#endif
diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c
index 03bbbb97fa9..6417dc6ec29 100644
--- a/source/blender/src/headerbuttons.c
+++ b/source/blender/src/headerbuttons.c
@@ -492,6 +492,8 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
void do_update_for_newframe(int mute)
{
+ Base *base;
+
extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */
allqueue(REDRAWVIEW3D, 0);
@@ -505,6 +507,13 @@ void do_update_for_newframe(int mute)
allqueue(REDRAWBUTSSHADING, 0);
allqueue(REDRAWBUTSOBJECT, 0);
+ /* Clear the constraint "done" flags -- this must be done
+ * before displists are calculated for objects that are
+ * deformed by armatures */
+ for (base = G.scene->base.first; base; base=base->next){
+ clear_object_constraint_status(base->object);
+ }
+
/* layers/materials, object ipos are calculted in where_is_object (too) */
do_all_ipos();
BPY_do_all_scripts(SCRIPT_FRAMECHANGED);