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:
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c1422
1 files changed, 711 insertions, 711 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1057b027d1b..bf279040760 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -115,26 +115,26 @@
#include "GPU_material.h"
/* Local function protos */
-static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
+static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
-float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
+float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
void BKE_object_workob_clear(Object *workob)
{
memset(workob, 0, sizeof(Object));
- workob->size[0]= workob->size[1]= workob->size[2]= 1.0f;
- workob->dscale[0]= workob->dscale[1]= workob->dscale[2]= 1.0f;
- workob->rotmode= ROT_MODE_EUL;
+ workob->size[0] = workob->size[1] = workob->size[2] = 1.0f;
+ workob->dscale[0] = workob->dscale[1] = workob->dscale[2] = 1.0f;
+ workob->rotmode = ROT_MODE_EUL;
}
void BKE_object_update_base_layer(struct Scene *scene, Object *ob)
{
- Base *base= scene->base.first;
+ Base *base = scene->base.first;
while (base) {
- if (base->object == ob) base->lay= ob->lay;
- base= base->next;
+ if (base->object == ob) base->lay = ob->lay;
+ base = base->next;
}
}
@@ -153,7 +153,7 @@ void BKE_object_free_softbody(Object *ob)
{
if (ob->soft) {
sbFree(ob->soft);
- ob->soft= NULL;
+ ob->soft = NULL;
}
}
@@ -161,7 +161,7 @@ void BKE_object_free_bulletsoftbody(Object *ob)
{
if (ob->bsoft) {
bsbFree(ob->bsoft);
- ob->bsoft= NULL;
+ ob->bsoft = NULL;
}
}
@@ -189,9 +189,9 @@ int BKE_object_support_modifier_type_check(Object *ob, int modifier_type)
mti = modifierType_getInfo(modifier_type);
if (!((mti->flags & eModifierTypeFlag_AcceptsCVs) ||
- (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh))))
+ (ob->type == OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh))))
{
- return FALSE;
+ return FALSE;
}
return TRUE;
@@ -208,7 +208,7 @@ void BKE_object_link_modifiers(struct Object *ob, struct Object *from)
return;
}
- for (md=from->modifiers.first; md; md=md->next) {
+ for (md = from->modifiers.first; md; md = md->next) {
ModifierData *nmd = NULL;
if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue;
@@ -234,12 +234,12 @@ void BKE_object_free_display(Object *ob)
if (ob->derivedDeform) {
ob->derivedDeform->needsFree = 1;
ob->derivedDeform->release(ob->derivedDeform);
- ob->derivedDeform= NULL;
+ ob->derivedDeform = NULL;
}
if (ob->derivedFinal) {
ob->derivedFinal->needsFree = 1;
ob->derivedFinal->release(ob->derivedFinal);
- ob->derivedFinal= NULL;
+ ob->derivedFinal = NULL;
}
freedisplist(&ob->disp);
@@ -260,12 +260,12 @@ void free_sculptsession(Object *ob)
{
if (ob && ob->sculpt) {
SculptSession *ss = ob->sculpt;
- DerivedMesh *dm= ob->derivedFinal;
+ DerivedMesh *dm = ob->derivedFinal;
if (ss->pbvh)
BLI_pbvh_free(ss->pbvh);
if (dm && dm->getPBVH)
- dm->getPBVH(NULL, dm); /* signal to clear */
+ dm->getPBVH(NULL, dm); /* signal to clear */
if (ss->texcache)
MEM_freeN(ss->texcache);
@@ -296,25 +296,25 @@ void BKE_object_free(Object *ob)
/* disconnect specific data */
if (ob->data) {
- ID *id= ob->data;
+ ID *id = ob->data;
id->us--;
- if (id->us==0) {
- if (ob->type==OB_MESH) BKE_mesh_unlink(ob->data);
- else if (ob->type==OB_CURVE) BKE_curve_unlink(ob->data);
- else if (ob->type==OB_MBALL) BKE_metaball_unlink(ob->data);
+ if (id->us == 0) {
+ if (ob->type == OB_MESH) BKE_mesh_unlink(ob->data);
+ else if (ob->type == OB_CURVE) BKE_curve_unlink(ob->data);
+ else if (ob->type == OB_MBALL) BKE_metaball_unlink(ob->data);
}
- ob->data= NULL;
+ ob->data = NULL;
}
- for (a=0; a<ob->totcol; a++) {
+ for (a = 0; a < ob->totcol; a++) {
if (ob->mat[a]) ob->mat[a]->id.us--;
}
if (ob->mat) MEM_freeN(ob->mat);
if (ob->matbits) MEM_freeN(ob->matbits);
- ob->mat= NULL;
- ob->matbits= NULL;
+ ob->mat = NULL;
+ ob->matbits = NULL;
if (ob->bb) MEM_freeN(ob->bb);
- ob->bb= NULL;
+ ob->bb = NULL;
if (ob->adt) BKE_free_animdata((ID *)ob);
if (ob->poselib) ob->poselib->id.us--;
if (ob->gpd) ((ID *)ob->gpd)->us--;
@@ -348,15 +348,15 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec
{
Object *unlinkOb = userData;
- if (*obpoin==unlinkOb) {
+ if (*obpoin == unlinkOb) {
*obpoin = NULL;
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA?
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA?
}
}
void BKE_object_unlink(Object *ob)
{
- Main *bmain= G.main;
+ Main *bmain = G.main;
Object *obt;
Material *mat;
World *wrld;
@@ -378,55 +378,55 @@ void BKE_object_unlink(Object *ob)
/* check all objects: parents en bevels and fields, also from libraries */
// FIXME: need to check all animation blocks (drivers)
- obt= bmain->object.first;
+ obt = bmain->object.first;
while (obt) {
- if (obt->proxy==ob)
- obt->proxy= NULL;
- if (obt->proxy_from==ob) {
- obt->proxy_from= NULL;
+ if (obt->proxy == ob)
+ obt->proxy = NULL;
+ if (obt->proxy_from == ob) {
+ obt->proxy_from = NULL;
obt->recalc |= OB_RECALC_OB;
}
- if (obt->proxy_group==ob)
- obt->proxy_group= NULL;
+ if (obt->proxy_group == ob)
+ obt->proxy_group = NULL;
- if (obt->parent==ob) {
- obt->parent= NULL;
- obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ if (obt->parent == ob) {
+ obt->parent = NULL;
+ obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
}
modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob);
if (ELEM(obt->type, OB_CURVE, OB_FONT)) {
- cu= obt->data;
+ cu = obt->data;
- if (cu->bevobj==ob) {
- cu->bevobj= NULL;
- obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ if (cu->bevobj == ob) {
+ cu->bevobj = NULL;
+ obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
}
- if (cu->taperobj==ob) {
- cu->taperobj= NULL;
- obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ if (cu->taperobj == ob) {
+ cu->taperobj = NULL;
+ obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
}
- if (cu->textoncurve==ob) {
- cu->textoncurve= NULL;
- obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ if (cu->textoncurve == ob) {
+ cu->textoncurve = NULL;
+ obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
}
}
- else if (obt->type==OB_ARMATURE && obt->pose) {
+ else if (obt->type == OB_ARMATURE && obt->pose) {
bPoseChannel *pchan;
- for (pchan= obt->pose->chanbase.first; pchan; pchan= pchan->next) {
- for (con = pchan->constraints.first; con; con=con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ for (pchan = obt->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (con = pchan->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == ob) {
ct->tar = NULL;
- ct->subtarget[0]= '\0';
+ ct->subtarget[0] = '\0';
obt->recalc |= OB_RECALC_DATA;
}
}
@@ -435,29 +435,29 @@ void BKE_object_unlink(Object *ob)
cti->flush_constraint_targets(con, &targets, 0);
}
}
- if (pchan->custom==ob)
- pchan->custom= NULL;
+ if (pchan->custom == ob)
+ pchan->custom = NULL;
}
}
else if (ELEM(OB_MBALL, ob->type, obt->type)) {
- if (BKE_metaball_is_basis_for (obt, ob))
- obt->recalc|= OB_RECALC_DATA;
+ if (BKE_metaball_is_basis_for(obt, ob))
+ obt->recalc |= OB_RECALC_DATA;
}
sca_remove_ob_poin(obt, ob);
- for (con = obt->constraints.first; con; con=con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ for (con = obt->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == ob) {
ct->tar = NULL;
- ct->subtarget[0]= '\0';
+ ct->subtarget[0] = '\0';
obt->recalc |= OB_RECALC_DATA;
}
}
@@ -473,73 +473,73 @@ void BKE_object_unlink(Object *ob)
obt->recalc |= OB_RECALC_DATA;
/* cloth */
- for (md=obt->modifiers.first; md; md=md->next)
+ for (md = obt->modifiers.first; md; md = md->next)
if (md->type == eModifierType_Cloth)
obt->recalc |= OB_RECALC_DATA;
}
/* strips */
#if 0 // XXX old animation system
- for (strip= obt->nlastrips.first; strip; strip= strip->next) {
- if (strip->object==ob)
- strip->object= NULL;
+ for (strip = obt->nlastrips.first; strip; strip = strip->next) {
+ if (strip->object == ob)
+ strip->object = NULL;
if (strip->modifiers.first) {
bActionModifier *amod;
- for (amod= strip->modifiers.first; amod; amod= amod->next)
- if (amod->ob==ob)
- amod->ob= NULL;
+ for (amod = strip->modifiers.first; amod; amod = amod->next)
+ if (amod->ob == ob)
+ amod->ob = NULL;
}
}
#endif // XXX old animation system
/* particle systems */
if (obt->particlesystem.first) {
- ParticleSystem *tpsys= obt->particlesystem.first;
- for (; tpsys; tpsys=tpsys->next) {
+ ParticleSystem *tpsys = obt->particlesystem.first;
+ for (; tpsys; tpsys = tpsys->next) {
BoidState *state = NULL;
BoidRule *rule = NULL;
ParticleTarget *pt = tpsys->targets.first;
- for (; pt; pt=pt->next) {
- if (pt->ob==ob) {
+ for (; pt; pt = pt->next) {
+ if (pt->ob == ob) {
pt->ob = NULL;
obt->recalc |= OB_RECALC_DATA;
break;
}
}
- if (tpsys->target_ob==ob) {
- tpsys->target_ob= NULL;
+ if (tpsys->target_ob == ob) {
+ tpsys->target_ob = NULL;
obt->recalc |= OB_RECALC_DATA;
}
- if (tpsys->part->dup_ob==ob)
- tpsys->part->dup_ob= NULL;
+ if (tpsys->part->dup_ob == ob)
+ tpsys->part->dup_ob = NULL;
- if (tpsys->part->phystype==PART_PHYS_BOIDS) {
+ if (tpsys->part->phystype == PART_PHYS_BOIDS) {
ParticleData *pa;
BoidParticle *bpa;
int p;
- for (p=0, pa=tpsys->particles; p<tpsys->totpart; p++, pa++) {
+ for (p = 0, pa = tpsys->particles; p < tpsys->totpart; p++, pa++) {
bpa = pa->boid;
if (bpa->ground == ob)
bpa->ground = NULL;
}
}
if (tpsys->part->boids) {
- for (state = tpsys->part->boids->states.first; state; state=state->next) {
- for (rule = state->rules.first; rule; rule=rule->next) {
- if (rule->type==eBoidRuleType_Avoid) {
- BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid*)rule;
- if (gabr->ob==ob)
- gabr->ob= NULL;
+ for (state = tpsys->part->boids->states.first; state; state = state->next) {
+ for (rule = state->rules.first; rule; rule = rule->next) {
+ if (rule->type == eBoidRuleType_Avoid) {
+ BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
+ if (gabr->ob == ob)
+ gabr->ob = NULL;
}
- else if (rule->type==eBoidRuleType_FollowLeader) {
- BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader*)rule;
- if (flbr->ob==ob)
- flbr->ob= NULL;
+ else if (rule->type == eBoidRuleType_FollowLeader) {
+ BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
+ if (flbr->ob == ob)
+ flbr->ob = NULL;
}
}
}
@@ -549,64 +549,64 @@ void BKE_object_unlink(Object *ob)
obt->recalc |= OB_RECALC_DATA;
}
- obt= obt->id.next;
+ obt = obt->id.next;
}
/* materials */
- mat= bmain->mat.first;
+ mat = bmain->mat.first;
while (mat) {
- for (a=0; a<MAX_MTEX; a++) {
- if (mat->mtex[a] && ob==mat->mtex[a]->object) {
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (mat->mtex[a] && ob == mat->mtex[a]->object) {
/* actually, test for lib here... to do */
- mat->mtex[a]->object= NULL;
+ mat->mtex[a]->object = NULL;
}
}
- mat= mat->id.next;
+ mat = mat->id.next;
}
/* textures */
- for (tex= bmain->tex.first; tex; tex= tex->id.next) {
- if (tex->env && (ob==tex->env->object)) tex->env->object= NULL;
- if (tex->pd && (ob==tex->pd->object)) tex->pd->object= NULL;
- if (tex->vd && (ob==tex->vd->object)) tex->vd->object= NULL;
+ for (tex = bmain->tex.first; tex; tex = tex->id.next) {
+ if (tex->env && (ob == tex->env->object)) tex->env->object = NULL;
+ if (tex->pd && (ob == tex->pd->object)) tex->pd->object = NULL;
+ if (tex->vd && (ob == tex->vd->object)) tex->vd->object = NULL;
}
/* worlds */
- wrld= bmain->world.first;
+ wrld = bmain->world.first;
while (wrld) {
- if (wrld->id.lib==NULL) {
- for (a=0; a<MAX_MTEX; a++) {
- if (wrld->mtex[a] && ob==wrld->mtex[a]->object)
- wrld->mtex[a]->object= NULL;
+ if (wrld->id.lib == NULL) {
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (wrld->mtex[a] && ob == wrld->mtex[a]->object)
+ wrld->mtex[a]->object = NULL;
}
}
- wrld= wrld->id.next;
+ wrld = wrld->id.next;
}
/* scenes */
- sce= bmain->scene.first;
+ sce = bmain->scene.first;
while (sce) {
- if (sce->id.lib==NULL) {
- if (sce->camera==ob) sce->camera= NULL;
- if (sce->toolsettings->skgen_template==ob) sce->toolsettings->skgen_template = NULL;
- if (sce->toolsettings->particle.object==ob) sce->toolsettings->particle.object= NULL;
+ if (sce->id.lib == NULL) {
+ if (sce->camera == ob) sce->camera = NULL;
+ if (sce->toolsettings->skgen_template == ob) sce->toolsettings->skgen_template = NULL;
+ if (sce->toolsettings->particle.object == ob) sce->toolsettings->particle.object = NULL;
#ifdef DURIAN_CAMERA_SWITCH
{
TimeMarker *m;
- for (m= sce->markers.first; m; m= m->next) {
- if (m->camera==ob)
- m->camera= NULL;
+ for (m = sce->markers.first; m; m = m->next) {
+ if (m->camera == ob)
+ m->camera = NULL;
}
}
#endif
if (sce->ed) {
Sequence *seq;
- SEQ_BEGIN (sce->ed, seq)
+ SEQ_BEGIN(sce->ed, seq)
{
if (seq->scene_camera == ob) {
seq->scene_camera = NULL;
@@ -616,19 +616,19 @@ void BKE_object_unlink(Object *ob)
}
}
- sce= sce->id.next;
+ sce = sce->id.next;
}
/* screens */
- sc= bmain->screen.first;
+ sc = bmain->screen.first;
while (sc) {
- ScrArea *sa= sc->areabase.first;
+ ScrArea *sa = sc->areabase.first;
while (sa) {
SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *) sl;
/* found doesn't need to be set here */
if (v3d->ob_centre == ob) {
@@ -640,74 +640,74 @@ void BKE_object_unlink(Object *ob)
v3d->localvd->ob_centre_bone[0] = '\0';
}
- found= 0;
- if (v3d->camera==ob) {
- v3d->camera= NULL;
- found= 1;
+ found = 0;
+ if (v3d->camera == ob) {
+ v3d->camera = NULL;
+ found = 1;
}
- if (v3d->localvd && v3d->localvd->camera==ob ) {
- v3d->localvd->camera= NULL;
+ if (v3d->localvd && v3d->localvd->camera == ob) {
+ v3d->localvd->camera = NULL;
found += 2;
}
if (found) {
if (sa->spacetype == SPACE_VIEW3D) {
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype==RGN_TYPE_WINDOW) {
- rv3d= (RegionView3D *)ar->regiondata;
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ rv3d = (RegionView3D *)ar->regiondata;
if (found == 1 || found == 3) {
if (rv3d->persp == RV3D_CAMOB)
- rv3d->persp= RV3D_PERSP;
+ rv3d->persp = RV3D_PERSP;
}
if (found == 2 || found == 3) {
if (rv3d->localvd && rv3d->localvd->persp == RV3D_CAMOB)
- rv3d->localvd->persp= RV3D_PERSP;
+ rv3d->localvd->persp = RV3D_PERSP;
}
}
}
}
}
}
- else if (sl->spacetype==SPACE_OUTLINER) {
- SpaceOops *so= (SpaceOops *)sl;
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOops *so = (SpaceOops *)sl;
if (so->treestore) {
- TreeStoreElem *tselem= so->treestore->data;
+ TreeStoreElem *tselem = so->treestore->data;
int a;
- for (a=0; a<so->treestore->usedelem; a++, tselem++) {
- if (tselem->id==(ID *)ob) tselem->id= NULL;
+ for (a = 0; a < so->treestore->usedelem; a++, tselem++) {
+ if (tselem->id == (ID *)ob) tselem->id = NULL;
}
}
}
- else if (sl->spacetype==SPACE_BUTS) {
- SpaceButs *sbuts= (SpaceButs *)sl;
+ else if (sl->spacetype == SPACE_BUTS) {
+ SpaceButs *sbuts = (SpaceButs *)sl;
- if (sbuts->pinid==(ID *)ob) {
- sbuts->flag&= ~SB_PIN_CONTEXT;
- sbuts->pinid= NULL;
+ if (sbuts->pinid == (ID *)ob) {
+ sbuts->flag &= ~SB_PIN_CONTEXT;
+ sbuts->pinid = NULL;
}
}
}
- sa= sa->next;
+ sa = sa->next;
}
- sc= sc->id.next;
+ sc = sc->id.next;
}
/* groups */
- group= bmain->group.first;
+ group = bmain->group.first;
while (group) {
rem_from_group(group, ob, NULL, NULL);
- group= group->id.next;
+ group = group->id.next;
}
/* cameras */
- camera= bmain->camera.first;
+ camera = bmain->camera.first;
while (camera) {
- if (camera->dof_ob==ob) {
+ if (camera->dof_ob == ob) {
camera->dof_ob = NULL;
}
- camera= camera->id.next;
+ camera = camera->id.next;
}
}
@@ -715,12 +715,12 @@ int BKE_object_exists_check(Object *obtest)
{
Object *ob;
- if (obtest==NULL) return 0;
+ if (obtest == NULL) return 0;
- ob= G.main->object.first;
+ ob = G.main->object.first;
while (ob) {
- if (ob==obtest) return 1;
- ob= ob->id.next;
+ if (ob == obtest) return 1;
+ ob = ob->id.next;
}
return 0;
}
@@ -730,40 +730,40 @@ int BKE_object_exists_check(Object *obtest)
void *BKE_object_obdata_add_from_type(int type)
{
switch (type) {
- case OB_MESH: return BKE_mesh_add("Mesh");
- case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE);
- case OB_SURF: return BKE_curve_add("Surf", OB_SURF);
- case OB_FONT: return BKE_curve_add("Text", OB_FONT);
- case OB_MBALL: return BKE_metaball_add("Meta");
- case OB_CAMERA: return BKE_camera_add("Camera");
- case OB_LAMP: return BKE_lamp_add("Lamp");
- case OB_LATTICE: return BKE_lattice_add("Lattice");
- case OB_ARMATURE: return BKE_armature_add("Armature");
- case OB_SPEAKER: return BKE_speaker_add("Speaker");
- case OB_EMPTY: return NULL;
- default:
- printf("BKE_object_obdata_add_from_type: Internal error, bad type: %d\n", type);
- return NULL;
+ case OB_MESH: return BKE_mesh_add("Mesh");
+ case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE);
+ case OB_SURF: return BKE_curve_add("Surf", OB_SURF);
+ case OB_FONT: return BKE_curve_add("Text", OB_FONT);
+ case OB_MBALL: return BKE_metaball_add("Meta");
+ case OB_CAMERA: return BKE_camera_add("Camera");
+ case OB_LAMP: return BKE_lamp_add("Lamp");
+ case OB_LATTICE: return BKE_lattice_add("Lattice");
+ case OB_ARMATURE: return BKE_armature_add("Armature");
+ case OB_SPEAKER: return BKE_speaker_add("Speaker");
+ case OB_EMPTY: return NULL;
+ default:
+ printf("BKE_object_obdata_add_from_type: Internal error, bad type: %d\n", type);
+ return NULL;
}
}
static const char *get_obdata_defname(int type)
{
switch (type) {
- case OB_MESH: return "Mesh";
- case OB_CURVE: return "Curve";
- case OB_SURF: return "Surf";
- case OB_FONT: return "Text";
- case OB_MBALL: return "Mball";
- case OB_CAMERA: return "Camera";
- case OB_LAMP: return "Lamp";
- case OB_LATTICE: return "Lattice";
- case OB_ARMATURE: return "Armature";
- case OB_SPEAKER: return "Speaker";
- case OB_EMPTY: return "Empty";
- default:
- printf("get_obdata_defname: Internal error, bad type: %d\n", type);
- return "Empty";
+ case OB_MESH: return "Mesh";
+ case OB_CURVE: return "Curve";
+ case OB_SURF: return "Surf";
+ case OB_FONT: return "Text";
+ case OB_MBALL: return "Mball";
+ case OB_CAMERA: return "Camera";
+ case OB_LAMP: return "Lamp";
+ case OB_LATTICE: return "Lattice";
+ case OB_ARMATURE: return "Armature";
+ case OB_SPEAKER: return "Speaker";
+ case OB_EMPTY: return "Empty";
+ default:
+ printf("get_obdata_defname: Internal error, bad type: %d\n", type);
+ return "Empty";
}
}
@@ -772,24 +772,24 @@ Object *BKE_object_add_only_object(int type, const char *name)
{
Object *ob;
- if(!name)
+ if (!name)
name = get_obdata_defname(type);
- ob= BKE_libblock_alloc(&G.main->object, ID_OB, name);
+ ob = BKE_libblock_alloc(&G.main->object, ID_OB, name);
/* default object vars */
- ob->type= type;
+ ob->type = type;
- ob->col[0]= ob->col[1]= ob->col[2]= 1.0;
- ob->col[3]= 1.0;
+ ob->col[0] = ob->col[1] = ob->col[2] = 1.0;
+ ob->col[3] = 1.0;
- ob->size[0]= ob->size[1]= ob->size[2]= 1.0;
- ob->dscale[0]= ob->dscale[1]= ob->dscale[2]= 1.0;
+ ob->size[0] = ob->size[1] = ob->size[2] = 1.0;
+ ob->dscale[0] = ob->dscale[1] = ob->dscale[2] = 1.0;
/* objects should default to having Euler XYZ rotations,
* but rotations default to quaternions
*/
- ob->rotmode= ROT_MODE_EUL;
+ ob->rotmode = ROT_MODE_EUL;
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
unit_axis_angle(ob->drotAxis, &ob->drotAngle);
@@ -803,35 +803,35 @@ Object *BKE_object_add_only_object(int type, const char *name)
unit_m4(ob->constinv);
unit_m4(ob->parentinv);
unit_m4(ob->obmat);
- ob->dt= OB_TEXTURE;
- ob->empty_drawtype= OB_PLAINAXES;
- ob->empty_drawsize= 1.0;
+ ob->dt = OB_TEXTURE;
+ ob->empty_drawtype = OB_PLAINAXES;
+ ob->empty_drawsize = 1.0;
- if (type==OB_CAMERA || type==OB_LAMP || type==OB_SPEAKER) {
- ob->trackflag= OB_NEGZ;
- ob->upflag= OB_POSY;
+ if (type == OB_CAMERA || type == OB_LAMP || type == OB_SPEAKER) {
+ ob->trackflag = OB_NEGZ;
+ ob->upflag = OB_POSY;
}
else {
- ob->trackflag= OB_POSY;
- ob->upflag= OB_POSZ;
+ ob->trackflag = OB_POSY;
+ ob->upflag = OB_POSZ;
}
- ob->dupon= 1; ob->dupoff= 0;
- ob->dupsta= 1; ob->dupend= 100;
+ ob->dupon = 1; ob->dupoff = 0;
+ ob->dupsta = 1; ob->dupend = 100;
ob->dupfacesca = 1.0;
/* Game engine defaults*/
- ob->mass= ob->inertia= 1.0f;
- ob->formfactor= 0.4f;
- ob->damping= 0.04f;
- ob->rdamping= 0.1f;
+ ob->mass = ob->inertia = 1.0f;
+ ob->formfactor = 0.4f;
+ ob->damping = 0.04f;
+ ob->rdamping = 0.1f;
ob->anisotropicFriction[0] = 1.0f;
ob->anisotropicFriction[1] = 1.0f;
ob->anisotropicFriction[2] = 1.0f;
- ob->gameflag= OB_PROP|OB_COLLISION;
+ ob->gameflag = OB_PROP | OB_COLLISION;
ob->margin = 0.0;
- ob->init_state=1;
- ob->state=1;
+ ob->init_state = 1;
+ ob->state = 1;
/* ob->pad3 == Contact Processing Threshold */
ob->m_contactProcessingThreshold = 1.0f;
ob->obstacleRad = 1.0f;
@@ -858,14 +858,14 @@ Object *BKE_object_add(struct Scene *scene, int type)
BLI_strncpy(name, get_obdata_defname(type), sizeof(name));
ob = BKE_object_add_only_object(type, name);
- ob->data= BKE_object_obdata_add_from_type(type);
+ ob->data = BKE_object_obdata_add_from_type(type);
- ob->lay= scene->lay;
+ ob->lay = scene->lay;
- base= BKE_scene_base_add(scene, ob);
+ base = BKE_scene_base_add(scene, ob);
BKE_scene_base_deselect_all(scene);
BKE_scene_base_select(scene, base);
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
return ob;
}
@@ -874,19 +874,19 @@ SoftBody *copy_softbody(SoftBody *sb)
{
SoftBody *sbn;
- if (sb==NULL) return(NULL);
+ if (sb == NULL) return(NULL);
- sbn= MEM_dupallocN(sb);
- sbn->totspring= sbn->totpoint= 0;
- sbn->bpoint= NULL;
- sbn->bspring= NULL;
+ sbn = MEM_dupallocN(sb);
+ sbn->totspring = sbn->totpoint = 0;
+ sbn->bpoint = NULL;
+ sbn->bspring = NULL;
- sbn->keys= NULL;
- sbn->totkey= sbn->totpointkey= 0;
+ sbn->keys = NULL;
+ sbn->totkey = sbn->totpointkey = 0;
- sbn->scratch= NULL;
+ sbn->scratch = NULL;
- sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches);
+ sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches);
if (sb->effector_weights)
sbn->effector_weights = MEM_dupallocN(sb->effector_weights);
@@ -911,12 +911,12 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
ParticleData *pa;
int p;
- psysn= MEM_dupallocN(psys);
- psysn->particles= MEM_dupallocN(psys->particles);
- psysn->child= MEM_dupallocN(psys->child);
+ psysn = MEM_dupallocN(psys);
+ psysn->particles = MEM_dupallocN(psys->particles);
+ psysn->child = MEM_dupallocN(psys->child);
if (psys->part->type == PART_HAIR) {
- for (p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++)
+ for (p = 0, pa = psysn->particles; p < psysn->totpart; p++, pa++)
pa->hair = MEM_dupallocN(pa->hair);
}
@@ -930,7 +930,7 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
if (boid)
boid = MEM_dupallocN(boid);
- for (p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) {
+ for (p = 0, pa = psysn->particles; p < psysn->totpart; p++, pa++) {
if (boid)
pa->boid = boid++;
if (key) {
@@ -942,29 +942,29 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
if (psys->clmd) {
psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
- modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)psysn->clmd);
+ modifier_copyData((ModifierData *)psys->clmd, (ModifierData *)psysn->clmd);
psys->hair_in_dm = psys->hair_out_dm = NULL;
}
BLI_duplicatelist(&psysn->targets, &psys->targets);
- psysn->pathcache= NULL;
- psysn->childcache= NULL;
- psysn->edit= NULL;
- psysn->frand= NULL;
- psysn->pdd= NULL;
- psysn->effectors= NULL;
+ psysn->pathcache = NULL;
+ psysn->childcache = NULL;
+ psysn->edit = NULL;
+ psysn->frand = NULL;
+ psysn->pdd = NULL;
+ psysn->effectors = NULL;
psysn->pathcachebufs.first = psysn->pathcachebufs.last = NULL;
psysn->childcachebufs.first = psysn->childcachebufs.last = NULL;
psysn->renderdata = NULL;
- psysn->pointcache= BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches);
+ psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches);
/* XXX - from reading existing code this seems correct but intended usage of
* pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
if (psysn->clmd) {
- psysn->clmd->point_cache= psysn->pointcache;
+ psysn->clmd->point_cache = psysn->pointcache;
}
id_us_plus((ID *)psysn->part);
@@ -982,34 +982,34 @@ void BKE_object_copy_particlesystems(Object *obn, Object *ob)
return;
}
- obn->particlesystem.first= obn->particlesystem.last= NULL;
- for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- npsys= copy_particlesystem(psys);
+ obn->particlesystem.first = obn->particlesystem.last = NULL;
+ for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+ npsys = copy_particlesystem(psys);
BLI_addtail(&obn->particlesystem, npsys);
/* need to update particle modifiers too */
- for (md=obn->modifiers.first; md; md=md->next) {
- if (md->type==eModifierType_ParticleSystem) {
- ParticleSystemModifierData *psmd= (ParticleSystemModifierData*)md;
- if (psmd->psys==psys)
- psmd->psys= npsys;
+ for (md = obn->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
+ if (psmd->psys == psys)
+ psmd->psys = npsys;
}
- else if (md->type==eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd= (DynamicPaintModifierData*)md;
+ else if (md->type == eModifierType_DynamicPaint) {
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->brush) {
- if (pmd->brush->psys==psys) {
- pmd->brush->psys= npsys;
+ if (pmd->brush->psys == psys) {
+ pmd->brush->psys = npsys;
}
}
}
- else if (md->type==eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData*) md;
+ else if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *) md;
- if (smd->type==MOD_SMOKE_TYPE_FLOW) {
+ if (smd->type == MOD_SMOKE_TYPE_FLOW) {
if (smd->flow) {
if (smd->flow->psys == psys)
- smd->flow->psys= npsys;
+ smd->flow->psys = npsys;
}
}
}
@@ -1020,7 +1020,7 @@ void BKE_object_copy_particlesystems(Object *obn, Object *ob)
void BKE_object_copy_softbody(Object *obn, Object *ob)
{
if (ob->soft)
- obn->soft= copy_softbody(ob->soft);
+ obn->soft = copy_softbody(ob->soft);
}
static void copy_object_pose(Object *obn, Object *ob)
@@ -1028,23 +1028,23 @@ static void copy_object_pose(Object *obn, Object *ob)
bPoseChannel *chan;
/* note: need to clear obn->pose pointer first, so that BKE_pose_copy_data works (otherwise there's a crash) */
- obn->pose= NULL;
- BKE_pose_copy_data(&obn->pose, ob->pose, 1); /* 1 = copy constraints */
+ obn->pose = NULL;
+ BKE_pose_copy_data(&obn->pose, ob->pose, 1); /* 1 = copy constraints */
- for (chan = obn->pose->chanbase.first; chan; chan=chan->next) {
+ for (chan = obn->pose->chanbase.first; chan; chan = chan->next) {
bConstraint *con;
- chan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
+ chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
- for (con= chan->constraints.first; con; con= con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ for (con = chan->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == ob)
ct->tar = obn;
}
@@ -1058,11 +1058,11 @@ static void copy_object_pose(Object *obn, Object *ob)
static int object_pose_context(Object *ob)
{
- if ( (ob) &&
- (ob->type == OB_ARMATURE) &&
- (ob->pose) &&
- (ob->mode & OB_MODE_POSE)
- ) {
+ if ( (ob) &&
+ (ob->type == OB_ARMATURE) &&
+ (ob->pose) &&
+ (ob->mode & OB_MODE_POSE))
+ {
return 1;
}
else {
@@ -1072,13 +1072,13 @@ static int object_pose_context(Object *ob)
Object *BKE_object_pose_armature_get(Object *ob)
{
- if (ob==NULL)
+ if (ob == NULL)
return NULL;
if (object_pose_context(ob))
return ob;
- ob= modifiers_isDeformedByArmature(ob);
+ ob = modifiers_isDeformedByArmature(ob);
if (object_pose_context(ob))
return ob;
@@ -1092,8 +1092,8 @@ static void copy_object_transform(Object *ob_tar, Object *ob_src)
copy_v3_v3(ob_tar->rot, ob_src->rot);
copy_v3_v3(ob_tar->quat, ob_src->quat);
copy_v3_v3(ob_tar->rotAxis, ob_src->rotAxis);
- ob_tar->rotAngle= ob_src->rotAngle;
- ob_tar->rotmode= ob_src->rotmode;
+ ob_tar->rotAngle = ob_src->rotAngle;
+ ob_tar->rotmode = ob_src->rotmode;
copy_v3_v3(ob_tar->size, ob_src->size);
}
@@ -1103,20 +1103,20 @@ Object *BKE_object_copy(Object *ob)
ModifierData *md;
int a;
- obn= BKE_libblock_copy(&ob->id);
+ obn = BKE_libblock_copy(&ob->id);
if (ob->totcol) {
- obn->mat= MEM_dupallocN(ob->mat);
- obn->matbits= MEM_dupallocN(ob->matbits);
- obn->totcol= ob->totcol;
+ obn->mat = MEM_dupallocN(ob->mat);
+ obn->matbits = MEM_dupallocN(ob->matbits);
+ obn->totcol = ob->totcol;
}
- if (ob->bb) obn->bb= MEM_dupallocN(ob->bb);
+ if (ob->bb) obn->bb = MEM_dupallocN(ob->bb);
obn->flag &= ~OB_FROMGROUP;
- obn->modifiers.first = obn->modifiers.last= NULL;
+ obn->modifiers.first = obn->modifiers.last = NULL;
- for (md=ob->modifiers.first; md; md=md->next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
ModifierData *nmd = modifier_new(md->type);
BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
modifier_copyData(md, nmd);
@@ -1133,7 +1133,7 @@ Object *BKE_object_copy(Object *ob)
if (ob->pose) {
copy_object_pose(obn, ob);
/* backwards compat... non-armatures can get poses in older files? */
- if (ob->type==OB_ARMATURE)
+ if (ob->type == OB_ARMATURE)
BKE_pose_rebuild(obn, obn->data);
}
defgroup_copy_list(&obn->defbase, &ob->defbase);
@@ -1147,18 +1147,18 @@ Object *BKE_object_copy(Object *ob)
id_us_plus((ID *)obn->gpd);
id_lib_extern((ID *)obn->dup_group);
- for (a=0; a<obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
+ for (a = 0; a < obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
- obn->disp.first= obn->disp.last= NULL;
+ obn->disp.first = obn->disp.last = NULL;
if (ob->pd) {
- obn->pd= MEM_dupallocN(ob->pd);
+ obn->pd = MEM_dupallocN(ob->pd);
if (obn->pd->tex)
id_us_plus(&(obn->pd->tex->id));
if (obn->pd->rng)
obn->pd->rng = MEM_dupallocN(ob->pd->rng);
}
- obn->soft= copy_softbody(ob->soft);
+ obn->soft = copy_softbody(ob->soft);
obn->bsoft = copy_bulletsoftbody(ob->bsoft);
BKE_object_copy_particlesystems(obn, ob);
@@ -1169,7 +1169,7 @@ Object *BKE_object_copy(Object *ob)
obn->gpulamp.first = obn->gpulamp.last = NULL;
obn->pc_ids.first = obn->pc_ids.last = NULL;
- obn->mpath= NULL;
+ obn->mpath = NULL;
return obn;
}
@@ -1185,35 +1185,35 @@ static void extern_local_object(Object *ob)
extern_local_matarar(ob->mat, ob->totcol);
- for (psys=ob->particlesystem.first; psys; psys=psys->next)
+ for (psys = ob->particlesystem.first; psys; psys = psys->next)
id_lib_extern((ID *)psys->part);
}
void BKE_object_make_local(Object *ob)
{
- Main *bmain= G.main;
+ Main *bmain = G.main;
Scene *sce;
Base *base;
- int is_local= FALSE, is_lib= FALSE;
+ int is_local = FALSE, is_lib = FALSE;
/* - only lib users: do nothing
* - only local users: set flag
* - mixed: make copy
*/
- if (ob->id.lib==NULL) return;
+ if (ob->id.lib == NULL) return;
- ob->proxy= ob->proxy_from= NULL;
+ ob->proxy = ob->proxy_from = NULL;
- if (ob->id.us==1) {
+ if (ob->id.us == 1) {
id_clear_lib_data(bmain, &ob->id);
extern_local_object(ob);
}
else {
- for (sce= bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce= sce->id.next) {
+ for (sce = bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce = sce->id.next) {
if (BKE_scene_base_find(sce, ob)) {
- if (sce->id.lib) is_lib= TRUE;
- else is_local= TRUE;
+ if (sce->id.lib) is_lib = TRUE;
+ else is_local = TRUE;
}
}
@@ -1222,27 +1222,27 @@ void BKE_object_make_local(Object *ob)
extern_local_object(ob);
}
else if (is_local && is_lib) {
- Object *ob_new= BKE_object_copy(ob);
+ Object *ob_new = BKE_object_copy(ob);
- ob_new->id.us= 0;
+ ob_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, ob->id.lib, &ob_new->id);
- sce= bmain->scene.first;
+ sce = bmain->scene.first;
while (sce) {
- if (sce->id.lib==NULL) {
- base= sce->base.first;
+ if (sce->id.lib == NULL) {
+ base = sce->base.first;
while (base) {
- if (base->object==ob) {
- base->object= ob_new;
+ if (base->object == ob) {
+ base->object = ob_new;
ob_new->id.us++;
ob->id.us--;
}
- base= base->next;
+ base = base->next;
}
}
- sce= sce->id.next;
+ sce = sce->id.next;
}
}
}
@@ -1263,9 +1263,9 @@ int BKE_object_is_libdata(Object *ob)
int BKE_object_obdata_is_libdata(Object *ob)
{
if (!ob) return 0;
- if (ob->proxy && (ob->data==NULL || ((ID *)ob->data)->lib==NULL)) return 0;
+ if (ob->proxy && (ob->data == NULL || ((ID *)ob->data)->lib == NULL)) return 0;
if (ob->id.lib) return 1;
- if (ob->data==NULL) return 0;
+ if (ob->data == NULL) return 0;
if (((ID *)ob->data)->lib) return 1;
return 0;
@@ -1276,11 +1276,11 @@ int BKE_object_obdata_is_libdata(Object *ob)
/* when you make proxy, ensure the exposed layers are extern */
static void armature_set_id_extern(Object *ob)
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
bPoseChannel *pchan;
- unsigned int lay= arm->layer_protected;
+ unsigned int lay = arm->layer_protected;
- for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (!(pchan->bone->layer & lay))
id_lib_extern((ID *)pchan->custom);
}
@@ -1294,27 +1294,27 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
/* add new animdata block */
if (!ob->adt)
- ob->adt= BKE_id_add_animdata(&ob->id);
+ ob->adt = BKE_id_add_animdata(&ob->id);
/* make a copy of all the drivers (for now), then correct any links that need fixing */
free_fcurves(&ob->adt->drivers);
copy_fcurves(&ob->adt->drivers, &target->adt->drivers);
- for (fcu= ob->adt->drivers.first; fcu; fcu= fcu->next) {
- ChannelDriver *driver= fcu->driver;
+ for (fcu = ob->adt->drivers.first; fcu; fcu = fcu->next) {
+ ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
- for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
+ for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* all drivers */
DRIVER_TARGETS_LOOPER(dvar)
{
if (dtar->id) {
if ((Object *)dtar->id == target)
- dtar->id= (ID *)ob;
+ dtar->id = (ID *)ob;
else {
/* only on local objects because this causes indirect links a -> b -> c, blend to point directly to a.blend
* when a.blend has a proxy thats linked into c.blend */
- if (ob->id.lib==NULL)
+ if (ob->id.lib == NULL)
id_lib_extern((ID *)dtar->id);
}
}
@@ -1332,16 +1332,16 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
{
/* paranoia checks */
- if (ob->id.lib || target->id.lib==NULL) {
+ if (ob->id.lib || target->id.lib == NULL) {
printf("cannot make proxy\n");
return;
}
- ob->proxy= target;
- ob->proxy_group= gob;
+ ob->proxy = target;
+ ob->proxy_group = gob;
id_lib_extern(&target->id);
- ob->recalc= target->recalc= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->recalc = target->recalc = OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
/* copy transform
* - gob means this proxy comes from a group, just apply the matrix
@@ -1350,7 +1350,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
* - no gob means this is being made from a linked object,
* this is closer to making a copy of the object - in-place. */
if (gob) {
- ob->rotmode= target->rotmode;
+ ob->rotmode = target->rotmode;
mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat);
if (gob->dup_group) { /* should always be true */
float tvec[3];
@@ -1362,7 +1362,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
}
else {
copy_object_transform(ob, target);
- ob->parent= target->parent; /* libdata */
+ ob->parent = target->parent; /* libdata */
copy_m4_m4(ob->parentinv, target->parentinv);
}
@@ -1373,25 +1373,25 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
// FIXME: this is considered by many as a bug
/* set object type and link to data */
- ob->type= target->type;
- ob->data= target->data;
- id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_EXTERN */
+ ob->type = target->type;
+ ob->data = target->data;
+ id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_EXTERN */
/* copy material and index information */
- ob->actcol= ob->totcol= 0;
+ ob->actcol = ob->totcol = 0;
if (ob->mat) MEM_freeN(ob->mat);
if (ob->matbits) MEM_freeN(ob->matbits);
ob->mat = NULL;
- ob->matbits= NULL;
+ ob->matbits = NULL;
if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
int i;
- ob->actcol= target->actcol;
- ob->totcol= target->totcol;
+ ob->actcol = target->actcol;
+ ob->totcol = target->totcol;
ob->mat = MEM_dupallocN(target->mat);
ob->matbits = MEM_dupallocN(target->matbits);
- for (i=0; i<target->totcol; i++) {
+ for (i = 0; i < target->totcol; i++) {
/* don't need to run test_object_materials since we know this object is new and not used elsewhere */
id_us_plus((ID *)ob->mat[i]);
}
@@ -1399,9 +1399,9 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
/* type conversions */
if (target->type == OB_ARMATURE) {
- copy_object_pose(ob, target); /* data copy, object pointers in constraints */
- BKE_pose_rest(ob->pose); /* clear all transforms in channels */
- BKE_pose_rebuild(ob, ob->data); /* set all internal links */
+ copy_object_pose(ob, target); /* data copy, object pointers in constraints */
+ BKE_pose_rest(ob->pose); /* clear all transforms in channels */
+ BKE_pose_rebuild(ob, ob->data); /* set all internal links */
armature_set_id_extern(ob);
}
@@ -1414,14 +1414,14 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
if (ob->id.properties) {
IDP_FreeProperty(ob->id.properties);
MEM_freeN(ob->id.properties);
- ob->id.properties= NULL;
+ ob->id.properties = NULL;
}
if (target->id.properties) {
- ob->id.properties= IDP_CopyProperty(target->id.properties);
+ ob->id.properties = IDP_CopyProperty(target->id.properties);
}
/* copy drawtype info */
- ob->dt= target->dt;
+ ob->dt = target->dt;
}
@@ -1471,7 +1471,7 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[][3])
void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
{
switch (ob->rotmode) {
- case ROT_MODE_QUAT:
+ case ROT_MODE_QUAT:
{
float dquat[4];
mat3_to_quat(ob->quat, mat);
@@ -1480,12 +1480,12 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
mul_qt_qtqt(ob->quat, dquat, ob->quat);
}
break;
- case ROT_MODE_AXISANGLE:
- mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat);
- sub_v3_v3(ob->rotAxis, ob->drotAxis);
- ob->rotAngle -= ob->drotAngle;
- break;
- default: /* euler */
+ case ROT_MODE_AXISANGLE:
+ mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat);
+ sub_v3_v3(ob->rotAxis, ob->drotAxis);
+ ob->rotAngle -= ob->drotAngle;
+ break;
+ default: /* euler */
{
float quat[4];
float dquat[4];
@@ -1499,19 +1499,19 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
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);
+ if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
+ else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
}
}
}
void BKE_object_tfm_protected_backup(const Object *ob,
- ObjectTfmProtectedChannels *obtfm)
+ ObjectTfmProtectedChannels *obtfm)
{
-#define TFMCPY( _v) (obtfm->_v = ob->_v)
-#define TFMCPY3D( _v) copy_v3_v3(obtfm->_v, ob->_v)
-#define TFMCPY4D( _v) copy_v4_v4(obtfm->_v, ob->_v)
+#define TFMCPY(_v) (obtfm->_v = ob->_v)
+#define TFMCPY3D(_v) copy_v3_v3(obtfm->_v, ob->_v)
+#define TFMCPY4D(_v) copy_v4_v4(obtfm->_v, ob->_v)
TFMCPY3D(loc);
TFMCPY3D(dloc);
@@ -1533,40 +1533,40 @@ void BKE_object_tfm_protected_backup(const Object *ob,
}
void BKE_object_tfm_protected_restore(Object *ob,
- const ObjectTfmProtectedChannels *obtfm,
- const short protectflag)
+ const ObjectTfmProtectedChannels *obtfm,
+ const short protectflag)
{
unsigned int i;
- for (i= 0; i < 3; i++) {
- if (protectflag & (OB_LOCK_LOCX<<i)) {
- ob->loc[i]= obtfm->loc[i];
- ob->dloc[i]= obtfm->dloc[i];
+ for (i = 0; i < 3; i++) {
+ if (protectflag & (OB_LOCK_LOCX << i)) {
+ ob->loc[i] = obtfm->loc[i];
+ ob->dloc[i] = obtfm->dloc[i];
}
- if (protectflag & (OB_LOCK_SCALEX<<i)) {
- ob->size[i]= obtfm->size[i];
- ob->dscale[i]= obtfm->dscale[i];
+ if (protectflag & (OB_LOCK_SCALEX << i)) {
+ ob->size[i] = obtfm->size[i];
+ ob->dscale[i] = obtfm->dscale[i];
}
- if (protectflag & (OB_LOCK_ROTX<<i)) {
- ob->rot[i]= obtfm->rot[i];
- ob->drot[i]= obtfm->drot[i];
+ if (protectflag & (OB_LOCK_ROTX << i)) {
+ ob->rot[i] = obtfm->rot[i];
+ ob->drot[i] = obtfm->drot[i];
- ob->quat[i + 1]= obtfm->quat[i + 1];
- ob->dquat[i + 1]= obtfm->dquat[i + 1];
+ ob->quat[i + 1] = obtfm->quat[i + 1];
+ ob->dquat[i + 1] = obtfm->dquat[i + 1];
- ob->rotAxis[i]= obtfm->rotAxis[i];
- ob->drotAxis[i]= obtfm->drotAxis[i];
+ ob->rotAxis[i] = obtfm->rotAxis[i];
+ ob->drotAxis[i] = obtfm->drotAxis[i];
}
}
if ((protectflag & OB_LOCK_ROT4D) && (protectflag & OB_LOCK_ROTW)) {
- ob->quat[0]= obtfm->quat[0];
- ob->dquat[0]= obtfm->dquat[0];
+ ob->quat[0] = obtfm->quat[0];
+ ob->dquat[0] = obtfm->dquat[0];
- ob->rotAngle= obtfm->rotAngle;
- ob->drotAngle= obtfm->drotAngle;
+ ob->rotAngle = obtfm->rotAngle;
+ ob->drotAngle = obtfm->drotAngle;
}
}
@@ -1600,7 +1600,7 @@ void BKE_object_apply_mat4(Object *ob, float mat[][4], const short use_compat, c
/* BKE_object_mat3_to_rot handles delta rotations */
}
-void BKE_object_to_mat3(Object *ob, float mat[][3]) /* no parent */
+void BKE_object_to_mat3(Object *ob, float mat[][3]) /* no parent */
{
float smat[3][3];
float rmat[3][3];
@@ -1626,7 +1626,7 @@ void BKE_object_to_mat4(Object *ob, float mat[][4])
}
/* extern */
-int enable_cu_speed= 1;
+int enable_cu_speed = 1;
static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
{
@@ -1636,14 +1636,14 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
unit_m4(mat);
- cu= par->data;
- if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
+ cu = par->data;
+ if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
makeDispListCurveTypes(scene, par, 0);
- if (cu->path==NULL) return;
+ if (cu->path == NULL) return;
/* catch exceptions: feature for nla stride editing */
if (ob->ipoflag & OB_DISABLE_PATH) {
- ctime= 0.0f;
+ ctime = 0.0f;
}
/* catch exceptions: curve paths used as a duplicator */
else if (enable_cu_speed) {
@@ -1654,14 +1654,14 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
* factor, which then gets clamped to lie within 0.0 - 1.0 range
*/
if (IS_EQF(cu->pathlen, 0.0f) == 0)
- ctime= cu->ctime / cu->pathlen;
+ ctime = cu->ctime / cu->pathlen;
else
- ctime= cu->ctime;
+ ctime = cu->ctime;
CLAMP(ctime, 0.0f, 1.0f);
}
else {
- ctime= scene->r.cfra;
+ ctime = scene->r.cfra;
if (IS_EQF(cu->pathlen, 0.0f) == 0)
ctime /= cu->pathlen;
@@ -1670,7 +1670,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
/* time calculus is correct, now apply distance offset */
if (cu->flag & CU_OFFS_PATHDIST) {
- ctime += timeoffs/cu->path->totdist;
+ ctime += timeoffs / cu->path->totdist;
/* restore */
SWAP(float, sf_orig, ob->sf);
@@ -1678,7 +1678,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
/* vec: 4 items! */
- if (where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL)) {
+ if (where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat : NULL, &radius, NULL)) {
if (cu->flag & CU_FOLLOW) {
#if 0
@@ -1687,11 +1687,11 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
/* the tilt */
normalize_v3(dir);
- q[0]= (float)cos(0.5*vec[3]);
- x1= (float)sin(0.5*vec[3]);
- q[1]= -x1*dir[0];
- q[2]= -x1*dir[1];
- q[3]= -x1*dir[2];
+ q[0] = (float)cos(0.5 * vec[3]);
+ x1 = (float)sin(0.5 * vec[3]);
+ q[1] = -x1 * dir[0];
+ q[2] = -x1 * dir[1];
+ q[3] = -x1 * dir[2];
mul_qt_qtqt(quat, q, quat);
#else
quat_apply_track(quat, ob->trackflag, ob->upflag);
@@ -1717,15 +1717,15 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
bPoseChannel *pchan;
float vec[3];
- if (par->type!=OB_ARMATURE) {
+ if (par->type != OB_ARMATURE) {
unit_m4(mat);
return;
}
/* Make sure the bone is still valid */
- pchan= BKE_pose_channel_find_name(par->pose, ob->parsubstr);
+ pchan = BKE_pose_channel_find_name(par->pose, ob->parsubstr);
if (!pchan) {
- printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr);
+ printf("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name + 2, ob->parsubstr);
unit_m4(mat);
return;
}
@@ -1744,15 +1744,15 @@ static void give_parvert(Object *par, int nr, float vec[3])
BMEditMesh *em;
int a, count;
- vec[0]=vec[1]=vec[2]= 0.0f;
+ vec[0] = vec[1] = vec[2] = 0.0f;
- if (par->type==OB_MESH) {
- Mesh *me= par->data;
+ if (par->type == OB_MESH) {
+ Mesh *me = par->data;
DerivedMesh *dm;
em = me->edit_btmesh;
-#if 0 /* this was bmesh only, better, evaluate why this was needed - campbell*/
+#if 0 /* this was bmesh only, better, evaluate why this was needed - campbell*/
if (em) {
BMVert *eve;
BMIter iter;
@@ -1760,7 +1760,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
- if (keyindex && *keyindex==nr) {
+ if (keyindex && *keyindex == nr) {
copy_v3_v3(vec, eve->co);
break;
}
@@ -1768,17 +1768,17 @@ static void give_parvert(Object *par, int nr, float vec[3])
}
#endif
- dm = (em)? em->derivedFinal: par->derivedFinal;
+ dm = (em) ? em->derivedFinal : par->derivedFinal;
if (dm) {
- MVert *mvert= dm->getVertArray(dm);
+ MVert *mvert = dm->getVertArray(dm);
int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX);
int i, vindex, numVerts = dm->getNumVerts(dm);
/* get the average of all verts with (original index == nr) */
- count= 0;
+ count = 0;
for (i = 0; i < numVerts; i++) {
- vindex= (index)? index[i]: i;
+ vindex = (index) ? index[i] : i;
if (vindex == nr) {
add_v3_v3(vec, mvert[i].co);
@@ -1786,7 +1786,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
}
}
- if (count==0) {
+ if (count == 0) {
/* keep as 0, 0, 0 */
}
else if (count > 0) {
@@ -1804,21 +1804,21 @@ static void give_parvert(Object *par, int nr, float vec[3])
Curve *cu;
BPoint *bp;
BezTriple *bezt;
- int found= 0;
+ int found = 0;
ListBase *nurbs;
- cu= par->data;
- nurbs= BKE_curve_nurbs_get(cu);
- nu= nurbs->first;
+ cu = par->data;
+ nurbs = BKE_curve_nurbs_get(cu);
+ nu = nurbs->first;
- count= 0;
+ count = 0;
while (nu && !found) {
if (nu->type == CU_BEZIER) {
- bezt= nu->bezt;
- a= nu->pntsu;
+ bezt = nu->bezt;
+ a = nu->pntsu;
while (a--) {
- if (count==nr) {
- found= 1;
+ if (count == nr) {
+ found = 1;
copy_v3_v3(vec, bezt->vec[1]);
break;
}
@@ -1827,43 +1827,43 @@ static void give_parvert(Object *par, int nr, float vec[3])
}
}
else {
- bp= nu->bp;
- a= nu->pntsu*nu->pntsv;
+ bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
while (a--) {
- if (count==nr) {
- found= 1;
- memcpy(vec, bp->vec, sizeof(float)*3);
+ if (count == nr) {
+ found = 1;
+ memcpy(vec, bp->vec, sizeof(float) * 3);
break;
}
count++;
bp++;
}
}
- nu= nu->next;
+ nu = nu->next;
}
}
- else if (par->type==OB_LATTICE) {
- Lattice *latt= par->data;
+ else if (par->type == OB_LATTICE) {
+ Lattice *latt = par->data;
BPoint *bp;
DispList *dl = find_displist(&par->disp, DL_VERTS);
- float *co = dl?dl->verts:NULL;
+ float *co = dl ? dl->verts : NULL;
- if (latt->editlatt) latt= latt->editlatt->latt;
+ if (latt->editlatt) latt = latt->editlatt->latt;
- a= latt->pntsu*latt->pntsv*latt->pntsw;
- count= 0;
- bp= latt->def;
+ a = latt->pntsu * latt->pntsv * latt->pntsw;
+ count = 0;
+ bp = latt->def;
while (a--) {
- if (count==nr) {
+ if (count == nr) {
if (co)
- memcpy(vec, co, 3*sizeof(float));
+ memcpy(vec, co, 3 * sizeof(float));
else
- memcpy(vec, bp->vec, 3*sizeof(float));
+ memcpy(vec, bp->vec, 3 * sizeof(float));
break;
}
count++;
- if (co) co+= 3;
+ if (co) co += 3;
else bp++;
}
}
@@ -1886,7 +1886,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
quat_to_mat3(cmat, q);
copy_m4_m3(mat, cmat);
- if (ob->type==OB_CURVE) {
+ if (ob->type == OB_CURVE) {
copy_v3_v3(mat[3], v1);
}
else {
@@ -1904,14 +1904,14 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
int a;
// include framerate
- fac1= (1.0f / (1.0f + fabsf(ob->sf)) );
+ fac1 = (1.0f / (1.0f + fabsf(ob->sf)) );
if (fac1 >= 1.0f) return 0;
- fac2= 1.0f-fac1;
+ fac2 = 1.0f - fac1;
- fp1= obmat[0];
- fp2= slowmat[0];
- for (a=0; a<16; a++, fp1++, fp2++) {
- fp1[0]= fac1*fp1[0] + fac2*fp2[0];
+ fp1 = obmat[0];
+ fp2 = slowmat[0];
+ for (a = 0; a < 16; a++, fp1++, fp2++) {
+ fp1[0] = fac1 * fp1[0] + fac2 * fp2[0];
}
return 1;
@@ -1920,32 +1920,32 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
{
float slowmat[4][4] = MAT4_UNITY;
- float stime=ctime;
+ float stime = ctime;
/* new version: correct parent+vertexparent and track+parent */
/* this one only calculates direct attached parent and track */
/* is faster, but should keep track of timeoffs */
- if (ob==NULL) return;
+ if (ob == NULL) return;
/* execute drivers only, as animation has already been done */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
if (ob->parent) {
- Object *par= ob->parent;
+ Object *par = ob->parent;
/* hurms, code below conflicts with depgraph... (ton) */
/* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */
if (stime != par->ctime) {
// only for ipo systems?
- Object tmp= *par;
+ Object tmp = *par;
- if (par->proxy_from); // was a copied matrix, no where_is! bad...
+ if (par->proxy_from) ; // was a copied matrix, no where_is! bad...
else BKE_object_where_is_calc_time(scene, par, ctime);
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
- *par= tmp;
+ *par = tmp;
}
else
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
@@ -1966,17 +1966,17 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
bConstraintOb *cob;
- cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
+ cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
/* constraints need ctime, not stime. Some call BKE_object_where_is_calc_time and bsystem_time */
- solve_constraints (&ob->constraints, cob, ctime);
+ solve_constraints(&ob->constraints, cob, ctime);
constraints_clear_evalob(cob);
}
/* set negative scale flag in object */
- if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
- else ob->transflag &= ~OB_NEG_SCALE;
+ if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
+ else ob->transflag &= ~OB_NEG_SCALE;
}
/* get object transformation matrix without recalculating dependencies and
@@ -1988,7 +1988,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
float slowmat[4][4] = MAT4_UNITY;
if (ob->parent) {
- Object *par= ob->parent;
+ Object *par = ob->parent;
solve_parenting(scene, ob, par, obmat, slowmat, 1);
@@ -2000,7 +2000,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
}
}
-static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul)
+static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul)
{
float totmat[4][4];
float tmat[4][4];
@@ -2013,53 +2013,53 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
switch (ob->partype & PARTYPE) {
- case PAROBJECT:
- ok= 0;
- if (par->type==OB_CURVE) {
- if (((Curve *)par->data)->flag & CU_PATH ) {
- ob_parcurve(scene, ob, par, tmat);
- ok= 1;
+ case PAROBJECT:
+ ok = 0;
+ if (par->type == OB_CURVE) {
+ if (((Curve *)par->data)->flag & CU_PATH) {
+ ob_parcurve(scene, ob, par, tmat);
+ ok = 1;
+ }
}
- }
- if (ok) mul_serie_m4(totmat, par->obmat, tmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
- else copy_m4_m4(totmat, par->obmat);
+ if (ok) mul_serie_m4(totmat, par->obmat, tmat,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ else copy_m4_m4(totmat, par->obmat);
- break;
- case PARBONE:
- ob_parbone(ob, par, tmat);
- mul_serie_m4(totmat, par->obmat, tmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
- break;
+ break;
+ case PARBONE:
+ ob_parbone(ob, par, tmat);
+ mul_serie_m4(totmat, par->obmat, tmat,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ break;
- case PARVERT1:
- unit_m4(totmat);
- if (simul) {
- copy_v3_v3(totmat[3], par->obmat[3]);
- }
- else {
- give_parvert(par, ob->par1, vec);
- mul_v3_m4v3(totmat[3], par->obmat, vec);
- }
- break;
- case PARVERT3:
- ob_parvert3(ob, par, tmat);
+ case PARVERT1:
+ unit_m4(totmat);
+ if (simul) {
+ copy_v3_v3(totmat[3], par->obmat[3]);
+ }
+ else {
+ give_parvert(par, ob->par1, vec);
+ mul_v3_m4v3(totmat[3], par->obmat, vec);
+ }
+ break;
+ case PARVERT3:
+ ob_parvert3(ob, par, tmat);
- mul_serie_m4(totmat, par->obmat, tmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
- break;
+ mul_serie_m4(totmat, par->obmat, tmat,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ break;
- case PARSKEL:
- copy_m4_m4(totmat, par->obmat);
- break;
+ case PARSKEL:
+ copy_m4_m4(totmat, par->obmat);
+ break;
}
// total
mul_serie_m4(tmat, totmat, ob->parentinv,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL);
mul_serie_m4(obmat, tmat, locmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL);
if (simul) {
@@ -2069,7 +2069,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
copy_m3_m4(originmat, tmat);
// origin, voor help line
- if ((ob->partype & PARTYPE)==PARSKEL ) {
+ if ((ob->partype & PARTYPE) == PARSKEL) {
copy_v3_v3(ob->orig, par->obmat[3]);
}
else {
@@ -2098,17 +2098,17 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
/* NO TIMEOFFS */
if (ob->parent) {
- par= ob->parent;
+ par = ob->parent;
solve_parenting(scene, ob, par, ob->obmat, slowmat, 1);
if (ob->partype & PARSLOW) {
- fac1= (float)(1.0/(1.0+ fabs(ob->sf)));
- fac2= 1.0f-fac1;
- fp1= ob->obmat[0];
- fp2= slowmat[0];
- for (a=0; a<16; a++, fp1++, fp2++) {
- fp1[0]= fac1*fp1[0] + fac2*fp2[0];
+ fac1 = (float)(1.0 / (1.0 + fabs(ob->sf)));
+ fac2 = 1.0f - fac1;
+ fp1 = ob->obmat[0];
+ fp2 = slowmat[0];
+ for (a = 0; a < 16; a++, fp1++, fp2++) {
+ fp1[0] = fac1 * fp1[0] + fac2 * fp2[0];
}
}
}
@@ -2120,7 +2120,7 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
if (ob->constraints.first) {
bConstraintOb *cob;
- cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
+ cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
solve_constraints(&ob->constraints, cob, (float)scene->r.cfra);
constraints_clear_evalob(cob);
}
@@ -2134,15 +2134,15 @@ void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
unit_m4(workob->obmat);
unit_m4(workob->parentinv);
unit_m4(workob->constinv);
- workob->parent= ob->parent;
+ workob->parent = ob->parent;
- workob->trackflag= ob->trackflag;
- workob->upflag= ob->upflag;
+ workob->trackflag = ob->trackflag;
+ workob->upflag = ob->upflag;
- workob->partype= ob->partype;
- workob->par1= ob->par1;
- workob->par2= ob->par2;
- workob->par3= ob->par3;
+ workob->partype = ob->partype;
+ workob->par1 = ob->par1;
+ workob->par2 = ob->par2;
+ workob->par3 = ob->par3;
workob->constraints.first = ob->constraints.first;
workob->constraints.last = ob->constraints.last;
@@ -2157,7 +2157,7 @@ BoundBox *BKE_boundbox_alloc_unit(void)
BoundBox *bb;
float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {-1.0f, -1.0f, -1.0f};
- bb= MEM_callocN(sizeof(BoundBox), "OB-BoundBox");
+ bb = MEM_callocN(sizeof(BoundBox), "OB-BoundBox");
BKE_boundbox_init_from_minmax(bb, min, max);
return bb;
@@ -2165,28 +2165,28 @@ BoundBox *BKE_boundbox_alloc_unit(void)
void BKE_boundbox_init_from_minmax(BoundBox *bb, float min[3], float max[3])
{
- bb->vec[0][0]=bb->vec[1][0]=bb->vec[2][0]=bb->vec[3][0]= min[0];
- bb->vec[4][0]=bb->vec[5][0]=bb->vec[6][0]=bb->vec[7][0]= max[0];
+ bb->vec[0][0] = bb->vec[1][0] = bb->vec[2][0] = bb->vec[3][0] = min[0];
+ bb->vec[4][0] = bb->vec[5][0] = bb->vec[6][0] = bb->vec[7][0] = max[0];
- bb->vec[0][1]=bb->vec[1][1]=bb->vec[4][1]=bb->vec[5][1]= min[1];
- bb->vec[2][1]=bb->vec[3][1]=bb->vec[6][1]=bb->vec[7][1]= max[1];
+ bb->vec[0][1] = bb->vec[1][1] = bb->vec[4][1] = bb->vec[5][1] = min[1];
+ bb->vec[2][1] = bb->vec[3][1] = bb->vec[6][1] = bb->vec[7][1] = max[1];
- bb->vec[0][2]=bb->vec[3][2]=bb->vec[4][2]=bb->vec[7][2]= min[2];
- bb->vec[1][2]=bb->vec[2][2]=bb->vec[5][2]=bb->vec[6][2]= max[2];
+ bb->vec[0][2] = bb->vec[3][2] = bb->vec[4][2] = bb->vec[7][2] = min[2];
+ bb->vec[1][2] = bb->vec[2][2] = bb->vec[5][2] = bb->vec[6][2] = max[2];
}
BoundBox *BKE_object_boundbox_get(Object *ob)
{
- BoundBox *bb= NULL;
+ BoundBox *bb = NULL;
- if (ob->type==OB_MESH) {
+ if (ob->type == OB_MESH) {
bb = BKE_mesh_boundbox_get(ob);
}
else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- bb= ob->bb ? ob->bb : ((Curve *)ob->data )->bb;
+ bb = ob->bb ? ob->bb : ((Curve *)ob->data)->bb;
}
- else if (ob->type==OB_MBALL) {
- bb= ob->bb;
+ else if (ob->type == OB_MBALL) {
+ bb = ob->bb;
}
return bb;
}
@@ -2194,7 +2194,7 @@ BoundBox *BKE_object_boundbox_get(Object *ob)
/* used to temporally disable/enable boundbox */
void BKE_object_boundbox_flag(Object *ob, int flag, int set)
{
- BoundBox *bb= BKE_object_boundbox_get(ob);
+ BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) {
if (set) bb->flag |= flag;
else bb->flag &= ~flag;
@@ -2205,7 +2205,7 @@ void BKE_object_dimensions_get(Object *ob, float vec[3])
{
BoundBox *bb = NULL;
- bb= BKE_object_boundbox_get(ob);
+ bb = BKE_object_boundbox_get(ob);
if (bb) {
float scale[3];
@@ -2224,7 +2224,7 @@ void BKE_object_dimensions_set(Object *ob, const float *value)
{
BoundBox *bb = NULL;
- bb= BKE_object_boundbox_get(ob);
+ bb = BKE_object_boundbox_get(ob);
if (bb) {
float scale[3], len[3];
@@ -2245,66 +2245,66 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3])
BoundBox bb;
float vec[3];
int a;
- short change= FALSE;
+ short change = FALSE;
switch (ob->type) {
- case OB_CURVE:
- case OB_FONT:
- case OB_SURF:
+ case OB_CURVE:
+ case OB_FONT:
+ case OB_SURF:
{
- Curve *cu= ob->data;
+ Curve *cu = ob->data;
- if (cu->bb==NULL) BKE_curve_texspace_calc(cu);
- bb= *(cu->bb);
+ if (cu->bb == NULL) BKE_curve_texspace_calc(cu);
+ bb = *(cu->bb);
- for (a=0; a<8; a++) {
+ for (a = 0; a < 8; a++) {
mul_m4_v3(ob->obmat, bb.vec[a]);
DO_MINMAX(bb.vec[a], min_r, max_r);
}
- change= TRUE;
+ change = TRUE;
}
break;
- case OB_LATTICE:
+ case OB_LATTICE:
{
- Lattice *lt= ob->data;
- BPoint *bp= lt->def;
+ 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++) {
+ 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_r, max_r);
}
}
}
- change= TRUE;
+ change = TRUE;
}
break;
- case OB_ARMATURE:
- if (ob->pose) {
- bPoseChannel *pchan;
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
- DO_MINMAX(vec, min_r, max_r);
- mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
- DO_MINMAX(vec, min_r, max_r);
+ case OB_ARMATURE:
+ if (ob->pose) {
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
+ DO_MINMAX(vec, min_r, max_r);
+ mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
+ DO_MINMAX(vec, min_r, max_r);
+ }
+ change = TRUE;
}
- change= TRUE;
- }
- break;
- case OB_MESH:
+ break;
+ case OB_MESH:
{
- Mesh *me= BKE_mesh_from_object(ob);
+ Mesh *me = BKE_mesh_from_object(ob);
if (me) {
bb = *BKE_mesh_boundbox_get(ob);
- for (a=0; a<8; a++) {
+ for (a = 0; a < 8; a++) {
mul_m4_v3(ob->obmat, bb.vec[a]);
DO_MINMAX(bb.vec[a], min_r, max_r);
}
- change= TRUE;
+ change = TRUE;
}
}
break;
@@ -2325,32 +2325,32 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3])
int BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_max[3])
{
- int ok= 0;
- if ((ob->transflag & OB_DUPLI)==0) {
+ int ok = 0;
+ if ((ob->transflag & OB_DUPLI) == 0) {
return ok;
}
else {
ListBase *lb;
DupliObject *dob;
- lb= object_duplilist(scene, ob);
- for (dob= lb->first; dob; dob= dob->next) {
+ lb = object_duplilist(scene, ob);
+ for (dob = lb->first; dob; dob = dob->next) {
if (dob->no_draw == 0) {
- BoundBox *bb= BKE_object_boundbox_get(dob->ob);
+ BoundBox *bb = BKE_object_boundbox_get(dob->ob);
if (bb) {
int i;
- for (i=0; i<8; i++) {
+ for (i = 0; i < 8; i++) {
float vec[3];
mul_v3_m4v3(vec, dob->mat, bb->vec[i]);
DO_MINMAX(vec, r_min, r_max);
}
- ok= 1;
+ ok = 1;
}
}
}
- free_object_duplilist(lb); /* does restore */
+ free_object_duplilist(lb); /* does restore */
}
return ok;
@@ -2363,12 +2363,12 @@ void BKE_object_foreach_display_point(
float co[3];
if (ob->derivedFinal) {
- DerivedMesh *dm= ob->derivedFinal;
- MVert *mv= dm->getVertArray(dm);
- int totvert= dm->getNumVerts(dm);
+ DerivedMesh *dm = ob->derivedFinal;
+ MVert *mv = dm->getVertArray(dm);
+ int totvert = dm->getNumVerts(dm);
int i;
- for (i= 0; i < totvert; i++, mv++) {
+ for (i = 0; i < totvert; i++, mv++) {
mul_v3_m4v3(co, obmat, mv->co);
func_cb(co, user_data);
}
@@ -2376,12 +2376,12 @@ void BKE_object_foreach_display_point(
else if (ob->disp.first) {
DispList *dl;
- for (dl=ob->disp.first; dl; dl=dl->next) {
- float *v3= dl->verts;
- int totvert= dl->nr;
+ for (dl = ob->disp.first; dl; dl = dl->next) {
+ float *v3 = dl->verts;
+ int totvert = dl->nr;
int i;
- for (i= 0; i < totvert; i++, v3+=3) {
+ for (i = 0; i < totvert; i++, v3 += 3) {
mul_v3_m4v3(co, obmat, v3);
func_cb(co, user_data);
}
@@ -2396,24 +2396,24 @@ void BKE_scene_foreach_display_point(
Base *base;
Object *ob;
- for (base= FIRSTBASE; base; base = base->next) {
+ for (base = FIRSTBASE; base; base = base->next) {
if (BASE_VISIBLE(v3d, base) && (base->flag & flag) == flag) {
- ob= base->object;
+ ob = base->object;
- if ((ob->transflag & OB_DUPLI)==0) {
+ if ((ob->transflag & OB_DUPLI) == 0) {
BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data);
}
else {
ListBase *lb;
DupliObject *dob;
- lb= object_duplilist(scene, ob);
- for (dob= lb->first; dob; dob= dob->next) {
+ lb = object_duplilist(scene, ob);
+ for (dob = lb->first; dob; dob = dob->next) {
if (dob->no_draw == 0) {
BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data);
}
}
- free_object_duplilist(lb); /* does restore */
+ free_object_duplilist(lb); /* does restore */
}
}
}
@@ -2422,20 +2422,20 @@ void BKE_scene_foreach_display_point(
/* copied from DNA_object_types.h */
typedef struct ObTfmBack {
float loc[3], dloc[3], orig[3];
- float size[3], dscale[3]; /* scale and delta scale */
- float rot[3], drot[3]; /* euler rotation */
- float quat[4], dquat[4]; /* quaternion rotation */
- float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */
- float rotAngle, drotAngle; /* axis angle rotation - angle part */
- float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */
+ float size[3], dscale[3]; /* scale and delta scale */
+ float rot[3], drot[3]; /* euler rotation */
+ float quat[4], dquat[4]; /* quaternion rotation */
+ float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */
+ float rotAngle, drotAngle; /* axis angle rotation - angle part */
+ float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */
float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */
float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */
- float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */
+ float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */
} ObTfmBack;
void *BKE_object_tfm_backup(Object *ob)
{
- ObTfmBack *obtfm= MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack");
+ ObTfmBack *obtfm = MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack");
copy_v3_v3(obtfm->loc, ob->loc);
copy_v3_v3(obtfm->dloc, ob->dloc);
copy_v3_v3(obtfm->orig, ob->orig);
@@ -2447,8 +2447,8 @@ void *BKE_object_tfm_backup(Object *ob)
copy_qt_qt(obtfm->dquat, ob->dquat);
copy_v3_v3(obtfm->rotAxis, ob->rotAxis);
copy_v3_v3(obtfm->drotAxis, ob->drotAxis);
- obtfm->rotAngle= ob->rotAngle;
- obtfm->drotAngle= ob->drotAngle;
+ obtfm->rotAngle = ob->rotAngle;
+ obtfm->drotAngle = ob->drotAngle;
copy_m4_m4(obtfm->obmat, ob->obmat);
copy_m4_m4(obtfm->parentinv, ob->parentinv);
copy_m4_m4(obtfm->constinv, ob->constinv);
@@ -2459,7 +2459,7 @@ void *BKE_object_tfm_backup(Object *ob)
void BKE_object_tfm_restore(Object *ob, void *obtfm_pt)
{
- ObTfmBack *obtfm= (ObTfmBack *)obtfm_pt;
+ ObTfmBack *obtfm = (ObTfmBack *)obtfm_pt;
copy_v3_v3(ob->loc, obtfm->loc);
copy_v3_v3(ob->dloc, obtfm->dloc);
copy_v3_v3(ob->orig, obtfm->orig);
@@ -2471,8 +2471,8 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt)
copy_qt_qt(ob->dquat, obtfm->dquat);
copy_v3_v3(ob->rotAxis, obtfm->rotAxis);
copy_v3_v3(ob->drotAxis, obtfm->drotAxis);
- ob->rotAngle= obtfm->rotAngle;
- ob->drotAngle= obtfm->drotAngle;
+ ob->rotAngle = obtfm->rotAngle;
+ ob->drotAngle = obtfm->drotAngle;
copy_m4_m4(ob->obmat, obtfm->obmat);
copy_m4_m4(ob->parentinv, obtfm->parentinv);
copy_m4_m4(ob->constinv, obtfm->constinv);
@@ -2502,12 +2502,12 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
BKE_pose_channels_hash_make(ob->pose);
if (ob->recalc & OB_RECALC_DATA) {
- if (ob->type==OB_ARMATURE) {
+ if (ob->type == OB_ARMATURE) {
/* this happens for reading old files and to match library armatures
* with poses we do it ahead of BKE_object_where_is_calc to ensure animation
* is evaluated on the rebuilt pose, otherwise we get incorrect poses
* on file load */
- if (ob->pose==NULL || (ob->pose->flag & POSE_RECALC))
+ if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC))
BKE_pose_rebuild(ob, ob->data);
}
}
@@ -2518,13 +2518,13 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
if (ob->recalc & OB_RECALC_ALL) {
if (G.debug & G_DEBUG)
- printf("recalcob %s\n", ob->id.name+2);
+ printf("recalcob %s\n", ob->id.name + 2);
/* handle proxy copy for target */
if (ob->id.lib && ob->proxy_from) {
// printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
- if (ob->proxy_from->proxy_group) {/* transform proxy into group space */
- Object *obg= ob->proxy_from->proxy_group;
+ if (ob->proxy_from->proxy_group) { /* transform proxy into group space */
+ Object *obg = ob->proxy_from->proxy_group;
invert_m4_m4(obg->imat, obg->obmat);
mult_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat);
if (obg->dup_group) { /* should always be true */
@@ -2539,14 +2539,14 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
}
if (ob->recalc & OB_RECALC_DATA) {
- ID *data_id= (ID *)ob->data;
- AnimData *adt= BKE_animdata_from_id(data_id);
- float ctime= (float)scene->r.cfra; // XXX this is bad...
+ ID *data_id = (ID *)ob->data;
+ AnimData *adt = BKE_animdata_from_id(data_id);
+ float ctime = (float)scene->r.cfra; // XXX this is bad...
ListBase pidlist;
PTCacheID *pid;
if (G.debug & G_DEBUG)
- printf("recalcdata %s\n", ob->id.name+2);
+ printf("recalcdata %s\n", ob->id.name + 2);
if (adt) {
/* evaluate drivers */
@@ -2556,9 +2556,9 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
/* includes all keys and modifiers */
switch (ob->type) {
- case OB_MESH:
+ case OB_MESH:
{
-#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
+#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
BMEditMesh *em = (ob == scene->obedit) ? BMEdit_FromObject(ob) : NULL;
BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH);
if (em) {
@@ -2568,9 +2568,9 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
makeDerivedMesh(scene, ob, NULL, scene->customdata_mask, 0);
}
-#else /* ensure CD_MASK_BAREMESH for now */
+#else /* ensure CD_MASK_BAREMESH for now */
BMEditMesh *em = (ob == scene->obedit) ? BMEdit_FromObject(ob) : NULL;
- uint64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
+ uint64_t data_mask = scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
if (em) {
makeDerivedMesh(scene, ob, em, data_mask, 0); /* was CD_MASK_BAREMESH */
}
@@ -2582,29 +2582,29 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
}
break;
- case OB_ARMATURE:
- if (ob->id.lib && ob->proxy_from) {
- // printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
- BKE_pose_copy_result(ob->pose, ob->proxy_from->pose);
- }
- else {
- BKE_pose_where_is(scene, ob);
- }
- break;
+ case OB_ARMATURE:
+ if (ob->id.lib && ob->proxy_from) {
+ // printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
+ BKE_pose_copy_result(ob->pose, ob->proxy_from->pose);
+ }
+ else {
+ BKE_pose_where_is(scene, ob);
+ }
+ break;
- case OB_MBALL:
- makeDispListMBall(scene, ob);
- break;
+ case OB_MBALL:
+ makeDispListMBall(scene, ob);
+ break;
- case OB_CURVE:
- case OB_SURF:
- case OB_FONT:
- makeDispListCurveTypes(scene, ob, 0);
- break;
+ case OB_CURVE:
+ case OB_SURF:
+ case OB_FONT:
+ makeDispListCurveTypes(scene, ob, 0);
+ break;
- case OB_LATTICE:
- BKE_lattice_modifiers_calc(scene, ob);
- break;
+ case OB_LATTICE:
+ BKE_lattice_modifiers_calc(scene, ob);
+ break;
}
@@ -2613,7 +2613,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
DerivedMesh *dm;
ob->transflag &= ~OB_DUPLIPARTS;
- psys= ob->particlesystem.first;
+ psys = ob->particlesystem.first;
while (psys) {
if (psys_check_enabled(ob, psys)) {
/* check use of dupli objects here */
@@ -2625,26 +2625,26 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
}
particle_system_update(scene, ob, psys);
- psys= psys->next;
+ psys = psys->next;
}
else if (psys->flag & PSYS_DELETE) {
- tpsys=psys->next;
+ tpsys = psys->next;
BLI_remlink(&ob->particlesystem, psys);
psys_free(ob, psys);
- psys= tpsys;
+ psys = tpsys;
}
else
- psys= psys->next;
+ psys = psys->next;
}
if (G.rendering && ob->transflag & OB_DUPLIPARTS) {
/* this is to make sure we get render level duplis in groups:
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
- dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
+ dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL);
dm->release(dm);
- for (psys=ob->particlesystem.first; psys; psys=psys->next)
+ for (psys = ob->particlesystem.first; psys; psys = psys->next)
psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
}
}
@@ -2652,18 +2652,18 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
/* check if quick cache is needed */
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
- for (pid=pidlist.first; pid; pid=pid->next) {
+ for (pid = pidlist.first; pid; pid = pid->next) {
if ((pid->cache->flag & PTCACHE_BAKED) ||
(pid->cache->flag & PTCACHE_QUICK_CACHE) == 0)
{
continue;
}
- if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) {
+ if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID) == 0) {
scene->physics_settings.quick_cache_step =
- scene->physics_settings.quick_cache_step ?
- MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) :
- pid->cache->step;
+ scene->physics_settings.quick_cache_step ?
+ MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) :
+ pid->cache->step;
}
}
@@ -2671,9 +2671,9 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
}
/* the no-group proxy case, we call update */
- if (ob->proxy && ob->proxy_group==NULL) {
+ if (ob->proxy && ob->proxy_group == NULL) {
/* set pointer in library proxy target, for copying, but restore it */
- ob->proxy->proxy_from= ob;
+ ob->proxy->proxy_from = ob;
// printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name);
BKE_object_handle_update(scene, ob->proxy);
}
@@ -2683,22 +2683,22 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
/* the case when this is a group proxy, object_update is called in group.c */
if (ob->proxy) {
- ob->proxy->proxy_from= ob;
+ ob->proxy->proxy_from = ob;
// printf("set proxy pointer for later group stuff %s\n", ob->id.name);
}
}
void BKE_object_sculpt_modifiers_changed(Object *ob)
{
- SculptSession *ss= ob->sculpt;
+ SculptSession *ss = ob->sculpt;
if (!ss->cache) {
/* we free pbvh on changes, except during sculpt since it can't deal with
* changing PVBH node organization, we hope topology does not change in
* the meantime .. weak */
if (ss->pbvh) {
- BLI_pbvh_free(ss->pbvh);
- ss->pbvh= NULL;
+ BLI_pbvh_free(ss->pbvh);
+ ss->pbvh = NULL;
}
free_sculptsession_deformMats(ob->sculpt);
@@ -2719,39 +2719,39 @@ void BKE_object_sculpt_modifiers_changed(Object *ob)
int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot)
{
- if (ob->data==NULL)
+ if (ob->data == NULL)
return 0;
switch (GS(((ID *)ob->data)->name)) {
- case ID_ME:
- {
- Mesh *me= ob->data;
- if (r_texflag) *r_texflag = &me->texflag;
- if (r_loc) *r_loc = me->loc;
- if (r_size) *r_size = me->size;
- if (r_rot) *r_rot = me->rot;
- break;
- }
- case ID_CU:
- {
- Curve *cu= ob->data;
- if (r_texflag) *r_texflag = &cu->texflag;
- if (r_loc) *r_loc = cu->loc;
- if (r_size) *r_size = cu->size;
- if (r_rot) *r_rot = cu->rot;
- break;
- }
- case ID_MB:
- {
- MetaBall *mb= ob->data;
- if (r_texflag) *r_texflag = &mb->texflag;
- if (r_loc) *r_loc = mb->loc;
- if (r_size) *r_size = mb->size;
- if (r_rot) *r_rot = mb->rot;
- break;
- }
- default:
- return 0;
+ case ID_ME:
+ {
+ Mesh *me = ob->data;
+ if (r_texflag) *r_texflag = &me->texflag;
+ if (r_loc) *r_loc = me->loc;
+ if (r_size) *r_size = me->size;
+ if (r_rot) *r_rot = me->rot;
+ break;
+ }
+ case ID_CU:
+ {
+ Curve *cu = ob->data;
+ if (r_texflag) *r_texflag = &cu->texflag;
+ if (r_loc) *r_loc = cu->loc;
+ if (r_size) *r_size = cu->size;
+ if (r_rot) *r_rot = cu->rot;
+ break;
+ }
+ case ID_MB:
+ {
+ MetaBall *mb = ob->data;
+ if (r_texflag) *r_texflag = &mb->texflag;
+ if (r_loc) *r_loc = mb->loc;
+ if (r_size) *r_size = mb->size;
+ if (r_rot) *r_rot = mb->rot;
+ break;
+ }
+ default:
+ return 0;
}
return 1;
}
@@ -2798,7 +2798,7 @@ int BKE_object_insert_ptcache(Object *ob)
BLI_sortlist(&ob->pc_ids, pc_cmp);
- for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) {
+ for (link = ob->pc_ids.first, i = 0; link; link = link->next, i++) {
int index = GET_INT_FROM_POINTER(link->data);
if (i < index)
@@ -2815,18 +2815,18 @@ int BKE_object_insert_ptcache(Object *ob)
#if 0
static int pc_findindex(ListBase *listbase, int index)
{
- LinkData *link= NULL;
- int number= 0;
+ LinkData *link = NULL;
+ int number = 0;
if (listbase == NULL) return -1;
- link= listbase->first;
+ link = listbase->first;
while (link) {
if ((int)link->data == index)
return number;
number++;
- link= link->next;
+ link = link->next;
}
return -1;
@@ -2845,30 +2845,30 @@ void object_delete_ptcache(Object *ob, int index)
/************************* Mesh ************************/
static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int from_mix)
{
- Mesh *me= ob->data;
- Key *key= me->key;
+ Mesh *me = ob->data;
+ Key *key = me->key;
KeyBlock *kb;
- int newkey= 0;
+ int newkey = 0;
if (key == NULL) {
- key= me->key= add_key((ID *)me);
- key->type= KEY_RELATIVE;
- newkey= 1;
+ key = me->key = add_key((ID *)me);
+ key->type = KEY_RELATIVE;
+ newkey = 1;
}
- if (newkey || from_mix==FALSE) {
+ if (newkey || from_mix == FALSE) {
/* create from mesh */
kb = add_keyblock_ctime(key, name, FALSE);
mesh_to_key(me, kb);
}
else {
/* copy from current values */
- float *data= do_ob_key(scene, ob);
+ float *data = do_ob_key(scene, ob);
/* create new block with prepared data */
kb = add_keyblock_ctime(key, name, FALSE);
- kb->data= data;
- kb->totelem= me->totvert;
+ kb->data = data;
+ kb->totelem = me->totvert;
}
return kb;
@@ -2876,23 +2876,23 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int
/************************* Lattice ************************/
static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int from_mix)
{
- Lattice *lt= ob->data;
- Key *key= lt->key;
+ Lattice *lt = ob->data;
+ Key *key = lt->key;
KeyBlock *kb;
- int newkey= 0;
+ int newkey = 0;
- if (key==NULL) {
- key= lt->key= add_key((ID *)lt);
- key->type= KEY_RELATIVE;
- newkey= 1;
+ if (key == NULL) {
+ key = lt->key = add_key((ID *)lt);
+ key->type = KEY_RELATIVE;
+ newkey = 1;
}
- if (newkey || from_mix==FALSE) {
+ if (newkey || from_mix == FALSE) {
kb = add_keyblock_ctime(key, name, FALSE);
if (!newkey) {
- KeyBlock *basekb= (KeyBlock *)key->block.first;
- kb->data= MEM_dupallocN(basekb->data);
- kb->totelem= basekb->totelem;
+ KeyBlock *basekb = (KeyBlock *)key->block.first;
+ kb->data = MEM_dupallocN(basekb->data);
+ kb->totelem = basekb->totelem;
}
else {
latt_to_key(lt, kb);
@@ -2900,12 +2900,12 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
}
else {
/* copy from current values */
- float *data= do_ob_key(scene, ob);
+ float *data = do_ob_key(scene, ob);
/* create new block with prepared data */
kb = add_keyblock_ctime(key, name, FALSE);
- kb->totelem= lt->pntsu*lt->pntsv*lt->pntsw;
- kb->data= data;
+ kb->totelem = lt->pntsu * lt->pntsv * lt->pntsw;
+ kb->data = data;
}
return kb;
@@ -2913,25 +2913,25 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
/************************* Curve ************************/
static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int from_mix)
{
- Curve *cu= ob->data;
- Key *key= cu->key;
+ Curve *cu = ob->data;
+ Key *key = cu->key;
KeyBlock *kb;
- ListBase *lb= BKE_curve_nurbs_get(cu);
- int newkey= 0;
+ ListBase *lb = BKE_curve_nurbs_get(cu);
+ int newkey = 0;
- if (key==NULL) {
- key= cu->key= add_key((ID *)cu);
+ if (key == NULL) {
+ key = cu->key = add_key((ID *)cu);
key->type = KEY_RELATIVE;
- newkey= 1;
+ newkey = 1;
}
- if (newkey || from_mix==FALSE) {
+ if (newkey || from_mix == FALSE) {
/* create from curve */
kb = add_keyblock_ctime(key, name, FALSE);
if (!newkey) {
- KeyBlock *basekb= (KeyBlock *)key->block.first;
- kb->data= MEM_dupallocN(basekb->data);
- kb->totelem= basekb->totelem;
+ KeyBlock *basekb = (KeyBlock *)key->block.first;
+ kb->data = MEM_dupallocN(basekb->data);
+ kb->totelem = basekb->totelem;
}
else {
curve_to_key(cu, kb, lb);
@@ -2939,12 +2939,12 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
}
else {
/* copy from current values */
- float *data= do_ob_key(scene, ob);
+ float *data = do_ob_key(scene, ob);
/* create new block with prepared data */
kb = add_keyblock_ctime(key, name, FALSE);
- kb->totelem= BKE_nurbList_verts_count(lb);
- kb->data= data;
+ kb->totelem = BKE_nurbList_verts_count(lb);
+ kb->data = data;
}
return kb;
@@ -2970,7 +2970,7 @@ KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name
* cases false positives are hard to avoid (shape keys for example) */
int BKE_object_is_modified(Scene *scene, Object *ob)
{
- int flag= 0;
+ int flag = 0;
if (ob_get_key(ob)) {
flag |= eModifierMode_Render;
@@ -2978,9 +2978,9 @@ int BKE_object_is_modified(Scene *scene, Object *ob)
else {
ModifierData *md;
/* cloth */
- for (md=modifiers_getVirtualModifierList(ob);
+ for (md = modifiers_getVirtualModifierList(ob);
md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
- md=md->next)
+ md = md->next)
{
if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render))
flag |= eModifierMode_Render;
@@ -2999,12 +2999,12 @@ int BKE_object_is_modified(Scene *scene, Object *ob)
int BKE_object_is_deform_modified(Scene *scene, Object *ob)
{
ModifierData *md;
- int flag= 0;
+ int flag = 0;
/* cloth */
- for (md=modifiers_getVirtualModifierList(ob);
- md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
- md=md->next)
+ for (md = modifiers_getVirtualModifierList(ob);
+ md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
+ md = md->next)
{
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -3034,7 +3034,7 @@ void BKE_object_relink(Object *ob)
relink_constraints(&ob->constraints);
if (ob->pose) {
bPoseChannel *chan;
- for (chan = ob->pose->chanbase.first; chan; chan=chan->next) {
+ for (chan = ob->pose->chanbase.first; chan; chan = chan->next) {
relink_constraints(&chan->constraints);
}
}
@@ -3051,24 +3051,24 @@ void BKE_object_relink(Object *ob)
MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, int use_default)
{
- MovieClip *clip= use_default ? scene->clip : NULL;
- bConstraint *con= ob->constraints.first, *scon= NULL;
+ MovieClip *clip = use_default ? scene->clip : NULL;
+ bConstraint *con = ob->constraints.first, *scon = NULL;
while (con) {
- if (con->type==CONSTRAINT_TYPE_CAMERASOLVER) {
- if (scon==NULL || (scon->flag&CONSTRAINT_OFF))
- scon= con;
+ if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) {
+ if (scon == NULL || (scon->flag & CONSTRAINT_OFF))
+ scon = con;
}
- con= con->next;
+ con = con->next;
}
if (scon) {
- bCameraSolverConstraint *solver= scon->data;
- if ((solver->flag&CAMERASOLVER_ACTIVECLIP)==0)
- clip= solver->clip;
+ bCameraSolverConstraint *solver = scon->data;
+ if ((solver->flag & CAMERASOLVER_ACTIVECLIP) == 0)
+ clip = solver->clip;
else
- clip= scene->clip;
+ clip = scene->clip;
}
return clip;