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.c618
1 files changed, 313 insertions, 305 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 00aa5d96bab..cd59b74243b 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -129,7 +129,7 @@ void copy_baseflags(struct Scene *scene)
{
Base *base= scene->base.first;
- while(base) {
+ while (base) {
base->object->flag= base->flag;
base= base->next;
}
@@ -139,7 +139,7 @@ void copy_objectflags(struct Scene *scene)
{
Base *base= scene->base.first;
- while(base) {
+ while (base) {
base->flag= base->object->flag;
base= base->next;
}
@@ -157,7 +157,7 @@ void update_base_layer(struct Scene *scene, Object *ob)
void object_free_particlesystems(Object *ob)
{
- while(ob->particlesystem.first){
+ while (ob->particlesystem.first) {
ParticleSystem *psys = ob->particlesystem.first;
BLI_remlink(&ob->particlesystem,psys);
@@ -168,7 +168,7 @@ void object_free_particlesystems(Object *ob)
void object_free_softbody(Object *ob)
{
- if(ob->soft) {
+ if (ob->soft) {
sbFree(ob->soft);
ob->soft= NULL;
}
@@ -176,7 +176,7 @@ void object_free_softbody(Object *ob)
void object_free_bulletsoftbody(Object *ob)
{
- if(ob->bsoft) {
+ if (ob->bsoft) {
bsbFree(ob->bsoft);
ob->bsoft= NULL;
}
@@ -207,7 +207,7 @@ void object_link_modifiers(struct Object *ob, struct Object *from)
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;
+ if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue;
nmd = modifier_new(md->type);
modifier_copyData(md, nmd);
@@ -224,12 +224,12 @@ void object_link_modifiers(struct Object *ob, struct Object *from)
/* also (ab)used in depsgraph */
void object_free_display(Object *ob)
{
- if(ob->derivedDeform) {
+ if (ob->derivedDeform) {
ob->derivedDeform->needsFree = 1;
ob->derivedDeform->release(ob->derivedDeform);
ob->derivedDeform= NULL;
}
- if(ob->derivedFinal) {
+ if (ob->derivedFinal) {
ob->derivedFinal->needsFree = 1;
ob->derivedFinal->release(ob->derivedFinal);
ob->derivedFinal= NULL;
@@ -240,9 +240,9 @@ void object_free_display(Object *ob)
void free_sculptsession_deformMats(SculptSession *ss)
{
- if(ss->orig_cos) MEM_freeN(ss->orig_cos);
- if(ss->deform_cos) MEM_freeN(ss->deform_cos);
- if(ss->deform_imats) MEM_freeN(ss->deform_imats);
+ if (ss->orig_cos) MEM_freeN(ss->orig_cos);
+ if (ss->deform_cos) MEM_freeN(ss->deform_cos);
+ if (ss->deform_imats) MEM_freeN(ss->deform_imats);
ss->orig_cos = NULL;
ss->deform_cos = NULL;
@@ -251,26 +251,26 @@ void free_sculptsession_deformMats(SculptSession *ss)
void free_sculptsession(Object *ob)
{
- if(ob && ob->sculpt) {
+ if (ob && ob->sculpt) {
SculptSession *ss = ob->sculpt;
DerivedMesh *dm= ob->derivedFinal;
- if(ss->pbvh)
+ if (ss->pbvh)
BLI_pbvh_free(ss->pbvh);
- if(dm && dm->getPBVH)
+ if (dm && dm->getPBVH)
dm->getPBVH(NULL, dm); /* signal to clear */
- if(ss->texcache)
+ if (ss->texcache)
MEM_freeN(ss->texcache);
- if(ss->layer_co)
+ if (ss->layer_co)
MEM_freeN(ss->layer_co);
- if(ss->orig_cos)
+ if (ss->orig_cos)
MEM_freeN(ss->orig_cos);
- if(ss->deform_cos)
+ if (ss->deform_cos)
MEM_freeN(ss->deform_cos);
- if(ss->deform_imats)
+ if (ss->deform_imats)
MEM_freeN(ss->deform_imats);
MEM_freeN(ss);
@@ -288,34 +288,34 @@ void free_object(Object *ob)
object_free_display(ob);
/* disconnect specific data */
- if(ob->data) {
+ if (ob->data) {
ID *id= ob->data;
id->us--;
- if(id->us==0) {
- if(ob->type==OB_MESH) unlink_mesh(ob->data);
- else if(ob->type==OB_CURVE) unlink_curve(ob->data);
- else if(ob->type==OB_MBALL) unlink_mball(ob->data);
+ if (id->us==0) {
+ if (ob->type==OB_MESH) unlink_mesh(ob->data);
+ else if (ob->type==OB_CURVE) unlink_curve(ob->data);
+ else if (ob->type==OB_MBALL) unlink_mball(ob->data);
}
ob->data= NULL;
}
- for(a=0; a<ob->totcol; a++) {
- if(ob->mat[a]) ob->mat[a]->id.us--;
+ 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);
+ if (ob->mat) MEM_freeN(ob->mat);
+ if (ob->matbits) MEM_freeN(ob->matbits);
ob->mat= NULL;
ob->matbits= NULL;
- if(ob->bb) MEM_freeN(ob->bb);
+ if (ob->bb) MEM_freeN(ob->bb);
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--;
- if(ob->defbase.first)
+ if (ob->adt) BKE_free_animdata((ID *)ob);
+ if (ob->poselib) ob->poselib->id.us--;
+ if (ob->gpd) ((ID *)ob->gpd)->us--;
+ if (ob->defbase.first)
BLI_freelistN(&ob->defbase);
- if(ob->pose)
+ if (ob->pose)
free_pose(ob->pose);
- if(ob->mpath)
+ if (ob->mpath)
animviz_free_motionpath(ob->mpath);
free_properties(&ob->prop);
object_free_modifiers(ob);
@@ -328,13 +328,13 @@ void free_object(Object *ob)
free_partdeflect(ob->pd);
- if(ob->soft) sbFree(ob->soft);
- if(ob->bsoft) bsbFree(ob->bsoft);
- if(ob->gpulamp.first) GPU_lamp_free(ob);
+ if (ob->soft) sbFree(ob->soft);
+ if (ob->bsoft) bsbFree(ob->bsoft);
+ if (ob->gpulamp.first) GPU_lamp_free(ob);
free_sculptsession(ob);
- if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
+ if (ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
}
static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin)
@@ -372,17 +372,17 @@ void unlink_object(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;
- while(obt) {
- if(obt->proxy==ob)
+ while (obt) {
+ if (obt->proxy==ob)
obt->proxy= NULL;
- if(obt->proxy_from==ob) {
+ if (obt->proxy_from==ob) {
obt->proxy_from= NULL;
obt->recalc |= OB_RECALC_OB;
}
- if(obt->proxy_group==ob)
+ if (obt->proxy_group==ob)
obt->proxy_group= NULL;
- if(obt->parent==ob) {
+ if (obt->parent==ob) {
obt->parent= NULL;
obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
@@ -392,22 +392,22 @@ void unlink_object(Object *ob)
if ELEM(obt->type, OB_CURVE, OB_FONT) {
cu= obt->data;
- if(cu->bevobj==ob) {
+ if (cu->bevobj==ob) {
cu->bevobj= NULL;
obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
- if(cu->taperobj==ob) {
+ if (cu->taperobj==ob) {
cu->taperobj= NULL;
obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
- if(cu->textoncurve==ob) {
+ 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 (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};
@@ -428,12 +428,12 @@ void unlink_object(Object *ob)
cti->flush_constraint_targets(con, &targets, 0);
}
}
- if(pchan->custom==ob)
+ if (pchan->custom==ob)
pchan->custom= NULL;
}
}
- else if(ELEM(OB_MBALL, ob->type, obt->type)) {
- if(is_mball_basis_for(obt, ob))
+ else if (ELEM(OB_MBALL, ob->type, obt->type)) {
+ if (is_mball_basis_for (obt, ob))
obt->recalc|= OB_RECALC_DATA;
}
@@ -461,84 +461,84 @@ void unlink_object(Object *ob)
}
/* object is deflector or field */
- if(ob->pd) {
- if(obt->soft)
+ if (ob->pd) {
+ if (obt->soft)
obt->recalc |= OB_RECALC_DATA;
/* cloth */
- for(md=obt->modifiers.first; md; md=md->next)
- if(md->type == eModifierType_Cloth)
+ 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)
+ for (strip= obt->nlastrips.first; strip; strip= strip->next) {
+ if (strip->object==ob)
strip->object= NULL;
- if(strip->modifiers.first) {
+ if (strip->modifiers.first) {
bActionModifier *amod;
- for(amod= strip->modifiers.first; amod; amod= amod->next)
- if(amod->ob==ob)
+ 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) {
+ if (obt->particlesystem.first) {
ParticleSystem *tpsys= obt->particlesystem.first;
- for(; tpsys; tpsys=tpsys->next) {
+ 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) {
+ if (tpsys->target_ob==ob) {
tpsys->target_ob= NULL;
obt->recalc |= OB_RECALC_DATA;
}
- if(tpsys->part->dup_ob==ob)
+ 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)
+ 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) {
+ 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)
+ if (gabr->ob==ob)
gabr->ob= NULL;
}
- else if(rule->type==eBoidRuleType_FollowLeader) {
+ else if (rule->type==eBoidRuleType_FollowLeader) {
BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader*)rule;
- if(flbr->ob==ob)
+ if (flbr->ob==ob)
flbr->ob= NULL;
}
}
}
}
}
- if(ob->pd)
+ if (ob->pd)
obt->recalc |= OB_RECALC_DATA;
}
@@ -547,10 +547,10 @@ void unlink_object(Object *ob)
/* materials */
mat= bmain->mat.first;
- while(mat) {
+ 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;
}
@@ -560,18 +560,18 @@ void unlink_object(Object *ob)
}
/* 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;
- while(wrld) {
- if(wrld->id.lib==NULL) {
- for(a=0; a<MAX_MTEX; a++) {
- if(wrld->mtex[a] && ob==wrld->mtex[a]->object)
+ 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;
}
}
@@ -581,26 +581,26 @@ void unlink_object(Object *ob)
/* scenes */
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;
+ 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;
#ifdef DURIAN_CAMERA_SWITCH
{
TimeMarker *m;
for (m= sce->markers.first; m; m= m->next) {
- if(m->camera==ob)
+ if (m->camera==ob)
m->camera= NULL;
}
}
#endif
- if(sce->ed) {
+ if (sce->ed) {
Sequence *seq;
SEQ_BEGIN(sce->ed, seq)
- if(seq->scene_camera==ob) {
+ if (seq->scene_camera==ob) {
seq->scene_camera= NULL;
}
SEQ_END
@@ -612,21 +612,21 @@ void unlink_object(Object *ob)
/* screens */
sc= bmain->screen.first;
- while(sc) {
+ while (sc) {
ScrArea *sa= sc->areabase.first;
- while(sa) {
+ while (sa) {
SpaceLink *sl;
for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if(sl->spacetype==SPACE_VIEW3D) {
+ if (sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D*) sl;
found= 0;
- if(v3d->camera==ob) {
+ if (v3d->camera==ob) {
v3d->camera= NULL;
found= 1;
}
- if(v3d->localvd && v3d->localvd->camera==ob ) {
+ if (v3d->localvd && v3d->localvd->camera==ob ) {
v3d->localvd->camera= NULL;
found += 2;
}
@@ -649,21 +649,21 @@ void unlink_object(Object *ob)
}
}
}
- else if(sl->spacetype==SPACE_OUTLINER) {
+ else if (sl->spacetype==SPACE_OUTLINER) {
SpaceOops *so= (SpaceOops *)sl;
- if(so->treestore) {
+ if (so->treestore) {
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) {
+ else if (sl->spacetype==SPACE_BUTS) {
SpaceButs *sbuts= (SpaceButs *)sl;
- if(sbuts->pinid==(ID *)ob) {
+ if (sbuts->pinid==(ID *)ob) {
sbuts->flag&= ~SB_PIN_CONTEXT;
sbuts->pinid= NULL;
}
@@ -677,14 +677,14 @@ void unlink_object(Object *ob)
/* groups */
group= bmain->group.first;
- while(group) {
+ while (group) {
rem_from_group(group, ob, NULL, NULL);
group= group->id.next;
}
/* cameras */
camera= bmain->camera.first;
- while(camera) {
+ while (camera) {
if (camera->dof_ob==ob) {
camera->dof_ob = NULL;
}
@@ -696,11 +696,11 @@ int exist_object(Object *obtest)
{
Object *ob;
- if(obtest==NULL) return 0;
+ if (obtest==NULL) return 0;
ob= G.main->object.first;
- while(ob) {
- if(ob==obtest) return 1;
+ while (ob) {
+ if (ob==obtest) return 1;
ob= ob->id.next;
}
return 0;
@@ -785,7 +785,7 @@ Object *add_only_object(int type, const char *name)
ob->empty_drawtype= OB_PLAINAXES;
ob->empty_drawsize= 1.0;
- if(type==OB_CAMERA || type==OB_LAMP || type==OB_SPEAKER) {
+ if (type==OB_CAMERA || type==OB_LAMP || type==OB_SPEAKER) {
ob->trackflag= OB_NEGZ;
ob->upflag= OB_POSY;
}
@@ -865,7 +865,7 @@ SoftBody *copy_softbody(SoftBody *sb)
sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches);
- if(sb->effector_weights)
+ if (sb->effector_weights)
sbn->effector_weights = MEM_dupallocN(sb->effector_weights);
return sbn;
@@ -892,32 +892,32 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *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++)
+ if (psys->part->type == PART_HAIR) {
+ for (p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++)
pa->hair = MEM_dupallocN(pa->hair);
}
- if(psysn->particles && (psysn->particles->keys || psysn->particles->boid)) {
+ if (psysn->particles && (psysn->particles->keys || psysn->particles->boid)) {
ParticleKey *key = psysn->particles->keys;
BoidParticle *boid = psysn->particles->boid;
- if(key)
+ if (key)
key = MEM_dupallocN(key);
- if(boid)
+ if (boid)
boid = MEM_dupallocN(boid);
- for(p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) {
- if(boid)
+ for (p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) {
+ if (boid)
pa->boid = boid++;
- if(key) {
+ if (key) {
pa->keys = key;
key += pa->totkey;
}
}
}
- if(psys->clmd) {
+ if (psys->clmd) {
psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)psysn->clmd);
psys->hair_in_dm = psys->hair_out_dm = NULL;
@@ -940,7 +940,7 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
/* 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) {
+ if (psysn->clmd) {
psysn->clmd->point_cache= psysn->pointcache;
}
@@ -955,22 +955,22 @@ void copy_object_particlesystems(Object *obn, Object *ob)
ModifierData *md;
obn->particlesystem.first= obn->particlesystem.last= NULL;
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
+ 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) {
+ for (md=obn->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd= (ParticleSystemModifierData*)md;
- if(psmd->psys==psys)
+ if (psmd->psys==psys)
psmd->psys= npsys;
}
- else if(md->type==eModifierType_DynamicPaint) {
+ else if (md->type==eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd= (DynamicPaintModifierData*)md;
if (pmd->brush) {
- if(pmd->brush->psys==psys) {
+ if (pmd->brush->psys==psys) {
pmd->brush->psys= npsys;
}
}
@@ -978,7 +978,7 @@ void copy_object_particlesystems(Object *obn, Object *ob)
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;
@@ -991,7 +991,7 @@ void copy_object_particlesystems(Object *obn, Object *ob)
void copy_object_softbody(Object *obn, Object *ob)
{
- if(ob->soft)
+ if (ob->soft)
obn->soft= copy_softbody(ob->soft);
}
@@ -1003,7 +1003,7 @@ static void copy_object_pose(Object *obn, Object *ob)
obn->pose= NULL;
copy_pose(&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);
@@ -1030,7 +1030,7 @@ static void copy_object_pose(Object *obn, Object *ob)
static int object_pose_context(Object *ob)
{
- if( (ob) &&
+ if ( (ob) &&
(ob->type == OB_ARMATURE) &&
(ob->pose) &&
(ob->mode & OB_MODE_POSE)
@@ -1044,15 +1044,15 @@ static int object_pose_context(Object *ob)
Object *object_pose_armature_get(Object *ob)
{
- if(ob==NULL)
+ if (ob==NULL)
return NULL;
- if(object_pose_context(ob))
+ if (object_pose_context(ob))
return ob;
ob= modifiers_isDeformedByArmature(ob);
- if(object_pose_context(ob))
+ if (object_pose_context(ob))
return ob;
return NULL;
@@ -1077,13 +1077,13 @@ Object *copy_object(Object *ob)
obn= copy_libblock(&ob->id);
- if(ob->totcol) {
+ if (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;
@@ -1102,10 +1102,10 @@ Object *copy_object(Object *ob)
copy_controllers(&obn->controllers, &ob->controllers);
copy_actuators(&obn->actuators, &ob->actuators);
- if(ob->pose) {
+ 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)
armature_rebuild_pose(obn, obn->data);
}
defgroup_copy_list(&obn->defbase, &ob->defbase);
@@ -1119,15 +1119,15 @@ Object *copy_object(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;
- if(ob->pd){
+ if (ob->pd) {
obn->pd= MEM_dupallocN(ob->pd);
- if(obn->pd->tex)
+ if (obn->pd->tex)
id_us_plus(&(obn->pd->tex->id));
- if(obn->pd->rng)
+ if (obn->pd->rng)
obn->pd->rng = MEM_dupallocN(ob->pd->rng);
}
obn->soft= copy_softbody(ob->soft);
@@ -1157,7 +1157,7 @@ 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);
}
@@ -1173,27 +1173,27 @@ void make_local_object(Object *ob)
* - mixed: make copy
*/
- if(ob->id.lib==NULL) return;
+ if (ob->id.lib==NULL) return;
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) {
- if(object_in_scene(ob, sce)) {
- if(sce->id.lib) is_lib= TRUE;
+ for (sce= bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce= sce->id.next) {
+ if (object_in_scene(ob, sce)) {
+ if (sce->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &ob->id);
extern_local_object(ob);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Object *ob_new= copy_object(ob);
ob_new->id.us= 0;
@@ -1202,11 +1202,11 @@ void make_local_object(Object *ob)
BKE_id_lib_local_paths(bmain, ob->id.lib, &ob_new->id);
sce= bmain->scene.first;
- while(sce) {
- if(sce->id.lib==NULL) {
+ while (sce) {
+ if (sce->id.lib==NULL) {
base= sce->base.first;
- while(base) {
- if(base->object==ob) {
+ while (base) {
+ if (base->object==ob) {
base->object= ob_new;
ob_new->id.us++;
ob->id.us--;
@@ -1234,11 +1234,11 @@ int object_is_libdata(Object *ob)
/* Returns true if the Object data is a from an external blend file (libdata) */
int object_data_is_libdata(Object *ob)
{
- if(!ob) 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(((ID *)ob->data)->lib) return 1;
+ if (!ob) 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 (((ID *)ob->data)->lib) return 1;
return 0;
}
@@ -1253,7 +1253,7 @@ static void armature_set_id_extern(Object *ob)
unsigned int lay= arm->layer_protected;
for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- if(!(pchan->bone->layer & lay))
+ if (!(pchan->bone->layer & lay))
id_lib_extern((ID *)pchan->custom);
}
@@ -1265,7 +1265,7 @@ void object_copy_proxy_drivers(Object *ob, Object *target)
FCurve *fcu;
/* add new animdata block */
- if(!ob->adt)
+ if (!ob->adt)
ob->adt= BKE_id_add_animdata(&ob->id);
/* make a copy of all the drivers (for now), then correct any links that need fixing */
@@ -1280,13 +1280,13 @@ void object_copy_proxy_drivers(Object *ob, Object *target)
/* all drivers */
DRIVER_TARGETS_LOOPER(dvar)
{
- if(dtar->id) {
+ if (dtar->id) {
if ((Object *)dtar->id == target)
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);
}
}
@@ -1304,7 +1304,7 @@ void object_copy_proxy_drivers(Object *ob, Object *target)
void 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;
}
@@ -1321,10 +1321,10 @@ void 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) {
+ if (gob) {
ob->rotmode= target->rotmode;
mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat);
- if(gob->dup_group) { /* should always be true */
+ if (gob->dup_group) { /* should always be true */
float tvec[3];
copy_v3_v3(tvec, gob->dup_group->dupli_ofs);
mul_mat3_m4_v3(ob->obmat, tvec);
@@ -1351,8 +1351,8 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
/* copy material and index information */
ob->actcol= ob->totcol= 0;
- if(ob->mat) MEM_freeN(ob->mat);
- if(ob->matbits) MEM_freeN(ob->matbits);
+ if (ob->mat) MEM_freeN(ob->mat);
+ if (ob->matbits) MEM_freeN(ob->matbits);
ob->mat = NULL;
ob->matbits= NULL;
if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
@@ -1363,14 +1363,14 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
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++) {
/* dont need to run test_object_materials since we know this object is new and not used elsewhere */
id_us_plus((ID *)ob->mat[i]);
}
}
/* type conversions */
- if(target->type == OB_ARMATURE) {
+ if (target->type == OB_ARMATURE) {
copy_object_pose(ob, target); /* data copy, object pointers in constraints */
rest_pose(ob->pose); /* clear all transforms in channels */
armature_rebuild_pose(ob, ob->data); /* set all internal links */
@@ -1383,12 +1383,12 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
}
/* copy IDProperties */
- if(ob->id.properties) {
+ if (ob->id.properties) {
IDP_FreeProperty(ob->id.properties);
MEM_freeN(ob->id.properties);
ob->id.properties= NULL;
}
- if(target->id.properties) {
+ if (target->id.properties) {
ob->id.properties= IDP_CopyProperty(target->id.properties);
}
@@ -1471,7 +1471,7 @@ void 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);
+ if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
}
}
@@ -1547,7 +1547,7 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
{
float rot[3][3];
- if(use_parent && ob->parent) {
+ if (use_parent && ob->parent) {
float rmat[4][4], diff_mat[4][4], imat[4][4];
mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
invert_m4_m4(imat, diff_mat);
@@ -1609,16 +1609,16 @@ 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! */
+ 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) {
+ if (ob->ipoflag & OB_DISABLE_PATH) {
ctime= 0.0f;
}
/* catch exceptions: curve paths used as a duplicator */
- else if(enable_cu_speed) {
+ else if (enable_cu_speed) {
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
* but this will only work if it actually is animated...
*
@@ -1641,7 +1641,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) {
+ if (cu->flag & CU_OFFS_PATHDIST) {
ctime += timeoffs/cu->path->totdist;
/* restore */
@@ -1650,9 +1650,9 @@ 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 (cu->flag & CU_FOLLOW) {
#if 0
float x1, q[4];
vec_to_quat( quat,dir, ob->trackflag, ob->upflag);
@@ -1672,7 +1672,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
quat_to_mat4(mat, quat);
}
- if(cu->flag & CU_PATH_RADIUS) {
+ if (cu->flag & CU_PATH_RADIUS) {
float tmat[4][4], rmat[4][4];
scale_m4_fl(tmat, radius);
mult_m4_m4m4(rmat, tmat, mat);
@@ -1696,7 +1696,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
/* Make sure the bone is still valid */
pchan= get_pose_channel(par->pose, ob->parsubstr);
- if (!pchan){
+ if (!pchan) {
printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr);
unit_m4(mat);
return;
@@ -1718,21 +1718,21 @@ static void give_parvert(Object *par, int nr, float *vec)
vec[0]=vec[1]=vec[2]= 0.0f;
- if(par->type==OB_MESH) {
+ 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(em) {
+ if (em) {
BMVert *eve;
BMIter iter;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
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;
}
@@ -1742,17 +1742,17 @@ static void give_parvert(Object *par, int nr, float *vec)
dm = (em)? em->derivedFinal: par->derivedFinal;
- if(dm) {
+ if (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;
- for(i = 0; i < numVerts; i++) {
+ for (i = 0; i < numVerts; i++) {
vindex= (index)? index[i]: i;
- if(vindex == nr) {
+ if (vindex == nr) {
add_v3_v3(vec, mvert[i].co);
count++;
}
@@ -1760,7 +1760,7 @@ static void give_parvert(Object *par, int nr, float *vec)
if (count==0) {
/* keep as 0,0,0 */
- } else if(count > 0) {
+ } else if (count > 0) {
mul_v3_fl(vec, 1.0f / count);
} else {
/* use first index if its out of range */
@@ -1782,12 +1782,12 @@ static void give_parvert(Object *par, int nr, float *vec)
nu= nurbs->first;
count= 0;
- while(nu && !found) {
- if(nu->type == CU_BEZIER) {
+ while (nu && !found) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(count==nr) {
+ while (a--) {
+ if (count==nr) {
found= 1;
copy_v3_v3(vec, bezt->vec[1]);
break;
@@ -1799,8 +1799,8 @@ static void give_parvert(Object *par, int nr, float *vec)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(count==nr) {
+ while (a--) {
+ if (count==nr) {
found= 1;
memcpy(vec, bp->vec, sizeof(float)*3);
break;
@@ -1813,27 +1813,27 @@ static void give_parvert(Object *par, int nr, float *vec)
}
}
- else if(par->type==OB_LATTICE) {
+ 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;
- 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;
- while(a--) {
- if(count==nr) {
- if(co)
+ while (a--) {
+ if (count==nr) {
+ if (co)
memcpy(vec, co, 3*sizeof(float));
else
memcpy(vec, bp->vec, 3*sizeof(float));
break;
}
count++;
- if(co) co+= 3;
+ if (co) co+= 3;
else bp++;
}
}
@@ -1856,7 +1856,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 {
@@ -1875,12 +1875,12 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
// include framerate
fac1= ( 1.0f / (1.0f + fabsf(ob->sf)) );
- if(fac1 >= 1.0f) return 0;
+ if (fac1 >= 1.0f) return 0;
fac2= 1.0f-fac1;
fp1= obmat[0];
fp2= slowmat[0];
- for(a=0; a<16; a++, fp1++, fp2++) {
+ for (a=0; a<16; a++, fp1++, fp2++) {
fp1[0]= fac1*fp1[0] + fac2*fp2[0];
}
@@ -1896,21 +1896,21 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
/* 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) {
+ if (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) {
+ if (stime != par->ctime) {
// only for ipo systems?
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 where_is_object_time(scene, par, ctime);
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
@@ -1923,8 +1923,8 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
* An old-fashioned hack which probably doesn't really cut it anymore
*/
- if(ob->partype & PARSLOW) {
- if(!where_is_object_parslow(ob, ob->obmat, slowmat))
+ if (ob->partype & PARSLOW) {
+ if (!where_is_object_parslow(ob, ob->obmat, slowmat))
return;
}
}
@@ -1945,7 +1945,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
}
/* set negative scale flag in object */
- if(is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
+ if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
}
@@ -1957,12 +1957,12 @@ void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4])
{
float slowmat[4][4] = MAT4_UNITY;
- if(ob->parent) {
+ if (ob->parent) {
Object *par= ob->parent;
solve_parenting(scene, ob, par, obmat, slowmat, 1);
- if(ob->partype & PARSLOW)
+ if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
}
else {
@@ -1980,19 +1980,19 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
object_to_mat4(ob, locmat);
- if(ob->partype & PARSLOW) copy_m4_m4(slowmat, 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 ) {
+ 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,
+ if (ok) mul_serie_m4(totmat, par->obmat, tmat,
NULL, NULL, NULL, NULL, NULL, NULL);
else copy_m4_m4(totmat, par->obmat);
@@ -2005,7 +2005,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
case PARVERT1:
unit_m4(totmat);
- if (simul){
+ if (simul) {
copy_v3_v3(totmat[3], par->obmat[3]);
}
else{
@@ -2039,7 +2039,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 {
@@ -2067,17 +2067,17 @@ for a lamp that is the child of another object */
int a;
/* NO TIMEOFFS */
- if(ob->parent) {
+ if (ob->parent) {
par= ob->parent;
solve_parenting(scene, ob, par, ob->obmat, slowmat, 1);
- if(ob->partype & PARSLOW) {
+ 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++) {
+ for (a=0; a<16; a++, fp1++, fp2++) {
fp1[0]= fac1*fp1[0] + fac2*fp2[0];
}
}
@@ -2149,13 +2149,13 @@ BoundBox *object_get_boundbox(Object *ob)
{
BoundBox *bb= NULL;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
bb = mesh_get_bb(ob);
}
else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
bb= ob->bb ? ob->bb : ( (Curve *)ob->data )->bb;
}
- else if(ob->type==OB_MBALL) {
+ else if (ob->type==OB_MBALL) {
bb= ob->bb;
}
return bb;
@@ -2165,8 +2165,8 @@ BoundBox *object_get_boundbox(Object *ob)
void object_boundbox_flag(Object *ob, int flag, int set)
{
BoundBox *bb= object_get_boundbox(ob);
- if(bb) {
- if(set) bb->flag |= flag;
+ if (bb) {
+ if (set) bb->flag |= flag;
else bb->flag &= ~flag;
}
}
@@ -2223,10 +2223,10 @@ void minmax_object(Object *ob, float min[3], float max[3])
{
Curve *cu= ob->data;
- if(cu->bb==NULL) tex_space_curve(cu);
+ if (cu->bb==NULL) tex_space_curve(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, max);
}
@@ -2239,9 +2239,9 @@ void minmax_object(Object *ob, float min[3], float max[3])
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, max);
}
@@ -2251,9 +2251,9 @@ void minmax_object(Object *ob, float min[3], float max[3])
}
break;
case OB_ARMATURE:
- if(ob->pose) {
+ if (ob->pose) {
bPoseChannel *pchan;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
DO_MINMAX(vec, min, max);
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
@@ -2266,10 +2266,10 @@ void minmax_object(Object *ob, float min[3], float max[3])
{
Mesh *me= get_mesh(ob);
- if(me) {
+ if (me) {
bb = *mesh_get_bb(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, max);
}
@@ -2279,7 +2279,7 @@ void minmax_object(Object *ob, float min[3], float max[3])
break;
}
- if(change == FALSE) {
+ if (change == FALSE) {
DO_MINMAX(ob->obmat[3], min, max);
copy_v3_v3(vec, ob->obmat[3]);
@@ -2302,13 +2302,13 @@ int minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max)
DupliObject *dob;
lb= object_duplilist(scene, ob);
- for(dob= lb->first; dob; dob= dob->next) {
- if(dob->no_draw == 0) {
+ for (dob= lb->first; dob; dob= dob->next) {
+ if (dob->no_draw == 0) {
BoundBox *bb= object_get_boundbox(dob->ob);
- if(bb) {
+ 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, min, max);
@@ -2364,8 +2364,8 @@ void BKE_scene_foreach_display_point(
Base *base;
Object *ob;
- for(base= FIRSTBASE; base; base = base->next) {
- if(BASE_VISIBLE(v3d, base) && (base->flag & flag) == flag) {
+ for (base= FIRSTBASE; base; base = base->next) {
+ if (BASE_VISIBLE(v3d, base) && (base->flag & flag) == flag) {
ob= base->object;
if ((ob->transflag & OB_DUPLI)==0) {
@@ -2376,8 +2376,8 @@ void BKE_scene_foreach_display_point(
DupliObject *dob;
lb= object_duplilist(scene, ob);
- for(dob= lb->first; dob; dob= dob->next) {
- if(dob->no_draw == 0) {
+ 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);
}
}
@@ -2450,8 +2450,8 @@ void object_tfm_restore(Object *ob, void *obtfm_pt)
int BKE_object_parent_loop_check(const Object *par, const Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
- if(par == NULL) return 0;
- if(ob == par) return 1;
+ if (par == NULL) return 0;
+ if (ob == par) return 1;
return BKE_object_parent_loop_check(par->parent, ob);
}
@@ -2464,18 +2464,18 @@ int BKE_object_parent_loop_check(const Object *par, const Object *ob)
/* requires flags to be set! */
void object_handle_update(Scene *scene, Object *ob)
{
- if(ob->recalc & OB_RECALC_ALL) {
+ if (ob->recalc & OB_RECALC_ALL) {
/* speed optimization for animation lookups */
- if(ob->pose)
+ if (ob->pose)
make_pose_channels_hash(ob->pose);
- if(ob->recalc & OB_RECALC_DATA) {
- if(ob->type==OB_ARMATURE) {
+ if (ob->recalc & OB_RECALC_DATA) {
+ if (ob->type==OB_ARMATURE) {
/* this happens for reading old files and to match library armatures
with poses we do it ahead of where_is_object 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))
armature_rebuild_pose(ob, ob->data);
}
}
@@ -2483,19 +2483,19 @@ void object_handle_update(Scene *scene, Object *ob)
/* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers,
which is only in where_is_object now */
// XXX: should this case be OB_RECALC_OB instead?
- if(ob->recalc & OB_RECALC_ALL) {
+ if (ob->recalc & OB_RECALC_ALL) {
if (G.f & G_DEBUG)
printf("recalcob %s\n", ob->id.name+2);
/* handle proxy copy for target */
- if(ob->id.lib && ob->proxy_from) {
+ 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 */
+ 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 */
+ if (obg->dup_group) { /* should always be true */
add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
}
}
@@ -2506,7 +2506,7 @@ void object_handle_update(Scene *scene, Object *ob)
where_is_object(scene, ob);
}
- if(ob->recalc & OB_RECALC_DATA) {
+ 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...
@@ -2516,7 +2516,7 @@ void object_handle_update(Scene *scene, Object *ob)
if (G.f & G_DEBUG)
printf("recalcdata %s\n", ob->id.name+2);
- if(adt) {
+ if (adt) {
/* evaluate drivers */
// XXX: for mesh types, should we push this to derivedmesh instead?
BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS);
@@ -2529,7 +2529,7 @@ void object_handle_update(Scene *scene, Object *ob)
#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH);
- if(em) {
+ if (em) {
makeDerivedMesh(scene, ob, em, scene->customdata_mask, 0); /* was CD_MASK_BAREMESH */
}
else {
@@ -2539,7 +2539,7 @@ void object_handle_update(Scene *scene, Object *ob)
#else /* ensure CD_MASK_BAREMESH for now */
BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
uint64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
- if(em) {
+ if (em) {
makeDerivedMesh(scene, ob, em, data_mask, 0); /* was CD_MASK_BAREMESH */
}
else {
@@ -2551,7 +2551,7 @@ void object_handle_update(Scene *scene, Object *ob)
break;
case OB_ARMATURE:
- if(ob->id.lib && ob->proxy_from) {
+ 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);
copy_pose_result(ob->pose, ob->proxy_from->pose);
}
@@ -2576,16 +2576,16 @@ void object_handle_update(Scene *scene, Object *ob)
}
- if(ob->particlesystem.first) {
+ if (ob->particlesystem.first) {
ParticleSystem *tpsys, *psys;
DerivedMesh *dm;
ob->transflag &= ~OB_DUPLIPARTS;
psys= ob->particlesystem.first;
- while(psys) {
- if(psys_check_enabled(ob, psys)) {
+ while (psys) {
+ if (psys_check_enabled(ob, psys)) {
/* check use of dupli objects here */
- if(psys->part && (psys->part->draw_as == PART_DRAW_REND || G.rendering) &&
+ if (psys->part && (psys->part->draw_as == PART_DRAW_REND || G.rendering) &&
((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob)
|| (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group)))
ob->transflag |= OB_DUPLIPARTS;
@@ -2593,7 +2593,7 @@ void object_handle_update(Scene *scene, Object *ob)
particle_system_update(scene, ob, psys);
psys= psys->next;
}
- else if(psys->flag & PSYS_DELETE) {
+ else if (psys->flag & PSYS_DELETE) {
tpsys=psys->next;
BLI_remlink(&ob->particlesystem, psys);
psys_free(ob,psys);
@@ -2603,14 +2603,14 @@ void object_handle_update(Scene *scene, Object *ob)
psys= psys->next;
}
- if(G.rendering && ob->transflag & OB_DUPLIPARTS) {
+ 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->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;
}
}
@@ -2618,12 +2618,12 @@ void 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) {
- if((pid->cache->flag & PTCACHE_BAKED)
+ 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) :
@@ -2635,7 +2635,7 @@ void 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;
// printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name);
@@ -2646,7 +2646,7 @@ void 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) {
+ if (ob->proxy) {
ob->proxy->proxy_from= ob;
// printf("set proxy pointer for later group stuff %s\n", ob->id.name);
}
@@ -2656,11 +2656,11 @@ void object_sculpt_modifiers_changed(Object *ob)
{
SculptSession *ss= ob->sculpt;
- if(!ss->cache) {
+ 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) {
+ if (ss->pbvh) {
BLI_pbvh_free(ss->pbvh);
ss->pbvh= NULL;
}
@@ -2672,7 +2672,7 @@ void object_sculpt_modifiers_changed(Object *ob)
BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
- for(n = 0; n < totnode; n++)
+ for (n = 0; n < totnode; n++)
BLI_pbvh_node_mark_update(nodes[n]);
MEM_freeN(nodes);
@@ -2750,7 +2750,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
static int pc_cmp(void *a, void *b)
{
LinkData *ad = a, *bd = b;
- if(GET_INT_FROM_POINTER(ad->data) > GET_INT_FROM_POINTER(bd->data))
+ if (GET_INT_FROM_POINTER(ad->data) > GET_INT_FROM_POINTER(bd->data))
return 1;
else return 0;
}
@@ -2762,11 +2762,11 @@ int 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)
+ if (i < index)
break;
}
@@ -2815,13 +2815,13 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int
KeyBlock *kb;
int newkey= 0;
- if(key == NULL) {
+ if (key == NULL) {
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(key, name);
mesh_to_key(me, kb);
@@ -2846,13 +2846,13 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
KeyBlock *kb;
int newkey= 0;
- if(key==NULL) {
+ 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(key, name);
if (!newkey) {
KeyBlock *basekb= (KeyBlock *)key->block.first;
@@ -2884,13 +2884,13 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
ListBase *lb= BKE_curve_nurbs(cu);
int newkey= 0;
- if(key==NULL) {
+ if (key==NULL) {
key= cu->key= add_key( (ID *)cu);
key->type = KEY_RELATIVE;
newkey= 1;
}
- if(newkey || from_mix==FALSE) {
+ if (newkey || from_mix==FALSE) {
/* create from curve */
kb= add_keyblock(key, name);
if (!newkey) {
@@ -2917,9 +2917,9 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix)
{
- if(ob->type==OB_MESH) return insert_meshkey(scene, ob, name, from_mix);
+ if (ob->type==OB_MESH) return insert_meshkey(scene, ob, name, from_mix);
else if ELEM(ob->type, OB_CURVE, OB_SURF)return insert_curvekey(scene, ob, name, from_mix);
- else if(ob->type==OB_LATTICE) return insert_lattkey(scene, ob, name, from_mix);
+ else if (ob->type==OB_LATTICE) return insert_lattkey(scene, ob, name, from_mix);
else return NULL;
}
@@ -2930,15 +2930,23 @@ int object_is_modified(Scene *scene, Object *ob)
{
int flag= 0;
- if(ob_get_key(ob)) {
+ if (ob_get_key(ob)) {
flag |= eModifierMode_Render;
}
else {
ModifierData *md;
/* cloth */
- for(md=modifiers_getVirtualModifierList(ob); md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); md=md->next) {
- if((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) flag |= eModifierMode_Render;
- if((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime)) flag |= eModifierMode_Realtime;
+ for (md=modifiers_getVirtualModifierList(ob);
+ md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
+ md=md->next)
+ {
+ if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) {
+ flag |= eModifierMode_Render;
+ }
+
+ if ((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
+ flag |= eModifierMode_Realtime;
+ }
}
}
@@ -2948,24 +2956,24 @@ int object_is_modified(Scene *scene, Object *ob)
static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin)
{
/* this is copied from ID_NEW; it might be better to have a macro */
- if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid;
+ if (*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid;
}
void object_relink(Object *ob)
{
- if(ob->id.lib)
+ if (ob->id.lib)
return;
relink_constraints(&ob->constraints);
- if (ob->pose){
+ 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);
}
}
modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL);
- if(ob->adt)
+ if (ob->adt)
BKE_relink_animdata(ob->adt);
ID_NEW(ob->parent);
@@ -2979,18 +2987,18 @@ MovieClip *object_get_movieclip(Scene *scene, Object *ob, int use_default)
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))
+ while (con) {
+ if (con->type==CONSTRAINT_TYPE_CAMERASOLVER) {
+ if (scon==NULL || (scon->flag&CONSTRAINT_OFF))
scon= con;
}
con= con->next;
}
- if(scon) {
+ if (scon) {
bCameraSolverConstraint *solver= scon->data;
- if((solver->flag&CAMERASOLVER_ACTIVECLIP)==0)
+ if ((solver->flag&CAMERASOLVER_ACTIVECLIP)==0)
clip= solver->clip;
else
clip= scene->clip;