[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11285] branches/pyapi_devel/source: * Added constructors to library data (tp_new) so the python types can be called to construct a new instance.
Campbell Barton
cbarton at metavr.com
Mon Jul 16 07:17:40 CEST 2007
Revision: 11285
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11285
Author: campbellbarton
Date: 2007-07-16 07:17:39 +0200 (Mon, 16 Jul 2007)
Log Message:
-----------
* Added constructors to library data (tp_new) so the python types can be called to construct a new instance. This is how python works.
* Foo_FromPyObject - made into #define rather then functions
* made Object use vectors for location and scale
* fixed some mistakes in softbody.
Modified Paths:
--------------
branches/pyapi_devel/source/blender/blenkernel/BKE_blender.h
branches/pyapi_devel/source/blender/blenkernel/BKE_constraint.h
branches/pyapi_devel/source/blender/blenkernel/BKE_object.h
branches/pyapi_devel/source/blender/blenkernel/bad_level_call_stubs/stubs.c
branches/pyapi_devel/source/blender/blenkernel/intern/action.c
branches/pyapi_devel/source/blender/blenkernel/intern/armature.c
branches/pyapi_devel/source/blender/blenkernel/intern/constraint.c
branches/pyapi_devel/source/blender/blenkernel/intern/object.c
branches/pyapi_devel/source/blender/blenlib/BLI_arithb.h
branches/pyapi_devel/source/blender/blenlib/intern/arithb.c
branches/pyapi_devel/source/blender/blenloader/intern/readfile.c
branches/pyapi_devel/source/blender/blenloader/intern/writefile.c
branches/pyapi_devel/source/blender/makesdna/DNA_action_types.h
branches/pyapi_devel/source/blender/makesdna/DNA_constraint_types.h
branches/pyapi_devel/source/blender/makesdna/DNA_object_types.h
branches/pyapi_devel/source/blender/python/BPY_extern.h
branches/pyapi_devel/source/blender/python/BPY_interface.c
branches/pyapi_devel/source/blender/python/SConscript
branches/pyapi_devel/source/blender/python/api2_2x/Armature.c
branches/pyapi_devel/source/blender/python/api2_2x/Armature.h
branches/pyapi_devel/source/blender/python/api2_2x/BezTriple.c
branches/pyapi_devel/source/blender/python/api2_2x/BezTriple.h
branches/pyapi_devel/source/blender/python/api2_2x/Blender.c
branches/pyapi_devel/source/blender/python/api2_2x/Camera.c
branches/pyapi_devel/source/blender/python/api2_2x/Camera.h
branches/pyapi_devel/source/blender/python/api2_2x/Constraint.c
branches/pyapi_devel/source/blender/python/api2_2x/Constraint.h
branches/pyapi_devel/source/blender/python/api2_2x/CurNurb.h
branches/pyapi_devel/source/blender/python/api2_2x/Curve.c
branches/pyapi_devel/source/blender/python/api2_2x/Curve.h
branches/pyapi_devel/source/blender/python/api2_2x/Font.c
branches/pyapi_devel/source/blender/python/api2_2x/Font.h
branches/pyapi_devel/source/blender/python/api2_2x/Group.c
branches/pyapi_devel/source/blender/python/api2_2x/Group.h
branches/pyapi_devel/source/blender/python/api2_2x/Image.c
branches/pyapi_devel/source/blender/python/api2_2x/Image.h
branches/pyapi_devel/source/blender/python/api2_2x/Ipo.c
branches/pyapi_devel/source/blender/python/api2_2x/Ipo.h
branches/pyapi_devel/source/blender/python/api2_2x/Ipocurve.c
branches/pyapi_devel/source/blender/python/api2_2x/Ipocurve.h
branches/pyapi_devel/source/blender/python/api2_2x/Lamp.c
branches/pyapi_devel/source/blender/python/api2_2x/Lamp.h
branches/pyapi_devel/source/blender/python/api2_2x/Lattice.c
branches/pyapi_devel/source/blender/python/api2_2x/Lattice.h
branches/pyapi_devel/source/blender/python/api2_2x/MTex.c
branches/pyapi_devel/source/blender/python/api2_2x/MTex.h
branches/pyapi_devel/source/blender/python/api2_2x/Material.c
branches/pyapi_devel/source/blender/python/api2_2x/Material.h
branches/pyapi_devel/source/blender/python/api2_2x/Mesh.c
branches/pyapi_devel/source/blender/python/api2_2x/Metaball.c
branches/pyapi_devel/source/blender/python/api2_2x/Metaball.h
branches/pyapi_devel/source/blender/python/api2_2x/Modifier.c
branches/pyapi_devel/source/blender/python/api2_2x/Modifier.h
branches/pyapi_devel/source/blender/python/api2_2x/NLA.c
branches/pyapi_devel/source/blender/python/api2_2x/NLA.h
branches/pyapi_devel/source/blender/python/api2_2x/Object.c
branches/pyapi_devel/source/blender/python/api2_2x/Object.h
branches/pyapi_devel/source/blender/python/api2_2x/Scene.c
branches/pyapi_devel/source/blender/python/api2_2x/Scene.h
branches/pyapi_devel/source/blender/python/api2_2x/Sound.c
branches/pyapi_devel/source/blender/python/api2_2x/Sound.h
branches/pyapi_devel/source/blender/python/api2_2x/SurfNurb.h
branches/pyapi_devel/source/blender/python/api2_2x/Text.c
branches/pyapi_devel/source/blender/python/api2_2x/Text3d.c
branches/pyapi_devel/source/blender/python/api2_2x/Text3d.h
branches/pyapi_devel/source/blender/python/api2_2x/Texture.c
branches/pyapi_devel/source/blender/python/api2_2x/Texture.h
branches/pyapi_devel/source/blender/python/api2_2x/World.c
branches/pyapi_devel/source/blender/python/api2_2x/World.h
branches/pyapi_devel/source/blender/python/api2_2x/bpy.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_data.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_data.h
branches/pyapi_devel/source/blender/python/api2_2x/bpy_types.h
branches/pyapi_devel/source/blender/python/api2_2x/euler.c
branches/pyapi_devel/source/blender/python/api2_2x/logic.c
branches/pyapi_devel/source/blender/python/api2_2x/logic.h
branches/pyapi_devel/source/blender/python/api2_2x/object_softbody.c
branches/pyapi_devel/source/blender/python/api2_2x/sceneSequence.c
branches/pyapi_devel/source/blender/python/api2_2x/sceneSequence.h
branches/pyapi_devel/source/blender/python/api2_2x/sceneTimeLine.h
branches/pyapi_devel/source/blender/python/api2_2x/vector.c
branches/pyapi_devel/source/blender/python/api2_2x/vector.h
branches/pyapi_devel/source/blender/src/buttons_editing.c
branches/pyapi_devel/source/blender/src/buttons_object.c
branches/pyapi_devel/source/blender/src/drawobject.c
branches/pyapi_devel/source/blender/src/drawview.c
branches/pyapi_devel/source/blender/src/editconstraint.c
branches/pyapi_devel/source/blender/src/editobject.c
branches/pyapi_devel/source/blender/src/transform_conversions.c
branches/pyapi_devel/source/creator/creator.c
Added Paths:
-----------
branches/pyapi_devel/source/blender/python/api2_2x/bpy_types.c
Removed Paths:
-------------
branches/pyapi_devel/source/blender/python/api2_2x/bpy_class.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_class.h
Modified: branches/pyapi_devel/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/pyapi_devel/source/blender/blenkernel/BKE_blender.h 2007-07-16 02:52:15 UTC (rev 11284)
+++ branches/pyapi_devel/source/blender/blenkernel/BKE_blender.h 2007-07-16 05:17:39 UTC (rev 11285)
@@ -44,7 +44,7 @@
struct MemFile;
#define BLENDER_VERSION 244
-#define BLENDER_SUBVERSION 2
+#define BLENDER_SUBVERSION 3
#define BLENDER_MINVERSION 240
#define BLENDER_MINSUBVERSION 0
Modified: branches/pyapi_devel/source/blender/blenkernel/BKE_constraint.h
===================================================================
--- branches/pyapi_devel/source/blender/blenkernel/BKE_constraint.h 2007-07-16 02:52:15 UTC (rev 11284)
+++ branches/pyapi_devel/source/blender/blenkernel/BKE_constraint.h 2007-07-16 05:17:39 UTC (rev 11285)
@@ -33,43 +33,66 @@
#ifndef BKE_CONSTRAINT_H
#define BKE_CONSTRAINT_H
+
struct bConstraint;
+struct ListBase;
struct Object;
-struct ListBase;
struct bConstraintChannel;
+struct bPoseChannel;
struct bAction;
struct bArmature;
-/* Function prototypes */
+/* ---------------------------------------------------------------------------- */
+
+/* Constraint target/owner types */
+#define TARGET_OBJECT 1 /* string is "" */
+#define TARGET_BONE 2 /* string is bone-name */
+#define TARGET_VERT 3 /* string is vertex-group name */
+#define TARGET_CV 4 /* string is vertex-group name - is not available until curves get vgroups */
+
+/* ---------------------------------------------------------------------------- */
+
+/* special struct for use in constraint evaluation */
+typedef struct bConstraintOb {
+ struct Object *ob; /* if pchan, then armature that it comes from, otherwise constraint owner */
+ struct bPoseChannel *pchan; /* pose channel that owns the constraints being evaluated */
+
+ float matrix[4][4]; /* matrix where constraints are accumulated + solved */
+ float startmat[4][4]; /* original matrix (before constraint solving) */
+
+ short type; /* type of owner */
+} bConstraintOb;
+
+/* ---------------------------------------------------------------------------- */
+
+/* Constraint function prototypes */
void unique_constraint_name (struct bConstraint *con, struct ListBase *list);
void *new_constraint_data (short type);
-void evaluate_constraint (struct bConstraint *constraint, struct Object *ob, short ownertype, void *ownerdata, float targetmat[][4]);
void free_constraints (struct ListBase *conlist);
void copy_constraints (struct ListBase *dst, struct ListBase *src);
-void copy_constraint_channels (ListBase *dst, ListBase *src);
-void clone_constraint_channels (struct ListBase *dst, struct ListBase *src);
void relink_constraints (struct ListBase *list);
void free_constraint_data (struct bConstraint *con);
-/* channels */
+/* Constraint Channel function prototypes */
struct bConstraintChannel *get_constraint_channel (ListBase *list, const char *name);
struct bConstraintChannel *verify_constraint_channel (ListBase *list, const char *name);
+void do_constraint_channels (struct ListBase *conbase, struct ListBase *chanbase, float ctime);
+void copy_constraint_channels (ListBase *dst, ListBase *src);
+void clone_constraint_channels (struct ListBase *dst, struct ListBase *src);
void free_constraint_channels (ListBase *chanbase);
-/* Gemeric functions */
-void do_constraint_channels (struct ListBase *conbase, struct ListBase *chanbase, float ctime);
-short get_constraint_target_matrix (struct bConstraint *con, short ownertype, void *ownerdata, float mat[][4], float size[3], float time);
+/* Target function prototypes */
char constraint_has_target (struct bConstraint *con);
struct Object *get_constraint_target(struct bConstraint *con, char **subtarget);
void set_constraint_target(struct bConstraint *con, struct Object *ob, char *subtarget);
+/* Constraint Evaluation function prototypes */
+struct bConstraintOb *constraints_make_evalob (struct Object *ob, void *subdata, short datatype);
+void constraints_clear_evalob(struct bConstraintOb *cob);
-/* Constraint target/owner types */
-#define TARGET_OBJECT 1 // string is ""
-#define TARGET_BONE 2 // string is bone-name
-#define TARGET_VERT 3 // string is "VE:#"
-#define TARGET_FACE 4 // string is "FA:#"
-#define TARGET_CV 5 // string is "CV:#"
+short get_constraint_target_matrix (struct bConstraint *con, short ownertype, void *ownerdata, float mat[][4], float time);
+void solve_constraints (struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
+
#endif
Modified: branches/pyapi_devel/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/pyapi_devel/source/blender/blenkernel/BKE_object.h 2007-07-16 02:52:15 UTC (rev 11284)
+++ branches/pyapi_devel/source/blender/blenkernel/BKE_object.h 2007-07-16 05:17:39 UTC (rev 11285)
@@ -104,7 +104,6 @@
void minmax_object(struct Object *ob, float *min, float *max);
void minmax_object_duplis(struct Object *ob, float *min, float *max);
void solve_tracking (struct Object *ob, float targetmat[][4]);
-void solve_constraints (struct Object *ob, short obtype, void *obdata, float ctime);
void object_handle_update(struct Object *ob);
Modified: branches/pyapi_devel/source/blender/blenkernel/bad_level_call_stubs/stubs.c
===================================================================
--- branches/pyapi_devel/source/blender/blenkernel/bad_level_call_stubs/stubs.c 2007-07-16 02:52:15 UTC (rev 11284)
+++ branches/pyapi_devel/source/blender/blenkernel/bad_level_call_stubs/stubs.c 2007-07-16 05:17:39 UTC (rev 11285)
@@ -126,7 +126,7 @@
}
/* constraint.c */
-void BPY_pyconstraint_eval(struct bPythonConstraint *con, float obmat[][4], short ownertype, void *ownerdata, float targetmat[][4])
+void BPY_pyconstraint_eval(struct bPythonConstraint *con, float ownermat[][4], float targetmat[][4])
{
}
int BPY_pyconstraint_targets(struct bPythonConstraint *con, float targetmat[][4])
Modified: branches/pyapi_devel/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/pyapi_devel/source/blender/blenkernel/intern/action.c 2007-07-16 02:52:15 UTC (rev 11284)
+++ branches/pyapi_devel/source/blender/blenkernel/intern/action.c 2007-07-16 05:17:39 UTC (rev 11285)
@@ -225,12 +225,12 @@
{
bPoseChannel *chan;
- if (!pose){
+ if (!pose) {
return NULL;
}
/* See if this channel exists */
- for (chan=pose->chanbase.first; chan; chan=chan->next){
+ for (chan=pose->chanbase.first; chan; chan=chan->next) {
if (!strcmp (name, chan->name))
return chan;
}
@@ -239,7 +239,7 @@
chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel");
strncpy (chan->name, name, 31);
- /* init vars to prevent mat errors */
+ /* init vars to prevent math errors */
chan->quat[0] = 1.0F;
chan->size[0] = chan->size[1] = chan->size[2] = 1.0F;
@@ -247,6 +247,8 @@
chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f;
chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f;
+ Mat4One(chan->constinv);
+
BLI_addtail (&pose->chanbase, chan);
return chan;
Modified: branches/pyapi_devel/source/blender/blenkernel/intern/armature.c
===================================================================
--- branches/pyapi_devel/source/blender/blenkernel/intern/armature.c 2007-07-16 02:52:15 UTC (rev 11284)
+++ branches/pyapi_devel/source/blender/blenkernel/intern/armature.c 2007-07-16 05:17:39 UTC (rev 11285)
@@ -1321,7 +1321,7 @@
float goalrot[3][3], goalpos[3];
float rootmat[4][4], imat[4][4];
float goal[4][4], goalinv[4][4];
- float size[3], irest_basis[3][3], full_basis[3][3];
+ float irest_basis[3][3], full_basis[3][3];
float end_pose[4][4], world_pose[4][4];
float length, basis[3][3], rest_basis[3][3], start[3], *ikstretch=NULL;
int a, flag, hasstretch=0;
@@ -1444,7 +1444,7 @@
data= (bKinematicConstraint*)target->con->data;
/* 1.0=ctime, we pass on object for auto-ik */
- get_constraint_target_matrix(target->con, TARGET_BONE, ob, rootmat, size, 1.0);
+ get_constraint_target_matrix(target->con, TARGET_BONE, ob, rootmat, 1.0);
/* and set and transform goal */
Mat4MulMat4(goal, rootmat, goalinv);
@@ -1603,211 +1603,7 @@
pchan->flag |= POSE_DONE;
}
-static void do_local_constraint(bPoseChannel *pchan, bConstraint *con)
-{
- switch(con->type) {
- case CONSTRAINT_TYPE_LOCLIKE:
- {
- bLocateLikeConstraint *data= con->data;
- float fac= con->enforce;
-
- if(data->tar && data->subtarget[0]) {
- bPoseChannel *pchant= get_pose_channel(data->tar->pose, data->subtarget);
- if(pchant) {
- float loc[3];
-
- /* copy location of tip of bone? */
- if (data->flag & LOCLIKE_TIP) {
- float mat[4][4], tmat[4][4];
-
- Mat4One(tmat);
- VECCOPY(tmat[3], pchant->pose_tail);
-
- armature_mat_pose_to_delta(mat, tmat, pchant->bone->arm_mat);
- VECCOPY(loc, mat[3]);
- }
- else
- VECCOPY(loc, pchant->loc);
-
- /* do offsets? */
- if (data->flag & LOCLIKE_OFFSET)
- VecAddf(loc, loc, pchan->loc);
-
- if (data->flag & LOCLIKE_X)
- pchan->loc[0]= FloatLerpf(loc[0], pchan->loc[0], fac);
- if (data->flag & LOCLIKE_Y)
- pchan->loc[1]= FloatLerpf(loc[1], pchan->loc[1], fac);
- if (data->flag & LOCLIKE_Z)
- pchan->loc[2]= FloatLerpf(loc[2], pchan->loc[2], fac);
- if (data->flag & LOCLIKE_X_INVERT)
- pchan->loc[0]= FloatLerpf(pchant->loc[0], pchan->loc[0], -fac);
- if (data->flag & LOCLIKE_Y_INVERT)
- pchan->loc[1]= FloatLerpf(pchant->loc[1], pchan->loc[1], -fac);
- if (data->flag & LOCLIKE_Z_INVERT)
- pchan->loc[2]= FloatLerpf(pchant->loc[2], pchan->loc[2], -fac);
- }
- }
- }
- break;
- case CONSTRAINT_TYPE_ROTLIKE:
- {
- bRotateLikeConstraint *data= con->data;
- if(data->tar && data->subtarget[0]) {
- bPoseChannel *pchant= get_pose_channel(data->tar->pose, data->subtarget);
- if(pchant) {
- if(data->flag != (ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z)) {
- float eul[3], eult[3], euln[3];
- float fac= con->enforce;
-
- QuatToEul(pchan->quat, eul);
- QuatToEul(pchant->quat, eult);
- VECCOPY(euln, eul);
-
- if(data->flag & ROTLIKE_X) euln[0]= FloatLerpf(eult[0], eul[0], fac);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list