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:
authorMitchell Stokes <mogurijin@gmail.com>2011-07-29 10:32:30 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-07-29 10:32:30 +0400
commitb46d8955509e805f06b76a6fd800ecb4edee113b (patch)
tree7ed0b1a3b5d04ab48d3e9062ff02ce54961ecb06 /source/blender/blenkernel/intern/object.c
parent6960127d2609620d52620539388ada5cb466bab2 (diff)
parent26589497529ca3c8da85391d4976d286a371e258 (diff)
Merging r36529-38806bge_components
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c166
1 files changed, 111 insertions, 55 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 79a4e6443d2..48c1c2b9b6e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -869,11 +869,32 @@ Lamp *copy_lamp(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
-#if 0 // XXX old animation system
- id_us_plus((ID *)lan->ipo);
-#endif // XXX old animation system
+ if(la->preview)
+ lan->preview = BKE_previewimg_copy(la->preview);
+
+ return lan;
+}
+
+Lamp *localize_lamp(Lamp *la)
+{
+ Lamp *lan;
+ int a;
+
+ lan= copy_libblock(la);
+ BLI_remlink(&G.main->lamp, lan);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ if(lan->mtex[a]) {
+ lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
+ memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
+ /* free lamp decrements */
+ id_us_plus((ID *)lan->mtex[a]->tex);
+ }
+ }
+
+ lan->curfalloff = curvemapping_copy(la->curfalloff);
- if (la->preview) lan->preview = BKE_previewimg_copy(la->preview);
+ lan->preview= NULL;
return lan;
}
@@ -1630,12 +1651,6 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
/* there is also a timing calculation in drawobject() */
-static int no_speed_curve= 0;
-
-void disable_speed_curve(int val)
-{
- no_speed_curve= val;
-}
// XXX THIS CRUFT NEEDS SERIOUS RECODING ASAP!
/* ob can be NULL */
@@ -1673,21 +1688,20 @@ void object_rot_to_mat3(Object *ob, float mat[][3])
{
float rmat[3][3], dmat[3][3];
- /* initialise the delta-rotation matrix, which will get (pre)multiplied
+ /* 'dmat' is the delta-rotation matrix, which will get (pre)multiplied
* with the rotation matrix to yield the appropriate rotation
*/
- unit_m3(dmat);
-
+
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (ob->rotmode > 0) {
/* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
- eulO_to_mat3( rmat,ob->rot, ob->rotmode);
- eulO_to_mat3( dmat,ob->drot, ob->rotmode);
+ eulO_to_mat3(rmat, ob->rot, ob->rotmode);
+ eulO_to_mat3(dmat, ob->drot, ob->rotmode);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
/* axis-angle - not really that great for 3D-changing orientations */
- axis_angle_to_mat3( rmat,ob->rotAxis, ob->rotAngle);
- axis_angle_to_mat3( dmat,ob->drotAxis, ob->drotAngle);
+ axis_angle_to_mat3(rmat, ob->rotAxis, ob->rotAngle);
+ axis_angle_to_mat3(dmat, ob->drotAxis, ob->drotAngle);
}
else {
/* quats are normalised before use to eliminate scaling issues */
@@ -1722,9 +1736,22 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
ob->rotAngle -= ob->drotAngle;
break;
default: /* euler */
- if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, mat);
- else mat3_to_eulO(ob->rot, ob->rotmode, mat);
- sub_v3_v3(ob->rot, ob->drot);
+ {
+ float quat[4];
+ float dquat[4];
+ float tmat[3][3];
+
+ /* without drot we could apply 'mat' directly */
+ mat3_to_quat(quat, mat);
+ eulO_to_quat(dquat, ob->drot, ob->rotmode);
+ invert_qt(dquat);
+ mul_qt_qtqt(quat, dquat, quat);
+ quat_to_mat3(tmat, quat);
+ /* end drot correction */
+
+ if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
+ else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
+ }
}
}
@@ -1740,7 +1767,7 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */
object_apply_mat4(ob, rmat, use_compat, FALSE);
- /* same as below, use rmat rather then mat */
+ /* same as below, use rmat rather than mat */
mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat);
object_mat3_to_rot(ob, rot, use_compat);
}
@@ -1916,9 +1943,10 @@ static void give_parvert(Object *par, int nr, float *vec)
if(dm) {
MVert *mvert= dm->getVertArray(dm);
int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX);
- int i, count = 0, vindex, numVerts = dm->getNumVerts(dm);
+ int i, vindex, numVerts = dm->getNumVerts(dm);
/* get the average of all verts with (original index == nr) */
+ count= 0;
for(i = 0; i < numVerts; i++) {
vindex= (index)? index[i]: i;
@@ -2362,24 +2390,42 @@ void object_set_dimensions(Object *ob, const float *value)
void minmax_object(Object *ob, float *min, float *max)
{
BoundBox bb;
- Mesh *me;
- Curve *cu;
float vec[3];
int a;
+ short change= FALSE;
switch(ob->type) {
-
case OB_CURVE:
case OB_FONT:
case OB_SURF:
- cu= ob->data;
-
- if(cu->bb==NULL) tex_space_curve(cu);
- bb= *(cu->bb);
-
- for(a=0; a<8; a++) {
- mul_m4_v3(ob->obmat, bb.vec[a]);
- DO_MINMAX(bb.vec[a], min, max);
+ {
+ Curve *cu= ob->data;
+
+ if(cu->bb==NULL) tex_space_curve(cu);
+ bb= *(cu->bb);
+
+ for(a=0; a<8; a++) {
+ mul_m4_v3(ob->obmat, bb.vec[a]);
+ DO_MINMAX(bb.vec[a], min, max);
+ }
+ change= TRUE;
+ }
+ break;
+ case OB_LATTICE:
+ {
+ Lattice *lt= ob->data;
+ BPoint *bp= lt->def;
+ int u, v, w;
+
+ for(w=0; w<lt->pntsw; w++) {
+ for(v=0; v<lt->pntsv; v++) {
+ for(u=0; u<lt->pntsu; u++, bp++) {
+ mul_v3_m4v3(vec, ob->obmat, bp->vec);
+ DO_MINMAX(vec, min, max);
+ }
+ }
+ }
+ change= TRUE;
}
break;
case OB_ARMATURE:
@@ -2391,25 +2437,27 @@ void minmax_object(Object *ob, float *min, float *max)
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
DO_MINMAX(vec, min, max);
}
- break;
+ change= TRUE;
}
- /* no break, get_mesh will give NULL and it passes on to default */
+ break;
case OB_MESH:
- me= get_mesh(ob);
-
- if(me) {
- bb = *mesh_get_bb(ob);
-
- for(a=0; a<8; a++) {
- mul_m4_v3(ob->obmat, bb.vec[a]);
- DO_MINMAX(bb.vec[a], min, max);
+ {
+ Mesh *me= get_mesh(ob);
+
+ if(me) {
+ bb = *mesh_get_bb(ob);
+
+ for(a=0; a<8; a++) {
+ mul_m4_v3(ob->obmat, bb.vec[a]);
+ DO_MINMAX(bb.vec[a], min, max);
+ }
+ change= TRUE;
}
}
- if(min[0] < max[0] ) break;
-
- /* else here no break!!!, mesh can be zero sized */
-
- default:
+ break;
+ }
+
+ if(change == FALSE) {
DO_MINMAX(ob->obmat[3], min, max);
copy_v3_v3(vec, ob->obmat[3]);
@@ -2419,7 +2467,6 @@ void minmax_object(Object *ob, float *min, float *max)
copy_v3_v3(vec, ob->obmat[3]);
sub_v3_v3(vec, ob->size);
DO_MINMAX(vec, min, max);
- break;
}
}
@@ -2597,11 +2644,12 @@ void object_handle_update(Scene *scene, Object *ob)
#else /* ensure CD_MASK_BAREMESH for now */
EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
+ unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
if(em) {
- makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */
BKE_mesh_end_editmesh(ob->data, em);
} else
- makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH);
+ makeDerivedMesh(scene, ob, NULL, data_mask);
#endif
}
@@ -3012,9 +3060,14 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
if(newkey || from_mix==FALSE) {
kb= add_keyblock(key, name);
-
- /* create from lattice */
- latt_to_key(lt, kb);
+ if (!newkey) {
+ KeyBlock *basekb= (KeyBlock *)key->block.first;
+ kb->data= MEM_dupallocN(basekb->data);
+ kb->totelem= basekb->totelem;
+ }
+ else {
+ latt_to_key(lt, kb);
+ }
}
else {
/* copy from current values */
@@ -3050,7 +3103,10 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
KeyBlock *basekb= (KeyBlock *)key->block.first;
kb->data= MEM_dupallocN(basekb->data);
kb->totelem= basekb->totelem;
- } else curve_to_key(cu, kb, lb);
+ }
+ else {
+ curve_to_key(cu, kb, lb);
+ }
}
else {
/* copy from current values */