diff options
author | Martin Poirier <theeth@yahoo.com> | 2004-08-16 05:14:18 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2004-08-16 05:14:18 +0400 |
commit | f9acfa722d5f5c3ebf3e0f058a1fd70a717cb0e7 (patch) | |
tree | 0932c52153ba37f01a2e1c8930764bbc29685fde /source/blender/blenkernel | |
parent | 0ce1304e1b941cac30ec9800349fcff4e12b3e72 (diff) |
Renamed get_constraint_target in constraint kernel file to get_constraint_target_matrix since that's what it really does
Moved get_con_target from editconstraint to constraint kernel file and renamed to get_constraint_target
Make scene.c use constraint functions from kernel instead of doing the switch itself (regrouping specific constraint code in one file).
Add LockTrack as an option in the Make Track menu (Ctrl-T)
Adding fun for vortex forces in 3D window, the representation now match the orientation and direction of the force (this is code will need optimisation). I'll probably be slapped for mixing two things in one commit but some function calls needed to be fixed for the new spelling and since this is really isolated code I didn't feel like wasting time getting a fresh copy, doing the changes and then readded this after commiting.
Fixed some warning regarding implicit casts and constants (this last one is a MSVCism where you need to explicitely tell the compiler to use floats with an f. AFAIK, it doesn't affect/bother other compilers).
Removed a useless commented piece of code in readfile (there was an uncommented copy a couple of lines before)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_constraint.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 93 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 78 |
4 files changed, 100 insertions, 79 deletions
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 273b9d2a0a5..cc2e5498fb4 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -54,10 +54,14 @@ void clear_object_constraint_status (struct Object *ob); void clear_all_constraints(void); void rebuild_all_armature_displists(void); void do_constraint_channels (struct ListBase *conbase, struct ListBase *chanbase, float ctime); -short get_constraint_target (struct bConstraint *con, short ownertype, void *ownerdata, float mat[][4], float size[3], float time); +short get_constraint_target_matrix (struct bConstraint *con, short ownertype, void *ownerdata, float mat[][4], float size[3], float time); struct bConstraintChannel *find_constraint_channel (ListBase *list, const char *name); void free_constraint_channels (ListBase *chanbase); + +/* Gemeric functions */ + char constraint_has_target (struct bConstraint *con); +struct Object *get_constraint_target(struct bConstraint *con); /* Constraint target/owner types */ #define TARGET_OBJECT 1 // string is "" diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c50e654465e..e590dd1dc24 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -124,10 +124,65 @@ char constraint_has_target (bConstraint *con) { } break; } - // Unknown types or CONSTRAINT_TYPE_NULL or no target + // Unknown types or CONSTRAINT_TYPE_NULL or no target return 0; } +Object *get_constraint_target(bConstraint *con) +{ + /* + * If the target for this constraint is target, return a pointer + * to the name for this constraints subtarget ... NULL otherwise + */ + switch (con->type) { + + case CONSTRAINT_TYPE_ACTION: + { + bActionConstraint *data = con->data; + return data->tar; + } + break; + case CONSTRAINT_TYPE_LOCLIKE: + { + bLocateLikeConstraint *data = con->data; + return data->tar; + } + break; + case CONSTRAINT_TYPE_ROTLIKE: + { + bRotateLikeConstraint *data = con->data; + return data->tar; + } + break; + case CONSTRAINT_TYPE_KINEMATIC: + { + bKinematicConstraint *data = con->data; + return data->tar; + } + break; + case CONSTRAINT_TYPE_TRACKTO: + { + bTrackToConstraint *data = con->data; + return data->tar; + } + break; + case CONSTRAINT_TYPE_LOCKTRACK: + { + bLockTrackConstraint *data = con->data; + return data->tar; + } + break; + case CONSTRAINT_TYPE_FOLLOWPATH: + { + bFollowPathConstraint *data = con->data; + return data->tar; + } + break; + } + + return NULL; +} + void unique_constraint_name (bConstraint *con, ListBase *list){ char tempname[64]; int number; @@ -428,7 +483,7 @@ void rebuild_all_armature_displists(void) { } } -short get_constraint_target (bConstraint *con, short ownertype, void* ownerdata, float mat[][4], float size[3], float ctime) +short get_constraint_target_matrix (bConstraint *con, short ownertype, void* ownerdata, float mat[][4], float size[3], float ctime) { short valid=0; @@ -701,6 +756,14 @@ void relink_constraints (struct ListBase *list) ID_NEW(data->tar); } break; + case CONSTRAINT_TYPE_LOCKTRACK: + { + bLockTrackConstraint *data; + data = con->data; + + ID_NEW(data->tar); + } + break; case CONSTRAINT_TYPE_ACTION: { bActionConstraint *data; @@ -725,6 +788,14 @@ void relink_constraints (struct ListBase *list) ID_NEW(data->tar); } break; + case CONSTRAINT_TYPE_FOLLOWPATH: + { + bFollowPathConstraint *data; + data = con->data; + + ID_NEW(data->tar); + } + break; } } } @@ -812,6 +883,14 @@ void copy_constraints (ListBase *dst, ListBase *src) data = (bTrackToConstraint*) con->data; } break; + case CONSTRAINT_TYPE_LOCKTRACK: + { + bLockTrackConstraint *data; + + con->data = MEM_dupallocN (con->data); + data = (bLockTrackConstraint*) con->data; + } + break; case CONSTRAINT_TYPE_KINEMATIC: { bKinematicConstraint *data; @@ -820,6 +899,14 @@ void copy_constraints (ListBase *dst, ListBase *src) data = (bKinematicConstraint*) con->data; } break; + case CONSTRAINT_TYPE_FOLLOWPATH: + { + bFollowPathConstraint *data; + + con->data = MEM_dupallocN (con->data); + data = (bFollowPathConstraint*) con->data; + } + break; default: con->data = MEM_dupallocN (con->data); break; @@ -1134,7 +1221,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype, Crossf(totmat[2], totmat[0], totmat[1]); } break; - case TRACK_Y: /* LOCK Y TRACK Z */ + case TRACK_Z: /* LOCK Y TRACK Z */ { /* Projection of Vector on the plane */ Projf(vec2, vec, ob->obmat[1]); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 99a7c577b12..d1f6da37a7c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1491,7 +1491,7 @@ void solve_constraints (Object *ob, short obtype, void *obdata, float ctime) enf = con->enforce; /* Get the targetmat */ - get_constraint_target(con, obtype, obdata, tmat, size, ctime); + get_constraint_target_matrix(con, obtype, obdata, tmat, size, ctime); Mat4CpyMat4(focusmat, tmat); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 34d6ea65a92..7cf90e92673 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -241,43 +241,8 @@ void sort_baselist(Scene *sce) { bConstraint *con; for (con = base->object->constraints.first; con; con=con->next){ - switch (con->type){ - case CONSTRAINT_TYPE_KINEMATIC: - { - bKinematicConstraint *data=con->data; - if (data->tar) doit++; - } - break; - case CONSTRAINT_TYPE_TRACKTO: - { - bTrackToConstraint *data=con->data; - if (data->tar) doit++; - } - break; - case CONSTRAINT_TYPE_NULL: - break; - case CONSTRAINT_TYPE_ROTLIKE: - { - bRotateLikeConstraint *data=con->data; - if (data->tar) doit++; - - } - break; - case CONSTRAINT_TYPE_LOCLIKE: - { - bLocateLikeConstraint *data=con->data; - if (data->tar) doit++; - } - break; - case CONSTRAINT_TYPE_ACTION: - { - bActionConstraint *data=con->data; - if (data->tar) doit++; - } - break; - default: - break; - } + if (constraint_has_target(con)) + doit++; } } @@ -294,43 +259,8 @@ void sort_baselist(Scene *sce) { bConstraint *con; for (con = base->object->constraints.first; con; con=con->next){ - switch (con->type){ - case CONSTRAINT_TYPE_KINEMATIC: - { - bKinematicConstraint *data=con->data; - if (test->object == data->tar && test->object!=base->object) doit--; - } - break; - case CONSTRAINT_TYPE_TRACKTO: - { - bTrackToConstraint *data=con->data; - if (test->object == data->tar && test->object!=base->object) doit--; - } - break; - case CONSTRAINT_TYPE_NULL: - break; - case CONSTRAINT_TYPE_ROTLIKE: - { - bRotateLikeConstraint *data=con->data; - if (test->object == data->tar && test->object!=base->object) doit--; - - } - break; - case CONSTRAINT_TYPE_LOCLIKE: - { - bLocateLikeConstraint *data=con->data; - if (test->object == data->tar && test->object!=base->object) doit--; - } - break; - case CONSTRAINT_TYPE_ACTION: - { - bActionConstraint *data=con->data; - if (test->object == data->tar && test->object!=base->object) doit--; - } - break; - default: - break; - } + if (test->object == get_constraint_target(con) && test->object!=base->object) + doit--; } } |