style cleanup: blenkernel
This commit is contained in:
@@ -88,23 +88,23 @@ void animviz_settings_init(bAnimVizSettings *avs)
|
||||
return;
|
||||
|
||||
/* ghosting settings */
|
||||
avs->ghost_bc= avs->ghost_ac= 10;
|
||||
avs->ghost_bc = avs->ghost_ac = 10;
|
||||
|
||||
avs->ghost_sf= 1; // xxx - take from scene instead?
|
||||
avs->ghost_ef= 250; // xxx - take from scene instead?
|
||||
avs->ghost_sf = 1; // xxx - take from scene instead?
|
||||
avs->ghost_ef = 250; // xxx - take from scene instead?
|
||||
|
||||
avs->ghost_step= 1;
|
||||
avs->ghost_step = 1;
|
||||
|
||||
|
||||
/* path settings */
|
||||
avs->path_bc= avs->path_ac= 10;
|
||||
avs->path_bc = avs->path_ac = 10;
|
||||
|
||||
avs->path_sf= 1; // xxx - take from scene instead?
|
||||
avs->path_ef= 250; // xxx - take from scene instead?
|
||||
avs->path_sf = 1; // xxx - take from scene instead?
|
||||
avs->path_ef = 250; // xxx - take from scene instead?
|
||||
|
||||
avs->path_viewflag= (MOTIONPATH_VIEW_KFRAS|MOTIONPATH_VIEW_KFNOS);
|
||||
avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS);
|
||||
|
||||
avs->path_step= 1;
|
||||
avs->path_step = 1;
|
||||
}
|
||||
|
||||
/* ------------------- */
|
||||
@@ -121,8 +121,8 @@ void animviz_free_motionpath_cache(bMotionPath *mpath)
|
||||
MEM_freeN(mpath->points);
|
||||
|
||||
/* reset the relevant parameters */
|
||||
mpath->points= NULL;
|
||||
mpath->length= 0;
|
||||
mpath->points = NULL;
|
||||
mpath->length = 0;
|
||||
}
|
||||
|
||||
/* Free the given motion path instance and its data
|
||||
@@ -162,22 +162,22 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
|
||||
/* get destination data */
|
||||
if (pchan) {
|
||||
/* paths for posechannel - assume that posechannel belongs to the object */
|
||||
avs= &ob->pose->avs;
|
||||
dst= &pchan->mpath;
|
||||
avs = &ob->pose->avs;
|
||||
dst = &pchan->mpath;
|
||||
}
|
||||
else {
|
||||
/* paths for object */
|
||||
avs= &ob->avs;
|
||||
dst= &ob->mpath;
|
||||
avs = &ob->avs;
|
||||
dst = &ob->mpath;
|
||||
}
|
||||
|
||||
/* avoid 0 size allocs */
|
||||
if (avs->path_sf >= avs->path_ef) {
|
||||
BKE_reportf(reports, RPT_ERROR,
|
||||
"Motion Path frame extents invalid for %s (%d to %d).%s\n",
|
||||
(pchan)? pchan->name : ob->id.name,
|
||||
avs->path_sf, avs->path_ef,
|
||||
(avs->path_sf == avs->path_ef)? " Cannot have single-frame paths." : "");
|
||||
"Motion Path frame extents invalid for %s (%d to %d).%s\n",
|
||||
(pchan) ? pchan->name : ob->id.name,
|
||||
avs->path_sf, avs->path_ef,
|
||||
(avs->path_sf == avs->path_ef) ? " Cannot have single-frame paths." : "");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
|
||||
if (*dst != NULL) {
|
||||
int expected_length = avs->path_ef - avs->path_sf;
|
||||
|
||||
mpath= *dst;
|
||||
mpath = *dst;
|
||||
|
||||
/* path is "valid" if length is valid, but must also be of the same length as is being requested */
|
||||
if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) {
|
||||
@@ -204,15 +204,15 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
|
||||
}
|
||||
else {
|
||||
/* create a new motionpath, and assign it */
|
||||
mpath= MEM_callocN(sizeof(bMotionPath), "bMotionPath");
|
||||
*dst= mpath;
|
||||
mpath = MEM_callocN(sizeof(bMotionPath), "bMotionPath");
|
||||
*dst = mpath;
|
||||
}
|
||||
|
||||
/* set settings from the viz settings */
|
||||
mpath->start_frame= avs->path_sf;
|
||||
mpath->end_frame= avs->path_ef;
|
||||
mpath->start_frame = avs->path_sf;
|
||||
mpath->end_frame = avs->path_ef;
|
||||
|
||||
mpath->length= mpath->end_frame - mpath->start_frame;
|
||||
mpath->length = mpath->end_frame - mpath->start_frame;
|
||||
|
||||
if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS)
|
||||
mpath->flag |= MOTIONPATH_FLAG_BHEAD;
|
||||
@@ -220,7 +220,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
|
||||
mpath->flag &= ~MOTIONPATH_FLAG_BHEAD;
|
||||
|
||||
/* allocate a cache */
|
||||
mpath->points= MEM_callocN(sizeof(bMotionPathVert)*mpath->length, "bMotionPathVerts");
|
||||
mpath->points = MEM_callocN(sizeof(bMotionPathVert) * mpath->length, "bMotionPathVerts");
|
||||
|
||||
/* tag viz settings as currently having some path(s) which use it */
|
||||
avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS;
|
||||
@@ -235,16 +235,16 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
|
||||
typedef struct MPathTarget {
|
||||
struct MPathTarget *next, *prev;
|
||||
|
||||
bMotionPath *mpath; /* motion path in question */
|
||||
bMotionPath *mpath; /* motion path in question */
|
||||
|
||||
Object *ob; /* source object */
|
||||
bPoseChannel *pchan; /* source posechannel (if applicable) */
|
||||
Object *ob; /* source object */
|
||||
bPoseChannel *pchan; /* source posechannel (if applicable) */
|
||||
} MPathTarget;
|
||||
|
||||
/* ........ */
|
||||
|
||||
/* get list of motion paths to be baked for the given object
|
||||
* - assumes the given list is ready to be used
|
||||
* - assumes the given list is ready to be used
|
||||
*/
|
||||
// TODO: it would be nice in future to be able to update objects dependent on these bones too?
|
||||
void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
|
||||
@@ -254,27 +254,27 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
|
||||
/* object itself first */
|
||||
if ((ob->avs.recalc & ANIMVIZ_RECALC_PATHS) && (ob->mpath)) {
|
||||
/* new target for object */
|
||||
mpt= MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob");
|
||||
mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob");
|
||||
BLI_addtail(targets, mpt);
|
||||
|
||||
mpt->mpath= ob->mpath;
|
||||
mpt->ob= ob;
|
||||
mpt->mpath = ob->mpath;
|
||||
mpt->ob = ob;
|
||||
}
|
||||
|
||||
/* bones */
|
||||
if ((ob->pose) && (ob->pose->avs.recalc & ANIMVIZ_RECALC_PATHS)) {
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
bPoseChannel *pchan;
|
||||
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if ((pchan->bone) && (arm->layer & pchan->bone->layer) && (pchan->mpath)) {
|
||||
/* new target for bone */
|
||||
mpt= MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone");
|
||||
mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone");
|
||||
BLI_addtail(targets, mpt);
|
||||
|
||||
mpt->mpath= pchan->mpath;
|
||||
mpt->ob= ob;
|
||||
mpt->pchan= pchan;
|
||||
mpt->mpath = pchan->mpath;
|
||||
mpt->ob = ob;
|
||||
mpt->pchan = pchan;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,12 +296,12 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
|
||||
MPathTarget *mpt;
|
||||
|
||||
/* make sure our temp-tag isn't already in use */
|
||||
for (base= scene->base.first; base; base= base->next)
|
||||
for (base = scene->base.first; base; base = base->next)
|
||||
base->object->flag &= ~BA_TEMP_TAG;
|
||||
|
||||
/* for each target, dump its object to the start of the list if it wasn't moved already */
|
||||
for (mpt= targets->first; mpt; mpt= mpt->next) {
|
||||
for (base=scene->base.first; base; base=baseNext) {
|
||||
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
||||
for (base = scene->base.first; base; base = baseNext) {
|
||||
baseNext = base->next;
|
||||
|
||||
if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) {
|
||||
@@ -322,7 +322,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
|
||||
static void motionpaths_calc_update_scene(Scene *scene)
|
||||
{
|
||||
#if 1 // 'production' optimisations always on
|
||||
Base *base, *last=NULL;
|
||||
Base *base, *last = NULL;
|
||||
|
||||
/* only stuff that moves or needs display still */
|
||||
DAG_scene_update_flags(G.main, scene, scene->lay, TRUE);
|
||||
@@ -331,7 +331,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
|
||||
* - all those afterwards are assumed to not be relevant for our calculations
|
||||
*/
|
||||
// optimize further by moving out...
|
||||
for (base=scene->base.first; base; base=base->next) {
|
||||
for (base = scene->base.first; base; base = base->next) {
|
||||
if (base->object->flag & BA_TEMP_TAG)
|
||||
last = base;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
|
||||
/* perform updates for tagged objects */
|
||||
// XXX: this will break if rigs depend on scene or other data that
|
||||
// is animated but not attached to/updatable from objects
|
||||
for (base=scene->base.first; base; base=base->next) {
|
||||
for (base = scene->base.first; base; base = base->next) {
|
||||
/* update this object */
|
||||
BKE_object_handle_update(scene, base->object);
|
||||
|
||||
@@ -348,11 +348,11 @@ static void motionpaths_calc_update_scene(Scene *scene)
|
||||
break;
|
||||
}
|
||||
#else // original, 'always correct' version
|
||||
/* do all updates
|
||||
* - if this is too slow, resort to using a more efficient way
|
||||
* that doesn't force complete update, but for now, this is the
|
||||
* most accurate way!
|
||||
*/
|
||||
/* do all updates
|
||||
* - if this is too slow, resort to using a more efficient way
|
||||
* that doesn't force complete update, but for now, this is the
|
||||
* most accurate way!
|
||||
*/
|
||||
BKE_scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving
|
||||
#endif
|
||||
}
|
||||
@@ -365,8 +365,8 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
|
||||
MPathTarget *mpt;
|
||||
|
||||
/* for each target, check if it can be baked on the current frame */
|
||||
for (mpt= targets->first; mpt; mpt= mpt->next) {
|
||||
bMotionPath *mpath= mpt->mpath;
|
||||
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
||||
bMotionPath *mpath = mpt->mpath;
|
||||
bMotionPathVert *mpv;
|
||||
|
||||
/* current frame must be within the range the cache works for
|
||||
@@ -376,7 +376,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
|
||||
continue;
|
||||
|
||||
/* get the relevant cache vert to write to */
|
||||
mpv= mpath->points + (CFRA - mpath->start_frame);
|
||||
mpv = mpath->points + (CFRA - mpath->start_frame);
|
||||
|
||||
/* pose-channel or object path baking? */
|
||||
if (mpt->pchan) {
|
||||
@@ -421,10 +421,10 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
|
||||
// TODO: this method could be improved...
|
||||
// 1) max range for standard baking
|
||||
// 2) minimum range for recalc baking (i.e. between keyframes, but how?)
|
||||
for (mpt= targets->first; mpt; mpt= mpt->next) {
|
||||
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
||||
/* try to increase area to do (only as much as needed) */
|
||||
sfra= MIN2(sfra, mpt->mpath->start_frame);
|
||||
efra= MAX2(efra, mpt->mpath->end_frame);
|
||||
sfra = MIN2(sfra, mpt->mpath->start_frame);
|
||||
efra = MAX2(efra, mpt->mpath->end_frame);
|
||||
}
|
||||
if (efra <= sfra) return;
|
||||
|
||||
@@ -433,7 +433,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
|
||||
motionpaths_calc_optimise_depsgraph(scene, targets);
|
||||
|
||||
/* calculate path over requested range */
|
||||
for (CFRA=sfra; CFRA<=efra; CFRA++) {
|
||||
for (CFRA = sfra; CFRA <= efra; CFRA++) {
|
||||
/* update relevant data for new frame */
|
||||
motionpaths_calc_update_scene(scene);
|
||||
|
||||
@@ -442,18 +442,18 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
|
||||
}
|
||||
|
||||
/* reset original environment */
|
||||
CFRA= cfra;
|
||||
CFRA = cfra;
|
||||
motionpaths_calc_update_scene(scene);
|
||||
|
||||
/* clear recalc flags from targets */
|
||||
for (mpt= targets->first; mpt; mpt= mpt->next) {
|
||||
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
||||
bAnimVizSettings *avs;
|
||||
|
||||
/* get pointer to animviz settings for each target */
|
||||
if (mpt->pchan)
|
||||
avs= &mpt->ob->pose->avs;
|
||||
avs = &mpt->ob->pose->avs;
|
||||
else
|
||||
avs= &mpt->ob->avs;
|
||||
avs = &mpt->ob->avs;
|
||||
|
||||
/* clear the flag requesting recalculation of targets */
|
||||
avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
|
||||
@@ -474,7 +474,7 @@ void free_path(Path *path)
|
||||
}
|
||||
|
||||
/* calculate a curve-deform path for a curve
|
||||
* - only called from displist.c -> do_makeDispListCurveTypes
|
||||
* - only called from displist.c -> do_makeDispListCurveTypes
|
||||
*/
|
||||
void calc_curvepath(Object *ob)
|
||||
{
|
||||
@@ -485,92 +485,92 @@ void calc_curvepath(Object *ob)
|
||||
Nurb *nu;
|
||||
Path *path;
|
||||
float *fp, *dist, *maxdist, xyz[3];
|
||||
float fac, d=0, fac1, fac2;
|
||||
int a, tot, cycl=0;
|
||||
float fac, d = 0, fac1, fac2;
|
||||
int a, tot, cycl = 0;
|
||||
ListBase *nurbs;
|
||||
|
||||
/* in a path vertices are with equal differences: path->len = number of verts */
|
||||
/* NOW WITH BEVELCURVE!!! */
|
||||
|
||||
if (ob==NULL || ob->type != OB_CURVE) return;
|
||||
cu= ob->data;
|
||||
if (ob == NULL || ob->type != OB_CURVE) return;
|
||||
cu = ob->data;
|
||||
|
||||
nurbs= BKE_curve_nurbs_get(cu);
|
||||
nu= nurbs->first;
|
||||
nurbs = BKE_curve_nurbs_get(cu);
|
||||
nu = nurbs->first;
|
||||
|
||||
if (cu->path) free_path(cu->path);
|
||||
cu->path= NULL;
|
||||
cu->path = NULL;
|
||||
|
||||
bl= cu->bev.first;
|
||||
if (bl==NULL || !bl->nr) return;
|
||||
bl = cu->bev.first;
|
||||
if (bl == NULL || !bl->nr) return;
|
||||
|
||||
cu->path=path= MEM_callocN(sizeof(Path), "calc_curvepath");
|
||||
cu->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
|
||||
|
||||
/* if POLY: last vertice != first vertice */
|
||||
cycl= (bl->poly!= -1);
|
||||
cycl = (bl->poly != -1);
|
||||
|
||||
if (cycl) tot= bl->nr;
|
||||
else tot= bl->nr-1;
|
||||
if (cycl) tot = bl->nr;
|
||||
else tot = bl->nr - 1;
|
||||
|
||||
path->len= tot+1;
|
||||
path->len = tot + 1;
|
||||
/* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */
|
||||
if (path->len<nu->resolu*SEGMENTSU(nu)) path->len= nu->resolu*SEGMENTSU(nu);
|
||||
if (path->len < nu->resolu * SEGMENTSU(nu)) path->len = nu->resolu * SEGMENTSU(nu);
|
||||
|
||||
dist= (float *)MEM_mallocN((tot+1)*4, "calcpathdist");
|
||||
dist = (float *)MEM_mallocN((tot + 1) * 4, "calcpathdist");
|
||||
|
||||
/* all lengths in *dist */
|
||||
bevp= bevpfirst= (BevPoint *)(bl+1);
|
||||
fp= dist;
|
||||
*fp= 0;
|
||||
for (a=0; a<tot; a++) {
|
||||
/* all lengths in *dist */
|
||||
bevp = bevpfirst = (BevPoint *)(bl + 1);
|
||||
fp = dist;
|
||||
*fp = 0;
|
||||
for (a = 0; a < tot; a++) {
|
||||
fp++;
|
||||
if (cycl && a==tot-1)
|
||||
if (cycl && a == tot - 1)
|
||||
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
|
||||
else
|
||||
sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec);
|
||||
sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec);
|
||||
|
||||
*fp= *(fp-1)+len_v3(xyz);
|
||||
*fp = *(fp - 1) + len_v3(xyz);
|
||||
bevp++;
|
||||
}
|
||||
|
||||
path->totdist= *fp;
|
||||
path->totdist = *fp;
|
||||
|
||||
/* the path verts in path->data */
|
||||
/* now also with TILT value */
|
||||
pp= path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint)*path->len, "pathdata");
|
||||
/* the path verts in path->data */
|
||||
/* now also with TILT value */
|
||||
pp = path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint) * path->len, "pathdata");
|
||||
|
||||
bevp = bevpfirst;
|
||||
bevpn = bevp + 1;
|
||||
bevplast = bevpfirst + (bl->nr - 1);
|
||||
fp = dist + 1;
|
||||
maxdist = dist + tot;
|
||||
fac = 1.0f / ((float)path->len - 1.0f);
|
||||
fac = fac * path->totdist;
|
||||
|
||||
bevp= bevpfirst;
|
||||
bevpn= bevp+1;
|
||||
bevplast= bevpfirst + (bl->nr-1);
|
||||
fp= dist+1;
|
||||
maxdist= dist+tot;
|
||||
fac= 1.0f/((float)path->len-1.0f);
|
||||
fac = fac * path->totdist;
|
||||
|
||||
for (a=0; a<path->len; a++) {
|
||||
for (a = 0; a < path->len; a++) {
|
||||
|
||||
d= ((float)a)*fac;
|
||||
d = ((float)a) * fac;
|
||||
|
||||
/* we're looking for location (distance) 'd' in the array */
|
||||
while ((d>= *fp) && fp<maxdist) {
|
||||
while ((d >= *fp) && fp < maxdist) {
|
||||
fp++;
|
||||
if (bevp<bevplast) bevp++;
|
||||
bevpn= bevp+1;
|
||||
if (bevpn>bevplast) {
|
||||
if (cycl) bevpn= bevpfirst;
|
||||
else bevpn= bevplast;
|
||||
if (bevp < bevplast) bevp++;
|
||||
bevpn = bevp + 1;
|
||||
if (bevpn > bevplast) {
|
||||
if (cycl) bevpn = bevpfirst;
|
||||
else bevpn = bevplast;
|
||||
}
|
||||
}
|
||||
|
||||
fac1= *(fp)- *(fp-1);
|
||||
fac2= *(fp)-d;
|
||||
fac1= fac2/fac1;
|
||||
fac2= 1.0f-fac1;
|
||||
fac1 = *(fp) - *(fp - 1);
|
||||
fac2 = *(fp) - d;
|
||||
fac1 = fac2 / fac1;
|
||||
fac2 = 1.0f - fac1;
|
||||
|
||||
interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
|
||||
pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa;
|
||||
pp->radius= fac1*bevp->radius + fac2*bevpn->radius;
|
||||
pp->weight= fac1*bevp->weight + fac2*bevpn->weight;
|
||||
pp->vec[3] = fac1 * bevp->alfa + fac2 * bevpn->alfa;
|
||||
pp->radius = fac1 * bevp->radius + fac2 * bevpn->radius;
|
||||
pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight;
|
||||
interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2);
|
||||
normalize_qt(pp->quat);
|
||||
|
||||
@@ -586,13 +586,13 @@ int interval_test(int min, int max, int p1, int cycl)
|
||||
{
|
||||
if (cycl) {
|
||||
if (p1 < min)
|
||||
p1= ((p1 -min) % (max-min+1)) + max+1;
|
||||
p1 = ((p1 - min) % (max - min + 1)) + max + 1;
|
||||
else if (p1 > max)
|
||||
p1= ((p1 -min) % (max-min+1)) + min;
|
||||
p1 = ((p1 - min) % (max - min + 1)) + min;
|
||||
}
|
||||
else {
|
||||
if (p1 < min) p1= min;
|
||||
else if (p1 > max) p1= max;
|
||||
if (p1 < min) p1 = min;
|
||||
else if (p1 > max) p1 = max;
|
||||
}
|
||||
return p1;
|
||||
}
|
||||
@@ -614,84 +614,84 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
|
||||
PathPoint *pp, *p0, *p1, *p2, *p3;
|
||||
float fac;
|
||||
float data[4];
|
||||
int cycl=0, s0, s1, s2, s3;
|
||||
int cycl = 0, s0, s1, s2, s3;
|
||||
|
||||
if (ob==NULL || ob->type != OB_CURVE) return 0;
|
||||
cu= ob->data;
|
||||
if (cu->path==NULL || cu->path->data==NULL) {
|
||||
if (ob == NULL || ob->type != OB_CURVE) return 0;
|
||||
cu = ob->data;
|
||||
if (cu->path == NULL || cu->path->data == NULL) {
|
||||
printf("no path!\n");
|
||||
return 0;
|
||||
}
|
||||
path= cu->path;
|
||||
pp= path->data;
|
||||
path = cu->path;
|
||||
pp = path->data;
|
||||
|
||||
/* test for cyclic */
|
||||
bl= cu->bev.first;
|
||||
bl = cu->bev.first;
|
||||
if (!bl) return 0;
|
||||
if (!bl->nr) return 0;
|
||||
if (bl->poly> -1) cycl= 1;
|
||||
if (bl->poly > -1) cycl = 1;
|
||||
|
||||
ctime *= (path->len-1);
|
||||
ctime *= (path->len - 1);
|
||||
|
||||
s1= (int)floor(ctime);
|
||||
fac= (float)(s1+1)-ctime;
|
||||
s1 = (int)floor(ctime);
|
||||
fac = (float)(s1 + 1) - ctime;
|
||||
|
||||
/* path->len is corected for cyclic */
|
||||
s0= interval_test(0, path->len-1-cycl, s1-1, cycl);
|
||||
s1= interval_test(0, path->len-1-cycl, s1, cycl);
|
||||
s2= interval_test(0, path->len-1-cycl, s1+1, cycl);
|
||||
s3= interval_test(0, path->len-1-cycl, s1+2, cycl);
|
||||
s0 = interval_test(0, path->len - 1 - cycl, s1 - 1, cycl);
|
||||
s1 = interval_test(0, path->len - 1 - cycl, s1, cycl);
|
||||
s2 = interval_test(0, path->len - 1 - cycl, s1 + 1, cycl);
|
||||
s3 = interval_test(0, path->len - 1 - cycl, s1 + 2, cycl);
|
||||
|
||||
p0= pp + s0;
|
||||
p1= pp + s1;
|
||||
p2= pp + s2;
|
||||
p3= pp + s3;
|
||||
p0 = pp + s0;
|
||||
p1 = pp + s1;
|
||||
p2 = pp + s2;
|
||||
p3 = pp + s3;
|
||||
|
||||
/* note, commented out for follow constraint */
|
||||
//if (cu->flag & CU_FOLLOW) {
|
||||
|
||||
key_curve_tangent_weights(1.0f-fac, data, KEY_BSPLINE);
|
||||
key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE);
|
||||
|
||||
interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data);
|
||||
interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data);
|
||||
|
||||
/* make compatible with vectoquat */
|
||||
negate_v3(dir);
|
||||
/* make compatible with vectoquat */
|
||||
negate_v3(dir);
|
||||
//}
|
||||
|
||||
nu= cu->nurb.first;
|
||||
nu = cu->nurb.first;
|
||||
|
||||
/* make sure that first and last frame are included in the vectors here */
|
||||
if (nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
|
||||
else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
|
||||
else if (s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL);
|
||||
else key_curve_position_weights(1.0f-fac, data, KEY_BSPLINE);
|
||||
if (nu->type == CU_POLY) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
|
||||
else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
|
||||
else if (s0 == s1 || p2 == p3) key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL);
|
||||
else key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE);
|
||||
|
||||
vec[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ; /* X */
|
||||
vec[1]= data[0]*p0->vec[1] + data[1]*p1->vec[1] + data[2]*p2->vec[1] + data[3]*p3->vec[1] ; /* Y */
|
||||
vec[2]= data[0]*p0->vec[2] + data[1]*p1->vec[2] + data[2]*p2->vec[2] + data[3]*p3->vec[2] ; /* Z */
|
||||
vec[3]= data[0]*p0->vec[3] + data[1]*p1->vec[3] + data[2]*p2->vec[3] + data[3]*p3->vec[3] ; /* Tilt, should not be needed since we have quat still used */
|
||||
vec[0] = data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] + data[3] * p3->vec[0]; /* X */
|
||||
vec[1] = data[0] * p0->vec[1] + data[1] * p1->vec[1] + data[2] * p2->vec[1] + data[3] * p3->vec[1]; /* Y */
|
||||
vec[2] = data[0] * p0->vec[2] + data[1] * p1->vec[2] + data[2] * p2->vec[2] + data[3] * p3->vec[2]; /* Z */
|
||||
vec[3] = data[0] * p0->vec[3] + data[1] * p1->vec[3] + data[2] * p2->vec[3] + data[3] * p3->vec[3]; /* Tilt, should not be needed since we have quat still used */
|
||||
|
||||
if (quat) {
|
||||
float totfac, q1[4], q2[4];
|
||||
|
||||
totfac= data[0]+data[3];
|
||||
if (totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
|
||||
else copy_qt_qt(q1, p1->quat);
|
||||
totfac = data[0] + data[3];
|
||||
if (totfac > FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
|
||||
else copy_qt_qt(q1, p1->quat);
|
||||
|
||||
totfac= data[1]+data[2];
|
||||
if (totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
|
||||
else copy_qt_qt(q2, p3->quat);
|
||||
totfac = data[1] + data[2];
|
||||
if (totfac > FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
|
||||
else copy_qt_qt(q2, p3->quat);
|
||||
|
||||
totfac = data[0]+data[1]+data[2]+data[3];
|
||||
if (totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac);
|
||||
else copy_qt_qt(quat, q2);
|
||||
totfac = data[0] + data[1] + data[2] + data[3];
|
||||
if (totfac > FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1] + data[2]) / totfac);
|
||||
else copy_qt_qt(quat, q2);
|
||||
}
|
||||
|
||||
if (radius)
|
||||
*radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius;
|
||||
*radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius + data[3] * p3->radius;
|
||||
|
||||
if (weight)
|
||||
*weight= data[0]*p0->weight + data[1]*p1->weight + data[2]*p2->weight + data[3]*p3->weight;
|
||||
*weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight + data[3] * p3->weight;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -701,17 +701,17 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
|
||||
|
||||
static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index, int type, int animated)
|
||||
{
|
||||
DupliObject *dob= MEM_callocN(sizeof(DupliObject), "dupliobject");
|
||||
DupliObject *dob = MEM_callocN(sizeof(DupliObject), "dupliobject");
|
||||
|
||||
BLI_addtail(lb, dob);
|
||||
dob->ob= ob;
|
||||
dob->ob = ob;
|
||||
copy_m4_m4(dob->mat, mat);
|
||||
copy_m4_m4(dob->omat, ob->obmat);
|
||||
dob->origlay= ob->lay;
|
||||
dob->index= index;
|
||||
dob->type= type;
|
||||
dob->animated= (type == OB_DUPLIGROUP) && animated;
|
||||
ob->lay= lay;
|
||||
dob->origlay = ob->lay;
|
||||
dob->index = index;
|
||||
dob->type = type;
|
||||
dob->animated = (type == OB_DUPLIGROUP) && animated;
|
||||
ob->lay = lay;
|
||||
|
||||
return dob;
|
||||
}
|
||||
@@ -723,20 +723,20 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
|
||||
GroupObject *go;
|
||||
float mat[4][4], tmat[4][4];
|
||||
|
||||
if (ob->dup_group==NULL) return;
|
||||
group= ob->dup_group;
|
||||
if (ob->dup_group == NULL) return;
|
||||
group = ob->dup_group;
|
||||
|
||||
/* simple preventing of too deep nested groups */
|
||||
if (level>MAX_DUPLI_RECUR) return;
|
||||
if (level > MAX_DUPLI_RECUR) return;
|
||||
|
||||
/* handles animated groups, and */
|
||||
/* we need to check update for objects that are not in scene... */
|
||||
group_handle_recalc_and_update(scene, ob, group);
|
||||
animated= animated || group_is_animated(ob, group);
|
||||
animated = animated || group_is_animated(ob, group);
|
||||
|
||||
for (go= group->gobject.first; go; go= go->next) {
|
||||
for (go = group->gobject.first; go; go = go->next) {
|
||||
/* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */
|
||||
if (go->ob!=ob) {
|
||||
if (go->ob != ob) {
|
||||
|
||||
/* group dupli offset, should apply after everything else */
|
||||
if (!is_zero_v3(group->dupli_ofs)) {
|
||||
@@ -748,22 +748,22 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
|
||||
mult_m4_m4m4(mat, ob->obmat, go->ob->obmat);
|
||||
}
|
||||
|
||||
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
|
||||
dob = new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
|
||||
|
||||
/* check the group instance and object layers match, also that the object visible flags are ok. */
|
||||
if ( (dob->origlay & group->layer)==0 ||
|
||||
(G.rendering==0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) ||
|
||||
(G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER)
|
||||
) {
|
||||
dob->no_draw= 1;
|
||||
if ( (dob->origlay & group->layer) == 0 ||
|
||||
(G.rendering == 0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) ||
|
||||
(G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER)
|
||||
) {
|
||||
dob->no_draw = 1;
|
||||
}
|
||||
else {
|
||||
dob->no_draw= 0;
|
||||
dob->no_draw = 0;
|
||||
}
|
||||
|
||||
if (go->ob->transflag & OB_DUPLI) {
|
||||
copy_m4_m4(dob->ob->obmat, dob->mat);
|
||||
object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level+1, animated);
|
||||
object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level + 1, animated);
|
||||
copy_m4_m4(dob->ob->obmat, dob->omat);
|
||||
}
|
||||
}
|
||||
@@ -772,7 +772,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
|
||||
|
||||
static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated)
|
||||
{
|
||||
extern int enable_cu_speed; /* object.c */
|
||||
extern int enable_cu_speed; /* object.c */
|
||||
Object copyob;
|
||||
int cfrao = scene->r.cfra;
|
||||
int dupend = ob->dupend;
|
||||
@@ -783,7 +783,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level,
|
||||
/* if we don't have any data/settings which will lead to object movement,
|
||||
* don't waste time trying, as it will all look the same...
|
||||
*/
|
||||
if (ob->parent==NULL && ob->constraints.first==NULL && ob->adt==NULL)
|
||||
if (ob->parent == NULL && ob->constraints.first == NULL && ob->adt == NULL)
|
||||
return;
|
||||
|
||||
/* make a copy of the object's original data (before any dupli-data overwrites it)
|
||||
@@ -794,18 +794,18 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level,
|
||||
copyob = *ob;
|
||||
|
||||
/* duplicate over the required range */
|
||||
if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0;
|
||||
if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed = 0;
|
||||
|
||||
for (scene->r.cfra= ob->dupsta; scene->r.cfra<=dupend; scene->r.cfra++) {
|
||||
short ok= 1;
|
||||
for (scene->r.cfra = ob->dupsta; scene->r.cfra <= dupend; scene->r.cfra++) {
|
||||
short ok = 1;
|
||||
|
||||
/* - dupoff = how often a frames within the range shouldn't be made into duplis
|
||||
* - dupon = the length of each "skipping" block in frames
|
||||
*/
|
||||
if (ob->dupoff) {
|
||||
ok= scene->r.cfra - ob->dupsta;
|
||||
ok= ok % (ob->dupon+ob->dupoff);
|
||||
ok= (ok < ob->dupon);
|
||||
ok = scene->r.cfra - ob->dupsta;
|
||||
ok = ok % (ob->dupon + ob->dupoff);
|
||||
ok = (ok < ob->dupon);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
@@ -818,17 +818,17 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level,
|
||||
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
|
||||
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
|
||||
|
||||
dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated);
|
||||
dob = new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated);
|
||||
copy_m4_m4(dob->omat, copyob.obmat);
|
||||
}
|
||||
}
|
||||
|
||||
enable_cu_speed= 1;
|
||||
enable_cu_speed = 1;
|
||||
|
||||
/* reset frame to original frame, then re-evaluate animation as above
|
||||
* as 2.5 animation data may have far-reaching consequences
|
||||
*/
|
||||
scene->r.cfra= cfrao;
|
||||
scene->r.cfra = cfrao;
|
||||
|
||||
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
|
||||
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
|
||||
@@ -857,7 +857,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
|
||||
const float no_f[3], const short no_s[3])
|
||||
{
|
||||
DupliObject *dob;
|
||||
vertexDupliData *vdd= userData;
|
||||
vertexDupliData *vdd = userData;
|
||||
float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4];
|
||||
int origlay;
|
||||
|
||||
@@ -870,10 +870,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
|
||||
|
||||
if (vdd->par->transflag & OB_DUPLIROT) {
|
||||
if (no_f) {
|
||||
vec[0]= -no_f[0]; vec[1]= -no_f[1]; vec[2]= -no_f[2];
|
||||
vec[0] = -no_f[0]; vec[1] = -no_f[1]; vec[2] = -no_f[2];
|
||||
}
|
||||
else if (no_s) {
|
||||
vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2];
|
||||
vec[0] = -no_s[0]; vec[1] = -no_s[1]; vec[2] = -no_s[2];
|
||||
}
|
||||
|
||||
vec_to_quat(q2, vec, vdd->ob->trackflag, vdd->ob->upflag);
|
||||
@@ -885,7 +885,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
|
||||
|
||||
origlay = vdd->ob->lay;
|
||||
|
||||
dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated);
|
||||
dob = new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated);
|
||||
|
||||
/* restore the original layer so that each dupli will have proper dob->origlay */
|
||||
vdd->ob->lay = origlay;
|
||||
@@ -897,7 +897,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
|
||||
float tmpmat[4][4];
|
||||
copy_m4_m4(tmpmat, vdd->ob->obmat);
|
||||
copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
|
||||
object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated);
|
||||
object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level + 1, vdd->animated);
|
||||
copy_m4_m4(vdd->ob->obmat, tmpmat);
|
||||
}
|
||||
}
|
||||
@@ -905,13 +905,13 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
|
||||
static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int level, int animated)
|
||||
{
|
||||
Object *ob, *ob_iter;
|
||||
Mesh *me= par->data;
|
||||
Mesh *me = par->data;
|
||||
Base *base = NULL;
|
||||
DerivedMesh *dm;
|
||||
vertexDupliData vdd;
|
||||
Scene *sce = NULL;
|
||||
Group *group = NULL;
|
||||
GroupObject * go = NULL;
|
||||
GroupObject *go = NULL;
|
||||
BMEditMesh *em;
|
||||
float vec[3], no[3], pmat[4][4];
|
||||
int totvert, a, oblay;
|
||||
@@ -920,54 +920,54 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
|
||||
copy_m4_m4(pmat, par->obmat);
|
||||
|
||||
/* simple preventing of too deep nested groups */
|
||||
if (level>MAX_DUPLI_RECUR) return;
|
||||
if (level > MAX_DUPLI_RECUR) return;
|
||||
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (em) {
|
||||
dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
|
||||
dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
|
||||
}
|
||||
else
|
||||
dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
|
||||
dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
|
||||
|
||||
if (G.rendering) {
|
||||
vdd.orco= (float(*)[3])BKE_mesh_orco_verts_get(par);
|
||||
vdd.orco = (float(*)[3])BKE_mesh_orco_verts_get(par);
|
||||
BKE_mesh_orco_verts_transform(me, vdd.orco, me->totvert, 0);
|
||||
}
|
||||
else
|
||||
vdd.orco= NULL;
|
||||
vdd.orco = NULL;
|
||||
|
||||
totvert = dm->getNumVerts(dm);
|
||||
|
||||
/* having to loop on scene OR group objects is NOT FUN */
|
||||
if (GS(id->name) == ID_SCE) {
|
||||
sce = (Scene *)id;
|
||||
lay= sce->lay;
|
||||
base= sce->base.first;
|
||||
lay = sce->lay;
|
||||
base = sce->base.first;
|
||||
}
|
||||
else {
|
||||
group = (Group *)id;
|
||||
lay= group->layer;
|
||||
lay = group->layer;
|
||||
go = group->gobject.first;
|
||||
}
|
||||
|
||||
/* Start looping on Scene OR Group objects */
|
||||
while (base || go) {
|
||||
if (sce) {
|
||||
ob_iter= base->object;
|
||||
ob_iter = base->object;
|
||||
oblay = base->lay;
|
||||
}
|
||||
else {
|
||||
ob_iter= go->ob;
|
||||
ob_iter = go->ob;
|
||||
oblay = ob_iter->lay;
|
||||
}
|
||||
|
||||
if (lay & oblay && scene->obedit!=ob_iter) {
|
||||
ob=ob_iter->parent;
|
||||
if (lay & oblay && scene->obedit != ob_iter) {
|
||||
ob = ob_iter->parent;
|
||||
while (ob) {
|
||||
if (ob==par) {
|
||||
if (ob == par) {
|
||||
ob = ob_iter;
|
||||
/* End Scene/Group object loop, below is generic */
|
||||
/* End Scene/Group object loop, below is generic */
|
||||
|
||||
|
||||
/* par_space_mat - only used for groups so we can modify the space dupli's are in
|
||||
@@ -978,23 +978,23 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
|
||||
else
|
||||
copy_m4_m4(vdd.obmat, ob->obmat);
|
||||
|
||||
vdd.id= id;
|
||||
vdd.level= level;
|
||||
vdd.animated= animated;
|
||||
vdd.lb= lb;
|
||||
vdd.ob= ob;
|
||||
vdd.scene= scene;
|
||||
vdd.par= par;
|
||||
vdd.id = id;
|
||||
vdd.level = level;
|
||||
vdd.animated = animated;
|
||||
vdd.lb = lb;
|
||||
vdd.ob = ob;
|
||||
vdd.scene = scene;
|
||||
vdd.par = par;
|
||||
copy_m4_m4(vdd.pmat, pmat);
|
||||
|
||||
/* mballs have a different dupli handling */
|
||||
if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
|
||||
if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
|
||||
|
||||
if (me->edit_btmesh) {
|
||||
dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd);
|
||||
dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void *) &vdd);
|
||||
}
|
||||
else {
|
||||
for (a=0; a<totvert; a++) {
|
||||
for (a = 0; a < totvert; a++) {
|
||||
dm->getVertCo(dm, a, vec);
|
||||
dm->getVertNo(dm, a, no);
|
||||
|
||||
@@ -1012,11 +1012,11 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
|
||||
|
||||
break;
|
||||
}
|
||||
ob= ob->parent;
|
||||
ob = ob->parent;
|
||||
}
|
||||
}
|
||||
if (sce) base= base->next; /* scene loop */
|
||||
else go= go->next; /* group loop */
|
||||
if (sce) base = base->next; /* scene loop */
|
||||
else go = go->next; /* group loop */
|
||||
}
|
||||
|
||||
if (vdd.orco)
|
||||
@@ -1030,7 +1030,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
Base *base = NULL;
|
||||
DupliObject *dob;
|
||||
DerivedMesh *dm;
|
||||
Mesh *me= par->data;
|
||||
Mesh *me = par->data;
|
||||
MLoopUV *mloopuv;
|
||||
MPoly *mpoly, *mp;
|
||||
MLoop *mloop;
|
||||
@@ -1044,63 +1044,63 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */
|
||||
|
||||
/* simple preventing of too deep nested groups */
|
||||
if (level>MAX_DUPLI_RECUR) return;
|
||||
if (level > MAX_DUPLI_RECUR) return;
|
||||
|
||||
copy_m4_m4(pmat, par->obmat);
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (em) {
|
||||
dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
|
||||
dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
|
||||
}
|
||||
else {
|
||||
dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
|
||||
}
|
||||
|
||||
totface= dm->getNumPolys(dm);
|
||||
mpoly= dm->getPolyArray(dm);
|
||||
mloop= dm->getLoopArray(dm);
|
||||
mvert= dm->getVertArray(dm);
|
||||
totface = dm->getNumPolys(dm);
|
||||
mpoly = dm->getPolyArray(dm);
|
||||
mloop = dm->getLoopArray(dm);
|
||||
mvert = dm->getVertArray(dm);
|
||||
|
||||
if (G.rendering) {
|
||||
|
||||
orco= (float(*)[3])BKE_mesh_orco_verts_get(par);
|
||||
orco = (float(*)[3])BKE_mesh_orco_verts_get(par);
|
||||
BKE_mesh_orco_verts_transform(me, orco, me->totvert, 0);
|
||||
mloopuv= me->mloopuv;
|
||||
mloopuv = me->mloopuv;
|
||||
}
|
||||
else {
|
||||
orco= NULL;
|
||||
mloopuv= NULL;
|
||||
orco = NULL;
|
||||
mloopuv = NULL;
|
||||
}
|
||||
|
||||
/* having to loop on scene OR group objects is NOT FUN */
|
||||
if (GS(id->name) == ID_SCE) {
|
||||
sce = (Scene *)id;
|
||||
lay= sce->lay;
|
||||
base= sce->base.first;
|
||||
lay = sce->lay;
|
||||
base = sce->base.first;
|
||||
}
|
||||
else {
|
||||
group = (Group *)id;
|
||||
lay= group->layer;
|
||||
lay = group->layer;
|
||||
go = group->gobject.first;
|
||||
}
|
||||
|
||||
/* Start looping on Scene OR Group objects */
|
||||
while (base || go) {
|
||||
if (sce) {
|
||||
ob_iter= base->object;
|
||||
ob_iter = base->object;
|
||||
oblay = base->lay;
|
||||
}
|
||||
else {
|
||||
ob_iter= go->ob;
|
||||
ob_iter = go->ob;
|
||||
oblay = ob_iter->lay;
|
||||
}
|
||||
|
||||
if (lay & oblay && scene->obedit!=ob_iter) {
|
||||
ob=ob_iter->parent;
|
||||
if (lay & oblay && scene->obedit != ob_iter) {
|
||||
ob = ob_iter->parent;
|
||||
while (ob) {
|
||||
if (ob==par) {
|
||||
if (ob == par) {
|
||||
ob = ob_iter;
|
||||
/* End Scene/Group object loop, below is generic */
|
||||
/* End Scene/Group object loop, below is generic */
|
||||
|
||||
/* par_space_mat - only used for groups so we can modify the space dupli's are in
|
||||
* when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
|
||||
@@ -1113,9 +1113,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
copy_m3_m4(imat, ob->parentinv);
|
||||
|
||||
/* mballs have a different dupli handling */
|
||||
if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
|
||||
if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
|
||||
|
||||
for (a=0, mp= mpoly; a<totface; a++, mp++) {
|
||||
for (a = 0, mp = mpoly; a < totface; a++, mp++) {
|
||||
int mv1;
|
||||
int mv2;
|
||||
int mv3;
|
||||
@@ -1125,19 +1125,19 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
float *v3;
|
||||
/* float *v4; */ /* UNUSED */
|
||||
float cent[3], quat[4], mat[3][3], mat3[3][3], tmat[4][4], obmat[4][4];
|
||||
MLoop *loopstart= mloop + mp->loopstart;
|
||||
MLoop *loopstart = mloop + mp->loopstart;
|
||||
|
||||
if (mp->totloop < 3) {
|
||||
/* highly unlikely but to be safe */
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
v1= mvert[(mv1= loopstart[0].v)].co;
|
||||
v2= mvert[(mv2= loopstart[1].v)].co;
|
||||
v3= mvert[(mv3= loopstart[2].v)].co;
|
||||
v1 = mvert[(mv1 = loopstart[0].v)].co;
|
||||
v2 = mvert[(mv2 = loopstart[1].v)].co;
|
||||
v3 = mvert[(mv3 = loopstart[2].v)].co;
|
||||
#if 0
|
||||
if (mp->totloop > 3) {
|
||||
v4= mvert[(mv4= loopstart[3].v)].co;
|
||||
v4 = mvert[(mv4 = loopstart[3].v)].co;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1160,8 +1160,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
|
||||
/* scale */
|
||||
if (par->transflag & OB_DUPLIFACES_SCALE) {
|
||||
float size= BKE_mesh_calc_poly_area(mp, loopstart, mvert, NULL);
|
||||
size= sqrtf(size) * par->dupfacesca;
|
||||
float size = BKE_mesh_calc_poly_area(mp, loopstart, mvert, NULL);
|
||||
size = sqrtf(size) * par->dupfacesca;
|
||||
mul_m3_fl(mat, size);
|
||||
}
|
||||
|
||||
@@ -1171,9 +1171,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
copy_m4_m4(tmat, obmat);
|
||||
mul_m4_m4m3(obmat, tmat, mat);
|
||||
|
||||
dob= new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated);
|
||||
dob = new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated);
|
||||
if (G.rendering) {
|
||||
w= 1.0f / (float)mp->totloop;
|
||||
w = 1.0f / (float)mp->totloop;
|
||||
|
||||
if (orco) {
|
||||
int j;
|
||||
@@ -1194,18 +1194,18 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
float tmpmat[4][4];
|
||||
copy_m4_m4(tmpmat, ob->obmat);
|
||||
copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */
|
||||
object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated);
|
||||
object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level + 1, animated);
|
||||
copy_m4_m4(ob->obmat, tmpmat);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
ob= ob->parent;
|
||||
ob = ob->parent;
|
||||
}
|
||||
}
|
||||
if (sce) base= base->next; /* scene loop */
|
||||
else go= go->next; /* group loop */
|
||||
if (sce) base = base->next; /* scene loop */
|
||||
else go = go->next; /* group loop */
|
||||
}
|
||||
|
||||
if (orco)
|
||||
@@ -1217,30 +1217,30 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
|
||||
static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated)
|
||||
{
|
||||
GroupObject *go;
|
||||
Object *ob=NULL, **oblist=NULL, obcopy, *obcopylist=NULL;
|
||||
Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL;
|
||||
DupliObject *dob;
|
||||
ParticleDupliWeight *dw;
|
||||
ParticleSettings *part;
|
||||
ParticleData *pa;
|
||||
ChildParticle *cpa=NULL;
|
||||
ChildParticle *cpa = NULL;
|
||||
ParticleKey state;
|
||||
ParticleCacheKey *cache;
|
||||
float ctime, pa_time, scale = 1.0f;
|
||||
float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size=0.0;
|
||||
float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size = 0.0;
|
||||
float (*obmat)[4], (*oldobmat)[4];
|
||||
int a, b, counter, hair = 0;
|
||||
int totpart, totchild, totgroup=0 /*, pa_num */;
|
||||
int totpart, totchild, totgroup = 0 /*, pa_num */;
|
||||
|
||||
int no_draw_flag = PARS_UNEXIST;
|
||||
|
||||
if (psys==NULL) return;
|
||||
if (psys == NULL) return;
|
||||
|
||||
/* simple preventing of too deep nested groups */
|
||||
if (level>MAX_DUPLI_RECUR) return;
|
||||
if (level > MAX_DUPLI_RECUR) return;
|
||||
|
||||
part=psys->part;
|
||||
part = psys->part;
|
||||
|
||||
if (part==NULL)
|
||||
if (part == NULL)
|
||||
return;
|
||||
|
||||
if (!psys_check_enabled(par, psys))
|
||||
@@ -1256,12 +1256,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
|
||||
BLI_srandom(31415926 + psys->seed);
|
||||
|
||||
if ((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
|
||||
ParticleSimulationData sim= {NULL};
|
||||
sim.scene= scene;
|
||||
sim.ob= par;
|
||||
sim.psys= psys;
|
||||
sim.psmd= psys_get_modifier(par, psys);
|
||||
if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
|
||||
ParticleSimulationData sim = {NULL};
|
||||
sim.scene = scene;
|
||||
sim.ob = par;
|
||||
sim.psys = psys;
|
||||
sim.psmd = psys_get_modifier(par, psys);
|
||||
/* make sure emitter imat is in global coordinates instead of render view coordinates */
|
||||
invert_m4_m4(par->imat, par->obmat);
|
||||
|
||||
@@ -1274,7 +1274,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
if (part->dup_group == NULL || part->dup_group->gobject.first == NULL)
|
||||
return;
|
||||
|
||||
for (go=part->dup_group->gobject.first; go; go=go->next)
|
||||
for (go = part->dup_group->gobject.first; go; go = go->next)
|
||||
if (go->ob == par)
|
||||
return;
|
||||
}
|
||||
@@ -1282,7 +1282,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
/* if we have a hair particle system, use the path cache */
|
||||
if (part->type == PART_HAIR) {
|
||||
if (psys->flag & PSYS_HAIR_DONE)
|
||||
hair= (totchild == 0 || psys->childcache) && psys->pathcache;
|
||||
hair = (totchild == 0 || psys->childcache) && psys->pathcache;
|
||||
if (!hair)
|
||||
return;
|
||||
|
||||
@@ -1296,29 +1296,29 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
psys->lattice = psys_get_lattice(&sim);
|
||||
|
||||
/* gather list of objects or single object */
|
||||
if (part->ren_as==PART_DRAW_GR) {
|
||||
if (part->ren_as == PART_DRAW_GR) {
|
||||
group_handle_recalc_and_update(scene, par, part->dup_group);
|
||||
|
||||
if (part->draw & PART_DRAW_COUNT_GR) {
|
||||
for (dw=part->dupliweights.first; dw; dw=dw->next)
|
||||
for (dw = part->dupliweights.first; dw; dw = dw->next)
|
||||
totgroup += dw->count;
|
||||
}
|
||||
else {
|
||||
for (go=part->dup_group->gobject.first; go; go=go->next)
|
||||
for (go = part->dup_group->gobject.first; go; go = go->next)
|
||||
totgroup++;
|
||||
}
|
||||
|
||||
/* we also copy the actual objects to restore afterwards, since
|
||||
* BKE_object_where_is_calc_time will change the object which breaks transform */
|
||||
oblist = MEM_callocN(totgroup*sizeof(Object *), "dupgroup object list");
|
||||
obcopylist = MEM_callocN(totgroup*sizeof(Object), "dupgroup copy list");
|
||||
oblist = MEM_callocN(totgroup * sizeof(Object *), "dupgroup object list");
|
||||
obcopylist = MEM_callocN(totgroup * sizeof(Object), "dupgroup copy list");
|
||||
|
||||
|
||||
if (part->draw & PART_DRAW_COUNT_GR && totgroup) {
|
||||
dw = part->dupliweights.first;
|
||||
|
||||
for (a=0; a<totgroup; dw=dw->next) {
|
||||
for (b=0; b<dw->count; b++, a++) {
|
||||
for (a = 0; a < totgroup; dw = dw->next) {
|
||||
for (b = 0; b < dw->count; b++, a++) {
|
||||
oblist[a] = dw->ob;
|
||||
obcopylist[a] = *dw->ob;
|
||||
}
|
||||
@@ -1326,7 +1326,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
}
|
||||
else {
|
||||
go = part->dup_group->gobject.first;
|
||||
for (a=0; a<totgroup; a++, go=go->next) {
|
||||
for (a = 0; a < totgroup; a++, go = go->next) {
|
||||
oblist[a] = go->ob;
|
||||
obcopylist[a] = *go->ob;
|
||||
}
|
||||
@@ -1337,13 +1337,13 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
obcopy = *ob;
|
||||
}
|
||||
|
||||
if (totchild==0 || part->draw & PART_DRAW_PARENT)
|
||||
if (totchild == 0 || part->draw & PART_DRAW_PARENT)
|
||||
a = 0;
|
||||
else
|
||||
a = totpart;
|
||||
|
||||
for (pa=psys->particles, counter=0; a<totpart+totchild; a++, pa++, counter++) {
|
||||
if (a<totpart) {
|
||||
for (pa = psys->particles, counter = 0; a < totpart + totchild; a++, pa++, counter++) {
|
||||
if (a < totpart) {
|
||||
/* handle parent particle */
|
||||
if (pa->flag & no_draw_flag)
|
||||
continue;
|
||||
@@ -1364,29 +1364,29 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
/* some hair paths might be non-existent so they can't be used for duplication */
|
||||
if (hair &&
|
||||
((a < totpart && psys->pathcache[a]->steps < 0) ||
|
||||
(a >= totpart && psys->childcache[a-totpart]->steps < 0)))
|
||||
(a >= totpart && psys->childcache[a - totpart]->steps < 0)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (part->ren_as==PART_DRAW_GR) {
|
||||
if (part->ren_as == PART_DRAW_GR) {
|
||||
/* prevent divide by zero below [#28336] */
|
||||
if (totgroup == 0)
|
||||
continue;
|
||||
|
||||
/* for groups, pick the object based on settings */
|
||||
if (part->draw&PART_DRAW_RAND_GR)
|
||||
b= BLI_rand() % totgroup;
|
||||
if (part->draw & PART_DRAW_RAND_GR)
|
||||
b = BLI_rand() % totgroup;
|
||||
else
|
||||
b= a % totgroup;
|
||||
b = a % totgroup;
|
||||
|
||||
ob = oblist[b];
|
||||
obmat = oblist[b]->obmat;
|
||||
oldobmat = obcopylist[b].obmat;
|
||||
}
|
||||
else {
|
||||
obmat= ob->obmat;
|
||||
oldobmat= obcopy.obmat;
|
||||
obmat = ob->obmat;
|
||||
oldobmat = obcopy.obmat;
|
||||
}
|
||||
|
||||
if (hair) {
|
||||
@@ -1396,12 +1396,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
psys_get_dupli_path_transform(&sim, pa, NULL, cache, pamat, &scale);
|
||||
}
|
||||
else {
|
||||
cache = psys->childcache[a-totpart];
|
||||
cache = psys->childcache[a - totpart];
|
||||
psys_get_dupli_path_transform(&sim, NULL, cpa, cache, pamat, &scale);
|
||||
}
|
||||
|
||||
copy_v3_v3(pamat[3], cache->co);
|
||||
pamat[3][3]= 1.0f;
|
||||
pamat[3][3] = 1.0f;
|
||||
|
||||
}
|
||||
else {
|
||||
@@ -1415,17 +1415,17 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
normalize_qt_qt(tquat, state.rot);
|
||||
quat_to_mat4(pamat, tquat);
|
||||
copy_v3_v3(pamat[3], state.co);
|
||||
pamat[3][3]= 1.0f;
|
||||
pamat[3][3] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
|
||||
for (go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
|
||||
if (part->ren_as == PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
|
||||
for (go = part->dup_group->gobject.first, b = 0; go; go = go->next, b++) {
|
||||
|
||||
copy_m4_m4(tmat, oblist[b]->obmat);
|
||||
/* apply particle scale */
|
||||
mul_mat3_m4_fl(tmat, size*scale);
|
||||
mul_v3_fl(tmat[3], size*scale);
|
||||
mul_mat3_m4_fl(tmat, size * scale);
|
||||
mul_v3_fl(tmat[3], size * scale);
|
||||
/* group dupli offset, should apply after everything else */
|
||||
if (!is_zero_v3(part->dup_group->dupli_ofs))
|
||||
sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
|
||||
@@ -1437,7 +1437,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
else
|
||||
copy_m4_m4(mat, tmat);
|
||||
|
||||
dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated);
|
||||
dob = new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated);
|
||||
copy_m4_m4(dob->omat, obcopylist[b].obmat);
|
||||
if (G.rendering)
|
||||
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
|
||||
@@ -1445,7 +1445,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
}
|
||||
else {
|
||||
/* to give ipos in object correct offset */
|
||||
BKE_object_where_is_calc_time(scene, ob, ctime-pa_time);
|
||||
BKE_object_where_is_calc_time(scene, ob, ctime - pa_time);
|
||||
|
||||
copy_v3_v3(vec, obmat[3]);
|
||||
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
|
||||
@@ -1457,7 +1457,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
xvec[1] = xvec[2] = 0;
|
||||
vec_to_quat(q, xvec, ob->trackflag, ob->upflag);
|
||||
quat_to_mat4(obmat, q);
|
||||
obmat[3][3]= 1.0f;
|
||||
obmat[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/* Normal particles and cached hair live in global space so we need to
|
||||
@@ -1469,7 +1469,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
copy_m4_m4(mat, pamat);
|
||||
|
||||
mult_m4_m4m4(tmat, mat, obmat);
|
||||
mul_mat3_m4_fl(tmat, size*scale);
|
||||
mul_mat3_m4_fl(tmat, size * scale);
|
||||
|
||||
if (par_space_mat)
|
||||
mult_m4_m4m4(mat, par_space_mat, tmat);
|
||||
@@ -1479,7 +1479,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
if (part->draw & PART_DRAW_GLOBAL_OB)
|
||||
add_v3_v3v3(mat[3], mat[3], vec);
|
||||
|
||||
dob= new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated);
|
||||
dob = new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated);
|
||||
copy_m4_m4(dob->omat, oldobmat);
|
||||
if (G.rendering)
|
||||
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
|
||||
@@ -1487,12 +1487,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
}
|
||||
|
||||
/* restore objects since they were changed in BKE_object_where_is_calc_time */
|
||||
if (part->ren_as==PART_DRAW_GR) {
|
||||
for (a=0; a<totgroup; a++)
|
||||
*(oblist[a])= obcopylist[a];
|
||||
if (part->ren_as == PART_DRAW_GR) {
|
||||
for (a = 0; a < totgroup; a++)
|
||||
*(oblist[a]) = obcopylist[a];
|
||||
}
|
||||
else
|
||||
*ob= obcopy;
|
||||
*ob = obcopy;
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
@@ -1512,19 +1512,19 @@ static Object *find_family_object(Object **obar, char *family, char ch)
|
||||
Object *ob;
|
||||
int flen;
|
||||
|
||||
if ( obar[(int)ch] ) return obar[(int)ch];
|
||||
if (obar[(int)ch]) return obar[(int)ch];
|
||||
|
||||
flen= strlen(family);
|
||||
flen = strlen(family);
|
||||
|
||||
ob= G.main->object.first;
|
||||
ob = G.main->object.first;
|
||||
while (ob) {
|
||||
if (ob->id.name[flen + 2] == ch) {
|
||||
if ( strncmp(ob->id.name+2, family, flen)==0 ) break;
|
||||
if (strncmp(ob->id.name + 2, family, flen) == 0) break;
|
||||
}
|
||||
ob= ob->id.next;
|
||||
ob = ob->id.next;
|
||||
}
|
||||
|
||||
obar[(int)ch]= ob;
|
||||
obar[(int)ch] = ob;
|
||||
|
||||
return ob;
|
||||
}
|
||||
@@ -1532,37 +1532,37 @@ static Object *find_family_object(Object **obar, char *family, char ch)
|
||||
|
||||
static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated)
|
||||
{
|
||||
Object *ob, *obar[256]= {NULL};
|
||||
Object *ob, *obar[256] = {NULL};
|
||||
Curve *cu;
|
||||
struct chartrans *ct, *chartransdata;
|
||||
float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof;
|
||||
int slen, a;
|
||||
|
||||
/* simple preventing of too deep nested groups */
|
||||
if (level>MAX_DUPLI_RECUR) return;
|
||||
if (level > MAX_DUPLI_RECUR) return;
|
||||
|
||||
copy_m4_m4(pmat, par->obmat);
|
||||
|
||||
/* in par the family name is stored, use this to find the other objects */
|
||||
|
||||
chartransdata= BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI);
|
||||
if (chartransdata==NULL) return;
|
||||
chartransdata = BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI);
|
||||
if (chartransdata == NULL) return;
|
||||
|
||||
cu= par->data;
|
||||
slen= strlen(cu->str);
|
||||
fsize= cu->fsize;
|
||||
xof= cu->xof;
|
||||
yof= cu->yof;
|
||||
cu = par->data;
|
||||
slen = strlen(cu->str);
|
||||
fsize = cu->fsize;
|
||||
xof = cu->xof;
|
||||
yof = cu->yof;
|
||||
|
||||
ct= chartransdata;
|
||||
ct = chartransdata;
|
||||
|
||||
for (a=0; a<slen; a++, ct++) {
|
||||
for (a = 0; a < slen; a++, ct++) {
|
||||
|
||||
ob= find_family_object(obar, cu->family, cu->str[a]);
|
||||
ob = find_family_object(obar, cu->family, cu->str[a]);
|
||||
if (ob) {
|
||||
vec[0]= fsize*(ct->xof - xof);
|
||||
vec[1]= fsize*(ct->yof - yof);
|
||||
vec[2]= 0.0;
|
||||
vec[0] = fsize * (ct->xof - xof);
|
||||
vec[1] = fsize * (ct->yof - yof);
|
||||
vec[2] = 0.0;
|
||||
|
||||
mul_m4_v3(pmat, vec);
|
||||
|
||||
@@ -1580,7 +1580,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
|
||||
|
||||
static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated)
|
||||
{
|
||||
if ((ob->transflag & OB_DUPLI)==0)
|
||||
if ((ob->transflag & OB_DUPLI) == 0)
|
||||
return;
|
||||
|
||||
/* Should the dupli's be generated for this object? - Respect restrict flags */
|
||||
@@ -1597,35 +1597,35 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
|
||||
|
||||
if (ob->transflag & OB_DUPLIPARTS) {
|
||||
ParticleSystem *psys = ob->particlesystem.first;
|
||||
for (; psys; psys=psys->next)
|
||||
new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level+1, animated);
|
||||
for (; psys; psys = psys->next)
|
||||
new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level + 1, animated);
|
||||
}
|
||||
else if (ob->transflag & OB_DUPLIVERTS) {
|
||||
if (ob->type==OB_MESH) {
|
||||
vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
|
||||
if (ob->type == OB_MESH) {
|
||||
vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level + 1, animated);
|
||||
}
|
||||
else if (ob->type==OB_FONT) {
|
||||
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
|
||||
font_duplilist(duplilist, scene, ob, level+1, animated);
|
||||
else if (ob->type == OB_FONT) {
|
||||
if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */
|
||||
font_duplilist(duplilist, scene, ob, level + 1, animated);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ob->transflag & OB_DUPLIFACES) {
|
||||
if (ob->type==OB_MESH)
|
||||
face_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
|
||||
if (ob->type == OB_MESH)
|
||||
face_duplilist(duplilist, id, scene, ob, par_space_mat, level + 1, animated);
|
||||
}
|
||||
else if (ob->transflag & OB_DUPLIFRAMES) {
|
||||
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
|
||||
frames_duplilist(duplilist, scene, ob, level+1, animated);
|
||||
if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */
|
||||
frames_duplilist(duplilist, scene, ob, level + 1, animated);
|
||||
}
|
||||
}
|
||||
else if (ob->transflag & OB_DUPLIGROUP) {
|
||||
DupliObject *dob;
|
||||
|
||||
group_duplilist(duplilist, scene, ob, level+1, animated); /* now recursive */
|
||||
group_duplilist(duplilist, scene, ob, level + 1, animated); /* now recursive */
|
||||
|
||||
if (level==0) {
|
||||
for (dob= duplilist->first; dob; dob= dob->next)
|
||||
if (level == 0) {
|
||||
for (dob = duplilist->first; dob; dob = dob->next)
|
||||
if (dob->type == OB_DUPLIGROUP)
|
||||
copy_m4_m4(dob->ob->obmat, dob->mat);
|
||||
}
|
||||
@@ -1636,8 +1636,8 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
|
||||
* note; group dupli's already set transform matrix. see note in group_duplilist() */
|
||||
ListBase *object_duplilist(Scene *sce, Object *ob)
|
||||
{
|
||||
ListBase *duplilist= MEM_mallocN(sizeof(ListBase), "duplilist");
|
||||
duplilist->first= duplilist->last= NULL;
|
||||
ListBase *duplilist = MEM_mallocN(sizeof(ListBase), "duplilist");
|
||||
duplilist->first = duplilist->last = NULL;
|
||||
object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, 0, 0);
|
||||
return duplilist;
|
||||
}
|
||||
@@ -1649,8 +1649,8 @@ void free_object_duplilist(ListBase *lb)
|
||||
/* loop in reverse order, if object is instanced multiple times
|
||||
* the original layer may not really be original otherwise, proper
|
||||
* solution is more complicated */
|
||||
for (dob= lb->last; dob; dob= dob->prev) {
|
||||
dob->ob->lay= dob->origlay;
|
||||
for (dob = lb->last; dob; dob = dob->prev) {
|
||||
dob->ob->lay = dob->origlay;
|
||||
copy_m4_m4(dob->ob->obmat, dob->omat);
|
||||
}
|
||||
|
||||
@@ -1662,16 +1662,16 @@ int count_duplilist(Object *ob)
|
||||
{
|
||||
if (ob->transflag & OB_DUPLI) {
|
||||
if (ob->transflag & OB_DUPLIVERTS) {
|
||||
if (ob->type==OB_MESH) {
|
||||
if (ob->type == OB_MESH) {
|
||||
if (ob->transflag & OB_DUPLIVERTS) {
|
||||
ParticleSystem *psys = ob->particlesystem.first;
|
||||
int pdup=0;
|
||||
int pdup = 0;
|
||||
|
||||
for (; psys; psys=psys->next)
|
||||
for (; psys; psys = psys->next)
|
||||
pdup += psys->totpart;
|
||||
|
||||
if (pdup==0) {
|
||||
Mesh *me= ob->data;
|
||||
if (pdup == 0) {
|
||||
Mesh *me = ob->data;
|
||||
return me->totvert;
|
||||
}
|
||||
else
|
||||
@@ -1680,9 +1680,9 @@ int count_duplilist(Object *ob)
|
||||
}
|
||||
}
|
||||
else if (ob->transflag & OB_DUPLIFRAMES) {
|
||||
int tot= ob->dupend - ob->dupsta;
|
||||
tot/= (ob->dupon+ob->dupoff);
|
||||
return tot*ob->dupon;
|
||||
int tot = ob->dupend - ob->dupsta;
|
||||
tot /= (ob->dupon + ob->dupoff);
|
||||
return tot * ob->dupon;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -95,7 +95,7 @@ Global G;
|
||||
UserDef U;
|
||||
/* ListBase = {NULL, NULL}; */
|
||||
|
||||
char versionstr[48]= "";
|
||||
char versionstr[48] = "";
|
||||
|
||||
/* ********** free ********** */
|
||||
|
||||
@@ -104,9 +104,9 @@ void free_blender(void)
|
||||
{
|
||||
/* samples are in a global list..., also sets G.main->sound->sample NULL */
|
||||
free_main(G.main);
|
||||
G.main= NULL;
|
||||
G.main = NULL;
|
||||
|
||||
BKE_spacetypes_free(); /* after free main, it uses space callbacks */
|
||||
BKE_spacetypes_free(); /* after free main, it uses space callbacks */
|
||||
|
||||
IMB_exit();
|
||||
|
||||
@@ -122,18 +122,18 @@ void initglobals(void)
|
||||
{
|
||||
memset(&G, 0, sizeof(Global));
|
||||
|
||||
U.savetime= 1;
|
||||
U.savetime = 1;
|
||||
|
||||
G.main= MEM_callocN(sizeof(Main), "initglobals");
|
||||
G.main = MEM_callocN(sizeof(Main), "initglobals");
|
||||
|
||||
strcpy(G.ima, "//");
|
||||
|
||||
if (BLENDER_SUBVERSION)
|
||||
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
|
||||
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
|
||||
else
|
||||
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100);
|
||||
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION / 100, BLENDER_VERSION % 100);
|
||||
|
||||
#ifdef _WIN32 // FULLSCREEN
|
||||
#ifdef _WIN32 // FULLSCREEN
|
||||
G.windowstate = G_WINDOWSTATE_USERDEF;
|
||||
#endif
|
||||
|
||||
@@ -154,11 +154,11 @@ static void clear_global(void)
|
||||
{
|
||||
// extern short winqueue_break; /* screen.c */
|
||||
|
||||
free_main(G.main); /* free all lib data */
|
||||
free_main(G.main); /* free all lib data */
|
||||
|
||||
// free_vertexpaint();
|
||||
|
||||
G.main= NULL;
|
||||
G.main = NULL;
|
||||
}
|
||||
|
||||
static int clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src)
|
||||
@@ -175,7 +175,7 @@ static void clean_paths(Main *main)
|
||||
|
||||
BLI_bpath_traverse_main(main, clean_paths_visit_cb, BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, NULL);
|
||||
|
||||
for (scene= main->scene.first; scene; scene= scene->id.next) {
|
||||
for (scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
BLI_clean(scene->r.pic);
|
||||
}
|
||||
}
|
||||
@@ -188,17 +188,17 @@ static void clean_paths(Main *main)
|
||||
|
||||
static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath)
|
||||
{
|
||||
bScreen *curscreen= NULL;
|
||||
Scene *curscene= NULL;
|
||||
bScreen *curscreen = NULL;
|
||||
Scene *curscene = NULL;
|
||||
int recover;
|
||||
char mode;
|
||||
|
||||
/* 'u' = undo save, 'n' = no UI load */
|
||||
if (bfd->main->screen.first==NULL) mode= 'u';
|
||||
else if (G.fileflags & G_FILE_NO_UI) mode= 'n';
|
||||
else mode= 0;
|
||||
if (bfd->main->screen.first == NULL) mode = 'u';
|
||||
else if (G.fileflags & G_FILE_NO_UI) mode = 'n';
|
||||
else mode = 0;
|
||||
|
||||
recover= (G.fileflags & G_FILE_RECOVER);
|
||||
recover = (G.fileflags & G_FILE_RECOVER);
|
||||
|
||||
/* Free all render results, without this stale data gets displayed after loading files */
|
||||
if (mode != 'u') {
|
||||
@@ -222,12 +222,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
|
||||
SWAP(ListBase, G.main->script, bfd->main->script);
|
||||
|
||||
/* we re-use current screen */
|
||||
curscreen= CTX_wm_screen(C);
|
||||
curscreen = CTX_wm_screen(C);
|
||||
/* but use new Scene pointer */
|
||||
curscene= bfd->curscene;
|
||||
if (curscene==NULL) curscene= bfd->main->scene.first;
|
||||
curscene = bfd->curscene;
|
||||
if (curscene == NULL) curscene = bfd->main->scene.first;
|
||||
/* and we enforce curscene to be in current screen */
|
||||
if (curscreen) curscreen->scene= curscene; /* can run in bgmode */
|
||||
if (curscreen) curscreen->scene = curscene; /* can run in bgmode */
|
||||
|
||||
/* clear_global will free G.main, here we can still restore pointers */
|
||||
lib_link_screen_restore(bfd->main, curscreen, curscene);
|
||||
@@ -240,7 +240,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
|
||||
/* clear old property update cache, in case some old references are left dangling */
|
||||
RNA_property_update_cache_free();
|
||||
|
||||
G.main= bfd->main;
|
||||
G.main = bfd->main;
|
||||
|
||||
CTX_data_main_set(C, G.main);
|
||||
|
||||
@@ -251,7 +251,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
|
||||
/* only here free userdef themes... */
|
||||
BKE_userdef_free();
|
||||
|
||||
U= *bfd->user;
|
||||
U = *bfd->user;
|
||||
MEM_freeN(bfd->user);
|
||||
}
|
||||
|
||||
@@ -261,9 +261,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
|
||||
CTX_data_scene_set(C, curscene);
|
||||
}
|
||||
else {
|
||||
G.winpos= bfd->winpos;
|
||||
G.displaymode= bfd->displaymode;
|
||||
G.fileflags= bfd->fileflags;
|
||||
G.winpos = bfd->winpos;
|
||||
G.displaymode = bfd->displaymode;
|
||||
G.fileflags = bfd->fileflags;
|
||||
CTX_wm_manager_set(C, bfd->main->wm.first);
|
||||
CTX_wm_screen_set(C, bfd->curscreen);
|
||||
CTX_data_scene_set(C, bfd->curscreen->scene);
|
||||
@@ -273,20 +273,20 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
|
||||
}
|
||||
|
||||
/* this can happen when active scene was lib-linked, and doesn't exist anymore */
|
||||
if (CTX_data_scene(C)==NULL) {
|
||||
if (CTX_data_scene(C) == NULL) {
|
||||
CTX_data_scene_set(C, bfd->main->scene.first);
|
||||
CTX_wm_screen(C)->scene= CTX_data_scene(C);
|
||||
curscene= CTX_data_scene(C);
|
||||
CTX_wm_screen(C)->scene = CTX_data_scene(C);
|
||||
curscene = CTX_data_scene(C);
|
||||
}
|
||||
|
||||
/* special cases, override loaded flags: */
|
||||
if (G.f != bfd->globalf) {
|
||||
const int flags_keep = (G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
|
||||
bfd->globalf= (bfd->globalf & ~flags_keep) | (G.f & flags_keep);
|
||||
bfd->globalf = (bfd->globalf & ~flags_keep) | (G.f & flags_keep);
|
||||
}
|
||||
|
||||
|
||||
G.f= bfd->globalf;
|
||||
G.f = bfd->globalf;
|
||||
|
||||
if (!G.background) {
|
||||
//setscreen(G.curscreen);
|
||||
@@ -300,12 +300,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
|
||||
if (recover && bfd->filename[0] && G.relbase_valid) {
|
||||
/* in case of autosave or quit.blend, use original filename instead
|
||||
* use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
|
||||
filepath= bfd->filename;
|
||||
filepath = bfd->filename;
|
||||
}
|
||||
#if 0
|
||||
else if (!G.relbase_valid) {
|
||||
/* otherwise, use an empty string as filename, rather than <memory2> */
|
||||
filepath="";
|
||||
filepath = "";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -324,8 +324,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
|
||||
static int handle_subversion_warning(Main *main, ReportList *reports)
|
||||
{
|
||||
if (main->minversionfile > BLENDER_VERSION ||
|
||||
(main->minversionfile == BLENDER_VERSION &&
|
||||
main->minsubversionfile > BLENDER_SUBVERSION)) {
|
||||
(main->minversionfile == BLENDER_VERSION &&
|
||||
main->minsubversionfile > BLENDER_SUBVERSION)) {
|
||||
BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
|
||||
}
|
||||
|
||||
@@ -348,8 +348,8 @@ void BKE_userdef_free(void)
|
||||
wmKeyMapItem *kmi;
|
||||
wmKeyMapDiffItem *kmdi;
|
||||
|
||||
for (km=U.user_keymaps.first; km; km=km->next) {
|
||||
for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
for (km = U.user_keymaps.first; km; km = km->next) {
|
||||
for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
|
||||
if (kmdi->add_item) {
|
||||
keymap_item_free(kmdi->add_item);
|
||||
MEM_freeN(kmdi->add_item);
|
||||
@@ -360,7 +360,7 @@ void BKE_userdef_free(void)
|
||||
}
|
||||
}
|
||||
|
||||
for (kmi=km->items.first; kmi; kmi=kmi->next)
|
||||
for (kmi = km->items.first; kmi; kmi = kmi->next)
|
||||
keymap_item_free(kmi);
|
||||
|
||||
BLI_freelistN(&km->diff_items);
|
||||
@@ -377,41 +377,41 @@ void BKE_userdef_free(void)
|
||||
int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
|
||||
{
|
||||
BlendFileData *bfd;
|
||||
int retval= BKE_READ_FILE_OK;
|
||||
int retval = BKE_READ_FILE_OK;
|
||||
|
||||
if (strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */
|
||||
if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) /* don't print user-pref loading */
|
||||
printf("read blend: %s\n", filepath);
|
||||
|
||||
bfd= BLO_read_from_file(filepath, reports);
|
||||
bfd = BLO_read_from_file(filepath, reports);
|
||||
if (bfd) {
|
||||
if (bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
|
||||
if (bfd->user) retval = BKE_READ_FILE_OK_USERPREFS;
|
||||
|
||||
if (0==handle_subversion_warning(bfd->main, reports)) {
|
||||
if (0 == handle_subversion_warning(bfd->main, reports)) {
|
||||
free_main(bfd->main);
|
||||
MEM_freeN(bfd);
|
||||
bfd= NULL;
|
||||
retval= BKE_READ_FILE_FAIL;
|
||||
bfd = NULL;
|
||||
retval = BKE_READ_FILE_FAIL;
|
||||
}
|
||||
else
|
||||
setup_app_data(C, bfd, filepath); // frees BFD
|
||||
setup_app_data(C, bfd, filepath); // frees BFD
|
||||
}
|
||||
else
|
||||
BKE_reports_prependf(reports, "Loading %s failed: ", filepath);
|
||||
|
||||
return (bfd?retval:BKE_READ_FILE_FAIL);
|
||||
return (bfd ? retval : BKE_READ_FILE_FAIL);
|
||||
}
|
||||
|
||||
int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, ReportList *reports)
|
||||
int BKE_read_file_from_memory(bContext *C, char *filebuf, int filelength, ReportList *reports)
|
||||
{
|
||||
BlendFileData *bfd;
|
||||
|
||||
bfd= BLO_read_from_memory(filebuf, filelength, reports);
|
||||
bfd = BLO_read_from_memory(filebuf, filelength, reports);
|
||||
if (bfd)
|
||||
setup_app_data(C, bfd, "<memory2>");
|
||||
else
|
||||
BKE_reports_prepend(reports, "Loading failed: ");
|
||||
|
||||
return (bfd?1:0);
|
||||
return (bfd ? 1 : 0);
|
||||
}
|
||||
|
||||
/* memfile is the undo buffer */
|
||||
@@ -419,13 +419,13 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report
|
||||
{
|
||||
BlendFileData *bfd;
|
||||
|
||||
bfd= BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
|
||||
bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
|
||||
if (bfd)
|
||||
setup_app_data(C, bfd, "<memory1>");
|
||||
else
|
||||
BKE_reports_prepend(reports, "Loading failed: ");
|
||||
|
||||
return (bfd?1:0);
|
||||
return (bfd ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ static void (*blender_test_break_cb)(void) = NULL;
|
||||
|
||||
void set_blender_test_break_cb(void (*func)(void) )
|
||||
{
|
||||
blender_test_break_cb= func;
|
||||
blender_test_break_cb = func;
|
||||
}
|
||||
|
||||
|
||||
@@ -446,15 +446,15 @@ int blender_test_break(void)
|
||||
blender_test_break_cb();
|
||||
}
|
||||
|
||||
return (G.afbreek==1);
|
||||
return (G.afbreek == 1);
|
||||
}
|
||||
|
||||
|
||||
/* ***************** GLOBAL UNDO *************** */
|
||||
|
||||
#define UNDO_DISK 0
|
||||
#define UNDO_DISK 0
|
||||
|
||||
#define MAXUNDONAME 64
|
||||
#define MAXUNDONAME 64
|
||||
typedef struct UndoElem {
|
||||
struct UndoElem *next, *prev;
|
||||
char str[FILE_MAX];
|
||||
@@ -463,31 +463,31 @@ typedef struct UndoElem {
|
||||
uintptr_t undosize;
|
||||
} UndoElem;
|
||||
|
||||
static ListBase undobase={NULL, NULL};
|
||||
static UndoElem *curundo= NULL;
|
||||
static ListBase undobase = {NULL, NULL};
|
||||
static UndoElem *curundo = NULL;
|
||||
|
||||
|
||||
static int read_undosave(bContext *C, UndoElem *uel)
|
||||
{
|
||||
char mainstr[sizeof(G.main->name)];
|
||||
int success=0, fileflags;
|
||||
int success = 0, fileflags;
|
||||
|
||||
/* This is needed so undoing/redoing doesn't crash with threaded previews going */
|
||||
WM_jobs_stop_all(CTX_wm_manager(C));
|
||||
|
||||
BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */
|
||||
BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */
|
||||
|
||||
fileflags= G.fileflags;
|
||||
fileflags = G.fileflags;
|
||||
G.fileflags |= G_FILE_NO_UI;
|
||||
|
||||
if (UNDO_DISK)
|
||||
success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL);
|
||||
success = (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL);
|
||||
else
|
||||
success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
|
||||
success = BKE_read_file_from_memfile(C, &uel->memfile, NULL);
|
||||
|
||||
/* restore */
|
||||
BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
|
||||
G.fileflags= fileflags;
|
||||
G.fileflags = fileflags;
|
||||
|
||||
if (success) {
|
||||
/* important not to update time here, else non keyed tranforms are lost */
|
||||
@@ -504,33 +504,33 @@ void BKE_write_undo(bContext *C, const char *name)
|
||||
int nr /*, success */ /* UNUSED */;
|
||||
UndoElem *uel;
|
||||
|
||||
if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
|
||||
if ( U.undosteps==0) return;
|
||||
if ( (U.uiflag & USER_GLOBALUNDO) == 0) return;
|
||||
if (U.undosteps == 0) return;
|
||||
|
||||
/* remove all undos after (also when curundo==NULL) */
|
||||
while (undobase.last != curundo) {
|
||||
uel= undobase.last;
|
||||
uel = undobase.last;
|
||||
BLI_remlink(&undobase, uel);
|
||||
BLO_free_memfile(&uel->memfile);
|
||||
MEM_freeN(uel);
|
||||
}
|
||||
|
||||
/* make new */
|
||||
curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file");
|
||||
curundo = uel = MEM_callocN(sizeof(UndoElem), "undo file");
|
||||
BLI_strncpy(uel->name, name, sizeof(uel->name));
|
||||
BLI_addtail(&undobase, uel);
|
||||
|
||||
/* and limit amount to the maximum */
|
||||
nr= 0;
|
||||
uel= undobase.last;
|
||||
nr = 0;
|
||||
uel = undobase.last;
|
||||
while (uel) {
|
||||
nr++;
|
||||
if (nr==U.undosteps) break;
|
||||
uel= uel->prev;
|
||||
if (nr == U.undosteps) break;
|
||||
uel = uel->prev;
|
||||
}
|
||||
if (uel) {
|
||||
while (undobase.first!=uel) {
|
||||
UndoElem *first= undobase.first;
|
||||
while (undobase.first != uel) {
|
||||
UndoElem *first = undobase.first;
|
||||
BLI_remlink(&undobase, first);
|
||||
/* the merge is because of compression */
|
||||
BLO_merge_memfile(&first->memfile, &first->next->memfile);
|
||||
@@ -541,14 +541,14 @@ void BKE_write_undo(bContext *C, const char *name)
|
||||
|
||||
/* disk save version */
|
||||
if (UNDO_DISK) {
|
||||
static int counter= 0;
|
||||
static int counter = 0;
|
||||
char filepath[FILE_MAX];
|
||||
char numstr[32];
|
||||
int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
|
||||
|
||||
/* calculate current filepath */
|
||||
counter++;
|
||||
counter= counter % U.undosteps;
|
||||
counter = counter % U.undosteps;
|
||||
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
|
||||
BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr);
|
||||
@@ -558,34 +558,34 @@ void BKE_write_undo(bContext *C, const char *name)
|
||||
BLI_strncpy(curundo->str, filepath, sizeof(curundo->str));
|
||||
}
|
||||
else {
|
||||
MemFile *prevfile=NULL;
|
||||
MemFile *prevfile = NULL;
|
||||
|
||||
if (curundo->prev) prevfile= &(curundo->prev->memfile);
|
||||
if (curundo->prev) prevfile = &(curundo->prev->memfile);
|
||||
|
||||
memused= MEM_get_memory_in_use();
|
||||
memused = MEM_get_memory_in_use();
|
||||
/* success= */ /* UNUSED */ BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags);
|
||||
curundo->undosize= MEM_get_memory_in_use() - memused;
|
||||
curundo->undosize = MEM_get_memory_in_use() - memused;
|
||||
}
|
||||
|
||||
if (U.undomemory != 0) {
|
||||
/* limit to maximum memory (afterwards, we can't know in advance) */
|
||||
totmem= 0;
|
||||
maxmem= ((uintptr_t)U.undomemory)*1024*1024;
|
||||
totmem = 0;
|
||||
maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024;
|
||||
|
||||
/* keep at least two (original + other) */
|
||||
uel= undobase.last;
|
||||
uel = undobase.last;
|
||||
while (uel && uel->prev) {
|
||||
totmem+= uel->undosize;
|
||||
if (totmem>maxmem) break;
|
||||
uel= uel->prev;
|
||||
totmem += uel->undosize;
|
||||
if (totmem > maxmem) break;
|
||||
uel = uel->prev;
|
||||
}
|
||||
|
||||
if (uel) {
|
||||
if (uel->prev && uel->prev->prev)
|
||||
uel= uel->prev;
|
||||
uel = uel->prev;
|
||||
|
||||
while (undobase.first!=uel) {
|
||||
UndoElem *first= undobase.first;
|
||||
while (undobase.first != uel) {
|
||||
UndoElem *first = undobase.first;
|
||||
BLI_remlink(&undobase, first);
|
||||
/* the merge is because of compression */
|
||||
BLO_merge_memfile(&first->memfile, &first->next->memfile);
|
||||
@@ -599,25 +599,25 @@ void BKE_write_undo(bContext *C, const char *name)
|
||||
void BKE_undo_step(bContext *C, int step)
|
||||
{
|
||||
|
||||
if (step==0) {
|
||||
if (step == 0) {
|
||||
read_undosave(C, curundo);
|
||||
}
|
||||
else if (step==1) {
|
||||
else if (step == 1) {
|
||||
/* curundo should never be NULL, after restart or load file it should call undo_save */
|
||||
if (curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available");
|
||||
if (curundo == NULL || curundo->prev == NULL) ; // XXX error("No undo available");
|
||||
else {
|
||||
if (G.debug & G_DEBUG) printf("undo %s\n", curundo->name);
|
||||
curundo= curundo->prev;
|
||||
curundo = curundo->prev;
|
||||
read_undosave(C, curundo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* curundo has to remain current situation! */
|
||||
|
||||
if (curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available");
|
||||
if (curundo == NULL || curundo->next == NULL) ; // XXX error("No redo available");
|
||||
else {
|
||||
read_undosave(C, curundo->next);
|
||||
curundo= curundo->next;
|
||||
curundo = curundo->next;
|
||||
if (G.debug & G_DEBUG) printf("redo %s\n", curundo->name);
|
||||
}
|
||||
}
|
||||
@@ -627,30 +627,30 @@ void BKE_reset_undo(void)
|
||||
{
|
||||
UndoElem *uel;
|
||||
|
||||
uel= undobase.first;
|
||||
uel = undobase.first;
|
||||
while (uel) {
|
||||
BLO_free_memfile(&uel->memfile);
|
||||
uel= uel->next;
|
||||
uel = uel->next;
|
||||
}
|
||||
|
||||
BLI_freelistN(&undobase);
|
||||
curundo= NULL;
|
||||
curundo = NULL;
|
||||
}
|
||||
|
||||
/* based on index nr it does a restore */
|
||||
void BKE_undo_number(bContext *C, int nr)
|
||||
{
|
||||
curundo= BLI_findlink(&undobase, nr);
|
||||
curundo = BLI_findlink(&undobase, nr);
|
||||
BKE_undo_step(C, 0);
|
||||
}
|
||||
|
||||
/* go back to the last occurance of name in stack */
|
||||
void BKE_undo_name(bContext *C, const char *name)
|
||||
{
|
||||
UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
|
||||
UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
|
||||
|
||||
if (uel && uel->prev) {
|
||||
curundo= uel->prev;
|
||||
curundo = uel->prev;
|
||||
BKE_undo_step(C, 0);
|
||||
}
|
||||
}
|
||||
@@ -659,7 +659,7 @@ void BKE_undo_name(bContext *C, const char *name)
|
||||
int BKE_undo_valid(const char *name)
|
||||
{
|
||||
if (name) {
|
||||
UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
|
||||
UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
|
||||
return uel && uel->prev;
|
||||
}
|
||||
|
||||
@@ -670,13 +670,13 @@ int BKE_undo_valid(const char *name)
|
||||
/* if active pointer, set it to 1 if true */
|
||||
const char *BKE_undo_get_name(int nr, int *active)
|
||||
{
|
||||
UndoElem *uel= BLI_findlink(&undobase, nr);
|
||||
UndoElem *uel = BLI_findlink(&undobase, nr);
|
||||
|
||||
if (active) *active= 0;
|
||||
if (active) *active = 0;
|
||||
|
||||
if (uel) {
|
||||
if (active && uel==curundo)
|
||||
*active= 1;
|
||||
if (active && uel == curundo)
|
||||
*active = 1;
|
||||
return uel->name;
|
||||
}
|
||||
return NULL;
|
||||
@@ -685,23 +685,23 @@ const char *BKE_undo_get_name(int nr, int *active)
|
||||
char *BKE_undo_menu_string(void)
|
||||
{
|
||||
UndoElem *uel;
|
||||
DynStr *ds= BLI_dynstr_new();
|
||||
DynStr *ds = BLI_dynstr_new();
|
||||
char *menu;
|
||||
|
||||
BLI_dynstr_append(ds, "Global Undo History %t");
|
||||
|
||||
for (uel= undobase.first; uel; uel= uel->next) {
|
||||
for (uel = undobase.first; uel; uel = uel->next) {
|
||||
BLI_dynstr_append(ds, "|");
|
||||
BLI_dynstr_append(ds, uel->name);
|
||||
}
|
||||
|
||||
menu= BLI_dynstr_get_cstring(ds);
|
||||
menu = BLI_dynstr_get_cstring(ds);
|
||||
BLI_dynstr_free(ds);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
/* saves quit.blend */
|
||||
/* saves quit.blend */
|
||||
void BKE_undo_save_quit(void)
|
||||
{
|
||||
UndoElem *uel;
|
||||
@@ -709,16 +709,16 @@ void BKE_undo_save_quit(void)
|
||||
int file;
|
||||
char str[FILE_MAX];
|
||||
|
||||
if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
|
||||
if ( (U.uiflag & USER_GLOBALUNDO) == 0) return;
|
||||
|
||||
uel= curundo;
|
||||
if (uel==NULL) {
|
||||
uel = curundo;
|
||||
if (uel == NULL) {
|
||||
printf("No undo buffer to save recovery file\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* no undo state to save */
|
||||
if (undobase.first==undobase.last) return;
|
||||
if (undobase.first == undobase.last) return;
|
||||
|
||||
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
|
||||
|
||||
@@ -728,28 +728,28 @@ void BKE_undo_save_quit(void)
|
||||
return;
|
||||
}
|
||||
|
||||
chunk= uel->memfile.chunks.first;
|
||||
chunk = uel->memfile.chunks.first;
|
||||
while (chunk) {
|
||||
if ( write(file, chunk->buf, chunk->size) != chunk->size) break;
|
||||
chunk= chunk->next;
|
||||
if (write(file, chunk->buf, chunk->size) != chunk->size) break;
|
||||
chunk = chunk->next;
|
||||
}
|
||||
|
||||
close(file);
|
||||
|
||||
if (chunk) ; //XXX error("Unable to save %s, internal error", str);
|
||||
if (chunk) ; //XXX error("Unable to save %s, internal error", str);
|
||||
else printf("Saved session recovery to %s\n", str);
|
||||
}
|
||||
|
||||
/* sets curscene */
|
||||
Main *BKE_undo_get_main(Scene **scene)
|
||||
{
|
||||
Main *mainp= NULL;
|
||||
BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
|
||||
Main *mainp = NULL;
|
||||
BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
|
||||
|
||||
if (bfd) {
|
||||
mainp= bfd->main;
|
||||
mainp = bfd->main;
|
||||
if (scene)
|
||||
*scene= bfd->curscene;
|
||||
*scene = bfd->curscene;
|
||||
|
||||
MEM_freeN(bfd);
|
||||
}
|
||||
|
||||
@@ -101,11 +101,11 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
sub_v3_v3v3(e1, v2, v0);
|
||||
|
||||
A00 = dot_v3v3(e0, e0);
|
||||
A01 = dot_v3v3(e0, e1 );
|
||||
A11 = dot_v3v3(e1, e1 );
|
||||
B0 = dot_v3v3(diff, e0 );
|
||||
B1 = dot_v3v3(diff, e1 );
|
||||
C = dot_v3v3(diff, diff );
|
||||
A01 = dot_v3v3(e0, e1);
|
||||
A11 = dot_v3v3(e1, e1);
|
||||
B0 = dot_v3v3(diff, e0);
|
||||
B1 = dot_v3v3(diff, e1);
|
||||
C = dot_v3v3(diff, diff);
|
||||
Det = fabs(A00 * A11 - A01 * A01);
|
||||
S = A01 * B1 - A11 * B0;
|
||||
T = A01 * B0 - A00 * B1;
|
||||
@@ -122,7 +122,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
}
|
||||
else {
|
||||
if (fabsf(A00) > FLT_EPSILON)
|
||||
S = -B0/A00;
|
||||
S = -B0 / A00;
|
||||
else
|
||||
S = 0.0f;
|
||||
sqrDist = B0 * S + C;
|
||||
@@ -195,7 +195,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
}
|
||||
}
|
||||
else { /* Region 0 */
|
||||
// Minimum at interior lv
|
||||
/* Minimum at interior lv */
|
||||
float invDet;
|
||||
if (fabsf(Det) > FLT_EPSILON)
|
||||
invDet = 1.0f / Det;
|
||||
@@ -203,8 +203,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
invDet = 0.0f;
|
||||
S *= invDet;
|
||||
T *= invDet;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -213,10 +213,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
if (S < 0.0f) { /* Region 2 */
|
||||
tmp0 = A01 + B0;
|
||||
tmp1 = A11 + B1;
|
||||
if ( tmp1 > tmp0 ) {
|
||||
if (tmp1 > tmp0) {
|
||||
numer = tmp1 - tmp0;
|
||||
denom = A00 - 2.0f * A01 + A11;
|
||||
if ( numer >= denom ) {
|
||||
if (numer >= denom) {
|
||||
S = 1.0f;
|
||||
T = 0.0f;
|
||||
sqrDist = A00 + 2.0f * B0 + C;
|
||||
@@ -228,14 +228,14 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
else
|
||||
S = 0.0f;
|
||||
T = 1.0f - S;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
le = 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
S = 0.0f;
|
||||
if ( tmp1 <= 0.0f ) {
|
||||
if (tmp1 <= 0.0f) {
|
||||
T = 1.0f;
|
||||
sqrDist = A11 + 2.0f * B1 + C;
|
||||
lv = 2;
|
||||
@@ -258,10 +258,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
else if (T < 0.0f) { /* Region 6 */
|
||||
tmp0 = A01 + B1;
|
||||
tmp1 = A00 + B0;
|
||||
if ( tmp1 > tmp0 ) {
|
||||
if (tmp1 > tmp0) {
|
||||
numer = tmp1 - tmp0;
|
||||
denom = A00 - 2.0f * A01 + A11;
|
||||
if ( numer >= denom ) {
|
||||
if (numer >= denom) {
|
||||
T = 1.0f;
|
||||
S = 0.0f;
|
||||
sqrDist = A11 + 2.0f * B1 + C;
|
||||
@@ -273,8 +273,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
else
|
||||
T = 0.0f;
|
||||
S = 1.0f - T;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
le = 2;
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
}
|
||||
else { /* Region 1 */
|
||||
numer = A11 + B1 - A01 - B0;
|
||||
if ( numer <= 0.0f ) {
|
||||
if (numer <= 0.0f) {
|
||||
S = 0.0f;
|
||||
T = 1.0f;
|
||||
sqrDist = A11 + 2.0f * B1 + C;
|
||||
@@ -310,7 +310,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
}
|
||||
else {
|
||||
denom = A00 - 2.0f * A01 + A11;
|
||||
if ( numer >= denom ) {
|
||||
if (numer >= denom) {
|
||||
S = 1.0f;
|
||||
T = 0.0f;
|
||||
sqrDist = A00 + 2.0f * B0 + C;
|
||||
@@ -322,8 +322,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
else
|
||||
S = 0.0f;
|
||||
T = 1.0f - S;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
le = 2;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +331,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
}
|
||||
|
||||
// Account for numerical round-off error
|
||||
if ( sqrDist < FLT_EPSILON )
|
||||
if (sqrDist < FLT_EPSILON)
|
||||
sqrDist = 0.0f;
|
||||
|
||||
{
|
||||
@@ -362,19 +362,18 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
|
||||
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
|
||||
static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
|
||||
{
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
|
||||
MVert *vert = data->vert;
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
|
||||
MVert *vert = data->vert;
|
||||
MFace *face = data->face + index;
|
||||
|
||||
float *t0, *t1, *t2, *t3;
|
||||
t0 = vert[ face->v1 ].co;
|
||||
t1 = vert[ face->v2 ].co;
|
||||
t2 = vert[ face->v3 ].co;
|
||||
t3 = face->v4 ? vert[ face->v4].co : NULL;
|
||||
t0 = vert[face->v1].co;
|
||||
t1 = vert[face->v2].co;
|
||||
t2 = vert[face->v3].co;
|
||||
t3 = face->v4 ? vert[face->v4].co : NULL;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
float nearest_tmp[3], dist;
|
||||
int vertex, edge;
|
||||
|
||||
@@ -397,8 +396,8 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3
|
||||
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
|
||||
static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
|
||||
{
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
|
||||
MVert *vert = data->vert;
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
|
||||
MVert *vert = data->vert;
|
||||
MFace *face = data->face + index;
|
||||
|
||||
float *t0, *t1, *t2, *t3;
|
||||
@@ -408,8 +407,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
|
||||
t3 = face->v4 ? vert[face->v4].co : NULL;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
float dist;
|
||||
if (data->sphere_radius == 0.0f)
|
||||
dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
|
||||
@@ -435,14 +433,14 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
|
||||
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
|
||||
static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
|
||||
{
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
|
||||
MVert *vert = data->vert;
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
|
||||
MVert *vert = data->vert;
|
||||
MEdge *edge = data->edge + index;
|
||||
float nearest_tmp[3], dist;
|
||||
|
||||
float *t0, *t1;
|
||||
t0 = vert[ edge->v1 ].co;
|
||||
t1 = vert[ edge->v2 ].co;
|
||||
t0 = vert[edge->v1].co;
|
||||
t1 = vert[edge->v2].co;
|
||||
|
||||
closest_to_line_segment_v3(nearest_tmp, co, t0, t1);
|
||||
dist = len_squared_v3v3(nearest_tmp, co);
|
||||
@@ -460,15 +458,15 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3
|
||||
* BVH builders
|
||||
*/
|
||||
// Builds a bvh tree.. where nodes are the vertexs of the given mesh
|
||||
BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
|
||||
BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
|
||||
{
|
||||
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES);
|
||||
|
||||
//Not in cache
|
||||
if (tree == NULL) {
|
||||
int i;
|
||||
int numVerts= mesh->getNumVerts(mesh);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
int numVerts = mesh->getNumVerts(mesh);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
|
||||
if (vert != NULL) {
|
||||
tree = BLI_bvhtree_new(numVerts, epsilon, tree_type, axis);
|
||||
@@ -514,14 +512,14 @@ BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
}
|
||||
|
||||
// Builds a bvh tree.. where nodes are the faces of the given mesh.
|
||||
BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
|
||||
BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
|
||||
{
|
||||
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES);
|
||||
|
||||
//Not in cache
|
||||
if (tree == NULL) {
|
||||
int i;
|
||||
int numFaces= mesh->getNumTessFaces(mesh);
|
||||
int numFaces = mesh->getNumTessFaces(mesh);
|
||||
|
||||
/* BMESH specific check that we have tessfaces,
|
||||
* we _could_ tessellate here but rather not - campbell
|
||||
@@ -534,7 +532,7 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
/* Create a bvh-tree of the given target */
|
||||
tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis);
|
||||
if (tree != NULL) {
|
||||
BMEditMesh *em= data->em_evil;
|
||||
BMEditMesh *em = data->em_evil;
|
||||
if (em) {
|
||||
/* data->em_evil is only set for snapping, and only for the mesh of the object
|
||||
* which is currently open in edit mode. When set, the bvhtree should not contain
|
||||
@@ -594,17 +592,17 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
}
|
||||
}
|
||||
else {
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
MFace *face = mesh->getTessFaceDataArray(mesh, CD_MFACE);
|
||||
|
||||
if (vert != NULL && face != NULL) {
|
||||
for (i = 0; i < numFaces; i++) {
|
||||
float co[4][3];
|
||||
copy_v3_v3(co[0], vert[ face[i].v1 ].co);
|
||||
copy_v3_v3(co[1], vert[ face[i].v2 ].co);
|
||||
copy_v3_v3(co[2], vert[ face[i].v3 ].co);
|
||||
copy_v3_v3(co[0], vert[face[i].v1].co);
|
||||
copy_v3_v3(co[1], vert[face[i].v2].co);
|
||||
copy_v3_v3(co[2], vert[face[i].v3].co);
|
||||
if (face[i].v4)
|
||||
copy_v3_v3(co[3], vert[ face[i].v4 ].co);
|
||||
copy_v3_v3(co[3], vert[face[i].v4].co);
|
||||
|
||||
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
|
||||
}
|
||||
@@ -644,15 +642,15 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
}
|
||||
|
||||
// Builds a bvh tree.. where nodes are the faces of the given mesh.
|
||||
BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
|
||||
BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
|
||||
{
|
||||
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES);
|
||||
|
||||
//Not in cache
|
||||
if (tree == NULL) {
|
||||
int i;
|
||||
int numEdges= mesh->getNumEdges(mesh);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
int numEdges = mesh->getNumEdges(mesh);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
MEdge *edge = mesh->getEdgeDataArray(mesh, CD_MEDGE);
|
||||
|
||||
if (vert != NULL && edge != NULL) {
|
||||
@@ -661,8 +659,8 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
if (tree != NULL) {
|
||||
for (i = 0; i < numEdges; i++) {
|
||||
float co[4][3];
|
||||
copy_v3_v3(co[0], vert[ edge[i].v1 ].co);
|
||||
copy_v3_v3(co[1], vert[ edge[i].v2 ].co);
|
||||
copy_v3_v3(co[0], vert[edge[i].v1].co);
|
||||
copy_v3_v3(co[1], vert[edge[i].v2].co);
|
||||
|
||||
BLI_bvhtree_insert(tree, i, co[0], 2);
|
||||
}
|
||||
@@ -712,8 +710,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
|
||||
|
||||
|
||||
/* BVHCache */
|
||||
typedef struct BVHCacheItem
|
||||
{
|
||||
typedef struct BVHCacheItem {
|
||||
int type;
|
||||
BVHTree *tree;
|
||||
|
||||
@@ -721,8 +718,8 @@ typedef struct BVHCacheItem
|
||||
|
||||
static void bvhcacheitem_set_if_match(void *_cached, void *_search)
|
||||
{
|
||||
BVHCacheItem * cached = (BVHCacheItem *)_cached;
|
||||
BVHCacheItem * search = (BVHCacheItem *)_search;
|
||||
BVHCacheItem *cached = (BVHCacheItem *)_cached;
|
||||
BVHCacheItem *search = (BVHCacheItem *)_search;
|
||||
|
||||
if (search->type == cached->type) {
|
||||
search->tree = cached->tree;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -172,7 +172,7 @@ static void cdDM_copyPolyArray(DerivedMesh *dm, MPoly *poly_r)
|
||||
|
||||
static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
int i;
|
||||
|
||||
if (dm->numVertData) {
|
||||
@@ -188,7 +188,7 @@ static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
||||
|
||||
static void cdDM_getVertCo(DerivedMesh *dm, int index, float co_r[3])
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
|
||||
copy_v3_v3(co_r, cddm->mvert[index].co);
|
||||
}
|
||||
@@ -204,16 +204,16 @@ static void cdDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
|
||||
|
||||
static void cdDM_getVertNo(DerivedMesh *dm, int index, float no_r[3])
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
normal_short_to_float_v3(no_r, cddm->mvert[index].no);
|
||||
}
|
||||
|
||||
static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
|
||||
if (!cddm->pmap && ob->type == OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
Mesh *me = ob->data;
|
||||
|
||||
create_vert_poly_map(&cddm->pmap, &cddm->pmap_mem,
|
||||
me->mpoly, me->mloop,
|
||||
@@ -225,7 +225,7 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm)
|
||||
|
||||
static int can_pbvh_draw(Object *ob, DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
Mesh *me = ob->data;
|
||||
int deformed = 0;
|
||||
|
||||
@@ -247,10 +247,10 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm)
|
||||
|
||||
static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
|
||||
if (!ob) {
|
||||
cddm->pbvh= NULL;
|
||||
cddm->pbvh = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
return NULL;
|
||||
|
||||
if (ob->sculpt->pbvh) {
|
||||
cddm->pbvh= ob->sculpt->pbvh;
|
||||
cddm->pbvh = ob->sculpt->pbvh;
|
||||
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
int totvert;
|
||||
|
||||
totvert = deformdm->getNumVerts(deformdm);
|
||||
vertCos = MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos");
|
||||
vertCos = MEM_callocN(3 * totvert * sizeof(float), "cdDM_getPBVH vertCos");
|
||||
deformdm->getVertCos(deformdm, vertCos);
|
||||
BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos);
|
||||
MEM_freeN(vertCos);
|
||||
@@ -300,7 +300,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
* TODO: proper fix is to support the pbvh in all drawing modes */
|
||||
static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
float (*face_nors)[3];
|
||||
|
||||
if (!cddm->pbvh || !cddm->pbvh_draw || !dm->numTessFaceData)
|
||||
@@ -313,7 +313,7 @@ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
|
||||
|
||||
static void cdDM_drawVerts(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *mv = cddm->mvert;
|
||||
int i;
|
||||
|
||||
@@ -323,7 +323,7 @@ static void cdDM_drawVerts(DerivedMesh *dm)
|
||||
glVertex3fv(mv->co);
|
||||
glEnd();
|
||||
}
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
GPU_vertex_setup(dm);
|
||||
if (!GPU_buffer_legacy(dm)) {
|
||||
if (dm->drawObject->tot_triangle_point)
|
||||
@@ -337,7 +337,7 @@ static void cdDM_drawVerts(DerivedMesh *dm)
|
||||
|
||||
static void cdDM_drawUVEdges(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MFace *mf = cddm->mface;
|
||||
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
||||
int i;
|
||||
@@ -346,7 +346,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
|
||||
if (GPU_buffer_legacy(dm)) {
|
||||
glBegin(GL_LINES);
|
||||
for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) {
|
||||
if (!(mf->flag&ME_HIDE)) {
|
||||
if (!(mf->flag & ME_HIDE)) {
|
||||
glVertex2fv(tf->uv[0]);
|
||||
glVertex2fv(tf->uv[1]);
|
||||
|
||||
@@ -377,19 +377,19 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
|
||||
GPU_uvedge_setup(dm);
|
||||
if (!GPU_buffer_legacy(dm)) {
|
||||
for (i = 0; i < dm->numTessFaceData; i++, mf++) {
|
||||
if (!(mf->flag&ME_HIDE)) {
|
||||
if (!(mf->flag & ME_HIDE)) {
|
||||
draw = 1;
|
||||
}
|
||||
else {
|
||||
draw = 0;
|
||||
}
|
||||
if ( prevdraw != draw ) {
|
||||
if ( prevdraw > 0 && (curpos-prevstart) > 0) {
|
||||
glDrawArrays(GL_LINES, prevstart, curpos-prevstart);
|
||||
if (prevdraw != draw) {
|
||||
if (prevdraw > 0 && (curpos - prevstart) > 0) {
|
||||
glDrawArrays(GL_LINES, prevstart, curpos - prevstart);
|
||||
}
|
||||
prevstart = curpos;
|
||||
}
|
||||
if ( mf->v4 ) {
|
||||
if (mf->v4) {
|
||||
curpos += 8;
|
||||
}
|
||||
else {
|
||||
@@ -397,8 +397,8 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
|
||||
}
|
||||
prevdraw = draw;
|
||||
}
|
||||
if ( prevdraw > 0 && (curpos-prevstart) > 0 ) {
|
||||
glDrawArrays(GL_LINES, prevstart, curpos-prevstart);
|
||||
if (prevdraw > 0 && (curpos - prevstart) > 0) {
|
||||
glDrawArrays(GL_LINES, prevstart, curpos - prevstart);
|
||||
}
|
||||
}
|
||||
GPU_buffer_unbind();
|
||||
@@ -408,7 +408,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
|
||||
|
||||
static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *mvert = cddm->mvert;
|
||||
MEdge *medge = cddm->medge;
|
||||
int i;
|
||||
@@ -426,7 +426,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
int prevstart = 0;
|
||||
int prevdraw = 1;
|
||||
int draw = TRUE;
|
||||
@@ -442,16 +442,16 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
|
||||
else {
|
||||
draw = FALSE;
|
||||
}
|
||||
if ( prevdraw != draw ) {
|
||||
if ( prevdraw > 0 && (i-prevstart) > 0 ) {
|
||||
if (prevdraw != draw) {
|
||||
if (prevdraw > 0 && (i - prevstart) > 0) {
|
||||
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2);
|
||||
}
|
||||
prevstart = i;
|
||||
}
|
||||
prevdraw = draw;
|
||||
}
|
||||
if ( prevdraw > 0 && (i-prevstart) > 0 ) {
|
||||
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i-prevstart) * 2);
|
||||
if (prevdraw > 0 && (i - prevstart) > 0) {
|
||||
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2);
|
||||
}
|
||||
}
|
||||
GPU_buffer_unbind();
|
||||
@@ -460,7 +460,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
|
||||
|
||||
static void cdDM_drawLooseEdges(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *mvert = cddm->mvert;
|
||||
MEdge *medge = cddm->medge;
|
||||
int i;
|
||||
@@ -469,14 +469,14 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
|
||||
DEBUG_VBO("Using legacy code. cdDM_drawLooseEdges\n");
|
||||
glBegin(GL_LINES);
|
||||
for (i = 0; i < dm->numEdgeData; i++, medge++) {
|
||||
if (medge->flag&ME_LOOSEEDGE) {
|
||||
if (medge->flag & ME_LOOSEEDGE) {
|
||||
glVertex3fv(mvert[medge->v1].co);
|
||||
glVertex3fv(mvert[medge->v2].co);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
int prevstart = 0;
|
||||
int prevdraw = 1;
|
||||
int draw = 1;
|
||||
@@ -484,21 +484,21 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
|
||||
GPU_edge_setup(dm);
|
||||
if (!GPU_buffer_legacy(dm)) {
|
||||
for (i = 0; i < dm->numEdgeData; i++, medge++) {
|
||||
if (medge->flag&ME_LOOSEEDGE) {
|
||||
if (medge->flag & ME_LOOSEEDGE) {
|
||||
draw = 1;
|
||||
}
|
||||
else {
|
||||
draw = 0;
|
||||
}
|
||||
if ( prevdraw != draw ) {
|
||||
if ( prevdraw > 0 && (i-prevstart) > 0) {
|
||||
if (prevdraw != draw) {
|
||||
if (prevdraw > 0 && (i - prevstart) > 0) {
|
||||
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2);
|
||||
}
|
||||
prevstart = i;
|
||||
}
|
||||
prevdraw = draw;
|
||||
}
|
||||
if ( prevdraw > 0 && (i-prevstart) > 0 ) {
|
||||
if (prevdraw > 0 && (i - prevstart) > 0) {
|
||||
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2);
|
||||
}
|
||||
}
|
||||
@@ -507,13 +507,13 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
|
||||
}
|
||||
|
||||
static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
||||
float (*partial_redraw_planes)[4],
|
||||
int UNUSED(fast), DMSetMaterial setMaterial)
|
||||
float (*partial_redraw_planes)[4],
|
||||
int UNUSED(fast), DMSetMaterial setMaterial)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *mvert = cddm->mvert;
|
||||
MFace *mface = cddm->mface;
|
||||
float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL);
|
||||
float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
|
||||
int a, glmode = -1, shademodel = -1, matnr = -1, drawCurrentMat = 1;
|
||||
|
||||
#define PASSVERT(index) { \
|
||||
@@ -521,7 +521,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
||||
short *no = mvert[index].no; \
|
||||
glNormal3sv(no); \
|
||||
} \
|
||||
glVertex3fv(mvert[index].co); \
|
||||
glVertex3fv(mvert[index].co); \
|
||||
}
|
||||
|
||||
if (cddm->pbvh && cddm->pbvh_draw) {
|
||||
@@ -541,9 +541,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
||||
for (a = 0; a < dm->numTessFaceData; a++, mface++) {
|
||||
int new_glmode, new_matnr, new_shademodel;
|
||||
|
||||
new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
|
||||
new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES;
|
||||
new_matnr = mface->mat_nr + 1;
|
||||
new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT;
|
||||
new_shademodel = (mface->flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT;
|
||||
|
||||
if (new_glmode != glmode || new_matnr != matnr || new_shademodel != shademodel) {
|
||||
glEnd();
|
||||
@@ -584,7 +584,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
|
||||
GPU_vertex_setup(dm);
|
||||
GPU_normal_setup(dm);
|
||||
if (!GPU_buffer_legacy(dm)) {
|
||||
@@ -604,16 +604,16 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
DMSetDrawOptionsTex drawParams,
|
||||
DMSetDrawOptions drawParamsMapped,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptionsTex drawParams,
|
||||
DMSetDrawOptions drawParamsMapped,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *mv = cddm->mvert;
|
||||
MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
|
||||
MCol *realcol = dm->getTessFaceDataArray(dm, CD_TEXTURE_MCOL);
|
||||
float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL);
|
||||
float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
|
||||
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
||||
int i, j, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
|
||||
int startFace = 0 /*, lastFlag = 0xdeadbeef */ /* UNUSED */;
|
||||
@@ -631,25 +631,25 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
unsigned char *cp = NULL;
|
||||
|
||||
if (drawParams) {
|
||||
draw_option = drawParams(tf? &tf[i]: NULL, (mcol != NULL), mf->mat_nr);
|
||||
draw_option = drawParams(tf ? &tf[i] : NULL, (mcol != NULL), mf->mat_nr);
|
||||
}
|
||||
else {
|
||||
if (index) {
|
||||
orig = *index++;
|
||||
if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; }
|
||||
if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; }
|
||||
if (drawParamsMapped) draw_option = drawParamsMapped(userData, orig);
|
||||
else { if (nors) nors += 3; continue; }
|
||||
else { if (nors) nors += 3; continue; }
|
||||
}
|
||||
else
|
||||
if (drawParamsMapped) draw_option = drawParamsMapped(userData, i);
|
||||
else { if (nors) nors += 3; continue; }
|
||||
if (drawParamsMapped) draw_option = drawParamsMapped(userData, i);
|
||||
else { if (nors) nors += 3; continue; }
|
||||
}
|
||||
|
||||
if (draw_option != DM_DRAW_OPTION_SKIP) {
|
||||
if (draw_option != DM_DRAW_OPTION_NO_MCOL && mcol)
|
||||
cp = (unsigned char*) &mcol[i*4];
|
||||
cp = (unsigned char *) &mcol[i * 4];
|
||||
|
||||
if (!(mf->flag&ME_SMOOTH)) {
|
||||
if (!(mf->flag & ME_SMOOTH)) {
|
||||
if (nors) {
|
||||
glNormal3fv(nors);
|
||||
}
|
||||
@@ -665,30 +665,30 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
}
|
||||
}
|
||||
|
||||
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
||||
glBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES);
|
||||
if (tf) glTexCoord2fv(tf[i].uv[0]);
|
||||
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
||||
mvert = &mv[mf->v1];
|
||||
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
glVertex3fv(mvert->co);
|
||||
|
||||
if (tf) glTexCoord2fv(tf[i].uv[1]);
|
||||
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
||||
mvert = &mv[mf->v2];
|
||||
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
glVertex3fv(mvert->co);
|
||||
|
||||
if (tf) glTexCoord2fv(tf[i].uv[2]);
|
||||
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
||||
mvert = &mv[mf->v3];
|
||||
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
glVertex3fv(mvert->co);
|
||||
|
||||
if (mf->v4) {
|
||||
if (tf) glTexCoord2fv(tf[i].uv[3]);
|
||||
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
||||
mvert = &mv[mf->v4];
|
||||
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
|
||||
glVertex3fv(mvert->co);
|
||||
}
|
||||
glEnd();
|
||||
@@ -705,7 +705,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
GPU_vertex_setup(dm);
|
||||
GPU_normal_setup(dm);
|
||||
GPU_uv_setup(dm);
|
||||
if ( col != NULL ) {
|
||||
if (col != NULL) {
|
||||
#if 0
|
||||
if (realcol && dm->drawObject->colType == CD_TEXTURE_MCOL) {
|
||||
col = 0;
|
||||
@@ -717,13 +717,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
if (col != 0)
|
||||
#endif
|
||||
{
|
||||
unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common");
|
||||
unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm) * 4 * 3 * sizeof(unsigned char), "cdDM_drawFacesTex_common");
|
||||
for (i = 0; i < dm->getNumTessFaces(dm); i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
/* bgr -> rgb is intentional (and stupid), but how its stored internally */
|
||||
colors[i*12+j*3] = col[i*4+j].b;
|
||||
colors[i*12+j*3+1] = col[i*4+j].g;
|
||||
colors[i*12+j*3+2] = col[i*4+j].r;
|
||||
colors[i * 12 + j * 3] = col[i * 4 + j].b;
|
||||
colors[i * 12 + j * 3 + 1] = col[i * 4 + j].g;
|
||||
colors[i * 12 + j * 3 + 2] = col[i * 4 + j].r;
|
||||
}
|
||||
}
|
||||
GPU_color3_upload(dm, colors);
|
||||
@@ -737,7 +737,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
if (!GPU_buffer_legacy(dm)) {
|
||||
int tottri = dm->drawObject->tot_triangle_point/3;
|
||||
int tottri = dm->drawObject->tot_triangle_point / 3;
|
||||
int next_actualFace = dm->drawObject->triangle_to_mface[0];
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
@@ -747,11 +747,11 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
|
||||
int flush = 0;
|
||||
|
||||
if (i != tottri-1)
|
||||
next_actualFace= dm->drawObject->triangle_to_mface[i+1];
|
||||
if (i != tottri - 1)
|
||||
next_actualFace = dm->drawObject->triangle_to_mface[i + 1];
|
||||
|
||||
if (drawParams) {
|
||||
draw_option = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr);
|
||||
draw_option = drawParams(tf ? &tf[actualFace] : NULL, (mcol != NULL), mf[actualFace].mat_nr);
|
||||
}
|
||||
else {
|
||||
if (index) {
|
||||
@@ -761,8 +761,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
draw_option = drawParamsMapped(userData, orig);
|
||||
}
|
||||
else
|
||||
if (drawParamsMapped)
|
||||
draw_option = drawParamsMapped(userData, actualFace);
|
||||
if (drawParamsMapped)
|
||||
draw_option = drawParamsMapped(userData, actualFace);
|
||||
}
|
||||
|
||||
/* flush buffer if current triangle isn't drawable or it's last triangle */
|
||||
@@ -771,13 +771,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
if (!flush && compareDrawOptions) {
|
||||
/* also compare draw options and flush buffer if they're different
|
||||
* need for face selection highlight in edit mode */
|
||||
flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
|
||||
flush |= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
|
||||
}
|
||||
|
||||
if (flush) {
|
||||
int first = startFace*3;
|
||||
int first = startFace * 3;
|
||||
/* Add one to the length if we're drawing at the end of the array */
|
||||
int count = (i-startFace+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3;
|
||||
int count = (i - startFace + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3;
|
||||
|
||||
if (count) {
|
||||
if (col)
|
||||
@@ -799,24 +799,24 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void cdDM_drawFacesTex(DerivedMesh *dm,
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData);
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, DMDrawFlag flag)
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, DMDrawFlag flag)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *mv = cddm->mvert;
|
||||
MFace *mf = cddm->mface;
|
||||
MCol *mc;
|
||||
float *nors= DM_get_tessface_data_layer(dm, CD_NORMAL);
|
||||
float *nors = DM_get_tessface_data_layer(dm, CD_NORMAL);
|
||||
int useColors = flag & DM_DRAW_USE_COLORS;
|
||||
int i, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
|
||||
|
||||
@@ -836,12 +836,12 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH);
|
||||
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
|
||||
|
||||
orig = (index==NULL) ? i : *index++;
|
||||
orig = (index == NULL) ? i : *index++;
|
||||
|
||||
if (orig == ORIGINDEX_NONE)
|
||||
draw_option= setMaterial(mf->mat_nr + 1, NULL);
|
||||
draw_option = setMaterial(mf->mat_nr + 1, NULL);
|
||||
else if (setDrawOptions != NULL)
|
||||
draw_option= setDrawOptions(userData, orig);
|
||||
draw_option = setDrawOptions(userData, orig);
|
||||
|
||||
if (draw_option != DM_DRAW_OPTION_SKIP) {
|
||||
unsigned char *cp = NULL;
|
||||
@@ -852,7 +852,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
/* no need to set shading mode to flat because
|
||||
* normals are already used to change shading */
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
||||
glBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES);
|
||||
|
||||
if (!drawSmooth) {
|
||||
if (nors) {
|
||||
@@ -907,10 +907,10 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
int prevstart = 0;
|
||||
GPU_vertex_setup(dm);
|
||||
GPU_normal_setup(dm);
|
||||
if ( useColors && mc )
|
||||
if (useColors && mc)
|
||||
GPU_color_setup(dm);
|
||||
if (!GPU_buffer_legacy(dm)) {
|
||||
int tottri = dm->drawObject->tot_triangle_point/3;
|
||||
int tottri = dm->drawObject->tot_triangle_point / 3;
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
if (tottri == 0) {
|
||||
@@ -932,15 +932,15 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
|
||||
int flush = 0;
|
||||
|
||||
if (i != tottri-1)
|
||||
next_actualFace= dm->drawObject->triangle_to_mface[i+1];
|
||||
if (i != tottri - 1)
|
||||
next_actualFace = dm->drawObject->triangle_to_mface[i + 1];
|
||||
|
||||
orig = (index==NULL) ? actualFace : index[actualFace];
|
||||
orig = (index == NULL) ? actualFace : index[actualFace];
|
||||
|
||||
if (orig == ORIGINDEX_NONE)
|
||||
draw_option= setMaterial(mface->mat_nr + 1, NULL);
|
||||
draw_option = setMaterial(mface->mat_nr + 1, NULL);
|
||||
else if (setDrawOptions != NULL)
|
||||
draw_option= setDrawOptions(userData, orig);
|
||||
draw_option = setDrawOptions(userData, orig);
|
||||
|
||||
/* Goal is to draw as long of a contiguous triangle
|
||||
* array as possible, so draw when we hit either an
|
||||
@@ -957,9 +957,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
if (flush) {
|
||||
int first = prevstart*3;
|
||||
int first = prevstart * 3;
|
||||
/* Add one to the length if we're drawing at the end of the array */
|
||||
int count = (i-prevstart+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3;
|
||||
int count = (i - prevstart + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3;
|
||||
|
||||
if (count)
|
||||
glDrawArrays(GL_TRIANGLES, first, count);
|
||||
@@ -976,9 +976,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedFacesTex(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
|
||||
}
|
||||
@@ -1007,15 +1007,15 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
|
||||
|
||||
/* vertex colors */
|
||||
for (b = 0; b < attribs->totmcol; b++) {
|
||||
MCol *cp = &attribs->mcol[b].array[a*4 + vert];
|
||||
MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
|
||||
GLubyte col[4];
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
|
||||
glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col);
|
||||
}
|
||||
|
||||
/* tangent for normal mapping */
|
||||
if (attribs->tottang) {
|
||||
float *tang = attribs->tang.array[a*4 + vert];
|
||||
float *tang = attribs->tang.array[a * 4 + vert];
|
||||
glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
|
||||
}
|
||||
|
||||
@@ -1028,11 +1028,11 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
GPUVertexAttribs gattribs;
|
||||
DMVertexAttribs attribs;
|
||||
MVert *mvert = cddm->mvert;
|
||||
@@ -1049,7 +1049,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
if ( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) {
|
||||
if (GPU_buffer_legacy(dm) || setDrawOptions != NULL) {
|
||||
DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n");
|
||||
memset(&attribs, 0, sizeof(attribs));
|
||||
|
||||
@@ -1073,7 +1073,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
continue;
|
||||
}
|
||||
else if (setDrawOptions) {
|
||||
orig = (index)? index[a]: a;
|
||||
orig = (index) ? index[a] : a;
|
||||
|
||||
if (orig == ORIGINDEX_NONE) {
|
||||
/* since the material is set by setMaterial(), faces with no
|
||||
@@ -1128,7 +1128,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
GPU_normal_setup(dm);
|
||||
|
||||
if (!GPU_buffer_legacy(dm)) {
|
||||
for (i = 0; i < dm->drawObject->tot_triangle_point/3; i++) {
|
||||
for (i = 0; i < dm->drawObject->tot_triangle_point / 3; i++) {
|
||||
|
||||
a = dm->drawObject->triangle_to_mface[i];
|
||||
|
||||
@@ -1148,7 +1148,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
GPU_interleaved_attrib_setup(buffer, datatypes, numdata);
|
||||
}
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, start*3, numfaces*3);
|
||||
glDrawArrays(GL_TRIANGLES, start * 3, numfaces * 3);
|
||||
|
||||
if (numdata != 0) {
|
||||
|
||||
@@ -1215,84 +1215,84 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
}
|
||||
}
|
||||
|
||||
if (dodraw && numdata != 0 ) {
|
||||
if (dodraw && numdata != 0) {
|
||||
offset = 0;
|
||||
if (attribs.totorco) {
|
||||
copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v1]);
|
||||
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v2]);
|
||||
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v3]);
|
||||
offset += sizeof(float)*3;
|
||||
copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]);
|
||||
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]);
|
||||
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]);
|
||||
offset += sizeof(float) * 3;
|
||||
}
|
||||
for (b = 0; b < attribs.tottface; b++) {
|
||||
MTFace *tf = &attribs.tface[b].array[a];
|
||||
copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[0]);
|
||||
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[1]);
|
||||
copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]);
|
||||
copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]);
|
||||
|
||||
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[2]);
|
||||
offset += sizeof(float)*2;
|
||||
copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]);
|
||||
offset += sizeof(float) * 2;
|
||||
}
|
||||
for (b = 0; b < attribs.totmcol; b++) {
|
||||
MCol *cp = &attribs.mcol[b].array[a*4 + 0];
|
||||
MCol *cp = &attribs.mcol[b].array[a * 4 + 0];
|
||||
GLubyte col[4];
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a*4 + 1];
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a*4 + 2];
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col);
|
||||
offset += sizeof(unsigned char)*4;
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a * 4 + 1];
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a * 4 + 2];
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
|
||||
offset += sizeof(unsigned char) * 4;
|
||||
}
|
||||
if (attribs.tottang) {
|
||||
float *tang = attribs.tang.array[a*4 + 0];
|
||||
copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang);
|
||||
tang = attribs.tang.array[a*4 + 1];
|
||||
copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize], tang);
|
||||
tang = attribs.tang.array[a*4 + 2];
|
||||
copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang);
|
||||
offset += sizeof(float)*4;
|
||||
float *tang = attribs.tang.array[a * 4 + 0];
|
||||
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
|
||||
tang = attribs.tang.array[a * 4 + 1];
|
||||
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang);
|
||||
tang = attribs.tang.array[a * 4 + 2];
|
||||
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang);
|
||||
offset += sizeof(float) * 4;
|
||||
}
|
||||
(void)offset;
|
||||
}
|
||||
curface++;
|
||||
if (mface->v4) {
|
||||
if (dodraw && numdata != 0 ) {
|
||||
if (dodraw && numdata != 0) {
|
||||
offset = 0;
|
||||
if (attribs.totorco) {
|
||||
copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v3]);
|
||||
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v4]);
|
||||
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v1]);
|
||||
offset += sizeof(float)*3;
|
||||
copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]);
|
||||
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v4]);
|
||||
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v1]);
|
||||
offset += sizeof(float) * 3;
|
||||
}
|
||||
for (b = 0; b < attribs.tottface; b++) {
|
||||
MTFace *tf = &attribs.tface[b].array[a];
|
||||
copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[2]);
|
||||
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[3]);
|
||||
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[0]);
|
||||
offset += sizeof(float)*2;
|
||||
copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]);
|
||||
copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]);
|
||||
copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]);
|
||||
offset += sizeof(float) * 2;
|
||||
}
|
||||
for (b = 0; b < attribs.totmcol; b++) {
|
||||
MCol *cp = &attribs.mcol[b].array[a*4 + 2];
|
||||
MCol *cp = &attribs.mcol[b].array[a * 4 + 2];
|
||||
GLubyte col[4];
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a*4 + 3];
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a*4 + 0];
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col);
|
||||
offset += sizeof(unsigned char)*4;
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a * 4 + 3];
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col);
|
||||
cp = &attribs.mcol[b].array[a * 4 + 0];
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
|
||||
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
|
||||
offset += sizeof(unsigned char) * 4;
|
||||
}
|
||||
if (attribs.tottang) {
|
||||
float *tang = attribs.tang.array[a*4 + 2];
|
||||
copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang);
|
||||
tang = attribs.tang.array[a*4 + 3];
|
||||
copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize], tang);
|
||||
tang = attribs.tang.array[a*4 + 0];
|
||||
copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang);
|
||||
offset += sizeof(float)*4;
|
||||
float *tang = attribs.tang.array[a * 4 + 2];
|
||||
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
|
||||
tang = attribs.tang.array[a * 4 + 3];
|
||||
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang);
|
||||
tang = attribs.tang.array[a * 4 + 0];
|
||||
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang);
|
||||
offset += sizeof(float) * 4;
|
||||
}
|
||||
(void)offset;
|
||||
}
|
||||
@@ -1307,7 +1307,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
GPU_buffer_unlock(buffer);
|
||||
GPU_interleaved_attrib_setup(buffer, datatypes, numdata);
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, start*3, (curface-start)*3);
|
||||
glDrawArrays(GL_TRIANGLES, start * 3, (curface - start) * 3);
|
||||
}
|
||||
}
|
||||
GPU_buffer_unbind();
|
||||
@@ -1324,10 +1324,10 @@ static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
|
||||
void (*setMaterial)(void *userData, int, void *attribs),
|
||||
int (*setFace)(void *userData, int index), void *userData)
|
||||
void (*setMaterial)(void *userData, int, void *attribs),
|
||||
int (*setFace)(void *userData, int index), void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
GPUVertexAttribs gattribs;
|
||||
DMVertexAttribs attribs;
|
||||
MVert *mvert = cddm->mvert;
|
||||
@@ -1363,7 +1363,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
|
||||
|
||||
/* skipping faces */
|
||||
if (setFace) {
|
||||
orig = (index)? index[a]: a;
|
||||
orig = (index) ? index[a] : a;
|
||||
|
||||
if (orig != ORIGINDEX_NONE && !setFace(userData, orig))
|
||||
continue;
|
||||
@@ -1404,7 +1404,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
|
||||
|
||||
static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *vert = cddm->mvert;
|
||||
MEdge *edge = cddm->medge;
|
||||
int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
||||
@@ -1450,7 +1450,7 @@ static void cdDM_foreachMappedEdge(
|
||||
void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]),
|
||||
void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
|
||||
MVert *mv = cddm->mvert;
|
||||
MEdge *med = cddm->medge;
|
||||
int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
||||
@@ -1471,7 +1471,7 @@ static void cdDM_foreachMappedFaceCenter(
|
||||
void (*func)(void *userData, int index, const float cent[3], const float no[3]),
|
||||
void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
MVert *mv = cddm->mvert;
|
||||
MPoly *mp = cddm->mpoly;
|
||||
MLoop *ml = cddm->mloop;
|
||||
@@ -1492,7 +1492,7 @@ static void cdDM_foreachMappedFaceCenter(
|
||||
|
||||
ml = &cddm->mloop[mp->loopstart];
|
||||
cent[0] = cent[1] = cent[2] = 0.0f;
|
||||
for (j=0; j<mp->totloop; j++, ml++) {
|
||||
for (j = 0; j < mp->totloop; j++, ml++) {
|
||||
add_v3_v3v3(cent, cent, mv[ml->v].co);
|
||||
}
|
||||
mul_v3_fl(cent, 1.0f / (float)j);
|
||||
@@ -1519,7 +1519,7 @@ static void cdDM_foreachMappedFaceCenter(
|
||||
|
||||
void CDDM_recalc_tessellation_ex(DerivedMesh *dm, const int do_face_nor_cpy)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
dm->numTessFaceData = BKE_mesh_recalc_tessellation(&dm->faceData, &dm->loopData, &dm->polyData,
|
||||
cddm->mvert,
|
||||
@@ -1551,7 +1551,7 @@ static void cdDM_free_internal(CDDerivedMesh *cddm)
|
||||
|
||||
static void cdDM_release(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
if (DM_release(dm)) {
|
||||
cdDM_free_internal(cddm);
|
||||
@@ -1671,18 +1671,18 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
|
||||
/* this does a referenced copy, with an exception for fluidsim */
|
||||
|
||||
DM_init(dm, DM_TYPE_CDDM, mesh->totvert, mesh->totedge, mesh->totface,
|
||||
mesh->totloop, mesh->totpoly);
|
||||
mesh->totloop, mesh->totpoly);
|
||||
|
||||
dm->deformedOnly = 1;
|
||||
|
||||
alloctype= CD_REFERENCE;
|
||||
alloctype = CD_REFERENCE;
|
||||
|
||||
CustomData_merge(&mesh->vdata, &dm->vertData, mask, alloctype,
|
||||
mesh->totvert);
|
||||
mesh->totvert);
|
||||
CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype,
|
||||
mesh->totedge);
|
||||
CustomData_merge(&mesh->fdata, &dm->faceData, mask|CD_MASK_POLYINDEX, alloctype,
|
||||
mesh->totface);
|
||||
mesh->totedge);
|
||||
CustomData_merge(&mesh->fdata, &dm->faceData, mask | CD_MASK_POLYINDEX, alloctype,
|
||||
mesh->totface);
|
||||
CustomData_merge(&mesh->ldata, &dm->loopData, mask, alloctype,
|
||||
mesh->totloop);
|
||||
CustomData_merge(&mesh->pdata, &dm->polyData, mask, alloctype,
|
||||
@@ -1733,12 +1733,12 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase)
|
||||
dm = CDDM_new(totvert, totedge, 0, totloop, totpoly);
|
||||
dm->deformedOnly = 1;
|
||||
|
||||
cddm = (CDDerivedMesh*)dm;
|
||||
cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
memcpy(cddm->mvert, allvert, totvert*sizeof(MVert));
|
||||
memcpy(cddm->medge, alledge, totedge*sizeof(MEdge));
|
||||
memcpy(cddm->mloop, allloop, totloop*sizeof(MLoop));
|
||||
memcpy(cddm->mpoly, allpoly, totpoly*sizeof(MPoly));
|
||||
memcpy(cddm->mvert, allvert, totvert * sizeof(MVert));
|
||||
memcpy(cddm->medge, alledge, totedge * sizeof(MEdge));
|
||||
memcpy(cddm->mloop, allloop, totloop * sizeof(MLoop));
|
||||
memcpy(cddm->mpoly, allpoly, totpoly * sizeof(MPoly));
|
||||
|
||||
MEM_freeN(allvert);
|
||||
MEM_freeN(alledge);
|
||||
@@ -1751,8 +1751,8 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase)
|
||||
}
|
||||
|
||||
static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
|
||||
int cdindex, BMLoop *l3[3],
|
||||
int numCol, int numTex)
|
||||
int cdindex, BMLoop *l3[3],
|
||||
int numCol, int numTex)
|
||||
{
|
||||
BMLoop *l;
|
||||
BMFace *f = l3[0]->f;
|
||||
@@ -1769,7 +1769,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
|
||||
|
||||
ME_MTEXFACE_CPY(texface, texpoly);
|
||||
|
||||
for (j = 0 ; j < 3; j++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
l = l3[j];
|
||||
mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
|
||||
copy_v2_v2(texface->uv[j], mloopuv->uv);
|
||||
@@ -1807,7 +1807,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
|
||||
bm->totloop,
|
||||
bm->totface);
|
||||
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
BMIter iter, liter;
|
||||
BMVert *eve;
|
||||
BMEdge *eed;
|
||||
@@ -1833,7 +1833,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
|
||||
/*don't add origindex layer if one already exists*/
|
||||
add_orig = !CustomData_has_layer(&bm->pdata, CD_ORIGINDEX);
|
||||
|
||||
mask = use_mdisps ? CD_MASK_DERIVEDMESH|CD_MASK_MDISPS : CD_MASK_DERIVEDMESH;
|
||||
mask = use_mdisps ? CD_MASK_DERIVEDMESH | CD_MASK_MDISPS : CD_MASK_DERIVEDMESH;
|
||||
|
||||
/* don't process shapekeys, we only feed them through the modifier stack as needed,
|
||||
* e.g. for applying modifiers or the like*/
|
||||
@@ -1867,7 +1867,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
|
||||
mv->flag = BM_vert_flag_to_mflag(eve);
|
||||
|
||||
if (has_vert_bweight)
|
||||
mv->bweight = (unsigned char)(BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT)*255.0f);
|
||||
mv->bweight = (unsigned char)(BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT) * 255.0f);
|
||||
|
||||
if (add_orig) *index = i;
|
||||
|
||||
@@ -1886,9 +1886,9 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
|
||||
med->v2 = BM_elem_index_get(eed->v2);
|
||||
|
||||
if (has_crease)
|
||||
med->crease = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_CREASE)*255.0f);
|
||||
med->crease = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_CREASE) * 255.0f);
|
||||
if (has_edge_bweight)
|
||||
med->bweight = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT)*255.0f);
|
||||
med->bweight = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT) * 255.0f);
|
||||
|
||||
med->flag = BM_edge_flag_to_mflag(eed);
|
||||
|
||||
@@ -1917,7 +1917,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
|
||||
mf->mat_nr = efa->mat_nr;
|
||||
mf->flag = BM_face_flag_to_mflag(efa);
|
||||
|
||||
*index = add_orig ? BM_elem_index_get(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
|
||||
*index = add_orig ? BM_elem_index_get(efa) : *(int *)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
|
||||
*polyindex = BM_elem_index_get(efa);
|
||||
|
||||
loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex);
|
||||
@@ -1974,7 +1974,7 @@ static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces)
|
||||
|
||||
/* this initializes dm, and copies all non mvert/medge/mface layers */
|
||||
DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces,
|
||||
numLoops, numPolys);
|
||||
numLoops, numPolys);
|
||||
dm->deformedOnly = source->deformedOnly;
|
||||
dm->dirty = source->dirty;
|
||||
|
||||
@@ -2056,7 +2056,7 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source,
|
||||
|
||||
void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
MVert *vert;
|
||||
int i;
|
||||
|
||||
@@ -2070,7 +2070,7 @@ void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
|
||||
|
||||
void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3])
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
MVert *vert;
|
||||
int i;
|
||||
|
||||
@@ -2084,7 +2084,7 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3])
|
||||
|
||||
void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
float (*face_nors)[3] = NULL;
|
||||
|
||||
if (dm->numVertData == 0) return;
|
||||
@@ -2114,7 +2114,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals
|
||||
}
|
||||
|
||||
|
||||
face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, "face_nors");
|
||||
face_nors = MEM_mallocN(sizeof(float) * 3 * dm->numTessFaceData, "face_nors");
|
||||
|
||||
/* calculate face normals */
|
||||
BKE_mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
|
||||
@@ -2123,7 +2123,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals
|
||||
only_face_normals);
|
||||
|
||||
CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN,
|
||||
face_nors, dm->numTessFaceData);
|
||||
face_nors, dm->numTessFaceData);
|
||||
}
|
||||
|
||||
|
||||
@@ -2138,7 +2138,7 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm)
|
||||
/* bmesh note: this matches what we have in trunk */
|
||||
void CDDM_calc_normals(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
float (*poly_nors)[3];
|
||||
|
||||
if (dm->numVertData == 0) return;
|
||||
@@ -2158,7 +2158,7 @@ void CDDM_calc_normals(DerivedMesh *dm)
|
||||
|
||||
void CDDM_calc_normals_tessface(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
float (*face_nors)[3];
|
||||
|
||||
if (dm->numVertData == 0) return;
|
||||
@@ -2190,7 +2190,7 @@ void CDDM_calc_normals_tessface(DerivedMesh *dm)
|
||||
*/
|
||||
DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
CDDerivedMesh *cddm2 = NULL;
|
||||
MVert *mv, *mvert = NULL;
|
||||
BLI_array_declare(mvert);
|
||||
@@ -2209,9 +2209,9 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
|
||||
totloop = dm->numLoopData;
|
||||
totpoly = dm->numPolyData;
|
||||
|
||||
newv = MEM_callocN(sizeof(int)*dm->numVertData, "newv vtable CDDM_merge_verts");
|
||||
newe = MEM_callocN(sizeof(int)*dm->numEdgeData, "newv etable CDDM_merge_verts");
|
||||
newl = MEM_callocN(sizeof(int)*totloop, "newv ltable CDDM_merge_verts");
|
||||
newv = MEM_callocN(sizeof(int) * dm->numVertData, "newv vtable CDDM_merge_verts");
|
||||
newe = MEM_callocN(sizeof(int) * dm->numEdgeData, "newv etable CDDM_merge_verts");
|
||||
newl = MEM_callocN(sizeof(int) * totloop, "newv ltable CDDM_merge_verts");
|
||||
|
||||
/*fill newl with destination vertex indices*/
|
||||
mv = cddm->mvert;
|
||||
@@ -2247,7 +2247,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
|
||||
if (LIKELY(med->v1 != med->v2)) {
|
||||
const unsigned int v1 = (vtargetmap[med->v1] != -1) ? vtargetmap[med->v1] : med->v1;
|
||||
const unsigned int v2 = (vtargetmap[med->v2] != -1) ? vtargetmap[med->v2] : med->v2;
|
||||
void **eh_p= BLI_edgehash_lookup_p(ehash, v1, v2);
|
||||
void **eh_p = BLI_edgehash_lookup_p(ehash, v1, v2);
|
||||
|
||||
if (eh_p) {
|
||||
newe[i] = GET_INT_FROM_POINTER(*eh_p);
|
||||
@@ -2275,8 +2275,8 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
|
||||
for (j = 0; j < mp->totloop; j++, ml++) {
|
||||
med = cddm->medge + ml->e;
|
||||
if (LIKELY(med->v1 != med->v2)) {
|
||||
newl[j+mp->loopstart] = BLI_array_count(mloop);
|
||||
BLI_array_append(oldl, j+mp->loopstart);
|
||||
newl[j + mp->loopstart] = BLI_array_count(mloop);
|
||||
BLI_array_append(oldl, j + mp->loopstart);
|
||||
BLI_array_append(mloop, *ml);
|
||||
c++;
|
||||
}
|
||||
@@ -2294,7 +2294,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
|
||||
}
|
||||
|
||||
/*create new cddm*/
|
||||
cddm2 = (CDDerivedMesh*) CDDM_from_template((DerivedMesh*)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly));
|
||||
cddm2 = (CDDerivedMesh *) CDDM_from_template((DerivedMesh *)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly));
|
||||
|
||||
/*update edge indices and copy customdata*/
|
||||
med = medge;
|
||||
@@ -2331,10 +2331,10 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
|
||||
}
|
||||
|
||||
/*copy over data. CustomData_add_layer can do this, need to look it up.*/
|
||||
memcpy(cddm2->mvert, mvert, sizeof(MVert)*BLI_array_count(mvert));
|
||||
memcpy(cddm2->medge, medge, sizeof(MEdge)*BLI_array_count(medge));
|
||||
memcpy(cddm2->mloop, mloop, sizeof(MLoop)*BLI_array_count(mloop));
|
||||
memcpy(cddm2->mpoly, mpoly, sizeof(MPoly)*BLI_array_count(mpoly));
|
||||
memcpy(cddm2->mvert, mvert, sizeof(MVert) * BLI_array_count(mvert));
|
||||
memcpy(cddm2->medge, medge, sizeof(MEdge) * BLI_array_count(medge));
|
||||
memcpy(cddm2->mloop, mloop, sizeof(MLoop) * BLI_array_count(mloop));
|
||||
memcpy(cddm2->mpoly, mpoly, sizeof(MPoly) * BLI_array_count(mpoly));
|
||||
BLI_array_free(mvert); BLI_array_free(medge); BLI_array_free(mloop); BLI_array_free(mpoly);
|
||||
|
||||
if (newv)
|
||||
@@ -2358,13 +2358,13 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
|
||||
dm->needsFree = 1;
|
||||
dm->release(dm);
|
||||
|
||||
return (DerivedMesh*)cddm2;
|
||||
return (DerivedMesh *)cddm2;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CDDM_calc_edges_tessface(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
CustomData edgeData;
|
||||
EdgeHashIterator *ehi;
|
||||
MFace *mf = cddm->mface;
|
||||
@@ -2401,10 +2401,10 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
|
||||
med = CustomData_get_layer(&edgeData, CD_MEDGE);
|
||||
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
|
||||
for (i = 0; !BLI_edgehashIterator_isDone(ehi);
|
||||
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
|
||||
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
|
||||
BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
|
||||
|
||||
med->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
||||
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
|
||||
*index = ORIGINDEX_NONE;
|
||||
}
|
||||
BLI_edgehashIterator_free(ehi);
|
||||
@@ -2422,7 +2422,7 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
|
||||
/* warning, this uses existing edges but CDDM_calc_edges_tessface() doesn't */
|
||||
void CDDM_calc_edges(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
CustomData edgeData;
|
||||
EdgeHashIterator *ehi;
|
||||
MPoly *mp = cddm->mpoly;
|
||||
@@ -2438,7 +2438,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
|
||||
med = cddm->medge;
|
||||
if (med) {
|
||||
for (i = 0; i < numEdges; i++, med++) {
|
||||
BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i+1));
|
||||
BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2464,12 +2464,12 @@ void CDDM_calc_edges(DerivedMesh *dm)
|
||||
med = CustomData_get_layer(&edgeData, CD_MEDGE);
|
||||
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
|
||||
for (i = 0; !BLI_edgehashIterator_isDone(ehi);
|
||||
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
|
||||
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
|
||||
BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
|
||||
j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
|
||||
|
||||
med->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
||||
*index = j==0 ? ORIGINDEX_NONE : eindex[j-1];
|
||||
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
|
||||
*index = j == 0 ? ORIGINDEX_NONE : eindex[j - 1];
|
||||
|
||||
BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i));
|
||||
}
|
||||
@@ -2498,7 +2498,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
|
||||
void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts)
|
||||
{
|
||||
if (numVerts < dm->numVertData)
|
||||
CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData-numVerts);
|
||||
CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData - numVerts);
|
||||
|
||||
dm->numVertData = numVerts;
|
||||
}
|
||||
@@ -2506,7 +2506,7 @@ void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts)
|
||||
void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges)
|
||||
{
|
||||
if (numEdges < dm->numEdgeData)
|
||||
CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData-numEdges);
|
||||
CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData - numEdges);
|
||||
|
||||
dm->numEdgeData = numEdges;
|
||||
}
|
||||
@@ -2514,7 +2514,7 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges)
|
||||
void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces)
|
||||
{
|
||||
if (numTessFaces < dm->numTessFaceData)
|
||||
CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData-numTessFaces);
|
||||
CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData - numTessFaces);
|
||||
|
||||
dm->numTessFaceData = numTessFaces;
|
||||
}
|
||||
@@ -2522,7 +2522,7 @@ void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces)
|
||||
void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys)
|
||||
{
|
||||
if (numPolys < dm->numPolyData)
|
||||
CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData-numPolys);
|
||||
CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData - numPolys);
|
||||
|
||||
dm->numPolyData = numPolys;
|
||||
}
|
||||
@@ -2531,60 +2531,60 @@ void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys)
|
||||
|
||||
MVert *CDDM_get_vert(DerivedMesh *dm, int index)
|
||||
{
|
||||
return &((CDDerivedMesh*)dm)->mvert[index];
|
||||
return &((CDDerivedMesh *)dm)->mvert[index];
|
||||
}
|
||||
|
||||
MEdge *CDDM_get_edge(DerivedMesh *dm, int index)
|
||||
{
|
||||
return &((CDDerivedMesh*)dm)->medge[index];
|
||||
return &((CDDerivedMesh *)dm)->medge[index];
|
||||
}
|
||||
|
||||
MFace *CDDM_get_tessface(DerivedMesh *dm, int index)
|
||||
{
|
||||
return &((CDDerivedMesh*)dm)->mface[index];
|
||||
return &((CDDerivedMesh *)dm)->mface[index];
|
||||
}
|
||||
|
||||
MLoop *CDDM_get_loop(DerivedMesh *dm, int index)
|
||||
{
|
||||
return &((CDDerivedMesh*)dm)->mloop[index];
|
||||
return &((CDDerivedMesh *)dm)->mloop[index];
|
||||
}
|
||||
|
||||
MPoly *CDDM_get_poly(DerivedMesh *dm, int index)
|
||||
{
|
||||
return &((CDDerivedMesh*)dm)->mpoly[index];
|
||||
return &((CDDerivedMesh *)dm)->mpoly[index];
|
||||
}
|
||||
|
||||
/* array access functions */
|
||||
|
||||
MVert *CDDM_get_verts(DerivedMesh *dm)
|
||||
{
|
||||
return ((CDDerivedMesh*)dm)->mvert;
|
||||
return ((CDDerivedMesh *)dm)->mvert;
|
||||
}
|
||||
|
||||
MEdge *CDDM_get_edges(DerivedMesh *dm)
|
||||
{
|
||||
return ((CDDerivedMesh*)dm)->medge;
|
||||
return ((CDDerivedMesh *)dm)->medge;
|
||||
}
|
||||
|
||||
MFace *CDDM_get_tessfaces(DerivedMesh *dm)
|
||||
{
|
||||
return ((CDDerivedMesh*)dm)->mface;
|
||||
return ((CDDerivedMesh *)dm)->mface;
|
||||
}
|
||||
|
||||
MLoop *CDDM_get_loops(DerivedMesh *dm)
|
||||
{
|
||||
return ((CDDerivedMesh*)dm)->mloop;
|
||||
return ((CDDerivedMesh *)dm)->mloop;
|
||||
}
|
||||
|
||||
MPoly *CDDM_get_polys(DerivedMesh *dm)
|
||||
{
|
||||
return ((CDDerivedMesh*)dm)->mpoly;
|
||||
return ((CDDerivedMesh *)dm)->mpoly;
|
||||
}
|
||||
|
||||
void CDDM_tessfaces_to_faces(DerivedMesh *dm)
|
||||
{
|
||||
/*converts mfaces to mpolys/mloops*/
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
MFace *mf;
|
||||
MEdge *me;
|
||||
EdgeHash *eh = BLI_edgehash_new();
|
||||
@@ -2628,13 +2628,13 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm)
|
||||
MPoly *mp;
|
||||
int l, *polyindex;
|
||||
|
||||
cddm->mloop = MEM_callocN(sizeof(MLoop)*totloop, "cddm->mloop in CDDM_tessfaces_to_faces");
|
||||
cddm->mpoly = MEM_callocN(sizeof(MPoly)*cddm->dm.numTessFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces");
|
||||
cddm->mloop = MEM_callocN(sizeof(MLoop) * totloop, "cddm->mloop in CDDM_tessfaces_to_faces");
|
||||
cddm->mpoly = MEM_callocN(sizeof(MPoly) * cddm->dm.numTessFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces");
|
||||
|
||||
CustomData_add_layer(&cddm->dm.loopData, CD_MLOOP, CD_ASSIGN, cddm->mloop, totloop);
|
||||
CustomData_add_layer(&cddm->dm.polyData, CD_MPOLY, CD_ASSIGN, cddm->mpoly, cddm->dm.numPolyData);
|
||||
CustomData_merge(&cddm->dm.faceData, &cddm->dm.polyData,
|
||||
CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numTessFaceData);
|
||||
CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numTessFaceData);
|
||||
|
||||
polyindex = CustomData_get_layer(&cddm->dm.faceData, CD_POLYINDEX);
|
||||
|
||||
@@ -2657,12 +2657,12 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm)
|
||||
ml++, l++;
|
||||
|
||||
ml->v = mf->v3;
|
||||
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v3, mf->v4?mf->v4:mf->v1));
|
||||
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v3, mf->v4 ? mf->v4 : mf->v1));
|
||||
ml++, l++;
|
||||
|
||||
if (mf->v4) {
|
||||
ml->v = mf->v4;
|
||||
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v4, mf->v1));
|
||||
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v4, mf->v1));
|
||||
ml++, l++;
|
||||
}
|
||||
|
||||
@@ -2675,7 +2675,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm)
|
||||
|
||||
void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
if (!CustomData_has_layer(&dm->vertData, CD_MVERT))
|
||||
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, mvert, dm->numVertData);
|
||||
@@ -2685,7 +2685,7 @@ void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert)
|
||||
|
||||
void CDDM_set_medge(DerivedMesh *dm, MEdge *medge)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
if (!CustomData_has_layer(&dm->edgeData, CD_MEDGE))
|
||||
CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, medge, dm->numEdgeData);
|
||||
@@ -2695,7 +2695,7 @@ void CDDM_set_medge(DerivedMesh *dm, MEdge *medge)
|
||||
|
||||
void CDDM_set_mface(DerivedMesh *dm, MFace *mface)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
if (!CustomData_has_layer(&dm->faceData, CD_MFACE))
|
||||
CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, mface, dm->numTessFaceData);
|
||||
@@ -2705,7 +2705,7 @@ void CDDM_set_mface(DerivedMesh *dm, MFace *mface)
|
||||
|
||||
void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
if (!CustomData_has_layer(&dm->loopData, CD_MLOOP))
|
||||
CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_ASSIGN, mloop, dm->numLoopData);
|
||||
@@ -2715,7 +2715,7 @@ void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop)
|
||||
|
||||
void CDDM_set_mpoly(DerivedMesh *dm, MPoly *mpoly)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
|
||||
|
||||
if (!CustomData_has_layer(&dm->polyData, CD_MPOLY))
|
||||
CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_ASSIGN, mpoly, dm->numPolyData);
|
||||
|
||||
@@ -62,9 +62,9 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa
|
||||
int a;
|
||||
float clipminx, clipminy, clipmaxx, clipmaxy;
|
||||
|
||||
cumap= MEM_callocN(sizeof(CurveMapping), "new curvemap");
|
||||
cumap->flag= CUMA_DO_CLIP;
|
||||
if (tot==4) cumap->cur= 3; /* rhms, hack for 'col' curve? */
|
||||
cumap = MEM_callocN(sizeof(CurveMapping), "new curvemap");
|
||||
cumap->flag = CUMA_DO_CLIP;
|
||||
if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */
|
||||
|
||||
clipminx = MIN2(minx, maxx);
|
||||
clipminy = MIN2(miny, maxy);
|
||||
@@ -72,20 +72,20 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa
|
||||
clipmaxy = MAX2(miny, maxy);
|
||||
|
||||
BLI_init_rctf(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy);
|
||||
cumap->clipr= cumap->curr;
|
||||
cumap->clipr = cumap->curr;
|
||||
|
||||
cumap->white[0]= cumap->white[1]= cumap->white[2]= 1.0f;
|
||||
cumap->bwmul[0]= cumap->bwmul[1]= cumap->bwmul[2]= 1.0f;
|
||||
cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
|
||||
cumap->bwmul[0] = cumap->bwmul[1] = cumap->bwmul[2] = 1.0f;
|
||||
|
||||
for (a=0; a<tot; a++) {
|
||||
cumap->cm[a].flag= CUMA_EXTEND_EXTRAPOLATE;
|
||||
cumap->cm[a].totpoint= 2;
|
||||
cumap->cm[a].curve= MEM_callocN(2*sizeof(CurveMapPoint), "curve points");
|
||||
|
||||
cumap->cm[a].curve[0].x= minx;
|
||||
cumap->cm[a].curve[0].y= miny;
|
||||
cumap->cm[a].curve[1].x= maxx;
|
||||
cumap->cm[a].curve[1].y= maxy;
|
||||
for (a = 0; a < tot; a++) {
|
||||
cumap->cm[a].flag = CUMA_EXTEND_EXTRAPOLATE;
|
||||
cumap->cm[a].totpoint = 2;
|
||||
cumap->cm[a].curve = MEM_callocN(2 * sizeof(CurveMapPoint), "curve points");
|
||||
|
||||
cumap->cm[a].curve[0].x = minx;
|
||||
cumap->cm[a].curve[0].y = miny;
|
||||
cumap->cm[a].curve[1].x = maxx;
|
||||
cumap->cm[a].curve[1].y = maxy;
|
||||
}
|
||||
|
||||
cumap->changed_timestamp = 0;
|
||||
@@ -98,7 +98,7 @@ void curvemapping_free(CurveMapping *cumap)
|
||||
int a;
|
||||
|
||||
if (cumap) {
|
||||
for (a=0; a<CM_TOT; a++) {
|
||||
for (a = 0; a < CM_TOT; a++) {
|
||||
if (cumap->cm[a].curve) MEM_freeN(cumap->cm[a].curve);
|
||||
if (cumap->cm[a].table) MEM_freeN(cumap->cm[a].table);
|
||||
if (cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable);
|
||||
@@ -112,14 +112,14 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap)
|
||||
int a;
|
||||
|
||||
if (cumap) {
|
||||
CurveMapping *cumapn= MEM_dupallocN(cumap);
|
||||
for (a=0; a<CM_TOT; a++) {
|
||||
CurveMapping *cumapn = MEM_dupallocN(cumap);
|
||||
for (a = 0; a < CM_TOT; a++) {
|
||||
if (cumap->cm[a].curve)
|
||||
cumapn->cm[a].curve= MEM_dupallocN(cumap->cm[a].curve);
|
||||
cumapn->cm[a].curve = MEM_dupallocN(cumap->cm[a].curve);
|
||||
if (cumap->cm[a].table)
|
||||
cumapn->cm[a].table= MEM_dupallocN(cumap->cm[a].table);
|
||||
cumapn->cm[a].table = MEM_dupallocN(cumap->cm[a].table);
|
||||
if (cumap->cm[a].premultable)
|
||||
cumapn->cm[a].premultable= MEM_dupallocN(cumap->cm[a].premultable);
|
||||
cumapn->cm[a].premultable = MEM_dupallocN(cumap->cm[a].premultable);
|
||||
}
|
||||
return cumapn;
|
||||
}
|
||||
@@ -135,11 +135,11 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con
|
||||
if (black)
|
||||
copy_v3_v3(cumap->black, black);
|
||||
|
||||
for (a=0; a<3; a++) {
|
||||
if (cumap->white[a]==cumap->black[a])
|
||||
cumap->bwmul[a]= 0.0f;
|
||||
for (a = 0; a < 3; a++) {
|
||||
if (cumap->white[a] == cumap->black[a])
|
||||
cumap->bwmul[a] = 0.0f;
|
||||
else
|
||||
cumap->bwmul[a]= 1.0f/(cumap->white[a] - cumap->black[a]);
|
||||
cumap->bwmul[a] = 1.0f / (cumap->white[a] - cumap->black[a]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,52 +149,52 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con
|
||||
/* removes with flag set */
|
||||
void curvemap_remove(CurveMap *cuma, int flag)
|
||||
{
|
||||
CurveMapPoint *cmp= MEM_mallocN((cuma->totpoint)*sizeof(CurveMapPoint), "curve points");
|
||||
int a, b, removed=0;
|
||||
CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points");
|
||||
int a, b, removed = 0;
|
||||
|
||||
/* well, lets keep the two outer points! */
|
||||
cmp[0]= cuma->curve[0];
|
||||
for (a=1, b=1; a<cuma->totpoint-1; a++) {
|
||||
cmp[0] = cuma->curve[0];
|
||||
for (a = 1, b = 1; a < cuma->totpoint - 1; a++) {
|
||||
if (!(cuma->curve[a].flag & flag)) {
|
||||
cmp[b]= cuma->curve[a];
|
||||
cmp[b] = cuma->curve[a];
|
||||
b++;
|
||||
}
|
||||
else removed++;
|
||||
}
|
||||
cmp[b]= cuma->curve[a];
|
||||
cmp[b] = cuma->curve[a];
|
||||
|
||||
MEM_freeN(cuma->curve);
|
||||
cuma->curve= cmp;
|
||||
cuma->curve = cmp;
|
||||
cuma->totpoint -= removed;
|
||||
}
|
||||
|
||||
void curvemap_insert(CurveMap *cuma, float x, float y)
|
||||
{
|
||||
CurveMapPoint *cmp= MEM_callocN((cuma->totpoint+1)*sizeof(CurveMapPoint), "curve points");
|
||||
int a, b, foundloc= 0;
|
||||
CurveMapPoint *cmp = MEM_callocN((cuma->totpoint + 1) * sizeof(CurveMapPoint), "curve points");
|
||||
int a, b, foundloc = 0;
|
||||
|
||||
/* insert fragments of the old one and the new point to the new curve */
|
||||
cuma->totpoint++;
|
||||
for (a=0, b=0; a<cuma->totpoint; a++) {
|
||||
for (a = 0, b = 0; a < cuma->totpoint; a++) {
|
||||
if ((x < cuma->curve[a].x) && !foundloc) {
|
||||
cmp[a].x= x;
|
||||
cmp[a].y= y;
|
||||
cmp[a].flag= CUMA_SELECT;
|
||||
foundloc= 1;
|
||||
cmp[a].x = x;
|
||||
cmp[a].y = y;
|
||||
cmp[a].flag = CUMA_SELECT;
|
||||
foundloc = 1;
|
||||
}
|
||||
else {
|
||||
cmp[a].x= cuma->curve[b].x;
|
||||
cmp[a].y= cuma->curve[b].y;
|
||||
cmp[a].flag= cuma->curve[b].flag;
|
||||
cmp[a].x = cuma->curve[b].x;
|
||||
cmp[a].y = cuma->curve[b].y;
|
||||
cmp[a].flag = cuma->curve[b].flag;
|
||||
cmp[a].flag &= ~CUMA_SELECT; /* make sure old points don't remain selected */
|
||||
cmp[a].shorty= cuma->curve[b].shorty;
|
||||
cmp[a].shorty = cuma->curve[b].shorty;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
|
||||
/* free old curve and replace it with new one */
|
||||
MEM_freeN(cuma->curve);
|
||||
cuma->curve= cmp;
|
||||
cuma->curve = cmp;
|
||||
}
|
||||
|
||||
void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
|
||||
@@ -203,91 +203,91 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
|
||||
MEM_freeN(cuma->curve);
|
||||
|
||||
switch (preset) {
|
||||
case CURVE_PRESET_LINE: cuma->totpoint= 2; break;
|
||||
case CURVE_PRESET_SHARP: cuma->totpoint= 4; break;
|
||||
case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break;
|
||||
case CURVE_PRESET_MAX: cuma->totpoint= 2; break;
|
||||
case CURVE_PRESET_MID9: cuma->totpoint= 9; break;
|
||||
case CURVE_PRESET_ROUND: cuma->totpoint= 4; break;
|
||||
case CURVE_PRESET_ROOT: cuma->totpoint= 4; break;
|
||||
case CURVE_PRESET_LINE: cuma->totpoint = 2; break;
|
||||
case CURVE_PRESET_SHARP: cuma->totpoint = 4; break;
|
||||
case CURVE_PRESET_SMOOTH: cuma->totpoint = 4; break;
|
||||
case CURVE_PRESET_MAX: cuma->totpoint = 2; break;
|
||||
case CURVE_PRESET_MID9: cuma->totpoint = 9; break;
|
||||
case CURVE_PRESET_ROUND: cuma->totpoint = 4; break;
|
||||
case CURVE_PRESET_ROOT: cuma->totpoint = 4; break;
|
||||
}
|
||||
|
||||
cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
|
||||
cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), "curve points");
|
||||
|
||||
switch (preset) {
|
||||
case CURVE_PRESET_LINE:
|
||||
cuma->curve[0].x= clipr->xmin;
|
||||
cuma->curve[0].y= clipr->ymax;
|
||||
cuma->curve[0].flag= 0;
|
||||
cuma->curve[1].x= clipr->xmax;
|
||||
cuma->curve[1].y= clipr->ymin;
|
||||
cuma->curve[1].flag= 0;
|
||||
cuma->curve[0].x = clipr->xmin;
|
||||
cuma->curve[0].y = clipr->ymax;
|
||||
cuma->curve[0].flag = 0;
|
||||
cuma->curve[1].x = clipr->xmax;
|
||||
cuma->curve[1].y = clipr->ymin;
|
||||
cuma->curve[1].flag = 0;
|
||||
break;
|
||||
case CURVE_PRESET_SHARP:
|
||||
cuma->curve[0].x= 0;
|
||||
cuma->curve[0].y= 1;
|
||||
cuma->curve[1].x= 0.25;
|
||||
cuma->curve[1].y= 0.50;
|
||||
cuma->curve[2].x= 0.75;
|
||||
cuma->curve[2].y= 0.04;
|
||||
cuma->curve[3].x= 1;
|
||||
cuma->curve[3].y= 0;
|
||||
cuma->curve[0].x = 0;
|
||||
cuma->curve[0].y = 1;
|
||||
cuma->curve[1].x = 0.25;
|
||||
cuma->curve[1].y = 0.50;
|
||||
cuma->curve[2].x = 0.75;
|
||||
cuma->curve[2].y = 0.04;
|
||||
cuma->curve[3].x = 1;
|
||||
cuma->curve[3].y = 0;
|
||||
break;
|
||||
case CURVE_PRESET_SMOOTH:
|
||||
cuma->curve[0].x= 0;
|
||||
cuma->curve[0].y= 1;
|
||||
cuma->curve[1].x= 0.25;
|
||||
cuma->curve[1].y= 0.94;
|
||||
cuma->curve[2].x= 0.75;
|
||||
cuma->curve[2].y= 0.06;
|
||||
cuma->curve[3].x= 1;
|
||||
cuma->curve[3].y= 0;
|
||||
cuma->curve[0].x = 0;
|
||||
cuma->curve[0].y = 1;
|
||||
cuma->curve[1].x = 0.25;
|
||||
cuma->curve[1].y = 0.94;
|
||||
cuma->curve[2].x = 0.75;
|
||||
cuma->curve[2].y = 0.06;
|
||||
cuma->curve[3].x = 1;
|
||||
cuma->curve[3].y = 0;
|
||||
break;
|
||||
case CURVE_PRESET_MAX:
|
||||
cuma->curve[0].x= 0;
|
||||
cuma->curve[0].y= 1;
|
||||
cuma->curve[1].x= 1;
|
||||
cuma->curve[1].y= 1;
|
||||
cuma->curve[0].x = 0;
|
||||
cuma->curve[0].y = 1;
|
||||
cuma->curve[1].x = 1;
|
||||
cuma->curve[1].y = 1;
|
||||
break;
|
||||
case CURVE_PRESET_MID9:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < cuma->totpoint; i++) {
|
||||
cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
|
||||
cuma->curve[i].y = 0.5;
|
||||
}
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < cuma->totpoint; i++) {
|
||||
cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
|
||||
cuma->curve[i].y = 0.5;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CURVE_PRESET_ROUND:
|
||||
cuma->curve[0].x= 0;
|
||||
cuma->curve[0].y= 1;
|
||||
cuma->curve[1].x= 0.5;
|
||||
cuma->curve[1].y= 0.90;
|
||||
cuma->curve[2].x= 0.86;
|
||||
cuma->curve[2].y= 0.5;
|
||||
cuma->curve[3].x= 1;
|
||||
cuma->curve[3].y= 0;
|
||||
cuma->curve[0].x = 0;
|
||||
cuma->curve[0].y = 1;
|
||||
cuma->curve[1].x = 0.5;
|
||||
cuma->curve[1].y = 0.90;
|
||||
cuma->curve[2].x = 0.86;
|
||||
cuma->curve[2].y = 0.5;
|
||||
cuma->curve[3].x = 1;
|
||||
cuma->curve[3].y = 0;
|
||||
break;
|
||||
case CURVE_PRESET_ROOT:
|
||||
cuma->curve[0].x= 0;
|
||||
cuma->curve[0].y= 1;
|
||||
cuma->curve[1].x= 0.25;
|
||||
cuma->curve[1].y= 0.95;
|
||||
cuma->curve[2].x= 0.75;
|
||||
cuma->curve[2].y= 0.44;
|
||||
cuma->curve[3].x= 1;
|
||||
cuma->curve[3].y= 0;
|
||||
cuma->curve[0].x = 0;
|
||||
cuma->curve[0].y = 1;
|
||||
cuma->curve[1].x = 0.25;
|
||||
cuma->curve[1].y = 0.95;
|
||||
cuma->curve[2].x = 0.75;
|
||||
cuma->curve[2].y = 0.44;
|
||||
cuma->curve[3].x = 1;
|
||||
cuma->curve[3].y = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* mirror curve in x direction to have positive slope
|
||||
* rather than default negative slope */
|
||||
if (slope == CURVEMAP_SLOPE_POSITIVE) {
|
||||
int i, last=cuma->totpoint-1;
|
||||
CurveMapPoint *newpoints= MEM_dupallocN(cuma->curve);
|
||||
int i, last = cuma->totpoint - 1;
|
||||
CurveMapPoint *newpoints = MEM_dupallocN(cuma->curve);
|
||||
|
||||
for (i=0; i<cuma->totpoint; i++) {
|
||||
newpoints[i].y = cuma->curve[last-i].y;
|
||||
for (i = 0; i < cuma->totpoint; i++) {
|
||||
newpoints[i].y = cuma->curve[last - i].y;
|
||||
}
|
||||
|
||||
MEM_freeN(cuma->curve);
|
||||
@@ -296,7 +296,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
|
||||
|
||||
if (cuma->table) {
|
||||
MEM_freeN(cuma->table);
|
||||
cuma->table= NULL;
|
||||
cuma->table = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ void curvemap_sethandle(CurveMap *cuma, int type)
|
||||
{
|
||||
int a;
|
||||
|
||||
for (a=0; a<cuma->totpoint; a++) {
|
||||
for (a = 0; a < cuma->totpoint; a++) {
|
||||
if (cuma->curve[a].flag & CUMA_SELECT) {
|
||||
if (type) cuma->curve[a].flag |= CUMA_VECTOR;
|
||||
else cuma->curve[a].flag &= ~CUMA_VECTOR;
|
||||
@@ -322,65 +322,65 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
|
||||
float len, len_a, len_b;
|
||||
float dvec_a[2], dvec_b[2];
|
||||
|
||||
if (bezt->h1==0 && bezt->h2==0) {
|
||||
if (bezt->h1 == 0 && bezt->h2 == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
p2= bezt->vec[1];
|
||||
p2 = bezt->vec[1];
|
||||
|
||||
if (prev==NULL) {
|
||||
p3= next->vec[1];
|
||||
pt[0]= 2.0f*p2[0] - p3[0];
|
||||
pt[1]= 2.0f*p2[1] - p3[1];
|
||||
p1= pt;
|
||||
if (prev == NULL) {
|
||||
p3 = next->vec[1];
|
||||
pt[0] = 2.0f * p2[0] - p3[0];
|
||||
pt[1] = 2.0f * p2[1] - p3[1];
|
||||
p1 = pt;
|
||||
}
|
||||
else {
|
||||
p1= prev->vec[1];
|
||||
p1 = prev->vec[1];
|
||||
}
|
||||
|
||||
if (next==NULL) {
|
||||
p1= prev->vec[1];
|
||||
pt[0]= 2.0f*p2[0] - p1[0];
|
||||
pt[1]= 2.0f*p2[1] - p1[1];
|
||||
p3= pt;
|
||||
if (next == NULL) {
|
||||
p1 = prev->vec[1];
|
||||
pt[0] = 2.0f * p2[0] - p1[0];
|
||||
pt[1] = 2.0f * p2[1] - p1[1];
|
||||
p3 = pt;
|
||||
}
|
||||
else {
|
||||
p3= next->vec[1];
|
||||
p3 = next->vec[1];
|
||||
}
|
||||
|
||||
sub_v2_v2v2(dvec_a, p2, p1);
|
||||
sub_v2_v2v2(dvec_b, p3, p2);
|
||||
|
||||
len_a= len_v2(dvec_a);
|
||||
len_b= len_v2(dvec_b);
|
||||
len_a = len_v2(dvec_a);
|
||||
len_b = len_v2(dvec_b);
|
||||
|
||||
if (len_a==0.0f) len_a=1.0f;
|
||||
if (len_b==0.0f) len_b=1.0f;
|
||||
if (len_a == 0.0f) len_a = 1.0f;
|
||||
if (len_b == 0.0f) len_b = 1.0f;
|
||||
|
||||
if (bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */
|
||||
if (bezt->h1 == HD_AUTO || bezt->h2 == HD_AUTO) { /* auto */
|
||||
float tvec[2];
|
||||
tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a;
|
||||
tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a;
|
||||
tvec[0] = dvec_b[0] / len_b + dvec_a[0] / len_a;
|
||||
tvec[1] = dvec_b[1] / len_b + dvec_a[1] / len_a;
|
||||
|
||||
len= len_v2(tvec) * 2.5614f;
|
||||
if (len!=0.0f) {
|
||||
len = len_v2(tvec) * 2.5614f;
|
||||
if (len != 0.0f) {
|
||||
|
||||
if (bezt->h1==HD_AUTO) {
|
||||
len_a/=len;
|
||||
madd_v2_v2v2fl(p2-3, p2, tvec, -len_a);
|
||||
if (bezt->h1 == HD_AUTO) {
|
||||
len_a /= len;
|
||||
madd_v2_v2v2fl(p2 - 3, p2, tvec, -len_a);
|
||||
}
|
||||
if (bezt->h2==HD_AUTO) {
|
||||
len_b/=len;
|
||||
madd_v2_v2v2fl(p2+3, p2, tvec, len_b);
|
||||
if (bezt->h2 == HD_AUTO) {
|
||||
len_b /= len;
|
||||
madd_v2_v2v2fl(p2 + 3, p2, tvec, len_b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bezt->h1==HD_VECT) { /* vector */
|
||||
madd_v2_v2v2fl(p2-3, p2, dvec_a, -1.0f/3.0f);
|
||||
if (bezt->h1 == HD_VECT) { /* vector */
|
||||
madd_v2_v2v2fl(p2 - 3, p2, dvec_a, -1.0f / 3.0f);
|
||||
}
|
||||
if (bezt->h2==HD_VECT) {
|
||||
madd_v2_v2v2fl(p2+3, p2, dvec_b, 1.0f/3.0f);
|
||||
if (bezt->h2 == HD_VECT) {
|
||||
madd_v2_v2v2fl(p2 + 3, p2, dvec_b, 1.0f / 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,27 +389,27 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
|
||||
static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], const float last[2])
|
||||
{
|
||||
if (x <= first[0]) {
|
||||
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) {
|
||||
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
|
||||
/* no extrapolate */
|
||||
return first[1];
|
||||
}
|
||||
else {
|
||||
if (cuma->ext_in[0]==0.0f)
|
||||
return first[1] + cuma->ext_in[1]*10000.0f;
|
||||
if (cuma->ext_in[0] == 0.0f)
|
||||
return first[1] + cuma->ext_in[1] * 10000.0f;
|
||||
else
|
||||
return first[1] + cuma->ext_in[1]*(x - first[0])/cuma->ext_in[0];
|
||||
return first[1] + cuma->ext_in[1] * (x - first[0]) / cuma->ext_in[0];
|
||||
}
|
||||
}
|
||||
else if (x >= last[0]) {
|
||||
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) {
|
||||
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
|
||||
/* no extrapolate */
|
||||
return last[1];
|
||||
}
|
||||
else {
|
||||
if (cuma->ext_out[0]==0.0f)
|
||||
return last[1] - cuma->ext_out[1]*10000.0f;
|
||||
if (cuma->ext_out[0] == 0.0f)
|
||||
return last[1] - cuma->ext_out[1] * 10000.0f;
|
||||
else
|
||||
return last[1] + cuma->ext_out[1]*(x - last[0])/cuma->ext_out[0];
|
||||
return last[1] + cuma->ext_out[1] * (x - last[0]) / cuma->ext_out[0];
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
@@ -418,74 +418,74 @@ static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2],
|
||||
/* only creates a table for a single channel in CurveMapping */
|
||||
static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
|
||||
{
|
||||
CurveMapPoint *cmp= cuma->curve;
|
||||
CurveMapPoint *cmp = cuma->curve;
|
||||
BezTriple *bezt;
|
||||
float *fp, *allpoints, *lastpoint, curf, range;
|
||||
int a, totpoint;
|
||||
|
||||
if (cuma->curve==NULL) return;
|
||||
if (cuma->curve == NULL) return;
|
||||
|
||||
/* default rect also is table range */
|
||||
cuma->mintable= clipr->xmin;
|
||||
cuma->maxtable= clipr->xmax;
|
||||
cuma->mintable = clipr->xmin;
|
||||
cuma->maxtable = clipr->xmax;
|
||||
|
||||
/* hrmf... we now rely on blender ipo beziers, these are more advanced */
|
||||
bezt= MEM_callocN(cuma->totpoint*sizeof(BezTriple), "beztarr");
|
||||
bezt = MEM_callocN(cuma->totpoint * sizeof(BezTriple), "beztarr");
|
||||
|
||||
for (a=0; a<cuma->totpoint; a++) {
|
||||
cuma->mintable= MIN2(cuma->mintable, cmp[a].x);
|
||||
cuma->maxtable= MAX2(cuma->maxtable, cmp[a].x);
|
||||
bezt[a].vec[1][0]= cmp[a].x;
|
||||
bezt[a].vec[1][1]= cmp[a].y;
|
||||
for (a = 0; a < cuma->totpoint; a++) {
|
||||
cuma->mintable = MIN2(cuma->mintable, cmp[a].x);
|
||||
cuma->maxtable = MAX2(cuma->maxtable, cmp[a].x);
|
||||
bezt[a].vec[1][0] = cmp[a].x;
|
||||
bezt[a].vec[1][1] = cmp[a].y;
|
||||
if (cmp[a].flag & CUMA_VECTOR)
|
||||
bezt[a].h1= bezt[a].h2= HD_VECT;
|
||||
bezt[a].h1 = bezt[a].h2 = HD_VECT;
|
||||
else
|
||||
bezt[a].h1= bezt[a].h2= HD_AUTO;
|
||||
bezt[a].h1 = bezt[a].h2 = HD_AUTO;
|
||||
}
|
||||
|
||||
for (a=0; a<cuma->totpoint; a++) {
|
||||
if (a==0)
|
||||
calchandle_curvemap(bezt, NULL, bezt+1, 0);
|
||||
else if (a==cuma->totpoint-1)
|
||||
calchandle_curvemap(bezt+a, bezt+a-1, NULL, 0);
|
||||
for (a = 0; a < cuma->totpoint; a++) {
|
||||
if (a == 0)
|
||||
calchandle_curvemap(bezt, NULL, bezt + 1, 0);
|
||||
else if (a == cuma->totpoint - 1)
|
||||
calchandle_curvemap(bezt + a, bezt + a - 1, NULL, 0);
|
||||
else
|
||||
calchandle_curvemap(bezt+a, bezt+a-1, bezt+a+1, 0);
|
||||
calchandle_curvemap(bezt + a, bezt + a - 1, bezt + a + 1, 0);
|
||||
}
|
||||
|
||||
/* first and last handle need correction, instead of pointing to center of next/prev,
|
||||
* we let it point to the closest handle */
|
||||
if (cuma->totpoint>2) {
|
||||
if (cuma->totpoint > 2) {
|
||||
float hlen, nlen, vec[3];
|
||||
|
||||
if (bezt[0].h2==HD_AUTO) {
|
||||
if (bezt[0].h2 == HD_AUTO) {
|
||||
|
||||
hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
|
||||
hlen = len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
|
||||
/* clip handle point */
|
||||
copy_v3_v3(vec, bezt[1].vec[0]);
|
||||
if (vec[0] < bezt[0].vec[1][0])
|
||||
vec[0]= bezt[0].vec[1][0];
|
||||
vec[0] = bezt[0].vec[1][0];
|
||||
|
||||
sub_v3_v3(vec, bezt[0].vec[1]);
|
||||
nlen= len_v3(vec);
|
||||
if (nlen>FLT_EPSILON) {
|
||||
mul_v3_fl(vec, hlen/nlen);
|
||||
nlen = len_v3(vec);
|
||||
if (nlen > FLT_EPSILON) {
|
||||
mul_v3_fl(vec, hlen / nlen);
|
||||
add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]);
|
||||
sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec);
|
||||
}
|
||||
}
|
||||
a= cuma->totpoint-1;
|
||||
if (bezt[a].h2==HD_AUTO) {
|
||||
a = cuma->totpoint - 1;
|
||||
if (bezt[a].h2 == HD_AUTO) {
|
||||
|
||||
hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
|
||||
hlen = len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
|
||||
/* clip handle point */
|
||||
copy_v3_v3(vec, bezt[a-1].vec[2]);
|
||||
copy_v3_v3(vec, bezt[a - 1].vec[2]);
|
||||
if (vec[0] > bezt[a].vec[1][0])
|
||||
vec[0]= bezt[a].vec[1][0];
|
||||
vec[0] = bezt[a].vec[1][0];
|
||||
|
||||
sub_v3_v3(vec, bezt[a].vec[1]);
|
||||
nlen= len_v3(vec);
|
||||
if (nlen>FLT_EPSILON) {
|
||||
mul_v3_fl(vec, hlen/nlen);
|
||||
nlen = len_v3(vec);
|
||||
if (nlen > FLT_EPSILON) {
|
||||
mul_v3_fl(vec, hlen / nlen);
|
||||
add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]);
|
||||
sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec);
|
||||
}
|
||||
@@ -494,63 +494,63 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
|
||||
/* make the bezier curve */
|
||||
if (cuma->table)
|
||||
MEM_freeN(cuma->table);
|
||||
totpoint= (cuma->totpoint-1)*CM_RESOL;
|
||||
fp= allpoints= MEM_callocN(totpoint*2*sizeof(float), "table");
|
||||
totpoint = (cuma->totpoint - 1) * CM_RESOL;
|
||||
fp = allpoints = MEM_callocN(totpoint * 2 * sizeof(float), "table");
|
||||
|
||||
for (a=0; a<cuma->totpoint-1; a++, fp += 2*CM_RESOL) {
|
||||
correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]);
|
||||
BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));
|
||||
BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
|
||||
for (a = 0; a < cuma->totpoint - 1; a++, fp += 2 * CM_RESOL) {
|
||||
correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 1].vec[1]);
|
||||
BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a + 1].vec[0][0], bezt[a + 1].vec[1][0], fp, CM_RESOL - 1, 2 * sizeof(float));
|
||||
BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a + 1].vec[0][1], bezt[a + 1].vec[1][1], fp + 1, CM_RESOL - 1, 2 * sizeof(float));
|
||||
}
|
||||
|
||||
/* store first and last handle for extrapolation, unit length */
|
||||
cuma->ext_in[0]= bezt[0].vec[0][0] - bezt[0].vec[1][0];
|
||||
cuma->ext_in[1]= bezt[0].vec[0][1] - bezt[0].vec[1][1];
|
||||
range= sqrt(cuma->ext_in[0]*cuma->ext_in[0] + cuma->ext_in[1]*cuma->ext_in[1]);
|
||||
cuma->ext_in[0]/= range;
|
||||
cuma->ext_in[1]/= range;
|
||||
|
||||
a= cuma->totpoint-1;
|
||||
cuma->ext_out[0]= bezt[a].vec[1][0] - bezt[a].vec[2][0];
|
||||
cuma->ext_out[1]= bezt[a].vec[1][1] - bezt[a].vec[2][1];
|
||||
range= sqrt(cuma->ext_out[0]*cuma->ext_out[0] + cuma->ext_out[1]*cuma->ext_out[1]);
|
||||
cuma->ext_out[0]/= range;
|
||||
cuma->ext_out[1]/= range;
|
||||
cuma->ext_in[0] = bezt[0].vec[0][0] - bezt[0].vec[1][0];
|
||||
cuma->ext_in[1] = bezt[0].vec[0][1] - bezt[0].vec[1][1];
|
||||
range = sqrt(cuma->ext_in[0] * cuma->ext_in[0] + cuma->ext_in[1] * cuma->ext_in[1]);
|
||||
cuma->ext_in[0] /= range;
|
||||
cuma->ext_in[1] /= range;
|
||||
|
||||
a = cuma->totpoint - 1;
|
||||
cuma->ext_out[0] = bezt[a].vec[1][0] - bezt[a].vec[2][0];
|
||||
cuma->ext_out[1] = bezt[a].vec[1][1] - bezt[a].vec[2][1];
|
||||
range = sqrt(cuma->ext_out[0] * cuma->ext_out[0] + cuma->ext_out[1] * cuma->ext_out[1]);
|
||||
cuma->ext_out[0] /= range;
|
||||
cuma->ext_out[1] /= range;
|
||||
|
||||
/* cleanup */
|
||||
MEM_freeN(bezt);
|
||||
|
||||
range= CM_TABLEDIV*(cuma->maxtable - cuma->mintable);
|
||||
cuma->range= 1.0f/range;
|
||||
range = CM_TABLEDIV * (cuma->maxtable - cuma->mintable);
|
||||
cuma->range = 1.0f / range;
|
||||
|
||||
/* now make a table with CM_TABLE equal x distances */
|
||||
fp= allpoints;
|
||||
lastpoint= allpoints + 2*(totpoint-1);
|
||||
cmp= MEM_callocN((CM_TABLE+1)*sizeof(CurveMapPoint), "dist table");
|
||||
|
||||
for (a=0; a<=CM_TABLE; a++) {
|
||||
curf= cuma->mintable + range*(float)a;
|
||||
cmp[a].x= curf;
|
||||
fp = allpoints;
|
||||
lastpoint = allpoints + 2 * (totpoint - 1);
|
||||
cmp = MEM_callocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "dist table");
|
||||
|
||||
for (a = 0; a <= CM_TABLE; a++) {
|
||||
curf = cuma->mintable + range * (float)a;
|
||||
cmp[a].x = curf;
|
||||
|
||||
/* get the first x coordinate larger than curf */
|
||||
while (curf >= fp[0] && fp!=lastpoint) {
|
||||
fp+=2;
|
||||
while (curf >= fp[0] && fp != lastpoint) {
|
||||
fp += 2;
|
||||
}
|
||||
if (fp==allpoints || (curf >= fp[0] && fp==lastpoint))
|
||||
cmp[a].y= curvemap_calc_extend(cuma, curf, allpoints, lastpoint);
|
||||
if (fp == allpoints || (curf >= fp[0] && fp == lastpoint))
|
||||
cmp[a].y = curvemap_calc_extend(cuma, curf, allpoints, lastpoint);
|
||||
else {
|
||||
float fac1= fp[0] - fp[-2];
|
||||
float fac2= fp[0] - curf;
|
||||
float fac1 = fp[0] - fp[-2];
|
||||
float fac2 = fp[0] - curf;
|
||||
if (fac1 > FLT_EPSILON)
|
||||
fac1= fac2/fac1;
|
||||
fac1 = fac2 / fac1;
|
||||
else
|
||||
fac1= 0.0f;
|
||||
cmp[a].y= fac1*fp[-1] + (1.0f-fac1)*fp[1];
|
||||
fac1 = 0.0f;
|
||||
cmp[a].y = fac1 * fp[-1] + (1.0f - fac1) * fp[1];
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(allpoints);
|
||||
cuma->table= cmp;
|
||||
cuma->table = cmp;
|
||||
}
|
||||
|
||||
/* call when you do images etc, needs restore too. also verifies tables */
|
||||
@@ -561,34 +561,34 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
|
||||
|
||||
if (restore) {
|
||||
if (cumap->flag & CUMA_PREMULLED) {
|
||||
for (a=0; a<3; a++) {
|
||||
for (a = 0; a < 3; a++) {
|
||||
MEM_freeN(cumap->cm[a].table);
|
||||
cumap->cm[a].table= cumap->cm[a].premultable;
|
||||
cumap->cm[a].premultable= NULL;
|
||||
cumap->cm[a].table = cumap->cm[a].premultable;
|
||||
cumap->cm[a].premultable = NULL;
|
||||
}
|
||||
|
||||
cumap->flag &= ~CUMA_PREMULLED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((cumap->flag & CUMA_PREMULLED)==0) {
|
||||
if ((cumap->flag & CUMA_PREMULLED) == 0) {
|
||||
/* verify and copy */
|
||||
for (a=0; a<3; a++) {
|
||||
if (cumap->cm[a].table==NULL)
|
||||
curvemap_make_table(cumap->cm+a, &cumap->clipr);
|
||||
cumap->cm[a].premultable= cumap->cm[a].table;
|
||||
cumap->cm[a].table= MEM_mallocN((CM_TABLE+1)*sizeof(CurveMapPoint), "premul table");
|
||||
memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE+1)*sizeof(CurveMapPoint));
|
||||
for (a = 0; a < 3; a++) {
|
||||
if (cumap->cm[a].table == NULL)
|
||||
curvemap_make_table(cumap->cm + a, &cumap->clipr);
|
||||
cumap->cm[a].premultable = cumap->cm[a].table;
|
||||
cumap->cm[a].table = MEM_mallocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "premul table");
|
||||
memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE + 1) * sizeof(CurveMapPoint));
|
||||
}
|
||||
|
||||
if (cumap->cm[3].table==NULL)
|
||||
curvemap_make_table(cumap->cm+3, &cumap->clipr);
|
||||
if (cumap->cm[3].table == NULL)
|
||||
curvemap_make_table(cumap->cm + 3, &cumap->clipr);
|
||||
|
||||
/* premul */
|
||||
for (a=0; a<3; a++) {
|
||||
for (a = 0; a < 3; a++) {
|
||||
int b;
|
||||
for (b=0; b<=CM_TABLE; b++) {
|
||||
cumap->cm[a].table[b].y= curvemap_evaluateF(cumap->cm+3, cumap->cm[a].table[b].y);
|
||||
for (b = 0; b <= CM_TABLE; b++) {
|
||||
cumap->cm[a].table[b].y = curvemap_evaluateF(cumap->cm + 3, cumap->cm[a].table[b].y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,10 +599,10 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
|
||||
|
||||
static int sort_curvepoints(const void *a1, const void *a2)
|
||||
{
|
||||
const struct CurveMapPoint *x1=a1, *x2=a2;
|
||||
const struct CurveMapPoint *x1 = a1, *x2 = a2;
|
||||
|
||||
if ( x1->x > x2->x ) return 1;
|
||||
else if ( x1->x < x2->x) return -1;
|
||||
if (x1->x > x2->x) return 1;
|
||||
else if (x1->x < x2->x) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -611,30 +611,30 @@ static int sort_curvepoints(const void *a1, const void *a2)
|
||||
/* note; only does current curvemap! */
|
||||
void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
|
||||
{
|
||||
CurveMap *cuma= cumap->cm+cumap->cur;
|
||||
CurveMapPoint *cmp= cuma->curve;
|
||||
rctf *clipr= &cumap->clipr;
|
||||
float thresh= 0.01f*(clipr->xmax - clipr->xmin);
|
||||
float dx= 0.0f, dy= 0.0f;
|
||||
CurveMap *cuma = cumap->cm + cumap->cur;
|
||||
CurveMapPoint *cmp = cuma->curve;
|
||||
rctf *clipr = &cumap->clipr;
|
||||
float thresh = 0.01f * (clipr->xmax - clipr->xmin);
|
||||
float dx = 0.0f, dy = 0.0f;
|
||||
int a;
|
||||
|
||||
cumap->changed_timestamp++;
|
||||
|
||||
/* clamp with clip */
|
||||
if (cumap->flag & CUMA_DO_CLIP) {
|
||||
for (a=0; a<cuma->totpoint; a++) {
|
||||
for (a = 0; a < cuma->totpoint; a++) {
|
||||
if (cmp[a].flag & CUMA_SELECT) {
|
||||
if (cmp[a].x < clipr->xmin)
|
||||
dx= MIN2(dx, cmp[a].x - clipr->xmin);
|
||||
dx = MIN2(dx, cmp[a].x - clipr->xmin);
|
||||
else if (cmp[a].x > clipr->xmax)
|
||||
dx= MAX2(dx, cmp[a].x - clipr->xmax);
|
||||
dx = MAX2(dx, cmp[a].x - clipr->xmax);
|
||||
if (cmp[a].y < clipr->ymin)
|
||||
dy= MIN2(dy, cmp[a].y - clipr->ymin);
|
||||
dy = MIN2(dy, cmp[a].y - clipr->ymin);
|
||||
else if (cmp[a].y > clipr->ymax)
|
||||
dy= MAX2(dy, cmp[a].y - clipr->ymax);
|
||||
dy = MAX2(dy, cmp[a].y - clipr->ymax);
|
||||
}
|
||||
}
|
||||
for (a=0; a<cuma->totpoint; a++) {
|
||||
for (a = 0; a < cuma->totpoint; a++) {
|
||||
if (cmp[a].flag & CUMA_SELECT) {
|
||||
cmp[a].x -= dx;
|
||||
cmp[a].y -= dy;
|
||||
@@ -646,25 +646,25 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
|
||||
qsort(cmp, cuma->totpoint, sizeof(CurveMapPoint), sort_curvepoints);
|
||||
|
||||
/* remove doubles, threshold set on 1% of default range */
|
||||
if (rem_doubles && cuma->totpoint>2) {
|
||||
for (a=0; a<cuma->totpoint-1; a++) {
|
||||
dx= cmp[a].x - cmp[a+1].x;
|
||||
dy= cmp[a].y - cmp[a+1].y;
|
||||
if ( sqrtf(dx*dx + dy*dy) < thresh ) {
|
||||
if (a==0) {
|
||||
cmp[a+1].flag|= 2;
|
||||
if (cmp[a+1].flag & CUMA_SELECT)
|
||||
if (rem_doubles && cuma->totpoint > 2) {
|
||||
for (a = 0; a < cuma->totpoint - 1; a++) {
|
||||
dx = cmp[a].x - cmp[a + 1].x;
|
||||
dy = cmp[a].y - cmp[a + 1].y;
|
||||
if (sqrtf(dx * dx + dy * dy) < thresh) {
|
||||
if (a == 0) {
|
||||
cmp[a + 1].flag |= 2;
|
||||
if (cmp[a + 1].flag & CUMA_SELECT)
|
||||
cmp[a].flag |= CUMA_SELECT;
|
||||
}
|
||||
else {
|
||||
cmp[a].flag|= 2;
|
||||
cmp[a].flag |= 2;
|
||||
if (cmp[a].flag & CUMA_SELECT)
|
||||
cmp[a+1].flag |= CUMA_SELECT;
|
||||
cmp[a + 1].flag |= CUMA_SELECT;
|
||||
}
|
||||
break; /* we assume 1 deletion per edit is ok */
|
||||
break; /* we assume 1 deletion per edit is ok */
|
||||
}
|
||||
}
|
||||
if (a != cuma->totpoint-1)
|
||||
if (a != cuma->totpoint - 1)
|
||||
curvemap_remove(cuma, 2);
|
||||
}
|
||||
curvemap_make_table(cuma, clipr);
|
||||
@@ -677,31 +677,31 @@ float curvemap_evaluateF(CurveMap *cuma, float value)
|
||||
int i;
|
||||
|
||||
/* index in table */
|
||||
fi= (value-cuma->mintable)*cuma->range;
|
||||
i= (int)fi;
|
||||
fi = (value - cuma->mintable) * cuma->range;
|
||||
i = (int)fi;
|
||||
|
||||
/* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */
|
||||
if (fi<0.0f || fi>CM_TABLE)
|
||||
if (fi < 0.0f || fi > CM_TABLE)
|
||||
return curvemap_calc_extend(cuma, value, &cuma->table[0].x, &cuma->table[CM_TABLE].x);
|
||||
else {
|
||||
if (i<0) return cuma->table[0].y;
|
||||
if (i>=CM_TABLE) return cuma->table[CM_TABLE].y;
|
||||
if (i < 0) return cuma->table[0].y;
|
||||
if (i >= CM_TABLE) return cuma->table[CM_TABLE].y;
|
||||
|
||||
fi= fi-(float)i;
|
||||
return (1.0f-fi)*cuma->table[i].y + (fi)*cuma->table[i+1].y;
|
||||
fi = fi - (float)i;
|
||||
return (1.0f - fi) * cuma->table[i].y + (fi) * cuma->table[i + 1].y;
|
||||
}
|
||||
}
|
||||
|
||||
/* works with curve 'cur' */
|
||||
float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value)
|
||||
{
|
||||
CurveMap *cuma= cumap->cm+cur;
|
||||
CurveMap *cuma = cumap->cm + cur;
|
||||
|
||||
/* allocate or bail out */
|
||||
if (cuma->table==NULL) {
|
||||
if (cuma->table == NULL) {
|
||||
curvemap_make_table(cuma, &cumap->clipr);
|
||||
if (cuma->table==NULL)
|
||||
return 1.0f-value;
|
||||
if (cuma->table == NULL)
|
||||
return 1.0f - value;
|
||||
}
|
||||
return curvemap_evaluateF(cuma, value);
|
||||
}
|
||||
@@ -709,17 +709,17 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value)
|
||||
/* vector case */
|
||||
void curvemapping_evaluate3F(CurveMapping *cumap, float vecout[3], const float vecin[3])
|
||||
{
|
||||
vecout[0]= curvemapping_evaluateF(cumap, 0, vecin[0]);
|
||||
vecout[1]= curvemapping_evaluateF(cumap, 1, vecin[1]);
|
||||
vecout[2]= curvemapping_evaluateF(cumap, 2, vecin[2]);
|
||||
vecout[0] = curvemapping_evaluateF(cumap, 0, vecin[0]);
|
||||
vecout[1] = curvemapping_evaluateF(cumap, 1, vecin[1]);
|
||||
vecout[2] = curvemapping_evaluateF(cumap, 2, vecin[2]);
|
||||
}
|
||||
|
||||
/* RGB case, no black/white points, no premult */
|
||||
void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3])
|
||||
{
|
||||
vecout[0]= curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0]));
|
||||
vecout[1]= curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1]));
|
||||
vecout[2]= curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2]));
|
||||
vecout[0] = curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0]));
|
||||
vecout[1] = curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1]));
|
||||
vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2]));
|
||||
}
|
||||
|
||||
|
||||
@@ -728,14 +728,14 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], cons
|
||||
{
|
||||
float fac;
|
||||
|
||||
fac= (vecin[0] - cumap->black[0])*cumap->bwmul[0];
|
||||
vecout[0]= curvemap_evaluateF(cumap->cm, fac);
|
||||
fac = (vecin[0] - cumap->black[0]) * cumap->bwmul[0];
|
||||
vecout[0] = curvemap_evaluateF(cumap->cm, fac);
|
||||
|
||||
fac= (vecin[1] - cumap->black[1])*cumap->bwmul[1];
|
||||
vecout[1]= curvemap_evaluateF(cumap->cm+1, fac);
|
||||
fac = (vecin[1] - cumap->black[1]) * cumap->bwmul[1];
|
||||
vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac);
|
||||
|
||||
fac= (vecin[2] - cumap->black[2])*cumap->bwmul[2];
|
||||
vecout[2]= curvemap_evaluateF(cumap->cm+2, fac);
|
||||
fac = (vecin[2] - cumap->black[2]) * cumap->bwmul[2];
|
||||
vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac);
|
||||
}
|
||||
|
||||
|
||||
@@ -746,14 +746,14 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
|
||||
int pixel;
|
||||
float *pix_in;
|
||||
float col[3];
|
||||
int stride= 4;
|
||||
int stride = 4;
|
||||
float *pix_out;
|
||||
|
||||
if (ibuf==NULL)
|
||||
if (ibuf == NULL)
|
||||
return;
|
||||
if (ibuf->rect_float==NULL)
|
||||
if (ibuf->rect_float == NULL)
|
||||
IMB_float_from_rect(ibuf);
|
||||
else if (ibuf->rect==NULL)
|
||||
else if (ibuf->rect == NULL)
|
||||
imb_addrectImBuf(ibuf);
|
||||
|
||||
if (!ibuf->rect || !ibuf->rect_float)
|
||||
@@ -765,27 +765,27 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
|
||||
|
||||
curvemapping_premultiply(cumap, 0);
|
||||
|
||||
pix_in= ibuf->rect_float;
|
||||
pix_out= tmpbuf->rect_float;
|
||||
pix_in = ibuf->rect_float;
|
||||
pix_out = tmpbuf->rect_float;
|
||||
|
||||
if (ibuf->channels)
|
||||
stride= ibuf->channels;
|
||||
stride = ibuf->channels;
|
||||
|
||||
for (pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=stride) {
|
||||
if (stride<3) {
|
||||
col[0]= curvemap_evaluateF(cumap->cm, *pix_in);
|
||||
for (pixel = ibuf->x * ibuf->y; pixel > 0; pixel--, pix_in += stride, pix_out += stride) {
|
||||
if (stride < 3) {
|
||||
col[0] = curvemap_evaluateF(cumap->cm, *pix_in);
|
||||
|
||||
pix_out[1]= pix_out[2]= pix_out[3]= pix_out[0]= col[0];
|
||||
pix_out[1] = pix_out[2] = pix_out[3] = pix_out[0] = col[0];
|
||||
}
|
||||
else {
|
||||
curvemapping_evaluate_premulRGBF(cumap, col, pix_in);
|
||||
pix_out[0]= col[0];
|
||||
pix_out[1]= col[1];
|
||||
pix_out[2]= col[2];
|
||||
if (stride>3)
|
||||
pix_out[3]= pix_in[3];
|
||||
pix_out[0] = col[0];
|
||||
pix_out[1] = col[1];
|
||||
pix_out[2] = col[2];
|
||||
if (stride > 3)
|
||||
pix_out[3] = pix_in[3];
|
||||
else
|
||||
pix_out[3]= 1.f;
|
||||
pix_out[3] = 1.f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,16 +800,16 @@ int curvemapping_RGBA_does_something(CurveMapping *cumap)
|
||||
{
|
||||
int a;
|
||||
|
||||
if (cumap->black[0]!=0.0f) return 1;
|
||||
if (cumap->black[1]!=0.0f) return 1;
|
||||
if (cumap->black[2]!=0.0f) return 1;
|
||||
if (cumap->white[0]!=1.0f) return 1;
|
||||
if (cumap->white[1]!=1.0f) return 1;
|
||||
if (cumap->white[2]!=1.0f) return 1;
|
||||
if (cumap->black[0] != 0.0f) return 1;
|
||||
if (cumap->black[1] != 0.0f) return 1;
|
||||
if (cumap->black[2] != 0.0f) return 1;
|
||||
if (cumap->white[0] != 1.0f) return 1;
|
||||
if (cumap->white[1] != 1.0f) return 1;
|
||||
if (cumap->white[2] != 1.0f) return 1;
|
||||
|
||||
for (a=0; a<CM_TOT; a++) {
|
||||
for (a = 0; a < CM_TOT; a++) {
|
||||
if (cumap->cm[a].curve) {
|
||||
if (cumap->cm[a].totpoint!=2) return 1;
|
||||
if (cumap->cm[a].totpoint != 2) return 1;
|
||||
|
||||
if (cumap->cm[a].curve[0].x != 0.0f) return 1;
|
||||
if (cumap->cm[a].curve[0].y != 0.0f) return 1;
|
||||
@@ -824,11 +824,11 @@ void curvemapping_initialize(CurveMapping *cumap)
|
||||
{
|
||||
int a;
|
||||
|
||||
if (cumap==NULL) return;
|
||||
if (cumap == NULL) return;
|
||||
|
||||
for (a=0; a<CM_TOT; a++) {
|
||||
if (cumap->cm[a].table==NULL)
|
||||
curvemap_make_table(cumap->cm+a, &cumap->clipr);
|
||||
for (a = 0; a < CM_TOT; a++) {
|
||||
if (cumap->cm[a].table == NULL)
|
||||
curvemap_make_table(cumap->cm + a, &cumap->clipr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -836,29 +836,29 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size)
|
||||
{
|
||||
int a;
|
||||
|
||||
*size = CM_TABLE+1;
|
||||
*array = MEM_callocN(sizeof(float)*(*size)*4, "CurveMapping");
|
||||
*size = CM_TABLE + 1;
|
||||
*array = MEM_callocN(sizeof(float) * (*size) * 4, "CurveMapping");
|
||||
curvemapping_initialize(cumap);
|
||||
|
||||
for (a=0; a<*size; a++) {
|
||||
for (a = 0; a < *size; a++) {
|
||||
if (cumap->cm[0].table)
|
||||
(*array)[a*4+0]= cumap->cm[0].table[a].y;
|
||||
(*array)[a * 4 + 0] = cumap->cm[0].table[a].y;
|
||||
if (cumap->cm[1].table)
|
||||
(*array)[a*4+1]= cumap->cm[1].table[a].y;
|
||||
(*array)[a * 4 + 1] = cumap->cm[1].table[a].y;
|
||||
if (cumap->cm[2].table)
|
||||
(*array)[a*4+2]= cumap->cm[2].table[a].y;
|
||||
(*array)[a * 4 + 2] = cumap->cm[2].table[a].y;
|
||||
if (cumap->cm[3].table)
|
||||
(*array)[a*4+3]= cumap->cm[3].table[a].y;
|
||||
(*array)[a * 4 + 3] = cumap->cm[3].table[a].y;
|
||||
}
|
||||
}
|
||||
|
||||
/* ***************** Histogram **************** */
|
||||
|
||||
#define INV_255 (1.f/255.f)
|
||||
#define INV_255 (1.f / 255.f)
|
||||
|
||||
DO_INLINE int get_bin_float(float f)
|
||||
{
|
||||
int bin= (int)((f*255.0f) + 0.5f); /* 0.5 to prevent quantisation differences */
|
||||
int bin = (int)((f * 255.0f) + 0.5f); /* 0.5 to prevent quantisation differences */
|
||||
|
||||
/* note: clamp integer instead of float to avoid problems with NaN */
|
||||
CLAMP(bin, 0, 255);
|
||||
@@ -907,17 +907,17 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
|
||||
int x, y, c;
|
||||
unsigned int n, nl;
|
||||
double div, divl;
|
||||
float *rf=NULL;
|
||||
unsigned char *rc=NULL;
|
||||
float *rf = NULL;
|
||||
unsigned char *rc = NULL;
|
||||
unsigned int *bin_r, *bin_g, *bin_b, *bin_lum;
|
||||
int savedlines, saveline;
|
||||
float rgb[3], ycc[3], luma;
|
||||
int ycc_mode=-1;
|
||||
int ycc_mode = -1;
|
||||
const short is_float = (ibuf->rect_float != NULL);
|
||||
|
||||
if (ibuf->rect==NULL && ibuf->rect_float==NULL) return;
|
||||
if (ibuf->rect == NULL && ibuf->rect_float == NULL) return;
|
||||
|
||||
if (scopes->ok == 1 ) return;
|
||||
if (scopes->ok == 1) return;
|
||||
|
||||
if (scopes->hist.ymax == 0.f) scopes->hist.ymax = 1.f;
|
||||
|
||||
@@ -950,19 +950,19 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
|
||||
bin_lum = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins");
|
||||
|
||||
/* convert to number of lines with logarithmic scale */
|
||||
scopes->sample_lines = (scopes->accuracy*0.01f) * (scopes->accuracy*0.01f) * ibuf->y;
|
||||
scopes->sample_lines = (scopes->accuracy * 0.01f) * (scopes->accuracy * 0.01f) * ibuf->y;
|
||||
|
||||
if (scopes->sample_full)
|
||||
scopes->sample_lines = ibuf->y;
|
||||
|
||||
/* scan the image */
|
||||
savedlines=0;
|
||||
for (c=0; c<3; c++) {
|
||||
scopes->minmax[c][0]=25500.0f;
|
||||
scopes->minmax[c][1]=-25500.0f;
|
||||
savedlines = 0;
|
||||
for (c = 0; c < 3; c++) {
|
||||
scopes->minmax[c][0] = 25500.0f;
|
||||
scopes->minmax[c][1] = -25500.0f;
|
||||
}
|
||||
|
||||
scopes->waveform_tot = ibuf->x*scopes->sample_lines;
|
||||
scopes->waveform_tot = ibuf->x * scopes->sample_lines;
|
||||
|
||||
if (scopes->waveform_1)
|
||||
MEM_freeN(scopes->waveform_1);
|
||||
@@ -973,10 +973,10 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
|
||||
if (scopes->vecscope)
|
||||
MEM_freeN(scopes->vecscope);
|
||||
|
||||
scopes->waveform_1= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1");
|
||||
scopes->waveform_2= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2");
|
||||
scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3");
|
||||
scopes->vecscope= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel");
|
||||
scopes->waveform_1 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1");
|
||||
scopes->waveform_2 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2");
|
||||
scopes->waveform_3 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3");
|
||||
scopes->vecscope = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel");
|
||||
|
||||
if (is_float)
|
||||
rf = ibuf->rect_float;
|
||||
@@ -984,7 +984,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
|
||||
rc = (unsigned char *)ibuf->rect;
|
||||
|
||||
for (y = 0; y < ibuf->y; y++) {
|
||||
if (savedlines<scopes->sample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) {
|
||||
if (savedlines < scopes->sample_lines && y >= ((savedlines) * ibuf->y) / (scopes->sample_lines + 1)) {
|
||||
saveline = 1;
|
||||
}
|
||||
else {
|
||||
@@ -999,7 +999,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
|
||||
copy_v3_v3(rgb, rf);
|
||||
}
|
||||
else {
|
||||
for (c=0; c<3; c++)
|
||||
for (c = 0; c < 3; c++)
|
||||
rgb[c] = rc[c] * INV_255;
|
||||
}
|
||||
|
||||
@@ -1007,44 +1007,44 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
|
||||
luma = rgb_to_luma(rgb);
|
||||
|
||||
/* check for min max */
|
||||
if (ycc_mode == -1 ) {
|
||||
for (c=0; c<3; c++) {
|
||||
if (ycc_mode == -1) {
|
||||
for (c = 0; c < 3; c++) {
|
||||
if (rgb[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = rgb[c];
|
||||
if (rgb[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = rgb[c];
|
||||
}
|
||||
}
|
||||
else {
|
||||
rgb_to_ycc(rgb[0], rgb[1], rgb[2], &ycc[0], &ycc[1], &ycc[2], ycc_mode);
|
||||
for (c=0; c<3; c++) {
|
||||
ycc[c] *=INV_255;
|
||||
for (c = 0; c < 3; c++) {
|
||||
ycc[c] *= INV_255;
|
||||
if (ycc[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = ycc[c];
|
||||
if (ycc[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = ycc[c];
|
||||
}
|
||||
}
|
||||
/* increment count for histo*/
|
||||
bin_r[ get_bin_float(rgb[0]) ] += 1;
|
||||
bin_g[ get_bin_float(rgb[1]) ] += 1;
|
||||
bin_b[ get_bin_float(rgb[2]) ] += 1;
|
||||
bin_lum[ get_bin_float(luma) ] += 1;
|
||||
bin_r[get_bin_float(rgb[0])] += 1;
|
||||
bin_g[get_bin_float(rgb[1])] += 1;
|
||||
bin_b[get_bin_float(rgb[2])] += 1;
|
||||
bin_lum[get_bin_float(luma)] += 1;
|
||||
|
||||
/* save sample if needed */
|
||||
if (saveline) {
|
||||
const float fx = (float)x / (float)ibuf->x;
|
||||
const int idx = 2*(ibuf->x*savedlines+x);
|
||||
const int idx = 2 * (ibuf->x * savedlines + x);
|
||||
save_sample_line(scopes, idx, fx, rgb, ycc);
|
||||
}
|
||||
|
||||
rf+= ibuf->channels;
|
||||
rc+= ibuf->channels;
|
||||
rf += ibuf->channels;
|
||||
rc += ibuf->channels;
|
||||
}
|
||||
if (saveline)
|
||||
savedlines +=1;
|
||||
savedlines += 1;
|
||||
}
|
||||
|
||||
/* convert hist data to float (proportional to max count) */
|
||||
n=0;
|
||||
nl=0;
|
||||
for (x=0; x<256; x++) {
|
||||
n = 0;
|
||||
nl = 0;
|
||||
for (x = 0; x < 256; x++) {
|
||||
if (bin_r[x] > n)
|
||||
n = bin_r[x];
|
||||
if (bin_g[x] > n)
|
||||
@@ -1054,9 +1054,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
|
||||
if (bin_lum[x] > nl)
|
||||
nl = bin_lum[x];
|
||||
}
|
||||
div = 1.0/(double)n;
|
||||
divl = 1.0/(double)nl;
|
||||
for (x=0; x<256; x++) {
|
||||
div = 1.0 / (double)n;
|
||||
divl = 1.0 / (double)nl;
|
||||
for (x = 0; x < 256; x++) {
|
||||
scopes->hist.data_r[x] = bin_r[x] * div;
|
||||
scopes->hist.data_g[x] = bin_g[x] * div;
|
||||
scopes->hist.data_b[x] = bin_b[x] * div;
|
||||
@@ -1092,14 +1092,14 @@ void scopes_free(Scopes *scopes)
|
||||
|
||||
void scopes_new(Scopes *scopes)
|
||||
{
|
||||
scopes->accuracy=30.0;
|
||||
scopes->hist.mode=HISTO_MODE_RGB;
|
||||
scopes->wavefrm_alpha=0.3;
|
||||
scopes->vecscope_alpha=0.3;
|
||||
scopes->wavefrm_height= 100;
|
||||
scopes->vecscope_height= 100;
|
||||
scopes->hist.height= 100;
|
||||
scopes->ok= 0;
|
||||
scopes->accuracy = 30.0;
|
||||
scopes->hist.mode = HISTO_MODE_RGB;
|
||||
scopes->wavefrm_alpha = 0.3;
|
||||
scopes->vecscope_alpha = 0.3;
|
||||
scopes->wavefrm_height = 100;
|
||||
scopes->vecscope_height = 100;
|
||||
scopes->hist.height = 100;
|
||||
scopes->ok = 0;
|
||||
scopes->waveform_1 = NULL;
|
||||
scopes->waveform_2 = NULL;
|
||||
scopes->waveform_3 = NULL;
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
#include "BKE_constraint.h"
|
||||
#include "BKE_displist.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_DerivedMesh.h" /* for geometry targets */
|
||||
#include "BKE_DerivedMesh.h" /* for geometry targets */
|
||||
#include "BKE_cdderivedmesh.h" /* for geometry targets */
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_ipo.h"
|
||||
@@ -90,7 +90,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
|
||||
@@ -113,15 +113,15 @@ void unique_constraint_name(bConstraint *con, ListBase *list)
|
||||
|
||||
/* package an object/bone for use in constraint evaluation */
|
||||
/* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */
|
||||
bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, short datatype)
|
||||
bConstraintOb *constraints_make_evalob(Scene *scene, Object *ob, void *subdata, short datatype)
|
||||
{
|
||||
bConstraintOb *cob;
|
||||
|
||||
/* create regardless of whether we have any data! */
|
||||
cob= MEM_callocN(sizeof(bConstraintOb), "bConstraintOb");
|
||||
cob = MEM_callocN(sizeof(bConstraintOb), "bConstraintOb");
|
||||
|
||||
/* for system time, part of deglobalization, code nicer later with local time (ton) */
|
||||
cob->scene= scene;
|
||||
cob->scene = scene;
|
||||
|
||||
/* based on type of available data */
|
||||
switch (datatype) {
|
||||
@@ -139,7 +139,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
|
||||
|
||||
copy_m4_m4(cob->startmat, cob->matrix);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case CONSTRAINT_OBTYPE_BONE:
|
||||
{
|
||||
/* only set if we have valid bone, otherwise default */
|
||||
@@ -150,11 +150,11 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
|
||||
|
||||
if (cob->pchan->rotmode > 0) {
|
||||
/* should be some type of Euler order */
|
||||
cob->rotOrder= cob->pchan->rotmode;
|
||||
cob->rotOrder = cob->pchan->rotmode;
|
||||
}
|
||||
else {
|
||||
/* Quats, so eulers should just use default order */
|
||||
cob->rotOrder= EULER_ORDER_DEFAULT;
|
||||
cob->rotOrder = EULER_ORDER_DEFAULT;
|
||||
}
|
||||
|
||||
/* matrix in world-space */
|
||||
@@ -165,7 +165,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
|
||||
|
||||
copy_m4_m4(cob->startmat, cob->matrix);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default: /* other types not yet handled */
|
||||
unit_m4(cob->matrix);
|
||||
@@ -202,7 +202,7 @@ void constraints_clear_evalob(bConstraintOb *cob)
|
||||
invert_m4_m4(cob->ob->constinv, delta);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case CONSTRAINT_OBTYPE_BONE:
|
||||
{
|
||||
/* cob->ob or cob->pchan might not exist */
|
||||
@@ -214,7 +214,7 @@ void constraints_clear_evalob(bConstraintOb *cob)
|
||||
invert_m4_m4(cob->pchan->constinv, delta);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* free tempolary struct */
|
||||
@@ -278,7 +278,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
|
||||
float imat[4][4];
|
||||
|
||||
/* prevent crashes in these unlikely events */
|
||||
if (ob==NULL || mat==NULL) return;
|
||||
if (ob == NULL || mat == NULL) return;
|
||||
/* optimize trick - check if need to do anything */
|
||||
if (from == to) return;
|
||||
|
||||
@@ -298,8 +298,8 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
|
||||
constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */
|
||||
break;
|
||||
case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */
|
||||
{
|
||||
/* pose to world */
|
||||
if (to == CONSTRAINT_SPACE_WORLD) {
|
||||
@@ -331,7 +331,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case CONSTRAINT_SPACE_LOCAL: /* ------------ FROM LOCALSPACE --------- */
|
||||
{
|
||||
/* local to pose - do inverse procedure that was done for pose to local */
|
||||
@@ -351,7 +351,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
|
||||
constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */
|
||||
{
|
||||
/* local + parent to pose */
|
||||
@@ -366,12 +366,12 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
|
||||
constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* objects */
|
||||
if (from==CONSTRAINT_SPACE_WORLD && to==CONSTRAINT_SPACE_LOCAL) {
|
||||
if (from == CONSTRAINT_SPACE_WORLD && to == CONSTRAINT_SPACE_LOCAL) {
|
||||
/* check if object has a parent */
|
||||
if (ob->parent) {
|
||||
/* 'subtract' parent's effects from owner */
|
||||
@@ -391,7 +391,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
|
||||
mult_m4_m4m4(mat, imat, mat);
|
||||
}
|
||||
}
|
||||
else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) {
|
||||
else if (from == CONSTRAINT_SPACE_LOCAL && to == CONSTRAINT_SPACE_WORLD) {
|
||||
/* check that object has a parent - otherwise this won't work */
|
||||
if (ob->parent) {
|
||||
/* 'add' parent's effect back to owner */
|
||||
@@ -415,15 +415,15 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
|
||||
/* ------------ General Target Matrix Tools ---------- */
|
||||
|
||||
/* function that sets the given matrix based on given vertex group in mesh */
|
||||
static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4])
|
||||
static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[][4])
|
||||
{
|
||||
DerivedMesh *dm = NULL;
|
||||
Mesh *me= ob->data;
|
||||
Mesh *me = ob->data;
|
||||
BMEditMesh *em = me->edit_btmesh;
|
||||
float vec[3] = {0.0f, 0.0f, 0.0f};
|
||||
float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
|
||||
float imat[3][3], tmat[3][3];
|
||||
const int defgroup= defgroup_name_index(ob, substring);
|
||||
const int defgroup = defgroup_name_index(ob, substring);
|
||||
short freeDM = 0;
|
||||
|
||||
/* initialize target matrix using target matrix */
|
||||
@@ -436,7 +436,7 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat
|
||||
if (em) {
|
||||
/* target is in editmode, so get a special derived mesh */
|
||||
dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
|
||||
freeDM= 1;
|
||||
freeDM = 1;
|
||||
}
|
||||
else {
|
||||
/* when not in EditMode, use the 'final' derived mesh, depsgraph
|
||||
@@ -454,10 +454,10 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat
|
||||
|
||||
/* check that dvert is a valid pointers (just in case) */
|
||||
if (dvert) {
|
||||
MDeformVert *dv= dvert;
|
||||
MDeformVert *dv = dvert;
|
||||
/* get the average of all verts with that are in the vertex-group */
|
||||
for (i = 0; i < numVerts; i++, dv++) {
|
||||
MDeformWeight *dw= defvert_find_index(dv, defgroup);
|
||||
MDeformWeight *dw = defvert_find_index(dv, defgroup);
|
||||
if (dw && dw->weight != 0.0f) {
|
||||
dm->getVertCo(dm, i, co);
|
||||
dm->getVertNo(dm, i, nor);
|
||||
@@ -512,20 +512,20 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat
|
||||
}
|
||||
|
||||
/* function that sets the given matrix based on given vertex group in lattice */
|
||||
static void contarget_get_lattice_mat (Object *ob, const char *substring, float mat[][4])
|
||||
static void contarget_get_lattice_mat(Object *ob, const char *substring, float mat[][4])
|
||||
{
|
||||
Lattice *lt= (Lattice *)ob->data;
|
||||
Lattice *lt = (Lattice *)ob->data;
|
||||
|
||||
DispList *dl = find_displist(&ob->disp, DL_VERTS);
|
||||
float *co = dl?dl->verts:NULL;
|
||||
float *co = dl ? dl->verts : NULL;
|
||||
BPoint *bp = lt->def;
|
||||
|
||||
MDeformVert *dv = lt->dvert;
|
||||
int tot_verts= lt->pntsu*lt->pntsv*lt->pntsw;
|
||||
float vec[3]= {0.0f, 0.0f, 0.0f}, tvec[3];
|
||||
int grouped=0;
|
||||
int tot_verts = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3];
|
||||
int grouped = 0;
|
||||
int i, n;
|
||||
const int defgroup= defgroup_name_index(ob, substring);
|
||||
const int defgroup = defgroup_name_index(ob, substring);
|
||||
|
||||
/* initialize target matrix using target matrix */
|
||||
copy_m4_m4(mat, ob->obmat);
|
||||
@@ -537,9 +537,9 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float
|
||||
/* 1. Loop through control-points checking if in nominated vertex-group.
|
||||
* 2. If it is, add it to vec to find the average point.
|
||||
*/
|
||||
for (i=0; i < tot_verts; i++, dv++) {
|
||||
for (n= 0; n < dv->totweight; n++) {
|
||||
MDeformWeight *dw= defvert_find_index(dv, defgroup);
|
||||
for (i = 0; i < tot_verts; i++, dv++) {
|
||||
for (n = 0; n < dv->totweight; n++) {
|
||||
MDeformWeight *dw = defvert_find_index(dv, defgroup);
|
||||
if (dw && dw->weight > 0.0f) {
|
||||
/* copy coordinates of point to temporary vector, then add to find average */
|
||||
memcpy(tvec, co ? co : bp->vec, 3 * sizeof(float));
|
||||
@@ -551,7 +551,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float
|
||||
|
||||
/* advance pointer to coordinate data */
|
||||
if (co) co += 3;
|
||||
else bp++;
|
||||
else bp++;
|
||||
}
|
||||
|
||||
/* find average location, then multiply by ob->obmat to find world-space location */
|
||||
@@ -565,14 +565,14 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float
|
||||
|
||||
/* generic function to get the appropriate matrix for most target cases */
|
||||
/* The cases where the target can be object data have not been implemented */
|
||||
static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail)
|
||||
static void constraint_target_to_mat4(Object *ob, const char *substring, float mat[][4], short from, short to, float headtail)
|
||||
{
|
||||
/* Case OBJECT */
|
||||
if (!strlen(substring)) {
|
||||
copy_m4_m4(mat, ob->obmat);
|
||||
constraint_mat_convertspace(ob, NULL, mat, from, to);
|
||||
}
|
||||
/* Case VERTEXGROUP */
|
||||
/* Case VERTEXGROUP */
|
||||
/* Current method just takes the average location of all the points in the
|
||||
* VertexGroup, and uses that as the location value of the targets. Where
|
||||
* possible, the orientation will also be calculated, by calculating an
|
||||
@@ -631,14 +631,14 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float
|
||||
*/
|
||||
|
||||
/* Template for type-info data:
|
||||
* - make a copy of this when creating new constraints, and just change the functions
|
||||
* pointed to as necessary
|
||||
* - although the naming of functions doesn't matter, it would help for code
|
||||
* readability, to follow the same naming convention as is presented here
|
||||
* - any functions that a constraint doesn't need to define, don't define
|
||||
* for such cases, just use NULL
|
||||
* - these should be defined after all the functions have been defined, so that
|
||||
* forward-definitions/prototypes don't need to be used!
|
||||
* - make a copy of this when creating new constraints, and just change the functions
|
||||
* pointed to as necessary
|
||||
* - although the naming of functions doesn't matter, it would help for code
|
||||
* readability, to follow the same naming convention as is presented here
|
||||
* - any functions that a constraint doesn't need to define, don't define
|
||||
* for such cases, just use NULL
|
||||
* - these should be defined after all the functions have been defined, so that
|
||||
* forward-definitions/prototypes don't need to be used!
|
||||
* - keep this copy #if-def'd so that future constraints can get based off this
|
||||
*/
|
||||
#if 0
|
||||
@@ -661,7 +661,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = {
|
||||
/* This function should be used for the get_target_matrix member of all
|
||||
* constraints that are not picky about what happens to their target matrix.
|
||||
*/
|
||||
static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
if (VALID_CONS_TARGET(ct))
|
||||
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
|
||||
@@ -677,26 +677,26 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC
|
||||
// TODO: cope with getting rotation order...
|
||||
#define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \
|
||||
{ \
|
||||
ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
|
||||
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
|
||||
\
|
||||
ct->tar= datatar; \
|
||||
ct->tar = datatar; \
|
||||
BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \
|
||||
ct->space= con->tarspace; \
|
||||
ct->flag= CONSTRAINT_TAR_TEMP; \
|
||||
ct->space = con->tarspace; \
|
||||
ct->flag = CONSTRAINT_TAR_TEMP; \
|
||||
\
|
||||
if (ct->tar) { \
|
||||
if ((ct->tar->type==OB_ARMATURE) && (ct->subtarget[0])) { \
|
||||
bPoseChannel *pchan= BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); \
|
||||
if ((ct->tar->type == OB_ARMATURE) && (ct->subtarget[0])) { \
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); \
|
||||
ct->type = CONSTRAINT_OBTYPE_BONE; \
|
||||
ct->rotOrder= (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \
|
||||
}\
|
||||
ct->rotOrder = (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \
|
||||
} \
|
||||
else if (OB_TYPE_SUPPORT_VGROUP(ct->tar->type) && (ct->subtarget[0])) { \
|
||||
ct->type = CONSTRAINT_OBTYPE_VERT; \
|
||||
ct->rotOrder = EULER_ORDER_DEFAULT; \
|
||||
} \
|
||||
else {\
|
||||
else { \
|
||||
ct->type = CONSTRAINT_OBTYPE_OBJECT; \
|
||||
ct->rotOrder= ct->tar->rotmode; \
|
||||
ct->rotOrder = ct->tar->rotmode; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@@ -711,11 +711,11 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC
|
||||
// TODO: cope with getting rotation order...
|
||||
#define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \
|
||||
{ \
|
||||
ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
|
||||
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
|
||||
\
|
||||
ct->tar= datatar; \
|
||||
ct->space= con->tarspace; \
|
||||
ct->flag= CONSTRAINT_TAR_TEMP; \
|
||||
ct->tar = datatar; \
|
||||
ct->space = con->tarspace; \
|
||||
ct->flag = CONSTRAINT_TAR_TEMP; \
|
||||
\
|
||||
if (ct->tar) ct->type = CONSTRAINT_OBTYPE_OBJECT; \
|
||||
\
|
||||
@@ -733,13 +733,13 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC
|
||||
if (ct) { \
|
||||
bConstraintTarget *ctn = ct->next; \
|
||||
if (nocopy == 0) { \
|
||||
datatar= ct->tar; \
|
||||
datatar = ct->tar; \
|
||||
BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \
|
||||
con->tarspace= (char)ct->space; \
|
||||
con->tarspace = (char)ct->space; \
|
||||
} \
|
||||
\
|
||||
BLI_freelinkN(list, ct); \
|
||||
ct= ctn; \
|
||||
ct = ctn; \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -754,39 +754,39 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC
|
||||
if (ct) { \
|
||||
bConstraintTarget *ctn = ct->next; \
|
||||
if (nocopy == 0) { \
|
||||
datatar= ct->tar; \
|
||||
con->tarspace= (char)ct->space; \
|
||||
datatar = ct->tar; \
|
||||
con->tarspace = (char)ct->space; \
|
||||
} \
|
||||
\
|
||||
BLI_freelinkN(list, ct); \
|
||||
ct= ctn; \
|
||||
ct = ctn; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* --------- ChildOf Constraint ------------ */
|
||||
|
||||
static void childof_new_data (void *cdata)
|
||||
static void childof_new_data(void *cdata)
|
||||
{
|
||||
bChildOfConstraint *data= (bChildOfConstraint *)cdata;
|
||||
bChildOfConstraint *data = (bChildOfConstraint *)cdata;
|
||||
|
||||
data->flag = (CHILDOF_LOCX | CHILDOF_LOCY | CHILDOF_LOCZ |
|
||||
CHILDOF_ROTX |CHILDOF_ROTY | CHILDOF_ROTZ |
|
||||
CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ);
|
||||
CHILDOF_ROTX | CHILDOF_ROTY | CHILDOF_ROTZ |
|
||||
CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ);
|
||||
unit_m4(data->invmat);
|
||||
}
|
||||
|
||||
static void childof_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void childof_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bChildOfConstraint *data= con->data;
|
||||
bChildOfConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int childof_get_tars (bConstraint *con, ListBase *list)
|
||||
static int childof_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bChildOfConstraint *data= con->data;
|
||||
bChildOfConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -798,21 +798,21 @@ static int childof_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void childof_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void childof_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bChildOfConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bChildOfConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bChildOfConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bChildOfConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
@@ -849,15 +849,15 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
mat4_to_size(sizo, invmat);
|
||||
|
||||
/* disable channels not enabled */
|
||||
if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f;
|
||||
if (!(data->flag & CHILDOF_LOCY)) loc[1]= loco[1]= 0.0f;
|
||||
if (!(data->flag & CHILDOF_LOCZ)) loc[2]= loco[2]= 0.0f;
|
||||
if (!(data->flag & CHILDOF_ROTX)) eul[0]= eulo[0]= 0.0f;
|
||||
if (!(data->flag & CHILDOF_ROTY)) eul[1]= eulo[1]= 0.0f;
|
||||
if (!(data->flag & CHILDOF_ROTZ)) eul[2]= eulo[2]= 0.0f;
|
||||
if (!(data->flag & CHILDOF_SIZEX)) size[0]= sizo[0]= 1.0f;
|
||||
if (!(data->flag & CHILDOF_SIZEY)) size[1]= sizo[1]= 1.0f;
|
||||
if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f;
|
||||
if (!(data->flag & CHILDOF_LOCX)) loc[0] = loco[0] = 0.0f;
|
||||
if (!(data->flag & CHILDOF_LOCY)) loc[1] = loco[1] = 0.0f;
|
||||
if (!(data->flag & CHILDOF_LOCZ)) loc[2] = loco[2] = 0.0f;
|
||||
if (!(data->flag & CHILDOF_ROTX)) eul[0] = eulo[0] = 0.0f;
|
||||
if (!(data->flag & CHILDOF_ROTY)) eul[1] = eulo[1] = 0.0f;
|
||||
if (!(data->flag & CHILDOF_ROTZ)) eul[2] = eulo[2] = 0.0f;
|
||||
if (!(data->flag & CHILDOF_SIZEX)) size[0] = sizo[0] = 1.0f;
|
||||
if (!(data->flag & CHILDOF_SIZEY)) size[1] = sizo[1] = 1.0f;
|
||||
if (!(data->flag & CHILDOF_SIZEZ)) size[2] = sizo[2] = 1.0f;
|
||||
|
||||
/* make new target mat and offset mat */
|
||||
loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder);
|
||||
@@ -877,9 +877,9 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
/* without this, changes to scale and rotation can change location
|
||||
* of a parentless bone or a disconnected bone. Even though its set
|
||||
* to zero above. */
|
||||
if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0];
|
||||
if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1];
|
||||
if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2];
|
||||
if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0] = tempmat[3][0];
|
||||
if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1] = tempmat[3][1];
|
||||
if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2] = tempmat[3][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -902,26 +902,26 @@ static bConstraintTypeInfo CTI_CHILDOF = {
|
||||
|
||||
/* -------- TrackTo Constraint ------- */
|
||||
|
||||
static void trackto_new_data (void *cdata)
|
||||
static void trackto_new_data(void *cdata)
|
||||
{
|
||||
bTrackToConstraint *data= (bTrackToConstraint *)cdata;
|
||||
bTrackToConstraint *data = (bTrackToConstraint *)cdata;
|
||||
|
||||
data->reserved1 = TRACK_Y;
|
||||
data->reserved2 = UP_Z;
|
||||
}
|
||||
|
||||
static void trackto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void trackto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bTrackToConstraint *data= con->data;
|
||||
bTrackToConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int trackto_get_tars (bConstraint *con, ListBase *list)
|
||||
static int trackto_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bTrackToConstraint *data= con->data;
|
||||
bTrackToConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -933,11 +933,11 @@ static int trackto_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void trackto_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void trackto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bTrackToConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bTrackToConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
@@ -945,9 +945,9 @@ static void trackto_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
}
|
||||
|
||||
|
||||
static int basis_cross (int n, int m)
|
||||
static int basis_cross(int n, int m)
|
||||
{
|
||||
switch (n-m) {
|
||||
switch (n - m) {
|
||||
case 1:
|
||||
case -2:
|
||||
return 1;
|
||||
@@ -961,7 +961,7 @@ static int basis_cross (int n, int m)
|
||||
}
|
||||
}
|
||||
|
||||
static void vectomat (float *vec, float *target_up, short axis, short upflag, short flags, float m[][3])
|
||||
static void vectomat(float *vec, float *target_up, short axis, short upflag, short flags, float m[][3])
|
||||
{
|
||||
float n[3];
|
||||
float u[3]; /* vector specifying the up axis */
|
||||
@@ -1025,10 +1025,10 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh
|
||||
}
|
||||
|
||||
|
||||
static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bTrackToConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bTrackToConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float size[3], vec[3];
|
||||
@@ -1039,23 +1039,23 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
mat4_to_size(size, cob->matrix);
|
||||
|
||||
/* Clear the object's rotation */
|
||||
cob->matrix[0][0]=size[0];
|
||||
cob->matrix[0][1]=0;
|
||||
cob->matrix[0][2]=0;
|
||||
cob->matrix[1][0]=0;
|
||||
cob->matrix[1][1]=size[1];
|
||||
cob->matrix[1][2]=0;
|
||||
cob->matrix[2][0]=0;
|
||||
cob->matrix[2][1]=0;
|
||||
cob->matrix[2][2]=size[2];
|
||||
cob->matrix[0][0] = size[0];
|
||||
cob->matrix[0][1] = 0;
|
||||
cob->matrix[0][2] = 0;
|
||||
cob->matrix[1][0] = 0;
|
||||
cob->matrix[1][1] = size[1];
|
||||
cob->matrix[1][2] = 0;
|
||||
cob->matrix[2][0] = 0;
|
||||
cob->matrix[2][1] = 0;
|
||||
cob->matrix[2][2] = size[2];
|
||||
|
||||
/* targetmat[2] instead of ownermat[2] is passed to vectomat
|
||||
* for backwards compatibility it seems... (Aligorith)
|
||||
*/
|
||||
sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);
|
||||
vectomat(vec, ct->matrix[2],
|
||||
(short)data->reserved1, (short)data->reserved2,
|
||||
data->flags, totmat);
|
||||
(short)data->reserved1, (short)data->reserved2,
|
||||
data->flags, totmat);
|
||||
|
||||
copy_m4_m4(tmat, cob->matrix);
|
||||
mul_m4_m3m4(cob->matrix, totmat, tmat);
|
||||
@@ -1079,32 +1079,32 @@ static bConstraintTypeInfo CTI_TRACKTO = {
|
||||
|
||||
/* --------- Inverse-Kinemetics --------- */
|
||||
|
||||
static void kinematic_new_data (void *cdata)
|
||||
static void kinematic_new_data(void *cdata)
|
||||
{
|
||||
bKinematicConstraint *data= (bKinematicConstraint *)cdata;
|
||||
bKinematicConstraint *data = (bKinematicConstraint *)cdata;
|
||||
|
||||
data->weight= 1.0f;
|
||||
data->orientweight= 1.0f;
|
||||
data->weight = 1.0f;
|
||||
data->orientweight = 1.0f;
|
||||
data->iterations = 500;
|
||||
data->dist= 1.0f;
|
||||
data->flag= CONSTRAINT_IK_TIP|CONSTRAINT_IK_STRETCH|CONSTRAINT_IK_POS;
|
||||
data->dist = 1.0f;
|
||||
data->flag = CONSTRAINT_IK_TIP | CONSTRAINT_IK_STRETCH | CONSTRAINT_IK_POS;
|
||||
}
|
||||
|
||||
static void kinematic_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void kinematic_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bKinematicConstraint *data= con->data;
|
||||
bKinematicConstraint *data = con->data;
|
||||
|
||||
/* chain target */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
|
||||
/* poletarget */
|
||||
func(con, (ID**)&data->poletar, FALSE, userdata);
|
||||
func(con, (ID **)&data->poletar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int kinematic_get_tars (bConstraint *con, ListBase *list)
|
||||
static int kinematic_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bKinematicConstraint *data= con->data;
|
||||
bKinematicConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints is used twice here */
|
||||
@@ -1117,11 +1117,11 @@ static int kinematic_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kinematic_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void kinematic_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bKinematicConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bKinematicConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
@@ -1129,15 +1129,15 @@ static void kinematic_flush_tars (bConstraint *con, ListBase *list, short nocopy
|
||||
}
|
||||
}
|
||||
|
||||
static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void kinematic_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
bKinematicConstraint *data= con->data;
|
||||
bKinematicConstraint *data = con->data;
|
||||
|
||||
if (VALID_CONS_TARGET(ct))
|
||||
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
|
||||
else if (ct) {
|
||||
if (data->flag & CONSTRAINT_IK_AUTO) {
|
||||
Object *ob= cob->ob;
|
||||
Object *ob = cob->ob;
|
||||
|
||||
if (ob == NULL) {
|
||||
unit_m4(ct->matrix);
|
||||
@@ -1172,9 +1172,9 @@ static bConstraintTypeInfo CTI_KINEMATIC = {
|
||||
|
||||
/* -------- Follow-Path Constraint ---------- */
|
||||
|
||||
static void followpath_new_data (void *cdata)
|
||||
static void followpath_new_data(void *cdata)
|
||||
{
|
||||
bFollowPathConstraint *data= (bFollowPathConstraint *)cdata;
|
||||
bFollowPathConstraint *data = (bFollowPathConstraint *)cdata;
|
||||
|
||||
data->trackflag = TRACK_Y;
|
||||
data->upflag = UP_Z;
|
||||
@@ -1182,18 +1182,18 @@ static void followpath_new_data (void *cdata)
|
||||
data->followflag = 0;
|
||||
}
|
||||
|
||||
static void followpath_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void followpath_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bFollowPathConstraint *data= con->data;
|
||||
bFollowPathConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int followpath_get_tars (bConstraint *con, ListBase *list)
|
||||
static int followpath_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bFollowPathConstraint *data= con->data;
|
||||
bFollowPathConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints without subtargets */
|
||||
@@ -1205,25 +1205,25 @@ static int followpath_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void followpath_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void followpath_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bFollowPathConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bFollowPathConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
bFollowPathConstraint *data= con->data;
|
||||
bFollowPathConstraint *data = con->data;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
Curve *cu= ct->tar->data;
|
||||
Curve *cu = ct->tar->data;
|
||||
float vec[4], dir[3], radius;
|
||||
float totmat[4][4]= MAT4_UNITY;
|
||||
float totmat[4][4] = MAT4_UNITY;
|
||||
float curvetime;
|
||||
|
||||
unit_m4(ct->matrix);
|
||||
@@ -1233,7 +1233,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
*/
|
||||
|
||||
/* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (cu->path==NULL || cu->path->data==NULL)
|
||||
if (cu->path == NULL || cu->path->data == NULL)
|
||||
makeDispListCurveTypes(cob->scene, ct->tar, 0);
|
||||
|
||||
if (cu->path && cu->path->data) {
|
||||
@@ -1241,7 +1241,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
|
||||
/* animated position along curve depending on time */
|
||||
Nurb *nu = cu->nurb.first;
|
||||
curvetime= cu->ctime - data->offset;
|
||||
curvetime = cu->ctime - data->offset;
|
||||
|
||||
/* 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...
|
||||
@@ -1265,21 +1265,21 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
}
|
||||
else {
|
||||
/* fixed position along curve */
|
||||
curvetime= data->offset_fac;
|
||||
curvetime = data->offset_fac;
|
||||
}
|
||||
|
||||
if ( where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/
|
||||
if (where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/
|
||||
if (data->followflag & FOLLOWPATH_FOLLOW) {
|
||||
#if 0
|
||||
float x1, q[4];
|
||||
vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag);
|
||||
|
||||
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, data->trackflag, data->upflag);
|
||||
@@ -1305,15 +1305,15 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
unit_m4(ct->matrix);
|
||||
}
|
||||
|
||||
static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float obmat[4][4];
|
||||
float size[3];
|
||||
bFollowPathConstraint *data= con->data;
|
||||
bFollowPathConstraint *data = con->data;
|
||||
|
||||
/* get Object transform (loc/rot/size) to determine transformation from path */
|
||||
// TODO: this used to be local at one point, but is probably more useful as-is
|
||||
@@ -1326,7 +1326,7 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
mul_serie_m4(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* un-apply scaling caused by path */
|
||||
if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */
|
||||
if ((data->followflag & FOLLOWPATH_RADIUS) == 0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */
|
||||
float obsize[3];
|
||||
|
||||
mat4_to_size(obsize, cob->matrix);
|
||||
@@ -1358,7 +1358,7 @@ static bConstraintTypeInfo CTI_FOLLOWPATH = {
|
||||
/* --------- Limit Location --------- */
|
||||
|
||||
|
||||
static void loclimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
static void loclimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
{
|
||||
bLocLimitConstraint *data = con->data;
|
||||
|
||||
@@ -1405,7 +1405,7 @@ static bConstraintTypeInfo CTI_LOCLIMIT = {
|
||||
|
||||
/* -------- Limit Rotation --------- */
|
||||
|
||||
static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
{
|
||||
bRotLimitConstraint *data = con->data;
|
||||
float loc[3];
|
||||
@@ -1463,7 +1463,7 @@ static bConstraintTypeInfo CTI_ROTLIMIT = {
|
||||
/* --------- Limit Scaling --------- */
|
||||
|
||||
|
||||
static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
{
|
||||
bSizeLimitConstraint *data = con->data;
|
||||
float obsize[3], size[3];
|
||||
@@ -1497,11 +1497,11 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
}
|
||||
|
||||
if (obsize[0])
|
||||
mul_v3_fl(cob->matrix[0], size[0]/obsize[0]);
|
||||
mul_v3_fl(cob->matrix[0], size[0] / obsize[0]);
|
||||
if (obsize[1])
|
||||
mul_v3_fl(cob->matrix[1], size[1]/obsize[1]);
|
||||
mul_v3_fl(cob->matrix[1], size[1] / obsize[1]);
|
||||
if (obsize[2])
|
||||
mul_v3_fl(cob->matrix[2], size[2]/obsize[2]);
|
||||
mul_v3_fl(cob->matrix[2], size[2] / obsize[2]);
|
||||
}
|
||||
|
||||
static bConstraintTypeInfo CTI_SIZELIMIT = {
|
||||
@@ -1521,25 +1521,25 @@ static bConstraintTypeInfo CTI_SIZELIMIT = {
|
||||
|
||||
/* ----------- Copy Location ------------- */
|
||||
|
||||
static void loclike_new_data (void *cdata)
|
||||
static void loclike_new_data(void *cdata)
|
||||
{
|
||||
bLocateLikeConstraint *data= (bLocateLikeConstraint *)cdata;
|
||||
bLocateLikeConstraint *data = (bLocateLikeConstraint *)cdata;
|
||||
|
||||
data->flag = LOCLIKE_X|LOCLIKE_Y|LOCLIKE_Z;
|
||||
data->flag = LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z;
|
||||
}
|
||||
|
||||
static void loclike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void loclike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bLocateLikeConstraint *data= con->data;
|
||||
bLocateLikeConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int loclike_get_tars (bConstraint *con, ListBase *list)
|
||||
static int loclike_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bLocateLikeConstraint *data= con->data;
|
||||
bLocateLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -1551,21 +1551,21 @@ static int loclike_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void loclike_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void loclike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bLocateLikeConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bLocateLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void loclike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void loclike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bLocateLikeConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bLocateLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float offset[3] = {0.0f, 0.0f, 0.0f};
|
||||
@@ -1611,25 +1611,25 @@ static bConstraintTypeInfo CTI_LOCLIKE = {
|
||||
|
||||
/* ----------- Copy Rotation ------------- */
|
||||
|
||||
static void rotlike_new_data (void *cdata)
|
||||
static void rotlike_new_data(void *cdata)
|
||||
{
|
||||
bRotateLikeConstraint *data= (bRotateLikeConstraint *)cdata;
|
||||
bRotateLikeConstraint *data = (bRotateLikeConstraint *)cdata;
|
||||
|
||||
data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
|
||||
data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
|
||||
}
|
||||
|
||||
static void rotlike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void rotlike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bChildOfConstraint *data= con->data;
|
||||
bChildOfConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int rotlike_get_tars (bConstraint *con, ListBase *list)
|
||||
static int rotlike_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bRotateLikeConstraint *data= con->data;
|
||||
bRotateLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -1641,26 +1641,26 @@ static int rotlike_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rotlike_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void rotlike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bRotateLikeConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bRotateLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bRotateLikeConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bRotateLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float loc[3];
|
||||
float eul[3], obeul[3];
|
||||
float size[3];
|
||||
float loc[3];
|
||||
float eul[3], obeul[3];
|
||||
float size[3];
|
||||
|
||||
copy_v3_v3(loc, cob->matrix[3]);
|
||||
mat4_to_size(size, cob->matrix);
|
||||
@@ -1670,7 +1670,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
/* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */
|
||||
mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix);
|
||||
|
||||
if ((data->flag & ROTLIKE_X)==0)
|
||||
if ((data->flag & ROTLIKE_X) == 0)
|
||||
eul[0] = obeul[0];
|
||||
else {
|
||||
if (data->flag & ROTLIKE_OFFSET)
|
||||
@@ -1680,7 +1680,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
eul[0] *= -1;
|
||||
}
|
||||
|
||||
if ((data->flag & ROTLIKE_Y)==0)
|
||||
if ((data->flag & ROTLIKE_Y) == 0)
|
||||
eul[1] = obeul[1];
|
||||
else {
|
||||
if (data->flag & ROTLIKE_OFFSET)
|
||||
@@ -1690,7 +1690,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
eul[1] *= -1;
|
||||
}
|
||||
|
||||
if ((data->flag & ROTLIKE_Z)==0)
|
||||
if ((data->flag & ROTLIKE_Z) == 0)
|
||||
eul[2] = obeul[2];
|
||||
else {
|
||||
if (data->flag & ROTLIKE_OFFSET)
|
||||
@@ -1723,25 +1723,25 @@ static bConstraintTypeInfo CTI_ROTLIKE = {
|
||||
|
||||
/* ---------- Copy Scaling ---------- */
|
||||
|
||||
static void sizelike_new_data (void *cdata)
|
||||
static void sizelike_new_data(void *cdata)
|
||||
{
|
||||
bSizeLikeConstraint *data= (bSizeLikeConstraint *)cdata;
|
||||
bSizeLikeConstraint *data = (bSizeLikeConstraint *)cdata;
|
||||
|
||||
data->flag = SIZELIKE_X|SIZELIKE_Y|SIZELIKE_Z;
|
||||
data->flag = SIZELIKE_X | SIZELIKE_Y | SIZELIKE_Z;
|
||||
}
|
||||
|
||||
static void sizelike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void sizelike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bSizeLikeConstraint *data= con->data;
|
||||
bSizeLikeConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int sizelike_get_tars (bConstraint *con, ListBase *list)
|
||||
static int sizelike_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bSizeLikeConstraint *data= con->data;
|
||||
bSizeLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -1753,21 +1753,21 @@ static int sizelike_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sizelike_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void sizelike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bSizeLikeConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bSizeLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void sizelike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void sizelike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bSizeLikeConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bSizeLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float obsize[3], size[3];
|
||||
@@ -1819,18 +1819,18 @@ static bConstraintTypeInfo CTI_SIZELIKE = {
|
||||
|
||||
/* ----------- Copy Transforms ------------- */
|
||||
|
||||
static void translike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void translike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bTransLikeConstraint *data= con->data;
|
||||
bTransLikeConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int translike_get_tars (bConstraint *con, ListBase *list)
|
||||
static int translike_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bTransLikeConstraint *data= con->data;
|
||||
bTransLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -1842,20 +1842,20 @@ static int translike_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void translike_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void translike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bTransLikeConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bTransLikeConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void translike_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
||||
static void translike_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
/* just copy the entire transform matrix of the target */
|
||||
@@ -1880,17 +1880,17 @@ static bConstraintTypeInfo CTI_TRANSLIKE = {
|
||||
|
||||
/* ---------- Maintain Volume ---------- */
|
||||
|
||||
static void samevolume_new_data (void *cdata)
|
||||
static void samevolume_new_data(void *cdata)
|
||||
{
|
||||
bSameVolumeConstraint *data= (bSameVolumeConstraint *)cdata;
|
||||
bSameVolumeConstraint *data = (bSameVolumeConstraint *)cdata;
|
||||
|
||||
data->flag = SAMEVOL_Y;
|
||||
data->volume = 1.0f;
|
||||
}
|
||||
|
||||
static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
{
|
||||
bSameVolumeConstraint *data= con->data;
|
||||
bSameVolumeConstraint *data = con->data;
|
||||
|
||||
float volume = data->volume;
|
||||
float fac = 1.0f;
|
||||
@@ -1936,9 +1936,9 @@ static bConstraintTypeInfo CTI_SAMEVOL = {
|
||||
|
||||
/* ----------- Python Constraint -------------- */
|
||||
|
||||
static void pycon_free (bConstraint *con)
|
||||
static void pycon_free(bConstraint *con)
|
||||
{
|
||||
bPythonConstraint *data= con->data;
|
||||
bPythonConstraint *data = con->data;
|
||||
|
||||
/* id-properties */
|
||||
IDP_FreeProperty(data->prop);
|
||||
@@ -1948,7 +1948,7 @@ static void pycon_free (bConstraint *con)
|
||||
BLI_freelistN(&data->targets);
|
||||
}
|
||||
|
||||
static void pycon_copy (bConstraint *con, bConstraint *srccon)
|
||||
static void pycon_copy(bConstraint *con, bConstraint *srccon)
|
||||
{
|
||||
bPythonConstraint *pycon = (bPythonConstraint *)con->data;
|
||||
bPythonConstraint *opycon = (bPythonConstraint *)srccon->data;
|
||||
@@ -1957,19 +1957,19 @@ static void pycon_copy (bConstraint *con, bConstraint *srccon)
|
||||
BLI_duplicatelist(&pycon->targets, &opycon->targets);
|
||||
}
|
||||
|
||||
static void pycon_new_data (void *cdata)
|
||||
static void pycon_new_data(void *cdata)
|
||||
{
|
||||
bPythonConstraint *data= (bPythonConstraint *)cdata;
|
||||
bPythonConstraint *data = (bPythonConstraint *)cdata;
|
||||
|
||||
/* everything should be set correctly by calloc, except for the prop->type constant.*/
|
||||
data->prop = MEM_callocN(sizeof(IDProperty), "PyConstraintProps");
|
||||
data->prop->type = IDP_GROUP;
|
||||
}
|
||||
|
||||
static int pycon_get_tars (bConstraint *con, ListBase *list)
|
||||
static int pycon_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bPythonConstraint *data= con->data;
|
||||
bPythonConstraint *data = con->data;
|
||||
|
||||
list->first = data->targets.first;
|
||||
list->last = data->targets.last;
|
||||
@@ -1980,33 +1980,33 @@ static int pycon_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bPythonConstraint *data= con->data;
|
||||
bPythonConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* targets */
|
||||
for (ct= data->targets.first; ct; ct= ct->next)
|
||||
func(con, (ID**)&ct->tar, FALSE, userdata);
|
||||
for (ct = data->targets.first; ct; ct = ct->next)
|
||||
func(con, (ID **)&ct->tar, FALSE, userdata);
|
||||
|
||||
/* script */
|
||||
func(con, (ID**)&data->text, TRUE, userdata);
|
||||
func(con, (ID **)&data->text, TRUE, userdata);
|
||||
}
|
||||
|
||||
/* Whether this approach is maintained remains to be seen (aligorith) */
|
||||
static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
bPythonConstraint *data= con->data;
|
||||
bPythonConstraint *data = con->data;
|
||||
#endif
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
/* special exception for curves - depsgraph issues */
|
||||
if (ct->tar->type == OB_CURVE) {
|
||||
Curve *cu= ct->tar->data;
|
||||
Curve *cu = ct->tar->data;
|
||||
|
||||
/* this check is to make sure curve objects get updated on file load correctly.*/
|
||||
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(cob->scene, ct->tar, 0);
|
||||
}
|
||||
|
||||
@@ -2025,16 +2025,16 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT
|
||||
unit_m4(ct->matrix);
|
||||
}
|
||||
|
||||
static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
#ifndef WITH_PYTHON
|
||||
(void)con; (void)cob; (void)targets; /* unused */
|
||||
return;
|
||||
#else
|
||||
bPythonConstraint *data= con->data;
|
||||
bPythonConstraint *data = con->data;
|
||||
|
||||
/* only evaluate in python if we're allowed to do so */
|
||||
if ((G.f & G_SCRIPT_AUTOEXEC)==0) return;
|
||||
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) return;
|
||||
|
||||
/* currently removed, until I this can be re-implemented for multiple targets */
|
||||
#if 0
|
||||
@@ -2067,29 +2067,29 @@ static bConstraintTypeInfo CTI_PYTHON = {
|
||||
|
||||
/* -------- Action Constraint ----------- */
|
||||
|
||||
static void actcon_new_data (void *cdata)
|
||||
static void actcon_new_data(void *cdata)
|
||||
{
|
||||
bActionConstraint *data= (bActionConstraint *)cdata;
|
||||
bActionConstraint *data = (bActionConstraint *)cdata;
|
||||
|
||||
/* set type to 20 (Loc X), as 0 is Rot X for backwards compatibility */
|
||||
data->type = 20;
|
||||
}
|
||||
|
||||
static void actcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void actcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bActionConstraint *data= con->data;
|
||||
bActionConstraint *data = con->data;
|
||||
|
||||
/* target */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
|
||||
/* action */
|
||||
func(con, (ID**)&data->act, TRUE, userdata);
|
||||
func(con, (ID **)&data->act, TRUE, userdata);
|
||||
}
|
||||
|
||||
static int actcon_get_tars (bConstraint *con, ListBase *list)
|
||||
static int actcon_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bActionConstraint *data= con->data;
|
||||
bActionConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -2101,18 +2101,18 @@ static int actcon_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void actcon_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void actcon_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bActionConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bActionConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
bActionConstraint *data = con->data;
|
||||
|
||||
@@ -2130,33 +2130,33 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
|
||||
/* determine where in transform range target is */
|
||||
/* data->type is mapped as follows for backwards compatibility:
|
||||
* 00,01,02 - rotation (it used to be like this)
|
||||
* 10,11,12 - scaling
|
||||
* 10,11,12 - scaling
|
||||
* 20,21,22 - location
|
||||
*/
|
||||
if (data->type < 10) {
|
||||
/* extract rotation (is in whatever space target should be in) */
|
||||
mat4_to_eul(vec, tempmat);
|
||||
mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */
|
||||
axis= data->type;
|
||||
axis = data->type;
|
||||
}
|
||||
else if (data->type < 20) {
|
||||
/* extract scaling (is in whatever space target should be in) */
|
||||
mat4_to_size(vec, tempmat);
|
||||
axis= data->type - 10;
|
||||
axis = data->type - 10;
|
||||
}
|
||||
else {
|
||||
/* extract location */
|
||||
copy_v3_v3(vec, tempmat[3]);
|
||||
axis= data->type - 20;
|
||||
axis = data->type - 20;
|
||||
}
|
||||
|
||||
/* Target defines the animation */
|
||||
s = (vec[axis]-data->min) / (data->max-data->min);
|
||||
s = (vec[axis] - data->min) / (data->max - data->min);
|
||||
CLAMP(s, 0, 1);
|
||||
t = (s * (data->end-data->start)) + data->start;
|
||||
t = (s * (data->end - data->start)) + data->start;
|
||||
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name+2, (cob->pchan)?cob->pchan->name:NULL);
|
||||
printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name + 2, (cob->pchan) ? cob->pchan->name : NULL);
|
||||
|
||||
/* Get the appropriate information from the action */
|
||||
if (cob->type == CONSTRAINT_OBTYPE_BONE) {
|
||||
@@ -2172,8 +2172,8 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
|
||||
*/
|
||||
pchan = cob->pchan;
|
||||
|
||||
tchan= BKE_pose_channel_verify(pose, pchan->name);
|
||||
tchan->rotmode= pchan->rotmode;
|
||||
tchan = BKE_pose_channel_verify(pose, pchan->name);
|
||||
tchan->rotmode = pchan->rotmode;
|
||||
|
||||
/* evaluate action using workob (it will only set the PoseChannel in question) */
|
||||
what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t);
|
||||
@@ -2200,9 +2200,9 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
|
||||
}
|
||||
}
|
||||
|
||||
static void actcon_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
||||
static void actcon_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float temp[4][4];
|
||||
@@ -2232,26 +2232,26 @@ static bConstraintTypeInfo CTI_ACTION = {
|
||||
|
||||
/* --------- Locked Track ---------- */
|
||||
|
||||
static void locktrack_new_data (void *cdata)
|
||||
static void locktrack_new_data(void *cdata)
|
||||
{
|
||||
bLockTrackConstraint *data= (bLockTrackConstraint *)cdata;
|
||||
bLockTrackConstraint *data = (bLockTrackConstraint *)cdata;
|
||||
|
||||
data->trackflag = TRACK_Y;
|
||||
data->lockflag = LOCK_Z;
|
||||
}
|
||||
|
||||
static void locktrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void locktrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bLockTrackConstraint *data= con->data;
|
||||
bLockTrackConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int locktrack_get_tars (bConstraint *con, ListBase *list)
|
||||
static int locktrack_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bLockTrackConstraint *data= con->data;
|
||||
bLockTrackConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
@@ -2263,21 +2263,21 @@ static int locktrack_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void locktrack_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void locktrack_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bLockTrackConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bLockTrackConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bLockTrackConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bLockTrackConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float vec[3], vec2[3];
|
||||
@@ -2290,217 +2290,217 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
/* Vector object -> target */
|
||||
sub_v3_v3v3(vec, ct->matrix[3], cob->matrix[3]);
|
||||
switch (data->lockflag) {
|
||||
case LOCK_X: /* LOCK X */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_Y: /* LOCK X TRACK Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
case LOCK_X: /* LOCK X */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_Y: /* LOCK X TRACK Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_Z: /* LOCK X TRACK Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
case TRACK_Z: /* LOCK X TRACK Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nY: /* LOCK X TRACK -Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
negate_v3(totmat[1]);
|
||||
case TRACK_nY: /* LOCK X TRACK -Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
negate_v3(totmat[1]);
|
||||
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nZ: /* LOCK X TRACK -Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
negate_v3(totmat[2]);
|
||||
case TRACK_nZ: /* LOCK X TRACK -Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
negate_v3(totmat[2]);
|
||||
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
/* the x axis is fixed */
|
||||
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LOCK_Y: /* LOCK Y */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_X: /* LOCK Y TRACK X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
case LOCK_Y: /* LOCK Y */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_X: /* LOCK Y TRACK X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_Z: /* LOCK Y TRACK Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
case TRACK_Z: /* LOCK Y TRACK Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nX: /* LOCK Y TRACK -X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
negate_v3(totmat[0]);
|
||||
case TRACK_nX: /* LOCK Y TRACK -X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
negate_v3(totmat[0]);
|
||||
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nZ: /* LOCK Y TRACK -Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
negate_v3(totmat[2]);
|
||||
case TRACK_nZ: /* LOCK Y TRACK -Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
||||
sub_v3_v3v3(totmat[2], vec, vec2);
|
||||
normalize_v3(totmat[2]);
|
||||
negate_v3(totmat[2]);
|
||||
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
/* the y axis is fixed */
|
||||
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
||||
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
/* the z axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LOCK_Z: /* LOCK Z */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_X: /* LOCK Z TRACK X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
case LOCK_Z: /* LOCK Z */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_X: /* LOCK Z TRACK X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
case TRACK_Y: /* LOCK Z TRACK Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
case TRACK_Y: /* LOCK Z TRACK Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nX: /* LOCK Z TRACK -X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
negate_v3(totmat[0]);
|
||||
case TRACK_nX: /* LOCK Z TRACK -X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[0], vec, vec2);
|
||||
normalize_v3(totmat[0]);
|
||||
negate_v3(totmat[0]);
|
||||
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nY: /* LOCK Z TRACK -Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
negate_v3(totmat[1]);
|
||||
case TRACK_nY: /* LOCK Z TRACK -Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
||||
sub_v3_v3v3(totmat[1], vec, vec2);
|
||||
normalize_v3(totmat[1]);
|
||||
negate_v3(totmat[1]);
|
||||
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
/* the z axis is fixed */
|
||||
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
||||
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
/* the x axis gets mapped onto a third orthogonal vector */
|
||||
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
default:
|
||||
{
|
||||
unit_m3(totmat);
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* Block to keep matrix heading */
|
||||
@@ -2508,16 +2508,16 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
normalize_m3(tmpmat);
|
||||
invert_m3_m3(invmat, tmpmat);
|
||||
mul_m3_m3m3(tmpmat, totmat, invmat);
|
||||
totmat[0][0] = tmpmat[0][0];totmat[0][1] = tmpmat[0][1];totmat[0][2] = tmpmat[0][2];
|
||||
totmat[1][0] = tmpmat[1][0];totmat[1][1] = tmpmat[1][1];totmat[1][2] = tmpmat[1][2];
|
||||
totmat[2][0] = tmpmat[2][0];totmat[2][1] = tmpmat[2][1];totmat[2][2] = tmpmat[2][2];
|
||||
totmat[0][0] = tmpmat[0][0]; totmat[0][1] = tmpmat[0][1]; totmat[0][2] = tmpmat[0][2];
|
||||
totmat[1][0] = tmpmat[1][0]; totmat[1][1] = tmpmat[1][1]; totmat[1][2] = tmpmat[1][2];
|
||||
totmat[2][0] = tmpmat[2][0]; totmat[2][1] = tmpmat[2][1]; totmat[2][2] = tmpmat[2][2];
|
||||
|
||||
copy_m4_m4(tmat, cob->matrix);
|
||||
|
||||
mdet = determinant_m3(totmat[0][0], totmat[0][1], totmat[0][2],
|
||||
totmat[1][0], totmat[1][1], totmat[1][2],
|
||||
totmat[2][0], totmat[2][1], totmat[2][2]);
|
||||
if (mdet==0) {
|
||||
if (mdet == 0) {
|
||||
unit_m3(totmat);
|
||||
}
|
||||
|
||||
@@ -2543,25 +2543,25 @@ static bConstraintTypeInfo CTI_LOCKTRACK = {
|
||||
|
||||
/* ---------- Limit Distance Constraint ----------- */
|
||||
|
||||
static void distlimit_new_data (void *cdata)
|
||||
static void distlimit_new_data(void *cdata)
|
||||
{
|
||||
bDistLimitConstraint *data= (bDistLimitConstraint *)cdata;
|
||||
bDistLimitConstraint *data = (bDistLimitConstraint *)cdata;
|
||||
|
||||
data->dist= 0.0f;
|
||||
data->dist = 0.0f;
|
||||
}
|
||||
|
||||
static void distlimit_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void distlimit_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bDistLimitConstraint *data= con->data;
|
||||
bDistLimitConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int distlimit_get_tars (bConstraint *con, ListBase *list)
|
||||
static int distlimit_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bDistLimitConstraint *data= con->data;
|
||||
bDistLimitConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -2573,40 +2573,40 @@ static int distlimit_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void distlimit_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void distlimit_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bDistLimitConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bDistLimitConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bDistLimitConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bDistLimitConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float dvec[3], dist=0.0f, sfac=1.0f;
|
||||
short clamp_surf= 0;
|
||||
float dvec[3], dist = 0.0f, sfac = 1.0f;
|
||||
short clamp_surf = 0;
|
||||
|
||||
/* calculate our current distance from the target */
|
||||
dist= len_v3v3(cob->matrix[3], ct->matrix[3]);
|
||||
dist = len_v3v3(cob->matrix[3], ct->matrix[3]);
|
||||
|
||||
/* set distance (flag is only set when user demands it) */
|
||||
if (data->dist == 0)
|
||||
data->dist= dist;
|
||||
data->dist = dist;
|
||||
|
||||
/* check if we're which way to clamp from, and calculate interpolation factor (if needed) */
|
||||
if (data->mode == LIMITDIST_OUTSIDE) {
|
||||
/* if inside, then move to surface */
|
||||
if (dist <= data->dist) {
|
||||
clamp_surf= 1;
|
||||
if (dist != 0.0f) sfac= data->dist / dist;
|
||||
clamp_surf = 1;
|
||||
if (dist != 0.0f) sfac = data->dist / dist;
|
||||
}
|
||||
/* if soft-distance is enabled, start fading once owner is dist+softdist from the target */
|
||||
else if (data->flag & LIMITDIST_USESOFT) {
|
||||
@@ -2618,24 +2618,24 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
else if (data->mode == LIMITDIST_INSIDE) {
|
||||
/* if outside, then move to surface */
|
||||
if (dist >= data->dist) {
|
||||
clamp_surf= 1;
|
||||
if (dist != 0.0f) sfac= data->dist / dist;
|
||||
clamp_surf = 1;
|
||||
if (dist != 0.0f) sfac = data->dist / dist;
|
||||
}
|
||||
/* if soft-distance is enabled, start fading once owner is dist-soft from the target */
|
||||
else if (data->flag & LIMITDIST_USESOFT) {
|
||||
// FIXME: there's a problem with "jumping" when this kicks in
|
||||
if (dist >= (data->dist - data->soft)) {
|
||||
sfac = (float)( data->soft*(1.0f - expf(-(dist - data->dist)/data->soft)) + data->dist );
|
||||
sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist);
|
||||
if (dist != 0.0f) sfac /= dist;
|
||||
|
||||
clamp_surf= 1;
|
||||
clamp_surf = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (IS_EQF(dist, data->dist)==0) {
|
||||
clamp_surf= 1;
|
||||
if (dist != 0.0f) sfac= data->dist / dist;
|
||||
if (IS_EQF(dist, data->dist) == 0) {
|
||||
clamp_surf = 1;
|
||||
if (dist != 0.0f) sfac = data->dist / dist;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2667,9 +2667,9 @@ static bConstraintTypeInfo CTI_DISTLIMIT = {
|
||||
|
||||
/* ---------- Stretch To ------------ */
|
||||
|
||||
static void stretchto_new_data (void *cdata)
|
||||
static void stretchto_new_data(void *cdata)
|
||||
{
|
||||
bStretchToConstraint *data= (bStretchToConstraint *)cdata;
|
||||
bStretchToConstraint *data = (bStretchToConstraint *)cdata;
|
||||
|
||||
data->volmode = 0;
|
||||
data->plane = 0;
|
||||
@@ -2677,18 +2677,18 @@ static void stretchto_new_data (void *cdata)
|
||||
data->bulge = 1.0;
|
||||
}
|
||||
|
||||
static void stretchto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void stretchto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bStretchToConstraint *data= con->data;
|
||||
bStretchToConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int stretchto_get_tars (bConstraint *con, ListBase *list)
|
||||
static int stretchto_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bStretchToConstraint *data= con->data;
|
||||
bStretchToConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -2700,21 +2700,21 @@ static int stretchto_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void stretchto_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void stretchto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bStretchToConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bStretchToConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bStretchToConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bStretchToConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
@@ -2750,40 +2750,40 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
if (data->bulge == 0)
|
||||
data->bulge = 1.0;
|
||||
|
||||
scale[1] = dist/data->orglength;
|
||||
scale[1] = dist / data->orglength;
|
||||
switch (data->volmode) {
|
||||
/* volume preserving scaling */
|
||||
case VOLUME_XZ :
|
||||
scale[0] = 1.0f - (float)sqrt(data->bulge) + (float)sqrt(data->bulge*(data->orglength/dist));
|
||||
scale[2] = scale[0];
|
||||
break;
|
||||
case VOLUME_X:
|
||||
scale[0] = 1.0f + data->bulge * (data->orglength /dist - 1);
|
||||
scale[2] = 1.0;
|
||||
break;
|
||||
case VOLUME_Z:
|
||||
scale[0] = 1.0;
|
||||
scale[2] = 1.0f + data->bulge * (data->orglength /dist - 1);
|
||||
break;
|
||||
/* volume preserving scaling */
|
||||
case VOLUME_XZ:
|
||||
scale[0] = 1.0f - (float)sqrt(data->bulge) + (float)sqrt(data->bulge * (data->orglength / dist));
|
||||
scale[2] = scale[0];
|
||||
break;
|
||||
case VOLUME_X:
|
||||
scale[0] = 1.0f + data->bulge * (data->orglength / dist - 1);
|
||||
scale[2] = 1.0;
|
||||
break;
|
||||
case VOLUME_Z:
|
||||
scale[0] = 1.0;
|
||||
scale[2] = 1.0f + data->bulge * (data->orglength / dist - 1);
|
||||
break;
|
||||
/* don't care for volume */
|
||||
case NO_VOLUME:
|
||||
scale[0] = 1.0;
|
||||
scale[2] = 1.0;
|
||||
break;
|
||||
default: /* should not happen, but in case*/
|
||||
return;
|
||||
case NO_VOLUME:
|
||||
scale[0] = 1.0;
|
||||
scale[2] = 1.0;
|
||||
break;
|
||||
default: /* should not happen, but in case*/
|
||||
return;
|
||||
} /* switch (data->volmode) */
|
||||
|
||||
/* Clear the object's rotation and scale */
|
||||
cob->matrix[0][0]=size[0]*scale[0];
|
||||
cob->matrix[0][1]=0;
|
||||
cob->matrix[0][2]=0;
|
||||
cob->matrix[1][0]=0;
|
||||
cob->matrix[1][1]=size[1]*scale[1];
|
||||
cob->matrix[1][2]=0;
|
||||
cob->matrix[2][0]=0;
|
||||
cob->matrix[2][1]=0;
|
||||
cob->matrix[2][2]=size[2]*scale[2];
|
||||
cob->matrix[0][0] = size[0] * scale[0];
|
||||
cob->matrix[0][1] = 0;
|
||||
cob->matrix[0][2] = 0;
|
||||
cob->matrix[1][0] = 0;
|
||||
cob->matrix[1][1] = size[1] * scale[1];
|
||||
cob->matrix[1][2] = 0;
|
||||
cob->matrix[2][0] = 0;
|
||||
cob->matrix[2][1] = 0;
|
||||
cob->matrix[2][2] = size[2] * scale[2];
|
||||
|
||||
sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);
|
||||
normalize_v3(vec);
|
||||
@@ -2791,32 +2791,32 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
/* new Y aligns object target connection*/
|
||||
negate_v3_v3(totmat[1], vec);
|
||||
switch (data->plane) {
|
||||
case PLANE_X:
|
||||
/* build new Z vector */
|
||||
/* othogonal to "new Y" "old X! plane */
|
||||
cross_v3_v3v3(orth, vec, xx);
|
||||
normalize_v3(orth);
|
||||
|
||||
/* new Z*/
|
||||
copy_v3_v3(totmat[2], orth);
|
||||
|
||||
/* we decided to keep X plane*/
|
||||
cross_v3_v3v3(xx, orth, vec);
|
||||
normalize_v3_v3(totmat[0], xx);
|
||||
break;
|
||||
case PLANE_Z:
|
||||
/* build new X vector */
|
||||
/* othogonal to "new Y" "old Z! plane */
|
||||
cross_v3_v3v3(orth, vec, zz);
|
||||
normalize_v3(orth);
|
||||
|
||||
/* new X */
|
||||
negate_v3_v3(totmat[0], orth);
|
||||
|
||||
/* we decided to keep Z */
|
||||
cross_v3_v3v3(zz, orth, vec);
|
||||
normalize_v3_v3(totmat[2], zz);
|
||||
break;
|
||||
case PLANE_X:
|
||||
/* build new Z vector */
|
||||
/* othogonal to "new Y" "old X! plane */
|
||||
cross_v3_v3v3(orth, vec, xx);
|
||||
normalize_v3(orth);
|
||||
|
||||
/* new Z*/
|
||||
copy_v3_v3(totmat[2], orth);
|
||||
|
||||
/* we decided to keep X plane*/
|
||||
cross_v3_v3v3(xx, orth, vec);
|
||||
normalize_v3_v3(totmat[0], xx);
|
||||
break;
|
||||
case PLANE_Z:
|
||||
/* build new X vector */
|
||||
/* othogonal to "new Y" "old Z! plane */
|
||||
cross_v3_v3v3(orth, vec, zz);
|
||||
normalize_v3(orth);
|
||||
|
||||
/* new X */
|
||||
negate_v3_v3(totmat[0], orth);
|
||||
|
||||
/* we decided to keep Z */
|
||||
cross_v3_v3v3(zz, orth, vec);
|
||||
normalize_v3_v3(totmat[2], zz);
|
||||
break;
|
||||
} /* switch (data->plane) */
|
||||
|
||||
copy_m4_m4(tmat, cob->matrix);
|
||||
@@ -2841,9 +2841,9 @@ static bConstraintTypeInfo CTI_STRETCHTO = {
|
||||
|
||||
/* ---------- Floor ------------ */
|
||||
|
||||
static void minmax_new_data (void *cdata)
|
||||
static void minmax_new_data(void *cdata)
|
||||
{
|
||||
bMinMaxConstraint *data= (bMinMaxConstraint *)cdata;
|
||||
bMinMaxConstraint *data = (bMinMaxConstraint *)cdata;
|
||||
|
||||
data->minmaxflag = TRACK_Z;
|
||||
data->offset = 0.0f;
|
||||
@@ -2851,18 +2851,18 @@ static void minmax_new_data (void *cdata)
|
||||
data->flag = 0;
|
||||
}
|
||||
|
||||
static void minmax_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void minmax_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bMinMaxConstraint *data= con->data;
|
||||
bMinMaxConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int minmax_get_tars (bConstraint *con, ListBase *list)
|
||||
static int minmax_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bMinMaxConstraint *data= con->data;
|
||||
bMinMaxConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -2874,21 +2874,21 @@ static int minmax_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void minmax_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void minmax_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bMinMaxConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bMinMaxConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bMinMaxConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bMinMaxConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
@@ -2908,38 +2908,38 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar
|
||||
}
|
||||
|
||||
switch (data->minmaxflag) {
|
||||
case TRACK_Z:
|
||||
val1 = tarmat[3][2];
|
||||
val2 = obmat[3][2]-data->offset;
|
||||
index = 2;
|
||||
break;
|
||||
case TRACK_Y:
|
||||
val1 = tarmat[3][1];
|
||||
val2 = obmat[3][1]-data->offset;
|
||||
index = 1;
|
||||
break;
|
||||
case TRACK_X:
|
||||
val1 = tarmat[3][0];
|
||||
val2 = obmat[3][0]-data->offset;
|
||||
index = 0;
|
||||
break;
|
||||
case TRACK_nZ:
|
||||
val2 = tarmat[3][2];
|
||||
val1 = obmat[3][2]-data->offset;
|
||||
index = 2;
|
||||
break;
|
||||
case TRACK_nY:
|
||||
val2 = tarmat[3][1];
|
||||
val1 = obmat[3][1]-data->offset;
|
||||
index = 1;
|
||||
break;
|
||||
case TRACK_nX:
|
||||
val2 = tarmat[3][0];
|
||||
val1 = obmat[3][0]-data->offset;
|
||||
index = 0;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case TRACK_Z:
|
||||
val1 = tarmat[3][2];
|
||||
val2 = obmat[3][2] - data->offset;
|
||||
index = 2;
|
||||
break;
|
||||
case TRACK_Y:
|
||||
val1 = tarmat[3][1];
|
||||
val2 = obmat[3][1] - data->offset;
|
||||
index = 1;
|
||||
break;
|
||||
case TRACK_X:
|
||||
val1 = tarmat[3][0];
|
||||
val2 = obmat[3][0] - data->offset;
|
||||
index = 0;
|
||||
break;
|
||||
case TRACK_nZ:
|
||||
val2 = tarmat[3][2];
|
||||
val1 = obmat[3][2] - data->offset;
|
||||
index = 2;
|
||||
break;
|
||||
case TRACK_nY:
|
||||
val2 = tarmat[3][1];
|
||||
val1 = obmat[3][1] - data->offset;
|
||||
index = 1;
|
||||
break;
|
||||
case TRACK_nX:
|
||||
val2 = tarmat[3][0];
|
||||
val1 = obmat[3][0] - data->offset;
|
||||
index = 0;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (val1 > val2) {
|
||||
@@ -2985,27 +2985,27 @@ static bConstraintTypeInfo CTI_MINMAX = {
|
||||
|
||||
/* ------- RigidBody Joint ---------- */
|
||||
|
||||
static void rbj_new_data (void *cdata)
|
||||
static void rbj_new_data(void *cdata)
|
||||
{
|
||||
bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint *)cdata;
|
||||
bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata;
|
||||
|
||||
// removed code which set target of this constraint
|
||||
data->type=1;
|
||||
data->type = 1;
|
||||
}
|
||||
|
||||
static void rbj_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void rbj_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bRigidBodyJointConstraint *data= con->data;
|
||||
bRigidBodyJointConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID**)&data->child, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->child, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int rbj_get_tars (bConstraint *con, ListBase *list)
|
||||
static int rbj_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bRigidBodyJointConstraint *data= con->data;
|
||||
bRigidBodyJointConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints without subtargets */
|
||||
@@ -3017,11 +3017,11 @@ static int rbj_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rbj_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void rbj_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bRigidBodyJointConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bRigidBodyJointConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy)
|
||||
@@ -3045,18 +3045,18 @@ static bConstraintTypeInfo CTI_RIGIDBODYJOINT = {
|
||||
|
||||
/* -------- Clamp To ---------- */
|
||||
|
||||
static void clampto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void clampto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bClampToConstraint *data= con->data;
|
||||
bClampToConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int clampto_get_tars (bConstraint *con, ListBase *list)
|
||||
static int clampto_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bClampToConstraint *data= con->data;
|
||||
bClampToConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints without subtargets */
|
||||
@@ -3068,28 +3068,28 @@ static int clampto_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void clampto_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void clampto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bClampToConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bClampToConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void clampto_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
Curve *cu= ct->tar->data;
|
||||
Curve *cu = ct->tar->data;
|
||||
|
||||
/* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
|
||||
* currently for paths to work it needs to go through the bevlist/displist system (ton)
|
||||
*/
|
||||
|
||||
/* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (cu->path==NULL || cu->path->data==NULL)
|
||||
if (cu->path == NULL || cu->path->data == NULL)
|
||||
makeDispListCurveTypes(cob->scene, ct->tar, 0);
|
||||
}
|
||||
|
||||
@@ -3100,17 +3100,17 @@ static void clampto_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bC
|
||||
unit_m4(ct->matrix);
|
||||
}
|
||||
|
||||
static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bClampToConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bClampToConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target and it is a curve */
|
||||
if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) {
|
||||
Curve *cu= data->tar->data;
|
||||
Curve *cu = data->tar->data;
|
||||
float obmat[4][4], ownLoc[3];
|
||||
float curveMin[3], curveMax[3];
|
||||
float targetMatrix[4][4]= MAT4_UNITY;
|
||||
float targetMatrix[4][4] = MAT4_UNITY;
|
||||
|
||||
copy_m4_m4(obmat, cob->matrix);
|
||||
copy_v3_v3(ownLoc, obmat[3]);
|
||||
@@ -3134,20 +3134,20 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
* extent. Otherwise, default to the x-axis, as that is quite
|
||||
* frequently used.
|
||||
*/
|
||||
if ((size[2]>size[0]) && (size[2]>size[1]))
|
||||
clamp_axis= CLAMPTO_Z - 1;
|
||||
else if ((size[1]>size[0]) && (size[1]>size[2]))
|
||||
clamp_axis= CLAMPTO_Y - 1;
|
||||
if ((size[2] > size[0]) && (size[2] > size[1]))
|
||||
clamp_axis = CLAMPTO_Z - 1;
|
||||
else if ((size[1] > size[0]) && (size[1] > size[2]))
|
||||
clamp_axis = CLAMPTO_Y - 1;
|
||||
else
|
||||
clamp_axis = CLAMPTO_X - 1;
|
||||
}
|
||||
else
|
||||
clamp_axis= data->flag - 1;
|
||||
clamp_axis = data->flag - 1;
|
||||
|
||||
/* 2. determine position relative to curve on a 0-1 scale based on bounding box */
|
||||
if (data->flag2 & CLAMPTO_CYCLIC) {
|
||||
/* cyclic, so offset within relative bounding box is used */
|
||||
float len= (curveMax[clamp_axis] - curveMin[clamp_axis]);
|
||||
float len = (curveMax[clamp_axis] - curveMin[clamp_axis]);
|
||||
float offset;
|
||||
|
||||
/* check to make sure len is not so close to zero that it'll cause errors */
|
||||
@@ -3162,7 +3162,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
}
|
||||
else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) {
|
||||
/* bounding-box range is after */
|
||||
offset= curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
|
||||
offset = curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
|
||||
|
||||
/* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */
|
||||
curvetime = (ownLoc[clamp_axis] - offset) / (len);
|
||||
@@ -3174,7 +3174,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
}
|
||||
else {
|
||||
/* as length is close to zero, curvetime by default should be 0 (i.e. the start) */
|
||||
curvetime= 0.0f;
|
||||
curvetime = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -3183,7 +3183,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
|
||||
curvetime = 0.0f;
|
||||
else if (ownLoc[clamp_axis] >= curveMax[clamp_axis])
|
||||
curvetime = 1.0f;
|
||||
else if ( IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0 )
|
||||
else if (IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0)
|
||||
curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) / (curveMax[clamp_axis] - curveMin[clamp_axis]);
|
||||
else
|
||||
curvetime = 0.0f;
|
||||
@@ -3220,27 +3220,27 @@ static bConstraintTypeInfo CTI_CLAMPTO = {
|
||||
|
||||
/* ---------- Transform Constraint ----------- */
|
||||
|
||||
static void transform_new_data (void *cdata)
|
||||
static void transform_new_data(void *cdata)
|
||||
{
|
||||
bTransformConstraint *data= (bTransformConstraint *)cdata;
|
||||
bTransformConstraint *data = (bTransformConstraint *)cdata;
|
||||
|
||||
data->map[0]= 0;
|
||||
data->map[1]= 1;
|
||||
data->map[2]= 2;
|
||||
data->map[0] = 0;
|
||||
data->map[1] = 1;
|
||||
data->map[2] = 2;
|
||||
}
|
||||
|
||||
static void transform_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void transform_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bTransformConstraint *data= con->data;
|
||||
bTransformConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int transform_get_tars (bConstraint *con, ListBase *list)
|
||||
static int transform_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bTransformConstraint *data= con->data;
|
||||
bTransformConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -3252,21 +3252,21 @@ static int transform_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void transform_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void transform_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bTransformConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bTransformConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bTransformConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bTransformConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
@@ -3295,21 +3295,21 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
|
||||
/* determine where in range current transforms lie */
|
||||
if (data->expo) {
|
||||
for (i=0; i<3; i++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (data->from_max[i] - data->from_min[i])
|
||||
sval[i]= (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
|
||||
sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
|
||||
else
|
||||
sval[i]= 0.0f;
|
||||
sval[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* clamp transforms out of range */
|
||||
for (i=0; i<3; i++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
CLAMP(dvec[i], data->from_min[i], data->from_max[i]);
|
||||
if (data->from_max[i] - data->from_min[i])
|
||||
sval[i]= (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
|
||||
sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
|
||||
else
|
||||
sval[i]= 0.0f;
|
||||
sval[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3317,18 +3317,18 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
/* apply transforms */
|
||||
switch (data->to) {
|
||||
case 2: /* scaling */
|
||||
for (i=0; i<3; i++)
|
||||
size[i]= data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]));
|
||||
for (i = 0; i < 3; i++)
|
||||
size[i] = data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]));
|
||||
break;
|
||||
case 1: /* rotation */
|
||||
for (i=0; i<3; i++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
float tmin, tmax;
|
||||
|
||||
tmin= data->to_min[i];
|
||||
tmax= data->to_max[i];
|
||||
tmin = data->to_min[i];
|
||||
tmax = data->to_max[i];
|
||||
|
||||
/* all values here should be in degrees */
|
||||
eul[i]= tmin + (sval[(int)data->map[i]] * (tmax - tmin));
|
||||
eul[i] = tmin + (sval[(int)data->map[i]] * (tmax - tmin));
|
||||
|
||||
/* now convert final value back to radians */
|
||||
eul[i] = DEG2RADF(eul[i]);
|
||||
@@ -3336,8 +3336,8 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
break;
|
||||
default: /* location */
|
||||
/* get new location */
|
||||
for (i=0; i<3; i++)
|
||||
loc[i]= (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])));
|
||||
for (i = 0; i < 3; i++)
|
||||
loc[i] = (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])));
|
||||
|
||||
/* add original location back on (so that it can still be moved) */
|
||||
add_v3_v3v3(loc, cob->matrix[3], loc);
|
||||
@@ -3366,15 +3366,15 @@ static bConstraintTypeInfo CTI_TRANSFORM = {
|
||||
|
||||
/* ---------- Shrinkwrap Constraint ----------- */
|
||||
|
||||
static void shrinkwrap_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void shrinkwrap_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bShrinkwrapConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->target, FALSE, userdata);
|
||||
func(con, (ID **)&data->target, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int shrinkwrap_get_tars (bConstraint *con, ListBase *list)
|
||||
static int shrinkwrap_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bShrinkwrapConstraint *data = con->data;
|
||||
@@ -3389,22 +3389,22 @@ static int shrinkwrap_get_tars (bConstraint *con, ListBase *list)
|
||||
}
|
||||
|
||||
|
||||
static void shrinkwrap_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bShrinkwrapConstraint *data = con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
SINGLETARGETNS_FLUSH_TARS(con, data->target, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
|
||||
|
||||
if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) {
|
||||
if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) {
|
||||
int fail = FALSE;
|
||||
float co[3] = {0.0f, 0.0f, 0.0f};
|
||||
float no[3] = {0.0f, 0.0f, 0.0f};
|
||||
@@ -3415,7 +3415,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
BVHTreeRayHit hit;
|
||||
BVHTreeNearest nearest;
|
||||
|
||||
BVHTreeFromMesh treeData= {NULL};
|
||||
BVHTreeFromMesh treeData = {NULL};
|
||||
|
||||
nearest.index = -1;
|
||||
nearest.dist = FLT_MAX;
|
||||
@@ -3448,10 +3448,10 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
|
||||
dist = len_v3v3(co, nearest.co);
|
||||
if (dist != 0.0f) {
|
||||
interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */
|
||||
interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist) / dist); /* linear interpolation */
|
||||
}
|
||||
space_transform_invert(&transform, co);
|
||||
break;
|
||||
break;
|
||||
|
||||
case MOD_SHRINKWRAP_PROJECT:
|
||||
if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f;
|
||||
@@ -3477,7 +3477,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
break;
|
||||
}
|
||||
copy_v3_v3(co, hit.co);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
free_bvhtree_from_mesh(&treeData);
|
||||
@@ -3496,9 +3496,9 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
}
|
||||
}
|
||||
|
||||
static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
||||
static void shrinkwrap_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
@@ -3523,25 +3523,25 @@ static bConstraintTypeInfo CTI_SHRINKWRAP = {
|
||||
|
||||
/* --------- Damped Track ---------- */
|
||||
|
||||
static void damptrack_new_data (void *cdata)
|
||||
static void damptrack_new_data(void *cdata)
|
||||
{
|
||||
bDampTrackConstraint *data= (bDampTrackConstraint *)cdata;
|
||||
bDampTrackConstraint *data = (bDampTrackConstraint *)cdata;
|
||||
|
||||
data->trackflag = TRACK_Y;
|
||||
}
|
||||
|
||||
static void damptrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void damptrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bDampTrackConstraint *data= con->data;
|
||||
bDampTrackConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int damptrack_get_tars (bConstraint *con, ListBase *list)
|
||||
static int damptrack_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bDampTrackConstraint *data= con->data;
|
||||
bDampTrackConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
@@ -3553,11 +3553,11 @@ static int damptrack_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void damptrack_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void damptrack_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bDampTrackConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bDampTrackConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
@@ -3566,14 +3566,14 @@ static void damptrack_flush_tars (bConstraint *con, ListBase *list, short nocopy
|
||||
|
||||
/* array of direction vectors for the tracking flags */
|
||||
static const float track_dir_vecs[6][3] = {
|
||||
{+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */
|
||||
{-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */
|
||||
{+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */
|
||||
{-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */
|
||||
};
|
||||
|
||||
static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bDampTrackConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bDampTrackConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
float obvec[3], tarvec[3], obloc[3];
|
||||
@@ -3614,8 +3614,8 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
|
||||
*/
|
||||
cross_v3_v3v3(raxis, obvec, tarvec);
|
||||
|
||||
rangle= dot_v3v3(obvec, tarvec);
|
||||
rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) );
|
||||
rangle = dot_v3v3(obvec, tarvec);
|
||||
rangle = acos(MAX2(-1.0f, MIN2(1.0f, rangle)) );
|
||||
|
||||
/* construct rotation matrix from the axis-angle rotation found above
|
||||
* - this call takes care to make sure that the axis provided is a unit vector first
|
||||
@@ -3650,43 +3650,43 @@ static bConstraintTypeInfo CTI_DAMPTRACK = {
|
||||
|
||||
/* ----------- Spline IK ------------ */
|
||||
|
||||
static void splineik_free (bConstraint *con)
|
||||
static void splineik_free(bConstraint *con)
|
||||
{
|
||||
bSplineIKConstraint *data= con->data;
|
||||
bSplineIKConstraint *data = con->data;
|
||||
|
||||
/* binding array */
|
||||
if (data->points)
|
||||
MEM_freeN(data->points);
|
||||
}
|
||||
|
||||
static void splineik_copy (bConstraint *con, bConstraint *srccon)
|
||||
static void splineik_copy(bConstraint *con, bConstraint *srccon)
|
||||
{
|
||||
bSplineIKConstraint *src= srccon->data;
|
||||
bSplineIKConstraint *dst= con->data;
|
||||
bSplineIKConstraint *src = srccon->data;
|
||||
bSplineIKConstraint *dst = con->data;
|
||||
|
||||
/* copy the binding array */
|
||||
dst->points= MEM_dupallocN(src->points);
|
||||
dst->points = MEM_dupallocN(src->points);
|
||||
}
|
||||
|
||||
static void splineik_new_data (void *cdata)
|
||||
static void splineik_new_data(void *cdata)
|
||||
{
|
||||
bSplineIKConstraint *data= (bSplineIKConstraint *)cdata;
|
||||
bSplineIKConstraint *data = (bSplineIKConstraint *)cdata;
|
||||
|
||||
data->chainlen= 1;
|
||||
data->chainlen = 1;
|
||||
}
|
||||
|
||||
static void splineik_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void splineik_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bSplineIKConstraint *data= con->data;
|
||||
bSplineIKConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int splineik_get_tars (bConstraint *con, ListBase *list)
|
||||
static int splineik_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bSplineIKConstraint *data= con->data;
|
||||
bSplineIKConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints without subtargets */
|
||||
@@ -3698,28 +3698,28 @@ static int splineik_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void splineik_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void splineik_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bSplineIKConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bSplineIKConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void splineik_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
||||
{
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
Curve *cu= ct->tar->data;
|
||||
Curve *cu = ct->tar->data;
|
||||
|
||||
/* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
|
||||
* currently for paths to work it needs to go through the bevlist/displist system (ton)
|
||||
*/
|
||||
|
||||
/* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (cu->path==NULL || cu->path->data==NULL)
|
||||
if (cu->path == NULL || cu->path->data == NULL)
|
||||
makeDispListCurveTypes(cob->scene, ct->tar, 0);
|
||||
}
|
||||
|
||||
@@ -3747,18 +3747,18 @@ static bConstraintTypeInfo CTI_SPLINEIK = {
|
||||
|
||||
/* ----------- Pivot ------------- */
|
||||
|
||||
static void pivotcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void pivotcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bPivotConstraint *data= con->data;
|
||||
bPivotConstraint *data = con->data;
|
||||
|
||||
/* target only */
|
||||
func(con, (ID**)&data->tar, FALSE, userdata);
|
||||
func(con, (ID **)&data->tar, FALSE, userdata);
|
||||
}
|
||||
|
||||
static int pivotcon_get_tars (bConstraint *con, ListBase *list)
|
||||
static int pivotcon_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bPivotConstraint *data= con->data;
|
||||
bPivotConstraint *data = con->data;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* standard target-getting macro for single-target constraints */
|
||||
@@ -3770,21 +3770,21 @@ static int pivotcon_get_tars (bConstraint *con, ListBase *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pivotcon_flush_tars (bConstraint *con, ListBase *list, short nocopy)
|
||||
static void pivotcon_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
||||
{
|
||||
if (con && list) {
|
||||
bPivotConstraint *data= con->data;
|
||||
bConstraintTarget *ct= list->first;
|
||||
bPivotConstraint *data = con->data;
|
||||
bConstraintTarget *ct = list->first;
|
||||
|
||||
/* the following macro is used for all standard single-target constraints */
|
||||
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
|
||||
}
|
||||
}
|
||||
|
||||
static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
bPivotConstraint *data= con->data;
|
||||
bConstraintTarget *ct= targets->first;
|
||||
bPivotConstraint *data = con->data;
|
||||
bConstraintTarget *ct = targets->first;
|
||||
|
||||
float pivot[3], vec[3];
|
||||
float rotMat[3][3];
|
||||
@@ -3845,11 +3845,11 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t
|
||||
}
|
||||
|
||||
/* perform the pivoting... */
|
||||
/* 1. take the vector from owner to the pivot */
|
||||
/* 1. take the vector from owner to the pivot */
|
||||
sub_v3_v3v3(vec, cob->matrix[3], pivot);
|
||||
/* 2. rotate this vector by the rotation of the object... */
|
||||
/* 2. rotate this vector by the rotation of the object... */
|
||||
mul_m3_v3(rotMat, vec);
|
||||
/* 3. make the rotation in terms of the pivot now */
|
||||
/* 3. make the rotation in terms of the pivot now */
|
||||
add_v3_v3v3(cob->matrix[3], pivot, vec);
|
||||
}
|
||||
|
||||
@@ -3883,9 +3883,9 @@ static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void
|
||||
{
|
||||
bFollowTrackConstraint *data = con->data;
|
||||
|
||||
func(con, (ID**)&data->clip, TRUE, userdata);
|
||||
func(con, (ID**)&data->camera, FALSE, userdata);
|
||||
func(con, (ID**)&data->depth_ob, FALSE, userdata);
|
||||
func(con, (ID **)&data->clip, TRUE, userdata);
|
||||
func(con, (ID **)&data->camera, FALSE, userdata);
|
||||
func(con, (ID **)&data->depth_ob, FALSE, userdata);
|
||||
}
|
||||
|
||||
static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
@@ -3896,10 +3896,10 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||
MovieTracking *tracking;
|
||||
MovieTrackingTrack *track;
|
||||
MovieTrackingObject *tracking_object;
|
||||
Object *camob= data->camera ? data->camera : scene->camera;
|
||||
Object *camob = data->camera ? data->camera : scene->camera;
|
||||
|
||||
if (data->flag & FOLLOWTRACK_ACTIVECLIP)
|
||||
clip= scene->clip;
|
||||
clip = scene->clip;
|
||||
|
||||
if (!clip || !data->track[0] || !camob)
|
||||
return;
|
||||
@@ -3925,7 +3925,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||
|
||||
copy_m4_m4(obmat, cob->matrix);
|
||||
|
||||
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA)==0) {
|
||||
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) {
|
||||
float imat[4][4];
|
||||
|
||||
copy_m4_m4(mat, camob->obmat);
|
||||
@@ -3947,7 +3947,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||
else {
|
||||
MovieTrackingMarker *marker;
|
||||
float vec[3], disp[3], axis[3], mat[4][4];
|
||||
float aspect= (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
|
||||
float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
|
||||
float len, d;
|
||||
|
||||
BKE_object_where_is_calc_mat4(scene, camob, mat);
|
||||
@@ -3995,7 +3995,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||
copy_v3_v3(cob->matrix[3], disp);
|
||||
}
|
||||
else {
|
||||
d= (len * params.sensor_x) / (2.0f * params.lens);
|
||||
d = (len * params.sensor_x) / (2.0f * params.lens);
|
||||
|
||||
vec[0] = d * (2.0f * (pos[0] + params.shiftx) - 1.0f);
|
||||
vec[1] = d * (2.0f * (pos[1] + params.shifty) - 1.0f);
|
||||
@@ -4076,7 +4076,7 @@ static void camerasolver_id_looper(bConstraint *con, ConstraintIDFunc func, void
|
||||
{
|
||||
bCameraSolverConstraint *data = con->data;
|
||||
|
||||
func(con, (ID**)&data->clip, TRUE, userdata);
|
||||
func(con, (ID **)&data->clip, TRUE, userdata);
|
||||
}
|
||||
|
||||
static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
@@ -4129,10 +4129,10 @@ static void objectsolver_new_data(void *cdata)
|
||||
|
||||
static void objectsolver_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bObjectSolverConstraint *data= con->data;
|
||||
bObjectSolverConstraint *data = con->data;
|
||||
|
||||
func(con, (ID**)&data->clip, FALSE, userdata);
|
||||
func(con, (ID**)&data->camera, FALSE, userdata);
|
||||
func(con, (ID **)&data->clip, FALSE, userdata);
|
||||
func(con, (ID **)&data->camera, FALSE, userdata);
|
||||
}
|
||||
|
||||
static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
@@ -4143,7 +4143,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||
Object *camob = data->camera ? data->camera : scene->camera;
|
||||
|
||||
if (data->flag & OBJECTSOLVER_ACTIVECLIP)
|
||||
clip= scene->clip;
|
||||
clip = scene->clip;
|
||||
|
||||
if (!camob || !clip)
|
||||
return;
|
||||
@@ -4196,46 +4196,46 @@ static bConstraintTypeInfo CTI_OBJECTSOLVER = {
|
||||
|
||||
/* These globals only ever get directly accessed in this file */
|
||||
static bConstraintTypeInfo *constraintsTypeInfo[NUM_CONSTRAINT_TYPES];
|
||||
static short CTI_INIT= 1; /* when non-zero, the list needs to be updated */
|
||||
static short CTI_INIT = 1; /* when non-zero, the list needs to be updated */
|
||||
|
||||
/* This function only gets called when CTI_INIT is non-zero */
|
||||
static void constraints_init_typeinfo (void)
|
||||
static void constraints_init_typeinfo(void)
|
||||
{
|
||||
constraintsTypeInfo[0]= NULL; /* 'Null' Constraint */
|
||||
constraintsTypeInfo[1]= &CTI_CHILDOF; /* ChildOf Constraint */
|
||||
constraintsTypeInfo[2]= &CTI_TRACKTO; /* TrackTo Constraint */
|
||||
constraintsTypeInfo[3]= &CTI_KINEMATIC; /* IK Constraint */
|
||||
constraintsTypeInfo[4]= &CTI_FOLLOWPATH; /* Follow-Path Constraint */
|
||||
constraintsTypeInfo[5]= &CTI_ROTLIMIT; /* Limit Rotation Constraint */
|
||||
constraintsTypeInfo[6]= &CTI_LOCLIMIT; /* Limit Location Constraint */
|
||||
constraintsTypeInfo[7]= &CTI_SIZELIMIT; /* Limit Scaling Constraint */
|
||||
constraintsTypeInfo[8]= &CTI_ROTLIKE; /* Copy Rotation Constraint */
|
||||
constraintsTypeInfo[9]= &CTI_LOCLIKE; /* Copy Location Constraint */
|
||||
constraintsTypeInfo[10]= &CTI_SIZELIKE; /* Copy Scaling Constraint */
|
||||
constraintsTypeInfo[11]= &CTI_PYTHON; /* Python/Script Constraint */
|
||||
constraintsTypeInfo[12]= &CTI_ACTION; /* Action Constraint */
|
||||
constraintsTypeInfo[13]= &CTI_LOCKTRACK; /* Locked-Track Constraint */
|
||||
constraintsTypeInfo[14]= &CTI_DISTLIMIT; /* Limit Distance Constraint */
|
||||
constraintsTypeInfo[15]= &CTI_STRETCHTO; /* StretchTo Constaint */
|
||||
constraintsTypeInfo[16]= &CTI_MINMAX; /* Floor Constraint */
|
||||
constraintsTypeInfo[17]= &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */
|
||||
constraintsTypeInfo[18]= &CTI_CLAMPTO; /* ClampTo Constraint */
|
||||
constraintsTypeInfo[19]= &CTI_TRANSFORM; /* Transformation Constraint */
|
||||
constraintsTypeInfo[20]= &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */
|
||||
constraintsTypeInfo[21]= &CTI_DAMPTRACK; /* Damped TrackTo Constraint */
|
||||
constraintsTypeInfo[22]= &CTI_SPLINEIK; /* Spline IK Constraint */
|
||||
constraintsTypeInfo[23]= &CTI_TRANSLIKE; /* Copy Transforms Constraint */
|
||||
constraintsTypeInfo[24]= &CTI_SAMEVOL; /* Maintain Volume Constraint */
|
||||
constraintsTypeInfo[25]= &CTI_PIVOT; /* Pivot Constraint */
|
||||
constraintsTypeInfo[26]= &CTI_FOLLOWTRACK; /* Follow Track Constraint */
|
||||
constraintsTypeInfo[27]= &CTI_CAMERASOLVER; /* Camera Solver Constraint */
|
||||
constraintsTypeInfo[28]= &CTI_OBJECTSOLVER; /* Object Solver Constraint */
|
||||
constraintsTypeInfo[0] = NULL; /* 'Null' Constraint */
|
||||
constraintsTypeInfo[1] = &CTI_CHILDOF; /* ChildOf Constraint */
|
||||
constraintsTypeInfo[2] = &CTI_TRACKTO; /* TrackTo Constraint */
|
||||
constraintsTypeInfo[3] = &CTI_KINEMATIC; /* IK Constraint */
|
||||
constraintsTypeInfo[4] = &CTI_FOLLOWPATH; /* Follow-Path Constraint */
|
||||
constraintsTypeInfo[5] = &CTI_ROTLIMIT; /* Limit Rotation Constraint */
|
||||
constraintsTypeInfo[6] = &CTI_LOCLIMIT; /* Limit Location Constraint */
|
||||
constraintsTypeInfo[7] = &CTI_SIZELIMIT; /* Limit Scaling Constraint */
|
||||
constraintsTypeInfo[8] = &CTI_ROTLIKE; /* Copy Rotation Constraint */
|
||||
constraintsTypeInfo[9] = &CTI_LOCLIKE; /* Copy Location Constraint */
|
||||
constraintsTypeInfo[10] = &CTI_SIZELIKE; /* Copy Scaling Constraint */
|
||||
constraintsTypeInfo[11] = &CTI_PYTHON; /* Python/Script Constraint */
|
||||
constraintsTypeInfo[12] = &CTI_ACTION; /* Action Constraint */
|
||||
constraintsTypeInfo[13] = &CTI_LOCKTRACK; /* Locked-Track Constraint */
|
||||
constraintsTypeInfo[14] = &CTI_DISTLIMIT; /* Limit Distance Constraint */
|
||||
constraintsTypeInfo[15] = &CTI_STRETCHTO; /* StretchTo Constaint */
|
||||
constraintsTypeInfo[16] = &CTI_MINMAX; /* Floor Constraint */
|
||||
constraintsTypeInfo[17] = &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */
|
||||
constraintsTypeInfo[18] = &CTI_CLAMPTO; /* ClampTo Constraint */
|
||||
constraintsTypeInfo[19] = &CTI_TRANSFORM; /* Transformation Constraint */
|
||||
constraintsTypeInfo[20] = &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */
|
||||
constraintsTypeInfo[21] = &CTI_DAMPTRACK; /* Damped TrackTo Constraint */
|
||||
constraintsTypeInfo[22] = &CTI_SPLINEIK; /* Spline IK Constraint */
|
||||
constraintsTypeInfo[23] = &CTI_TRANSLIKE; /* Copy Transforms Constraint */
|
||||
constraintsTypeInfo[24] = &CTI_SAMEVOL; /* Maintain Volume Constraint */
|
||||
constraintsTypeInfo[25] = &CTI_PIVOT; /* Pivot Constraint */
|
||||
constraintsTypeInfo[26] = &CTI_FOLLOWTRACK; /* Follow Track Constraint */
|
||||
constraintsTypeInfo[27] = &CTI_CAMERASOLVER; /* Camera Solver Constraint */
|
||||
constraintsTypeInfo[28] = &CTI_OBJECTSOLVER; /* Object Solver Constraint */
|
||||
}
|
||||
|
||||
/* This function should be used for getting the appropriate type-info when only
|
||||
* a constraint type is known
|
||||
*/
|
||||
bConstraintTypeInfo *get_constraint_typeinfo (int type)
|
||||
bConstraintTypeInfo *get_constraint_typeinfo(int type)
|
||||
{
|
||||
/* initialize the type-info list? */
|
||||
if (CTI_INIT) {
|
||||
@@ -4245,7 +4245,7 @@ bConstraintTypeInfo *get_constraint_typeinfo (int type)
|
||||
|
||||
/* only return for valid types */
|
||||
if ( (type >= CONSTRAINT_TYPE_NULL) &&
|
||||
(type < NUM_CONSTRAINT_TYPES ) )
|
||||
(type < NUM_CONSTRAINT_TYPES) )
|
||||
{
|
||||
/* there shouldn't be any segfaults here... */
|
||||
return constraintsTypeInfo[type];
|
||||
@@ -4260,7 +4260,7 @@ bConstraintTypeInfo *get_constraint_typeinfo (int type)
|
||||
/* This function should always be used to get the appropriate type-info, as it
|
||||
* has checks which prevent segfaults in some weird cases.
|
||||
*/
|
||||
bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con)
|
||||
bConstraintTypeInfo *constraint_get_typeinfo(bConstraint *con)
|
||||
{
|
||||
/* only return typeinfo for valid constraints */
|
||||
if (con)
|
||||
@@ -4290,7 +4290,7 @@ static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isRe
|
||||
void free_constraint_data(bConstraint *con)
|
||||
{
|
||||
if (con->data) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
|
||||
if (cti) {
|
||||
/* perform any special freeing constraint may have */
|
||||
@@ -4313,7 +4313,7 @@ void free_constraints(ListBase *list)
|
||||
bConstraint *con;
|
||||
|
||||
/* Free constraint data and also any extra data */
|
||||
for (con= list->first; con; con= con->next)
|
||||
for (con = list->first; con; con = con->next)
|
||||
free_constraint_data(con);
|
||||
|
||||
/* Free the whole list */
|
||||
@@ -4342,8 +4342,8 @@ void remove_constraints_type(ListBase *list, short type, short last_only)
|
||||
return;
|
||||
|
||||
/* remove from the end of the list to make it faster to find the last instance */
|
||||
for (con= list->last; con; con= conp) {
|
||||
conp= con->prev;
|
||||
for (con = list->last; con; con = conp) {
|
||||
conp = con->prev;
|
||||
|
||||
if (con->type == type) {
|
||||
remove_constraint(list, con);
|
||||
@@ -4356,10 +4356,10 @@ void remove_constraints_type(ListBase *list, short type, short last_only)
|
||||
/* ......... */
|
||||
|
||||
/* Creates a new constraint, initializes its data, and returns it */
|
||||
static bConstraint *add_new_constraint_internal (const char *name, short type)
|
||||
static bConstraint *add_new_constraint_internal(const char *name, short type)
|
||||
{
|
||||
bConstraint *con= MEM_callocN(sizeof(bConstraint), "Constraint");
|
||||
bConstraintTypeInfo *cti= get_constraint_typeinfo(type);
|
||||
bConstraint *con = MEM_callocN(sizeof(bConstraint), "Constraint");
|
||||
bConstraintTypeInfo *cti = get_constraint_typeinfo(type);
|
||||
const char *newName;
|
||||
|
||||
/* Set up a generic constraint datablock */
|
||||
@@ -4377,12 +4377,12 @@ static bConstraint *add_new_constraint_internal (const char *name, short type)
|
||||
cti->new_data(con->data);
|
||||
|
||||
/* if no name is provided, use the type of the constraint as the name */
|
||||
newName= (name && name[0]) ? name : cti->name;
|
||||
newName = (name && name[0]) ? name : cti->name;
|
||||
}
|
||||
else {
|
||||
/* if no name is provided, use the generic "Const" name */
|
||||
// NOTE: any constraint type that gets here really shouldn't get added...
|
||||
newName= (name && name[0]) ? name : "Const";
|
||||
newName = (name && name[0]) ? name : "Const";
|
||||
}
|
||||
|
||||
/* copy the name */
|
||||
@@ -4393,13 +4393,13 @@ static bConstraint *add_new_constraint_internal (const char *name, short type)
|
||||
}
|
||||
|
||||
/* if pchan is not NULL then assume we're adding a pose constraint */
|
||||
static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type)
|
||||
static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type)
|
||||
{
|
||||
bConstraint *con;
|
||||
ListBase *list;
|
||||
|
||||
/* add the constraint */
|
||||
con= add_new_constraint_internal(name, type);
|
||||
con = add_new_constraint_internal(name, type);
|
||||
|
||||
/* find the constraint stack - bone or object? */
|
||||
list = (pchan) ? (&pchan->constraints) : (&ob->constraints);
|
||||
@@ -4434,7 +4434,7 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c
|
||||
con->flag |= CONSTRAINT_SPACEONCE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return con;
|
||||
@@ -4443,7 +4443,7 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c
|
||||
/* ......... */
|
||||
|
||||
/* Add new constraint for the given bone */
|
||||
bConstraint *add_pose_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type)
|
||||
bConstraint *add_pose_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type)
|
||||
{
|
||||
if (pchan == NULL)
|
||||
return NULL;
|
||||
@@ -4485,8 +4485,8 @@ void id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdat
|
||||
{
|
||||
bConstraint *con;
|
||||
|
||||
for (con= conlist->first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = conlist->first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
|
||||
if (cti) {
|
||||
if (cti->id_looper)
|
||||
@@ -4517,11 +4517,11 @@ void copy_constraints(ListBase *dst, const ListBase *src, int do_extern)
|
||||
{
|
||||
bConstraint *con, *srccon;
|
||||
|
||||
dst->first= dst->last= NULL;
|
||||
dst->first = dst->last = NULL;
|
||||
BLI_duplicatelist(dst, src);
|
||||
|
||||
for (con=dst->first, srccon=src->first; con && srccon; srccon=srccon->next, con=con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
|
||||
/* make a new copy of the constraint's data */
|
||||
con->data = MEM_dupallocN(con->data);
|
||||
@@ -4554,13 +4554,13 @@ bConstraint *constraints_findByName(ListBase *list, const char *name)
|
||||
}
|
||||
|
||||
/* finds the 'active' constraint in a constraint stack */
|
||||
bConstraint *constraints_get_active (ListBase *list)
|
||||
bConstraint *constraints_get_active(ListBase *list)
|
||||
{
|
||||
bConstraint *con;
|
||||
|
||||
/* search for the first constraint with the 'active' flag set */
|
||||
if (list) {
|
||||
for (con= list->first; con; con= con->next) {
|
||||
for (con = list->first; con; con = con->next) {
|
||||
if (con->flag & CONSTRAINT_ACTIVE)
|
||||
return con;
|
||||
}
|
||||
@@ -4576,7 +4576,7 @@ void constraints_set_active(ListBase *list, bConstraint *con)
|
||||
bConstraint *c;
|
||||
|
||||
if (list) {
|
||||
for (c= list->first; c; c= c->next) {
|
||||
for (c = list->first; c; c = c->next) {
|
||||
if (c == con)
|
||||
c->flag |= CONSTRAINT_ACTIVE;
|
||||
else
|
||||
@@ -4593,8 +4593,8 @@ void extract_proxylocal_constraints(ListBase *dst, ListBase *src)
|
||||
bConstraint *con, *next;
|
||||
|
||||
/* for each tagged constraint, remove from src and move to dst */
|
||||
for (con= src->first; con; con= next) {
|
||||
next= con->next;
|
||||
for (con = src->first; con; con = next) {
|
||||
next = con->next;
|
||||
|
||||
/* check if tagged */
|
||||
if (con->flag & CONSTRAINT_PROXY_LOCAL) {
|
||||
@@ -4610,7 +4610,7 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan)
|
||||
/* Currently, constraints can only be on object or bone level */
|
||||
if (ob && ob->proxy) {
|
||||
if (ob->pose && pchan) {
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
/* On bone-level, check if bone is on proxy-protected layer */
|
||||
if ((pchan->bone) && (pchan->bone->layer & arm->layer_protected))
|
||||
@@ -4636,21 +4636,21 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan)
|
||||
*/
|
||||
void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime)
|
||||
{
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintOb *cob;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
/* make 'constraint-ob' */
|
||||
cob= MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb");
|
||||
cob->type= ownertype;
|
||||
cob = MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb");
|
||||
cob->type = ownertype;
|
||||
cob->scene = scene;
|
||||
switch (ownertype) {
|
||||
case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */
|
||||
{
|
||||
cob->ob= (Object *)ownerdata;
|
||||
cob->pchan= NULL;
|
||||
cob->ob = (Object *)ownerdata;
|
||||
cob->pchan = NULL;
|
||||
if (cob->ob) {
|
||||
copy_m4_m4(cob->matrix, cob->ob->obmat);
|
||||
copy_m4_m4(cob->startmat, cob->matrix);
|
||||
@@ -4660,11 +4660,11 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n,
|
||||
unit_m4(cob->startmat);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */
|
||||
{
|
||||
cob->ob= NULL; /* this might not work at all :/ */
|
||||
cob->pchan= (bPoseChannel *)ownerdata;
|
||||
cob->ob = NULL; /* this might not work at all :/ */
|
||||
cob->pchan = (bPoseChannel *)ownerdata;
|
||||
if (cob->pchan) {
|
||||
copy_m4_m4(cob->matrix, cob->pchan->pose_mat);
|
||||
copy_m4_m4(cob->startmat, cob->matrix);
|
||||
@@ -4674,16 +4674,16 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n,
|
||||
unit_m4(cob->startmat);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* get targets - we only need the first one though (and there should only be one) */
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
/* only calculate the target matrix on the first target */
|
||||
ct= (bConstraintTarget *)targets.first;
|
||||
ct = (bConstraintTarget *)targets.first;
|
||||
while (ct && n-- > 0)
|
||||
ct= ct->next;
|
||||
ct = ct->next;
|
||||
|
||||
if (ct) {
|
||||
if (cti->get_target_matrix)
|
||||
@@ -4705,26 +4705,26 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n,
|
||||
/* Get the list of targets required for solving a constraint */
|
||||
void get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
|
||||
{
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
bConstraintTarget *ct;
|
||||
|
||||
/* get targets
|
||||
* - constraints should use ct->matrix, not directly accessing values
|
||||
* - constraints should use ct->matrix, not directly accessing values
|
||||
* - ct->matrix members have not yet been calculated here!
|
||||
*/
|
||||
cti->get_constraint_targets(con, targets);
|
||||
|
||||
/* set matrices
|
||||
* - calculate if possible, otherwise just initialize as identity matrix
|
||||
* - calculate if possible, otherwise just initialize as identity matrix
|
||||
*/
|
||||
if (cti->get_target_matrix) {
|
||||
for (ct= targets->first; ct; ct= ct->next)
|
||||
for (ct = targets->first; ct; ct = ct->next)
|
||||
cti->get_target_matrix(con, cob, ct, ctime);
|
||||
}
|
||||
else {
|
||||
for (ct= targets->first; ct; ct= ct->next)
|
||||
for (ct = targets->first; ct; ct = ct->next)
|
||||
unit_m4(ct->matrix);
|
||||
}
|
||||
}
|
||||
@@ -4749,20 +4749,20 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime)
|
||||
return;
|
||||
|
||||
/* loop over available constraints, solving and blending them */
|
||||
for (con= conlist->first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = conlist->first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
|
||||
/* these we can skip completely (invalid constraints...) */
|
||||
if (cti == NULL) continue;
|
||||
if (con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF)) continue;
|
||||
if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) continue;
|
||||
/* these constraints can't be evaluated anyway */
|
||||
if (cti->evaluate_constraint == NULL) continue;
|
||||
/* influence == 0 should be ignored */
|
||||
if (con->enforce == 0.0f) continue;
|
||||
|
||||
/* influence of constraint
|
||||
* - value should have been set from animation data already
|
||||
* - value should have been set from animation data already
|
||||
*/
|
||||
enf = con->enforce;
|
||||
|
||||
@@ -4791,9 +4791,9 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime)
|
||||
constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD);
|
||||
|
||||
/* Interpolate the enforcement, to blend result of constraint into final owner transform
|
||||
* - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]),
|
||||
* since some constraints may not convert the solution back to the input space before blending
|
||||
* but all are guaranteed to end up in good "worldspace" result
|
||||
* - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]),
|
||||
* since some constraints may not convert the solution back to the input space before blending
|
||||
* but all are guaranteed to end up in good "worldspace" result
|
||||
*/
|
||||
/* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */
|
||||
if (enf < 1.0f) {
|
||||
|
||||
@@ -92,14 +92,14 @@ bContext *CTX_create(void)
|
||||
{
|
||||
bContext *C;
|
||||
|
||||
C= MEM_callocN(sizeof(bContext), "bContext");
|
||||
C = MEM_callocN(sizeof(bContext), "bContext");
|
||||
|
||||
return C;
|
||||
}
|
||||
|
||||
bContext *CTX_copy(const bContext *C)
|
||||
{
|
||||
bContext *newC= MEM_dupallocN((void*)C);
|
||||
bContext *newC = MEM_dupallocN((void *)C);
|
||||
|
||||
return newC;
|
||||
}
|
||||
@@ -118,23 +118,23 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p
|
||||
|
||||
/* ensure we have a context to put the entry in, if it was already used
|
||||
* we have to copy the context to ensure */
|
||||
ctx= contexts->last;
|
||||
ctx = contexts->last;
|
||||
|
||||
if (!ctx || ctx->used) {
|
||||
if (ctx) {
|
||||
lastctx= ctx;
|
||||
ctx= MEM_dupallocN(lastctx);
|
||||
lastctx = ctx;
|
||||
ctx = MEM_dupallocN(lastctx);
|
||||
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
|
||||
}
|
||||
else
|
||||
ctx= MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
|
||||
BLI_addtail(contexts, ctx);
|
||||
}
|
||||
|
||||
entry= MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
|
||||
entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
|
||||
BLI_strncpy(entry->name, name, sizeof(entry->name));
|
||||
entry->ptr= *ptr;
|
||||
entry->ptr = *ptr;
|
||||
|
||||
BLI_addtail(&ctx->entries, entry);
|
||||
|
||||
@@ -148,22 +148,22 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
|
||||
|
||||
/* ensure we have a context to put the entries in, if it was already used
|
||||
* we have to copy the context to ensure */
|
||||
ctx= contexts->last;
|
||||
ctx = contexts->last;
|
||||
|
||||
if (!ctx || ctx->used) {
|
||||
if (ctx) {
|
||||
lastctx= ctx;
|
||||
ctx= MEM_dupallocN(lastctx);
|
||||
lastctx = ctx;
|
||||
ctx = MEM_dupallocN(lastctx);
|
||||
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
|
||||
}
|
||||
else
|
||||
ctx= MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
|
||||
BLI_addtail(contexts, ctx);
|
||||
}
|
||||
|
||||
for (tentry= context->entries.first; tentry; tentry= tentry->next) {
|
||||
entry= MEM_dupallocN(tentry);
|
||||
for (tentry = context->entries.first; tentry; tentry = tentry->next) {
|
||||
entry = MEM_dupallocN(tentry);
|
||||
BLI_addtail(&ctx->entries, entry);
|
||||
}
|
||||
|
||||
@@ -172,14 +172,14 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
|
||||
|
||||
void CTX_store_set(bContext *C, bContextStore *store)
|
||||
{
|
||||
C->wm.store= store;
|
||||
C->wm.store = store;
|
||||
}
|
||||
|
||||
bContextStore *CTX_store_copy(bContextStore *store)
|
||||
{
|
||||
bContextStore *ctx;
|
||||
|
||||
ctx= MEM_dupallocN(store);
|
||||
ctx = MEM_dupallocN(store);
|
||||
BLI_duplicatelist(&ctx->entries, &store->entries);
|
||||
|
||||
return ctx;
|
||||
@@ -195,7 +195,7 @@ void CTX_store_free_list(ListBase *contexts)
|
||||
{
|
||||
bContextStore *ctx;
|
||||
|
||||
while ((ctx= contexts->first)) {
|
||||
while ((ctx = contexts->first)) {
|
||||
BLI_remlink(contexts, ctx);
|
||||
CTX_store_free(ctx);
|
||||
}
|
||||
@@ -209,7 +209,7 @@ int CTX_py_init_get(bContext *C)
|
||||
}
|
||||
void CTX_py_init_set(bContext *C, int value)
|
||||
{
|
||||
C->data.py_init= value;
|
||||
C->data.py_init = value;
|
||||
}
|
||||
|
||||
void *CTX_py_dict_get(const bContext *C)
|
||||
@@ -218,7 +218,7 @@ void *CTX_py_dict_get(const bContext *C)
|
||||
}
|
||||
void CTX_py_dict_set(bContext *C, void *value)
|
||||
{
|
||||
C->data.py_context= value;
|
||||
C->data.py_context = value;
|
||||
}
|
||||
|
||||
/* data context utility functions */
|
||||
@@ -237,8 +237,8 @@ static void *ctx_wm_python_context_get(const bContext *C, const char *member, vo
|
||||
|
||||
if (C && CTX_py_dict_get(C)) {
|
||||
memset(&result, 0, sizeof(bContextDataResult));
|
||||
BPY_context_member_get((bContext*)C, member, &result);
|
||||
if(result.ptr.data)
|
||||
BPY_context_member_get((bContext *)C, member, &result);
|
||||
if (result.ptr.data)
|
||||
return result.ptr.data;
|
||||
}
|
||||
#endif
|
||||
@@ -251,8 +251,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
|
||||
bScreen *sc;
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
int done= 0, recursion= C->data.recursion;
|
||||
int ret= 0;
|
||||
int done = 0, recursion = C->data.recursion;
|
||||
int ret = 0;
|
||||
|
||||
memset(result, 0, sizeof(bContextDataResult));
|
||||
#ifdef WITH_PYTHON
|
||||
@@ -271,42 +271,42 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
|
||||
* Values in order of importance
|
||||
* (0, -1, 1) - Where 1 is highest priority
|
||||
* */
|
||||
if (done!=1 && recursion < 1 && C->wm.store) {
|
||||
if (done != 1 && recursion < 1 && C->wm.store) {
|
||||
bContextStoreEntry *entry;
|
||||
|
||||
C->data.recursion= 1;
|
||||
C->data.recursion = 1;
|
||||
|
||||
entry= BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
|
||||
entry = BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
|
||||
if (entry) {
|
||||
result->ptr= entry->ptr;
|
||||
done= 1;
|
||||
result->ptr = entry->ptr;
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
if (done!=1 && recursion < 2 && (ar=CTX_wm_region(C))) {
|
||||
C->data.recursion= 2;
|
||||
if (done != 1 && recursion < 2 && (ar = CTX_wm_region(C))) {
|
||||
C->data.recursion = 2;
|
||||
if (ar->type && ar->type->context) {
|
||||
ret = ar->type->context(C, member, result);
|
||||
if (ret) done= -(-ret | -done);
|
||||
if (ret) done = -(-ret | -done);
|
||||
|
||||
}
|
||||
}
|
||||
if (done!=1 && recursion < 3 && (sa=CTX_wm_area(C))) {
|
||||
C->data.recursion= 3;
|
||||
if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) {
|
||||
C->data.recursion = 3;
|
||||
if (sa->type && sa->type->context) {
|
||||
ret = sa->type->context(C, member, result);
|
||||
if (ret) done= -(-ret | -done);
|
||||
if (ret) done = -(-ret | -done);
|
||||
}
|
||||
}
|
||||
if (done!=1 && recursion < 4 && (sc=CTX_wm_screen(C))) {
|
||||
bContextDataCallback cb= sc->context;
|
||||
C->data.recursion= 4;
|
||||
if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) {
|
||||
bContextDataCallback cb = sc->context;
|
||||
C->data.recursion = 4;
|
||||
if (cb) {
|
||||
ret = cb(C, member, result);
|
||||
if (ret) done= -(-ret | -done);
|
||||
if (ret) done = -(-ret | -done);
|
||||
}
|
||||
}
|
||||
|
||||
C->data.recursion= recursion;
|
||||
C->data.recursion = recursion;
|
||||
|
||||
return done;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
|
||||
{
|
||||
bContextDataResult result;
|
||||
|
||||
if (C && ctx_data_get((bContext*)C, member, &result)==1)
|
||||
if (C && ctx_data_get((bContext *)C, member, &result) == 1)
|
||||
return result.ptr.data;
|
||||
|
||||
return NULL;
|
||||
@@ -327,15 +327,15 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void *
|
||||
|
||||
/* if context is NULL, pointer must be NULL too and that is a valid return */
|
||||
if (C == NULL) {
|
||||
*pointer= NULL;
|
||||
*pointer = NULL;
|
||||
return 1;
|
||||
}
|
||||
else if (ctx_data_get((bContext*)C, member, &result)==1) {
|
||||
*pointer= result.ptr.data;
|
||||
else if (ctx_data_get((bContext *)C, member, &result) == 1) {
|
||||
*pointer = result.ptr.data;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
*pointer= NULL;
|
||||
*pointer = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -344,13 +344,13 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
|
||||
{
|
||||
bContextDataResult result;
|
||||
|
||||
if (ctx_data_get((bContext*)C, member, &result)==1) {
|
||||
*list= result.list;
|
||||
if (ctx_data_get((bContext *)C, member, &result) == 1) {
|
||||
*list = result.list;
|
||||
return 1;
|
||||
}
|
||||
|
||||
list->first= NULL;
|
||||
list->last= NULL;
|
||||
list->first = NULL;
|
||||
list->last = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
|
||||
{
|
||||
bContextDataResult result;
|
||||
|
||||
if (ctx_data_get((bContext*)C, member, &result)==1)
|
||||
if (ctx_data_get((bContext *)C, member, &result) == 1)
|
||||
return result.ptr;
|
||||
else
|
||||
return PointerRNA_NULL;
|
||||
@@ -379,11 +379,11 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
|
||||
{
|
||||
bContextDataResult result;
|
||||
|
||||
if (ctx_data_get((bContext*)C, member, &result)==1) {
|
||||
if (ctx_data_get((bContext *)C, member, &result) == 1) {
|
||||
return result.list;
|
||||
}
|
||||
else {
|
||||
ListBase list= {NULL, NULL};
|
||||
ListBase list = {NULL, NULL};
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -392,17 +392,17 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
|
||||
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type)
|
||||
{
|
||||
bContextDataResult result;
|
||||
int ret= ctx_data_get((bContext*)C, member, &result);
|
||||
int ret = ctx_data_get((bContext *)C, member, &result);
|
||||
|
||||
if (ret==1) {
|
||||
*r_ptr= result.ptr;
|
||||
*r_lb= result.list;
|
||||
*r_type= result.type;
|
||||
if (ret == 1) {
|
||||
*r_ptr = result.ptr;
|
||||
*r_lb = result.list;
|
||||
*r_type = result.type;
|
||||
}
|
||||
else {
|
||||
memset(r_ptr, 0, sizeof(*r_ptr));
|
||||
memset(r_lb, 0, sizeof(*r_lb));
|
||||
*r_type= 0;
|
||||
*r_type = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -418,8 +418,8 @@ static void data_dir_add(ListBase *lb, const char *member)
|
||||
if (BLI_findstring(lb, member, offsetof(LinkData, data)))
|
||||
return;
|
||||
|
||||
link= MEM_callocN(sizeof(LinkData), "LinkData");
|
||||
link->data= (void*)member;
|
||||
link = MEM_callocN(sizeof(LinkData), "LinkData");
|
||||
link->data = (void *)member;
|
||||
BLI_addtail(lb, link);
|
||||
}
|
||||
|
||||
@@ -437,32 +437,32 @@ ListBase CTX_data_dir_get(const bContext *C)
|
||||
if (C->wm.store) {
|
||||
bContextStoreEntry *entry;
|
||||
|
||||
for (entry=C->wm.store->entries.first; entry; entry=entry->next)
|
||||
for (entry = C->wm.store->entries.first; entry; entry = entry->next)
|
||||
data_dir_add(&lb, entry->name);
|
||||
}
|
||||
if ((ar=CTX_wm_region(C)) && ar->type && ar->type->context) {
|
||||
if ((ar = CTX_wm_region(C)) && ar->type && ar->type->context) {
|
||||
memset(&result, 0, sizeof(result));
|
||||
ar->type->context(C, "", &result);
|
||||
|
||||
if (result.dir)
|
||||
for (a=0; result.dir[a]; a++)
|
||||
for (a = 0; result.dir[a]; a++)
|
||||
data_dir_add(&lb, result.dir[a]);
|
||||
}
|
||||
if ((sa=CTX_wm_area(C)) && sa->type && sa->type->context) {
|
||||
if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) {
|
||||
memset(&result, 0, sizeof(result));
|
||||
sa->type->context(C, "", &result);
|
||||
|
||||
if (result.dir)
|
||||
for (a=0; result.dir[a]; a++)
|
||||
for (a = 0; result.dir[a]; a++)
|
||||
data_dir_add(&lb, result.dir[a]);
|
||||
}
|
||||
if ((sc=CTX_wm_screen(C)) && sc->context) {
|
||||
bContextDataCallback cb= sc->context;
|
||||
if ((sc = CTX_wm_screen(C)) && sc->context) {
|
||||
bContextDataCallback cb = sc->context;
|
||||
memset(&result, 0, sizeof(result));
|
||||
cb(C, "", &result);
|
||||
|
||||
if (result.dir)
|
||||
for (a=0; result.dir[a]; a++)
|
||||
for (a = 0; result.dir[a]; a++)
|
||||
data_dir_add(&lb, result.dir[a]);
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ void CTX_data_id_list_add(bContextDataResult *result, ID *id)
|
||||
{
|
||||
CollectionPointerLink *link;
|
||||
|
||||
link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
|
||||
link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
|
||||
RNA_id_pointer_create(id, &link->ptr);
|
||||
|
||||
BLI_addtail(&result->list, link);
|
||||
@@ -503,18 +503,18 @@ void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void
|
||||
{
|
||||
CollectionPointerLink *link;
|
||||
|
||||
link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
|
||||
link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
|
||||
RNA_pointer_create(id, type, data, &link->ptr);
|
||||
|
||||
BLI_addtail(&result->list, link);
|
||||
}
|
||||
|
||||
int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*))
|
||||
int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *))
|
||||
{
|
||||
ListBase list;
|
||||
|
||||
if (func(C, &list)) {
|
||||
int tot= BLI_countlist(&list);
|
||||
int tot = BLI_countlist(&list);
|
||||
BLI_freelistN(&list);
|
||||
return tot;
|
||||
}
|
||||
@@ -524,12 +524,12 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase
|
||||
|
||||
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
|
||||
{
|
||||
result->dir= dir;
|
||||
result->dir = dir;
|
||||
}
|
||||
|
||||
void CTX_data_type_set(bContextDataResult *result, short type)
|
||||
{
|
||||
result->type= type;
|
||||
result->type = type;
|
||||
}
|
||||
|
||||
short CTX_data_type_get(bContextDataResult *result)
|
||||
@@ -564,7 +564,7 @@ ScrArea *CTX_wm_area(const bContext *C)
|
||||
SpaceLink *CTX_wm_space_data(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
return (sa)? sa->spacedata.first: NULL;
|
||||
return (sa) ? sa->spacedata.first : NULL;
|
||||
}
|
||||
|
||||
ARegion *CTX_wm_region(const bContext *C)
|
||||
@@ -575,7 +575,7 @@ ARegion *CTX_wm_region(const bContext *C)
|
||||
void *CTX_wm_region_data(const bContext *C)
|
||||
{
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
return (ar)? ar->regiondata: NULL;
|
||||
return (ar) ? ar->regiondata : NULL;
|
||||
}
|
||||
|
||||
struct ARegion *CTX_wm_menu(const bContext *C)
|
||||
@@ -594,7 +594,7 @@ struct ReportList *CTX_wm_reports(const bContext *C)
|
||||
View3D *CTX_wm_view3d(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_VIEW3D)
|
||||
if (sa && sa->spacetype == SPACE_VIEW3D)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -604,7 +604,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
if (sa && sa->spacetype==SPACE_VIEW3D)
|
||||
if (sa && sa->spacetype == SPACE_VIEW3D)
|
||||
if (ar)
|
||||
return ar->regiondata;
|
||||
return NULL;
|
||||
@@ -613,7 +613,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
||||
struct SpaceText *CTX_wm_space_text(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_TEXT)
|
||||
if (sa && sa->spacetype == SPACE_TEXT)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -621,7 +621,7 @@ struct SpaceText *CTX_wm_space_text(const bContext *C)
|
||||
struct SpaceConsole *CTX_wm_space_console(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_CONSOLE)
|
||||
if (sa && sa->spacetype == SPACE_CONSOLE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -629,7 +629,7 @@ struct SpaceConsole *CTX_wm_space_console(const bContext *C)
|
||||
struct SpaceImage *CTX_wm_space_image(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_IMAGE)
|
||||
if (sa && sa->spacetype == SPACE_IMAGE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -637,7 +637,7 @@ struct SpaceImage *CTX_wm_space_image(const bContext *C)
|
||||
struct SpaceButs *CTX_wm_space_buts(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_BUTS)
|
||||
if (sa && sa->spacetype == SPACE_BUTS)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -645,7 +645,7 @@ struct SpaceButs *CTX_wm_space_buts(const bContext *C)
|
||||
struct SpaceFile *CTX_wm_space_file(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_FILE)
|
||||
if (sa && sa->spacetype == SPACE_FILE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -653,7 +653,7 @@ struct SpaceFile *CTX_wm_space_file(const bContext *C)
|
||||
struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_SEQ)
|
||||
if (sa && sa->spacetype == SPACE_SEQ)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -661,7 +661,7 @@ struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
||||
struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_OUTLINER)
|
||||
if (sa && sa->spacetype == SPACE_OUTLINER)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -669,7 +669,7 @@ struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
|
||||
struct SpaceNla *CTX_wm_space_nla(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_NLA)
|
||||
if (sa && sa->spacetype == SPACE_NLA)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -677,7 +677,7 @@ struct SpaceNla *CTX_wm_space_nla(const bContext *C)
|
||||
struct SpaceTime *CTX_wm_space_time(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_TIME)
|
||||
if (sa && sa->spacetype == SPACE_TIME)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -685,7 +685,7 @@ struct SpaceTime *CTX_wm_space_time(const bContext *C)
|
||||
struct SpaceNode *CTX_wm_space_node(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_NODE)
|
||||
if (sa && sa->spacetype == SPACE_NODE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -693,7 +693,7 @@ struct SpaceNode *CTX_wm_space_node(const bContext *C)
|
||||
struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_LOGIC)
|
||||
if (sa && sa->spacetype == SPACE_LOGIC)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -701,7 +701,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
|
||||
struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_IPO)
|
||||
if (sa && sa->spacetype == SPACE_IPO)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -709,7 +709,7 @@ struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
|
||||
struct SpaceAction *CTX_wm_space_action(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_ACTION)
|
||||
if (sa && sa->spacetype == SPACE_ACTION)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -717,7 +717,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C)
|
||||
struct SpaceInfo *CTX_wm_space_info(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_INFO)
|
||||
if (sa && sa->spacetype == SPACE_INFO)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -725,7 +725,7 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C)
|
||||
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_USERPREF)
|
||||
if (sa && sa->spacetype == SPACE_USERPREF)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@@ -733,58 +733,58 @@ struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
||||
struct SpaceClip *CTX_wm_space_clip(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_CLIP)
|
||||
if (sa && sa->spacetype == SPACE_CLIP)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
|
||||
{
|
||||
C->wm.manager= wm;
|
||||
C->wm.window= NULL;
|
||||
C->wm.screen= NULL;
|
||||
C->wm.area= NULL;
|
||||
C->wm.region= NULL;
|
||||
C->wm.manager = wm;
|
||||
C->wm.window = NULL;
|
||||
C->wm.screen = NULL;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_window_set(bContext *C, wmWindow *win)
|
||||
{
|
||||
C->wm.window= win;
|
||||
C->wm.screen= (win)? win->screen: NULL;
|
||||
C->wm.window = win;
|
||||
C->wm.screen = (win) ? win->screen : NULL;
|
||||
if (C->wm.screen)
|
||||
C->data.scene= C->wm.screen->scene;
|
||||
C->wm.area= NULL;
|
||||
C->wm.region= NULL;
|
||||
C->data.scene = C->wm.screen->scene;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_screen_set(bContext *C, bScreen *screen)
|
||||
{
|
||||
C->wm.screen= screen;
|
||||
C->wm.screen = screen;
|
||||
if (C->wm.screen)
|
||||
C->data.scene= C->wm.screen->scene;
|
||||
C->wm.area= NULL;
|
||||
C->wm.region= NULL;
|
||||
C->data.scene = C->wm.screen->scene;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_area_set(bContext *C, ScrArea *area)
|
||||
{
|
||||
C->wm.area= area;
|
||||
C->wm.region= NULL;
|
||||
C->wm.area = area;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_region_set(bContext *C, ARegion *region)
|
||||
{
|
||||
C->wm.region= region;
|
||||
C->wm.region = region;
|
||||
}
|
||||
|
||||
void CTX_wm_menu_set(bContext *C, ARegion *menu)
|
||||
{
|
||||
C->wm.menu= menu;
|
||||
C->wm.menu = menu;
|
||||
}
|
||||
|
||||
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
|
||||
{
|
||||
C->wm.operator_poll_msg= msg;
|
||||
C->wm.operator_poll_msg = msg;
|
||||
}
|
||||
|
||||
const char *CTX_wm_operator_poll_msg_get(bContext *C)
|
||||
@@ -798,7 +798,7 @@ Main *CTX_data_main(const bContext *C)
|
||||
{
|
||||
Main *bmain;
|
||||
|
||||
if (ctx_data_pointer_verify(C, "blend_data", (void*)&bmain))
|
||||
if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain))
|
||||
return bmain;
|
||||
else
|
||||
return C->data.main;
|
||||
@@ -806,14 +806,14 @@ Main *CTX_data_main(const bContext *C)
|
||||
|
||||
void CTX_data_main_set(bContext *C, Main *bmain)
|
||||
{
|
||||
C->data.main= bmain;
|
||||
C->data.main = bmain;
|
||||
}
|
||||
|
||||
Scene *CTX_data_scene(const bContext *C)
|
||||
{
|
||||
Scene *scene;
|
||||
|
||||
if (ctx_data_pointer_verify(C, "scene", (void*)&scene))
|
||||
if (ctx_data_pointer_verify(C, "scene", (void *)&scene))
|
||||
return scene;
|
||||
else
|
||||
return C->data.scene;
|
||||
@@ -821,7 +821,7 @@ Scene *CTX_data_scene(const bContext *C)
|
||||
|
||||
int CTX_data_mode_enum(const bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
|
||||
if (obedit) {
|
||||
switch (obedit->type) {
|
||||
@@ -846,7 +846,7 @@ int CTX_data_mode_enum(const bContext *C)
|
||||
|
||||
if (ob) {
|
||||
if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
|
||||
else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT;
|
||||
else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT;
|
||||
else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
|
||||
else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
|
||||
else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
|
||||
@@ -884,7 +884,7 @@ const char *CTX_data_mode_string(const bContext *C)
|
||||
|
||||
void CTX_data_scene_set(bContext *C, Scene *scene)
|
||||
{
|
||||
C->data.scene= scene;
|
||||
C->data.scene = scene;
|
||||
}
|
||||
|
||||
ToolSettings *CTX_data_tool_settings(const bContext *C)
|
||||
|
||||
@@ -82,10 +82,10 @@
|
||||
* the queue store a list of freenodes to avoid successive alloc/dealloc
|
||||
*/
|
||||
|
||||
DagNodeQueue * queue_create (int slots)
|
||||
DagNodeQueue *queue_create(int slots)
|
||||
{
|
||||
DagNodeQueue * queue;
|
||||
DagNodeQueueElem * elem;
|
||||
DagNodeQueue *queue;
|
||||
DagNodeQueueElem *elem;
|
||||
int i;
|
||||
|
||||
queue = MEM_mallocN(sizeof(DagNodeQueue), "DAG queue");
|
||||
@@ -98,7 +98,7 @@ DagNodeQueue * queue_create (int slots)
|
||||
elem->next = NULL;
|
||||
queue->freenodes->first = queue->freenodes->last = elem;
|
||||
|
||||
for (i = 1; i <slots;i++) {
|
||||
for (i = 1; i < slots; i++) {
|
||||
elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem4");
|
||||
elem->node = NULL;
|
||||
elem->next = NULL;
|
||||
@@ -111,7 +111,7 @@ DagNodeQueue * queue_create (int slots)
|
||||
|
||||
void queue_raz(DagNodeQueue *queue)
|
||||
{
|
||||
DagNodeQueueElem * elem;
|
||||
DagNodeQueueElem *elem;
|
||||
|
||||
elem = queue->first;
|
||||
if (queue->freenodes->last)
|
||||
@@ -132,8 +132,8 @@ void queue_raz(DagNodeQueue *queue)
|
||||
|
||||
void queue_delete(DagNodeQueue *queue)
|
||||
{
|
||||
DagNodeQueueElem * elem;
|
||||
DagNodeQueueElem * temp;
|
||||
DagNodeQueueElem *elem;
|
||||
DagNodeQueueElem *temp;
|
||||
|
||||
elem = queue->first;
|
||||
while (elem) {
|
||||
@@ -156,7 +156,7 @@ void queue_delete(DagNodeQueue *queue)
|
||||
/* insert in queue, remove in front */
|
||||
void push_queue(DagNodeQueue *queue, DagNode *node)
|
||||
{
|
||||
DagNodeQueueElem * elem;
|
||||
DagNodeQueueElem *elem;
|
||||
int i;
|
||||
|
||||
if (node == NULL) {
|
||||
@@ -168,7 +168,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node)
|
||||
elem = queue->freenodes->first;
|
||||
if (elem != NULL) {
|
||||
queue->freenodes->first = elem->next;
|
||||
if ( queue->freenodes->last == elem) {
|
||||
if (queue->freenodes->last == elem) {
|
||||
queue->freenodes->last = NULL;
|
||||
queue->freenodes->first = NULL;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node)
|
||||
elem->next = NULL;
|
||||
queue->freenodes->first = queue->freenodes->last = elem;
|
||||
|
||||
for (i = 1; i <DAGQUEUEALLOC;i++) {
|
||||
for (i = 1; i < DAGQUEUEALLOC; i++) {
|
||||
elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem2");
|
||||
elem->node = NULL;
|
||||
elem->next = NULL;
|
||||
@@ -207,13 +207,13 @@ void push_queue(DagNodeQueue *queue, DagNode *node)
|
||||
/* insert in front, remove in front */
|
||||
void push_stack(DagNodeQueue *queue, DagNode *node)
|
||||
{
|
||||
DagNodeQueueElem * elem;
|
||||
DagNodeQueueElem *elem;
|
||||
int i;
|
||||
|
||||
elem = queue->freenodes->first;
|
||||
if (elem != NULL) {
|
||||
queue->freenodes->first = elem->next;
|
||||
if ( queue->freenodes->last == elem) {
|
||||
if (queue->freenodes->last == elem) {
|
||||
queue->freenodes->last = NULL;
|
||||
queue->freenodes->first = NULL;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void push_stack(DagNodeQueue *queue, DagNode *node)
|
||||
elem->next = NULL;
|
||||
queue->freenodes->first = queue->freenodes->last = elem;
|
||||
|
||||
for (i = 1; i <DAGQUEUEALLOC;i++) {
|
||||
for (i = 1; i < DAGQUEUEALLOC; i++) {
|
||||
elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem2");
|
||||
elem->node = NULL;
|
||||
elem->next = NULL;
|
||||
@@ -246,24 +246,24 @@ void push_stack(DagNodeQueue *queue, DagNode *node)
|
||||
}
|
||||
|
||||
|
||||
DagNode * pop_queue(DagNodeQueue *queue)
|
||||
DagNode *pop_queue(DagNodeQueue *queue)
|
||||
{
|
||||
DagNodeQueueElem * elem;
|
||||
DagNodeQueueElem *elem;
|
||||
DagNode *node;
|
||||
|
||||
elem = queue->first;
|
||||
if (elem) {
|
||||
queue->first = elem->next;
|
||||
if (queue->last == elem) {
|
||||
queue->last=NULL;
|
||||
queue->first=NULL;
|
||||
queue->last = NULL;
|
||||
queue->first = NULL;
|
||||
}
|
||||
queue->count--;
|
||||
if (queue->freenodes->last)
|
||||
queue->freenodes->last->next=elem;
|
||||
queue->freenodes->last=elem;
|
||||
queue->freenodes->last->next = elem;
|
||||
queue->freenodes->last = elem;
|
||||
if (queue->freenodes->first == NULL)
|
||||
queue->freenodes->first=elem;
|
||||
queue->freenodes->first = elem;
|
||||
node = elem->node;
|
||||
elem->node = NULL;
|
||||
elem->next = NULL;
|
||||
@@ -276,17 +276,17 @@ DagNode * pop_queue(DagNodeQueue *queue)
|
||||
}
|
||||
}
|
||||
|
||||
void *pop_ob_queue(struct DagNodeQueue *queue)
|
||||
void *pop_ob_queue(struct DagNodeQueue *queue)
|
||||
{
|
||||
return(pop_queue(queue)->ob);
|
||||
}
|
||||
|
||||
DagNode * get_top_node_queue(DagNodeQueue *queue)
|
||||
DagNode *get_top_node_queue(DagNodeQueue *queue)
|
||||
{
|
||||
return queue->first->node;
|
||||
}
|
||||
|
||||
int queue_count(struct DagNodeQueue *queue)
|
||||
int queue_count(struct DagNodeQueue *queue)
|
||||
{
|
||||
return queue->count;
|
||||
}
|
||||
@@ -307,37 +307,37 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
|
||||
FCurve *fcu;
|
||||
DagNode *node1;
|
||||
|
||||
for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
DriverVar *dvar;
|
||||
int isdata_fcu = isdata || (fcu->rna_path && strstr(fcu->rna_path, "modifiers["));
|
||||
|
||||
/* loop over variables to get the target relationships */
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
/* only used targets */
|
||||
DRIVER_TARGETS_USED_LOOPER(dvar)
|
||||
{
|
||||
if (dtar->id) {
|
||||
// FIXME: other data types need to be added here so that they can work!
|
||||
if (GS(dtar->id->name)==ID_OB) {
|
||||
Object *ob= (Object *)dtar->id;
|
||||
if (GS(dtar->id->name) == ID_OB) {
|
||||
Object *ob = (Object *)dtar->id;
|
||||
|
||||
/* normal channel-drives-channel */
|
||||
node1 = dag_get_node(dag, dtar->id);
|
||||
|
||||
/* check if bone... */
|
||||
if ((ob->type==OB_ARMATURE) &&
|
||||
( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) ||
|
||||
((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) ))
|
||||
if ((ob->type == OB_ARMATURE) &&
|
||||
( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) ||
|
||||
((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) ))
|
||||
{
|
||||
dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver");
|
||||
dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver");
|
||||
}
|
||||
/* check if ob data */
|
||||
else if (dtar->rna_path && strstr(dtar->rna_path, "data."))
|
||||
dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver");
|
||||
dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver");
|
||||
/* normal */
|
||||
else
|
||||
dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Driver");
|
||||
dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_OB_DATA : DAG_RL_OB_OB, "Driver");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,12 +353,12 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec
|
||||
|
||||
// would be nice to have a list of colliders here
|
||||
// so for now walk all objects in scene check 'same layer rule'
|
||||
for (base = scene->base.first; base; base= base->next) {
|
||||
for (base = scene->base.first; base; base = base->next) {
|
||||
if ((base->lay & ob->lay) && base->object->pd) {
|
||||
Object *ob1= base->object;
|
||||
Object *ob1 = base->object;
|
||||
if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) {
|
||||
node2 = dag_get_node(dag, ob1);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Field Collision");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,16 +367,16 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec
|
||||
static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, Object *ob, int mask)
|
||||
{
|
||||
bConstraint *con;
|
||||
DagNode * node;
|
||||
DagNode * node2;
|
||||
DagNode * node3;
|
||||
DagNode *node;
|
||||
DagNode *node2;
|
||||
DagNode *node3;
|
||||
Key *key;
|
||||
ParticleSystem *psys;
|
||||
int addtoroot= 1;
|
||||
int addtoroot = 1;
|
||||
|
||||
node = dag_get_node(dag, ob);
|
||||
|
||||
if ((ob->data) && (mask&DAG_RL_DATA)) {
|
||||
if ((ob->data) && (mask & DAG_RL_DATA)) {
|
||||
node2 = dag_get_node(dag, ob->data);
|
||||
dag_add_relation(dag, node, node2, DAG_RL_DATA, "Object-Data Relation");
|
||||
node2->first_ancestor = ob;
|
||||
@@ -384,34 +384,34 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
}
|
||||
|
||||
/* also build a custom data mask for dependencies that need certain layers */
|
||||
node->customdata_mask= 0;
|
||||
node->customdata_mask = 0;
|
||||
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
if (ob->pose) {
|
||||
bPoseChannel *pchan;
|
||||
bConstraint *con;
|
||||
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
|
||||
for (con = pchan->constraints.first; con; con=con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (pchan = ob->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 && ct->tar != ob) {
|
||||
// fprintf(stderr, "armature %s target :%s\n", ob->id.name, target->id.name);
|
||||
node3 = dag_get_node(dag, ct->tar);
|
||||
|
||||
if (ct->subtarget[0]) {
|
||||
dag_add_relation(dag, node3, node, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, cti->name);
|
||||
dag_add_relation(dag, node3, node, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, cti->name);
|
||||
if (ct->tar->type == OB_MESH)
|
||||
node3->customdata_mask |= CD_MASK_MDEFORMVERT;
|
||||
}
|
||||
else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK))
|
||||
dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, cti->name);
|
||||
dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, cti->name);
|
||||
else
|
||||
dag_add_relation(dag, node3, node, DAG_RL_OB_DATA, cti->name);
|
||||
}
|
||||
@@ -431,13 +431,13 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
if (ob->nlastrips.first) {
|
||||
bActionStrip *strip;
|
||||
bActionChannel *chan;
|
||||
for (strip= ob->nlastrips.first; strip; strip= strip->next) {
|
||||
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
|
||||
if (strip->modifiers.first) {
|
||||
bActionModifier *amod;
|
||||
for (amod= strip->modifiers.first; amod; amod= amod->next) {
|
||||
for (amod = strip->modifiers.first; amod; amod = amod->next) {
|
||||
if (amod->ob) {
|
||||
node2 = dag_get_node(dag, amod->ob);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "NLA Strip Modifier");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "NLA Strip Modifier");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,16 +445,16 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
}
|
||||
#endif // XXX old animation system
|
||||
if (ob->adt)
|
||||
dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation
|
||||
dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation
|
||||
|
||||
key= ob_get_key(ob);
|
||||
key = ob_get_key(ob);
|
||||
if (key && key->adt)
|
||||
dag_add_driver_relation(key->adt, dag, node, 1);
|
||||
|
||||
if (ob->modifiers.first) {
|
||||
ModifierData *md;
|
||||
|
||||
for (md=ob->modifiers.first; md; md=md->next) {
|
||||
for (md = ob->modifiers.first; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (mti->updateDepgraph) mti->updateDepgraph(md, dag, scene, ob, node);
|
||||
@@ -465,22 +465,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
|
||||
switch (ob->partype) {
|
||||
case PARSKEL:
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Parent");
|
||||
break;
|
||||
case PARVERT1: case PARVERT3:
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Vertex Parent");
|
||||
node2->customdata_mask |= CD_MASK_ORIGINDEX;
|
||||
break;
|
||||
case PARBONE:
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Bone Parent");
|
||||
break;
|
||||
default:
|
||||
if (ob->parent->type==OB_LATTICE)
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Lattice Parent");
|
||||
else if (ob->parent->type==OB_CURVE) {
|
||||
Curve *cu= ob->parent->data;
|
||||
if (ob->parent->type == OB_LATTICE)
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Lattice Parent");
|
||||
else if (ob->parent->type == OB_CURVE) {
|
||||
Curve *cu = ob->parent->data;
|
||||
if (cu->flag & CU_PATH)
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Curve Parent");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Curve Parent");
|
||||
else
|
||||
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Curve Parent");
|
||||
}
|
||||
@@ -488,22 +488,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Parent");
|
||||
}
|
||||
/* exception case: parent is duplivert */
|
||||
if (ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) {
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Duplivert");
|
||||
if (ob->type == OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) {
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Duplivert");
|
||||
}
|
||||
|
||||
addtoroot = 0;
|
||||
}
|
||||
if (ob->proxy) {
|
||||
node2 = dag_get_node(dag, ob->proxy);
|
||||
dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Proxy");
|
||||
dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Proxy");
|
||||
/* inverted relation, so addtoroot shouldn't be set to zero */
|
||||
}
|
||||
|
||||
if (ob->transflag & OB_DUPLI) {
|
||||
if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
|
||||
GroupObject *go;
|
||||
for (go= ob->dup_group->gobject.first; go; go= go->next) {
|
||||
for (go = ob->dup_group->gobject.first; go; go = go->next) {
|
||||
if (go->ob) {
|
||||
node2 = dag_get_node(dag, go->ob);
|
||||
/* node2 changes node1, this keeps animations updated in groups?? not logical? */
|
||||
@@ -514,14 +514,14 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
}
|
||||
|
||||
/* softbody collision */
|
||||
if ((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) {
|
||||
if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) {
|
||||
if (modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first)
|
||||
dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */
|
||||
dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */
|
||||
}
|
||||
|
||||
/* object data drivers */
|
||||
if (ob->data) {
|
||||
AnimData *adt= BKE_animdata_from_id((ID *)ob->data);
|
||||
AnimData *adt = BKE_animdata_from_id((ID *)ob->data);
|
||||
if (adt)
|
||||
dag_add_driver_relation(adt, dag, node, 1);
|
||||
}
|
||||
@@ -537,49 +537,49 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Camera DoF");
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case OB_MBALL:
|
||||
{
|
||||
Object *mom= BKE_metaball_basis_find(scene, ob);
|
||||
Object *mom = BKE_metaball_basis_find(scene, ob);
|
||||
|
||||
if (mom!=ob) {
|
||||
if (mom != ob) {
|
||||
node2 = dag_get_node(dag, mom);
|
||||
dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children!
|
||||
dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); // mom depends on children!
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case OB_CURVE:
|
||||
case OB_FONT:
|
||||
{
|
||||
Curve *cu= ob->data;
|
||||
Curve *cu = ob->data;
|
||||
|
||||
if (cu->bevobj) {
|
||||
node2 = dag_get_node(dag, cu->bevobj);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Bevel");
|
||||
}
|
||||
if (cu->taperobj) {
|
||||
node2 = dag_get_node(dag, cu->taperobj);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Taper");
|
||||
}
|
||||
if (ob->type == OB_FONT) {
|
||||
if (cu->textoncurve) {
|
||||
node2 = dag_get_node(dag, cu->textoncurve);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Texture On Curve");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* particles */
|
||||
psys= ob->particlesystem.first;
|
||||
psys = ob->particlesystem.first;
|
||||
if (psys) {
|
||||
GroupObject *go;
|
||||
|
||||
for (; psys; psys=psys->next) {
|
||||
for (; psys; psys = psys->next) {
|
||||
BoidRule *rule = NULL;
|
||||
BoidState *state = NULL;
|
||||
ParticleSettings *part= psys->part;
|
||||
ParticleSettings *part = psys->part;
|
||||
ListBase *effectors = NULL;
|
||||
EffectorCache *eff;
|
||||
|
||||
@@ -591,12 +591,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) {
|
||||
ParticleTarget *pt = psys->targets.first;
|
||||
|
||||
for (; pt; pt=pt->next) {
|
||||
if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys-1)) {
|
||||
for (; pt; pt = pt->next) {
|
||||
if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys - 1)) {
|
||||
node2 = dag_get_node(dag, pt->ob);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Targets");
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Targets");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (part->ren_as == PART_DRAW_OB && part->dup_ob) {
|
||||
@@ -610,7 +610,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
}
|
||||
|
||||
if (part->ren_as == PART_DRAW_GR && part->dup_group) {
|
||||
for (go=part->dup_group->gobject.first; go; go=go->next) {
|
||||
for (go = part->dup_group->gobject.first; go; go = go->next) {
|
||||
node2 = dag_get_node(dag, go->ob);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation");
|
||||
}
|
||||
@@ -618,23 +618,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
|
||||
effectors = pdInitEffectors(scene, ob, psys, part->effector_weights);
|
||||
|
||||
if (effectors) for (eff = effectors->first; eff; eff=eff->next) {
|
||||
if (eff->psys) {
|
||||
node2 = dag_get_node(dag, eff->ob);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Field");
|
||||
if (effectors) {
|
||||
for (eff = effectors->first; eff; eff = eff->next) {
|
||||
if (eff->psys) {
|
||||
node2 = dag_get_node(dag, eff->ob);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Field");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pdEndEffectors(&effectors);
|
||||
|
||||
if (part->boids) {
|
||||
for (state = part->boids->states.first; state; state=state->next) {
|
||||
for (rule = state->rules.first; rule; rule=rule->next) {
|
||||
for (state = part->boids->states.first; state; state = state->next) {
|
||||
for (rule = state->rules.first; rule; rule = rule->next) {
|
||||
Object *ruleob = NULL;
|
||||
if (rule->type==eBoidRuleType_Avoid)
|
||||
ruleob = ((BoidRuleGoalAvoid*)rule)->ob;
|
||||
else if (rule->type==eBoidRuleType_FollowLeader)
|
||||
ruleob = ((BoidRuleFollowLeader*)rule)->ob;
|
||||
if (rule->type == eBoidRuleType_Avoid)
|
||||
ruleob = ((BoidRuleGoalAvoid *)rule)->ob;
|
||||
else if (rule->type == eBoidRuleType_FollowLeader)
|
||||
ruleob = ((BoidRuleFollowLeader *)rule)->ob;
|
||||
|
||||
if (ruleob) {
|
||||
node2 = dag_get_node(dag, ruleob);
|
||||
@@ -647,8 +649,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
}
|
||||
|
||||
/* object constraints */
|
||||
for (con = ob->constraints.first; con; con=con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = ob->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -657,25 +659,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
|
||||
/* special case for camera tracking -- it doesn't use targets to define relations */
|
||||
if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) {
|
||||
int depends_on_camera= 0;
|
||||
int depends_on_camera = 0;
|
||||
|
||||
if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
|
||||
bFollowTrackConstraint *data= (bFollowTrackConstraint *)con->data;
|
||||
if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
|
||||
bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data;
|
||||
|
||||
if ((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0])
|
||||
depends_on_camera= 1;
|
||||
if ((data->clip || data->flag & FOLLOWTRACK_ACTIVECLIP) && data->track[0])
|
||||
depends_on_camera = 1;
|
||||
|
||||
if (data->depth_ob) {
|
||||
node2 = dag_get_node(dag, data->depth_ob);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name);
|
||||
}
|
||||
}
|
||||
else if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER)
|
||||
depends_on_camera= 1;
|
||||
else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER)
|
||||
depends_on_camera = 1;
|
||||
|
||||
if (depends_on_camera && scene->camera) {
|
||||
node2 = dag_get_node(dag, scene->camera);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name);
|
||||
}
|
||||
|
||||
dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation");
|
||||
@@ -684,20 +686,20 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
else if (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) {
|
||||
Object *obt;
|
||||
|
||||
if (ct->tar)
|
||||
obt= ct->tar;
|
||||
obt = ct->tar;
|
||||
else
|
||||
continue;
|
||||
|
||||
node2 = dag_get_node(dag, obt);
|
||||
if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO))
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name);
|
||||
else {
|
||||
if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) {
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
|
||||
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name);
|
||||
if (obt->type == OB_MESH)
|
||||
node2->customdata_mask |= CD_MASK_MDEFORMVERT;
|
||||
}
|
||||
@@ -712,12 +714,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
}
|
||||
}
|
||||
|
||||
if (addtoroot == 1 )
|
||||
if (addtoroot == 1)
|
||||
dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation");
|
||||
}
|
||||
|
||||
struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
|
||||
{
|
||||
struct DagForest *build_dag(Main *bmain, Scene *sce, short mask){
|
||||
Base *base;
|
||||
Object *ob;
|
||||
Group *group;
|
||||
@@ -728,8 +729,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
|
||||
DagAdjList *itA;
|
||||
|
||||
dag = sce->theDag;
|
||||
sce->dagisvalid=1;
|
||||
if ( dag)
|
||||
sce->dagisvalid = 1;
|
||||
if (dag)
|
||||
free_forest(dag);
|
||||
else {
|
||||
dag = dag_init();
|
||||
@@ -740,8 +741,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
|
||||
scenenode = dag_add_node(dag, sce);
|
||||
|
||||
/* add current scene objects */
|
||||
for (base = sce->base.first; base; base= base->next) {
|
||||
ob= base->object;
|
||||
for (base = sce->base.first; base; base = base->next) {
|
||||
ob = base->object;
|
||||
|
||||
build_dag_object(dag, scenenode, sce, ob, mask);
|
||||
if (ob->proxy)
|
||||
@@ -753,9 +754,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
|
||||
}
|
||||
|
||||
/* add groups used in current scene objects */
|
||||
for (group= bmain->group.first; group; group= group->id.next) {
|
||||
for (group = bmain->group.first; group; group = group->id.next) {
|
||||
if (group->id.flag & LIB_DOIT) {
|
||||
for (go= group->gobject.first; go; go= go->next) {
|
||||
for (go = group->gobject.first; go; go = go->next) {
|
||||
build_dag_object(dag, scenenode, sce, go->ob, mask);
|
||||
}
|
||||
group->id.flag &= ~LIB_DOIT;
|
||||
@@ -767,23 +768,23 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
|
||||
* the relation type has to be synced. One of the parents can change, and should give same event to child */
|
||||
|
||||
/* nodes were callocced, so we can use node->color for temporal storage */
|
||||
for (node = sce->theDag->DagNode.first; node; node= node->next) {
|
||||
if (node->type==ID_OB) {
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
if (itA->node->type==ID_OB) {
|
||||
for (node = sce->theDag->DagNode.first; node; node = node->next) {
|
||||
if (node->type == ID_OB) {
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
if (itA->node->type == ID_OB) {
|
||||
itA->node->color |= itA->type;
|
||||
}
|
||||
}
|
||||
|
||||
/* also flush custom data mask */
|
||||
((Object*)node->ob)->customdata_mask= node->customdata_mask;
|
||||
((Object *)node->ob)->customdata_mask = node->customdata_mask;
|
||||
}
|
||||
}
|
||||
/* now set relations equal, so that when only one parent changes, the correct recalcs are found */
|
||||
for (node = sce->theDag->DagNode.first; node; node= node->next) {
|
||||
if (node->type==ID_OB) {
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
if (itA->node->type==ID_OB) {
|
||||
for (node = sce->theDag->DagNode.first; node; node = node->next) {
|
||||
if (node->type == ID_OB) {
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
if (itA->node->type == ID_OB) {
|
||||
itA->type |= itA->node->color;
|
||||
}
|
||||
}
|
||||
@@ -825,14 +826,14 @@ void free_forest(DagForest *Dag)
|
||||
}
|
||||
|
||||
BLI_ghash_free(Dag->nodeHash, NULL, NULL);
|
||||
Dag->nodeHash= NULL;
|
||||
Dag->nodeHash = NULL;
|
||||
Dag->DagNode.first = NULL;
|
||||
Dag->DagNode.last = NULL;
|
||||
Dag->numNodes = 0;
|
||||
|
||||
}
|
||||
|
||||
DagNode * dag_find_node (DagForest *forest, void * fob)
|
||||
DagNode *dag_find_node(DagForest *forest, void *fob)
|
||||
{
|
||||
if (forest->nodeHash)
|
||||
return BLI_ghash_lookup(forest->nodeHash, fob);
|
||||
@@ -840,11 +841,11 @@ DagNode * dag_find_node (DagForest *forest, void * fob)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int ugly_hack_sorry= 1; // prevent type check
|
||||
static int dag_print_dependencies= 0; // debugging
|
||||
static int ugly_hack_sorry = 1; // prevent type check
|
||||
static int dag_print_dependencies = 0; // debugging
|
||||
|
||||
/* no checking of existence, use dag_find_node first or dag_get_node */
|
||||
DagNode * dag_add_node (DagForest *forest, void * fob)
|
||||
DagNode *dag_add_node(DagForest *forest, void *fob)
|
||||
{
|
||||
DagNode *node;
|
||||
|
||||
@@ -853,7 +854,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob)
|
||||
node->ob = fob;
|
||||
node->color = DAG_WHITE;
|
||||
|
||||
if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting
|
||||
if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting
|
||||
if (forest->numNodes) {
|
||||
((DagNode *) forest->DagNode.last)->next = node;
|
||||
forest->DagNode.last = node;
|
||||
@@ -866,18 +867,18 @@ DagNode * dag_add_node (DagForest *forest, void * fob)
|
||||
}
|
||||
|
||||
if (!forest->nodeHash)
|
||||
forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh");
|
||||
forest->nodeHash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh");
|
||||
BLI_ghash_insert(forest->nodeHash, fob, node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
DagNode * dag_get_node (DagForest *forest, void * fob)
|
||||
DagNode *dag_get_node(DagForest *forest, void *fob)
|
||||
{
|
||||
DagNode *node;
|
||||
|
||||
node = dag_find_node (forest, fob);
|
||||
node = dag_find_node(forest, fob);
|
||||
if (!node)
|
||||
node = dag_add_node(forest, fob);
|
||||
return node;
|
||||
@@ -885,10 +886,10 @@ DagNode * dag_get_node (DagForest *forest, void * fob)
|
||||
|
||||
|
||||
|
||||
DagNode * dag_get_sub_node (DagForest *forest, void * fob)
|
||||
DagNode *dag_get_sub_node(DagForest *forest, void *fob)
|
||||
{
|
||||
DagNode *node;
|
||||
DagAdjList *mainchild, *prev=NULL;
|
||||
DagAdjList *mainchild, *prev = NULL;
|
||||
|
||||
mainchild = ((DagNode *) forest->DagNode.first)->child;
|
||||
/* remove from first node (scene) adj list if present */
|
||||
@@ -908,7 +909,7 @@ DagNode * dag_get_sub_node (DagForest *forest, void * fob)
|
||||
prev = mainchild;
|
||||
mainchild = mainchild->next;
|
||||
}
|
||||
node = dag_find_node (forest, fob);
|
||||
node = dag_find_node(forest, fob);
|
||||
if (!node)
|
||||
node = dag_add_node(forest, fob);
|
||||
return node;
|
||||
@@ -966,9 +967,9 @@ static const char *dag_node_name(DagNode *node)
|
||||
if (node->ob == NULL)
|
||||
return "null";
|
||||
else if (ugly_hack_sorry)
|
||||
return ((ID*)(node->ob))->name+2;
|
||||
return ((ID *)(node->ob))->name + 2;
|
||||
else
|
||||
return ((bPoseChannel*)(node->ob))->name;
|
||||
return ((bPoseChannel *)(node->ob))->name;
|
||||
}
|
||||
|
||||
static void dag_node_print_dependencies(DagNode *node)
|
||||
@@ -977,7 +978,7 @@ static void dag_node_print_dependencies(DagNode *node)
|
||||
|
||||
printf("%s depends on:\n", dag_node_name(node));
|
||||
|
||||
for (itA= node->parent; itA; itA= itA->next)
|
||||
for (itA = node->parent; itA; itA = itA->next)
|
||||
printf(" %s through %s\n", dag_node_name(itA->node), itA->name);
|
||||
printf("\n");
|
||||
}
|
||||
@@ -989,12 +990,12 @@ static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode)
|
||||
if (node->color == DAG_BLACK)
|
||||
return 0;
|
||||
|
||||
node->color= DAG_BLACK;
|
||||
node->color = DAG_BLACK;
|
||||
|
||||
if (node == endnode)
|
||||
return 1;
|
||||
|
||||
for (itA= node->parent; itA; itA= itA->next) {
|
||||
for (itA = node->parent; itA; itA = itA->next) {
|
||||
if (dag_node_print_dependency_recurs(itA->node, endnode)) {
|
||||
printf(" %s depends on %s through %s.\n", dag_node_name(node), dag_node_name(itA->node), itA->name);
|
||||
return 1;
|
||||
@@ -1008,8 +1009,8 @@ static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode,
|
||||
{
|
||||
DagNode *node;
|
||||
|
||||
for (node = dag->DagNode.first; node; node= node->next)
|
||||
node->color= DAG_WHITE;
|
||||
for (node = dag->DagNode.first; node; node = node->next)
|
||||
node->color = DAG_WHITE;
|
||||
|
||||
printf(" %s depends on %s through %s.\n", dag_node_name(endnode), dag_node_name(startnode), name);
|
||||
dag_node_print_dependency_recurs(startnode, endnode);
|
||||
@@ -1021,16 +1022,16 @@ static int dag_node_recurs_level(DagNode *node, int level)
|
||||
DagAdjList *itA;
|
||||
int newlevel;
|
||||
|
||||
node->color= DAG_BLACK; /* done */
|
||||
newlevel= ++level;
|
||||
node->color = DAG_BLACK; /* done */
|
||||
newlevel = ++level;
|
||||
|
||||
for (itA= node->parent; itA; itA= itA->next) {
|
||||
if (itA->node->color==DAG_WHITE) {
|
||||
itA->node->ancestor_count= dag_node_recurs_level(itA->node, level);
|
||||
newlevel= MAX2(newlevel, level+itA->node->ancestor_count);
|
||||
for (itA = node->parent; itA; itA = itA->next) {
|
||||
if (itA->node->color == DAG_WHITE) {
|
||||
itA->node->ancestor_count = dag_node_recurs_level(itA->node, level);
|
||||
newlevel = MAX2(newlevel, level + itA->node->ancestor_count);
|
||||
}
|
||||
else
|
||||
newlevel= MAX2(newlevel, level+itA->node->ancestor_count);
|
||||
newlevel = MAX2(newlevel, level + itA->node->ancestor_count);
|
||||
}
|
||||
|
||||
return newlevel;
|
||||
@@ -1043,22 +1044,22 @@ static void dag_check_cycle(DagForest *dag)
|
||||
|
||||
/* debugging print */
|
||||
if (dag_print_dependencies)
|
||||
for (node = dag->DagNode.first; node; node= node->next)
|
||||
for (node = dag->DagNode.first; node; node = node->next)
|
||||
dag_node_print_dependencies(node);
|
||||
|
||||
/* tag nodes unchecked */
|
||||
for (node = dag->DagNode.first; node; node= node->next)
|
||||
node->color= DAG_WHITE;
|
||||
for (node = dag->DagNode.first; node; node = node->next)
|
||||
node->color = DAG_WHITE;
|
||||
|
||||
for (node = dag->DagNode.first; node; node= node->next) {
|
||||
if (node->color==DAG_WHITE) {
|
||||
node->ancestor_count= dag_node_recurs_level(node, 0);
|
||||
for (node = dag->DagNode.first; node; node = node->next) {
|
||||
if (node->color == DAG_WHITE) {
|
||||
node->ancestor_count = dag_node_recurs_level(node, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* check relations, and print errors */
|
||||
for (node = dag->DagNode.first; node; node= node->next) {
|
||||
for (itA= node->parent; itA; itA= itA->next) {
|
||||
for (node = dag->DagNode.first; node; node = node->next) {
|
||||
for (itA = node->parent; itA; itA = itA->next) {
|
||||
if (itA->node->ancestor_count > node->ancestor_count) {
|
||||
if (node->ob && itA->node->ob) {
|
||||
printf("Dependency cycle detected:\n");
|
||||
@@ -1069,7 +1070,7 @@ static void dag_check_cycle(DagForest *dag)
|
||||
}
|
||||
|
||||
/* parent relations are only needed for cycle checking, so free now */
|
||||
for (node = dag->DagNode.first; node; node= node->next) {
|
||||
for (node = dag->DagNode.first; node; node = node->next) {
|
||||
while (node->parent) {
|
||||
itA = node->parent->next;
|
||||
MEM_freeN(node->parent);
|
||||
@@ -1082,7 +1083,7 @@ static void dag_check_cycle(DagForest *dag)
|
||||
* MainDAG is the DAG of all objects in current scene
|
||||
* used only for drawing there is one also in each scene
|
||||
*/
|
||||
static DagForest * MainDag = NULL;
|
||||
static DagForest *MainDag = NULL;
|
||||
|
||||
DagForest *getMainDag(void)
|
||||
{
|
||||
@@ -1121,7 +1122,7 @@ void graph_bfs(void)
|
||||
|
||||
/* fprintf(stderr, "starting BFS\n ------------\n"); */
|
||||
nqueue = queue_create(DAGQUEUEALLOC);
|
||||
for ( i=0; i<50; i++)
|
||||
for (i = 0; i < 50; i++)
|
||||
pos[i] = 0;
|
||||
|
||||
/* Init
|
||||
@@ -1160,14 +1161,14 @@ void graph_bfs(void)
|
||||
|
||||
itA = itA->next;
|
||||
}
|
||||
if (pos[node->BFS_dist] > node->k ) {
|
||||
if (pos[node->BFS_dist] > node->k) {
|
||||
pos[node->BFS_dist] += 1;
|
||||
node->k = (float) pos[node->BFS_dist];
|
||||
}
|
||||
else {
|
||||
pos[node->BFS_dist] = (int) node->k +1;
|
||||
pos[node->BFS_dist] = (int) node->k + 1;
|
||||
}
|
||||
set_node_xy(node, node->BFS_dist*DEPSX*2, pos[node->BFS_dist]*DEPSY*2);
|
||||
set_node_xy(node, node->BFS_dist * DEPSX * 2, pos[node->BFS_dist] * DEPSY * 2);
|
||||
node->color = DAG_BLACK;
|
||||
|
||||
// fprintf(stderr, "BFS node : %20s %i %5.0f %5.0f\n", ((ID *) node->ob)->name, node->BFS_dist, node->x, node->y);
|
||||
@@ -1190,7 +1191,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a
|
||||
DagNode *node;
|
||||
DagNodeQueue *nqueue;
|
||||
DagAdjList *itA;
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
/* fprintf(stderr, "starting BFS\n ------------\n"); */
|
||||
|
||||
/* Init
|
||||
@@ -1238,7 +1239,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a
|
||||
}
|
||||
|
||||
/* non recursive version of DFS, return queue -- outer loop present to catch odd cases (first level cycles)*/
|
||||
DagNodeQueue * graph_dfs(void)
|
||||
DagNodeQueue *graph_dfs(void)
|
||||
{
|
||||
DagNode *node;
|
||||
DagNodeQueue *nqueue;
|
||||
@@ -1249,14 +1250,14 @@ DagNodeQueue * graph_dfs(void)
|
||||
int time;
|
||||
int skip = 0;
|
||||
int minheight;
|
||||
int maxpos=0;
|
||||
int maxpos = 0;
|
||||
/* int is_cycle = 0; */ /* UNUSED */
|
||||
/*
|
||||
*fprintf(stderr, "starting DFS\n ------------\n");
|
||||
*fprintf(stderr, "starting DFS\n ------------\n");
|
||||
*/
|
||||
nqueue = queue_create(DAGQUEUEALLOC);
|
||||
retqueue = queue_create(MainDag->numNodes);
|
||||
for ( i=0; i<50; i++)
|
||||
for (i = 0; i < 50; i++)
|
||||
pos[i] = 0;
|
||||
|
||||
/* Init
|
||||
@@ -1276,86 +1277,86 @@ DagNodeQueue * graph_dfs(void)
|
||||
node = MainDag->DagNode.first;
|
||||
|
||||
do {
|
||||
if (node->color == DAG_WHITE) {
|
||||
node->color = DAG_GRAY;
|
||||
node->DFS_dist = 1;
|
||||
node->DFS_dvtm = time;
|
||||
time++;
|
||||
push_stack(nqueue, node);
|
||||
if (node->color == DAG_WHITE) {
|
||||
node->color = DAG_GRAY;
|
||||
node->DFS_dist = 1;
|
||||
node->DFS_dvtm = time;
|
||||
time++;
|
||||
push_stack(nqueue, node);
|
||||
|
||||
while (nqueue->count) {
|
||||
//graph_print_queue(nqueue);
|
||||
while (nqueue->count) {
|
||||
//graph_print_queue(nqueue);
|
||||
|
||||
skip = 0;
|
||||
node = get_top_node_queue(nqueue);
|
||||
skip = 0;
|
||||
node = get_top_node_queue(nqueue);
|
||||
|
||||
minheight = pos[node->DFS_dist];
|
||||
minheight = pos[node->DFS_dist];
|
||||
|
||||
itA = node->child;
|
||||
while (itA != NULL) {
|
||||
if (itA->node->color == DAG_WHITE) {
|
||||
itA->node->DFS_dvtm = time;
|
||||
itA->node->color = DAG_GRAY;
|
||||
itA = node->child;
|
||||
while (itA != NULL) {
|
||||
if (itA->node->color == DAG_WHITE) {
|
||||
itA->node->DFS_dvtm = time;
|
||||
itA->node->color = DAG_GRAY;
|
||||
|
||||
time++;
|
||||
itA->node->DFS_dist = node->DFS_dist + 1;
|
||||
itA->node->k = (float) minheight;
|
||||
push_stack(nqueue, itA->node);
|
||||
skip = 1;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (itA->node->color == DAG_GRAY) { // back edge
|
||||
fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name);
|
||||
/* is_cycle = 1; */ /* UNUSED */
|
||||
time++;
|
||||
itA->node->DFS_dist = node->DFS_dist + 1;
|
||||
itA->node->k = (float) minheight;
|
||||
push_stack(nqueue, itA->node);
|
||||
skip = 1;
|
||||
break;
|
||||
}
|
||||
else if (itA->node->color == DAG_BLACK) {
|
||||
/* already processed node but we may want later to change distance either to shorter to longer.
|
||||
* DFS_dist is the first encounter
|
||||
*/
|
||||
else {
|
||||
if (itA->node->color == DAG_GRAY) { // back edge
|
||||
fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name);
|
||||
/* is_cycle = 1; */ /* UNUSED */
|
||||
}
|
||||
else if (itA->node->color == DAG_BLACK) {
|
||||
/* already processed node but we may want later to change distance either to shorter to longer.
|
||||
* DFS_dist is the first encounter
|
||||
*/
|
||||
#if 0
|
||||
if (node->DFS_dist >= itA->node->DFS_dist)
|
||||
itA->node->DFS_dist = node->DFS_dist + 1;
|
||||
if (node->DFS_dist >= itA->node->DFS_dist)
|
||||
itA->node->DFS_dist = node->DFS_dist + 1;
|
||||
|
||||
fprintf(stderr, "dfs forward or cross edge :%15s %i-%i %15s %i-%i\n",
|
||||
((ID *) node->ob)->name,
|
||||
node->DFS_dvtm,
|
||||
node->DFS_fntm,
|
||||
((ID *) itA->node->ob)->name,
|
||||
itA->node->DFS_dvtm,
|
||||
itA->node->DFS_fntm);
|
||||
((ID *) node->ob)->name,
|
||||
node->DFS_dvtm,
|
||||
node->DFS_fntm,
|
||||
((ID *) itA->node->ob)->name,
|
||||
itA->node->DFS_dvtm,
|
||||
itA->node->DFS_fntm);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "dfs unknown edge\n");
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "dfs unknown edge\n");
|
||||
itA = itA->next;
|
||||
}
|
||||
itA = itA->next;
|
||||
}
|
||||
|
||||
if (!skip) {
|
||||
node = pop_queue(nqueue);
|
||||
node->color = DAG_BLACK;
|
||||
if (!skip) {
|
||||
node = pop_queue(nqueue);
|
||||
node->color = DAG_BLACK;
|
||||
|
||||
node->DFS_fntm = time;
|
||||
time++;
|
||||
if (node->DFS_dist > maxpos)
|
||||
maxpos = node->DFS_dist;
|
||||
if (pos[node->DFS_dist] > node->k ) {
|
||||
pos[node->DFS_dist] += 1;
|
||||
node->k = (float) pos[node->DFS_dist];
|
||||
}
|
||||
else {
|
||||
pos[node->DFS_dist] = (int) node->k +1;
|
||||
}
|
||||
set_node_xy(node, node->DFS_dist*DEPSX*2, pos[node->DFS_dist]*DEPSY*2);
|
||||
node->DFS_fntm = time;
|
||||
time++;
|
||||
if (node->DFS_dist > maxpos)
|
||||
maxpos = node->DFS_dist;
|
||||
if (pos[node->DFS_dist] > node->k) {
|
||||
pos[node->DFS_dist] += 1;
|
||||
node->k = (float) pos[node->DFS_dist];
|
||||
}
|
||||
else {
|
||||
pos[node->DFS_dist] = (int) node->k + 1;
|
||||
}
|
||||
set_node_xy(node, node->DFS_dist * DEPSX * 2, pos[node->DFS_dist] * DEPSY * 2);
|
||||
|
||||
// fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm );
|
||||
// fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm );
|
||||
|
||||
push_stack(retqueue, node);
|
||||
push_stack(retqueue, node);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node = node->next;
|
||||
} while (node);
|
||||
// fprintf(stderr, "i size : %i\n", maxpos);
|
||||
@@ -1382,7 +1383,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
|
||||
int skip = 0;
|
||||
int retval = 0;
|
||||
/*
|
||||
*fprintf(stderr, "starting DFS\n ------------\n");
|
||||
* fprintf(stderr, "starting DFS\n ------------\n");
|
||||
*/
|
||||
nqueue = queue_create(DAGQUEUEALLOC);
|
||||
|
||||
@@ -1429,7 +1430,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (itA->node->color == DAG_GRAY) {// back edge
|
||||
if (itA->node->color == DAG_GRAY) { // back edge
|
||||
retval = 1;
|
||||
}
|
||||
// else if (itA->node->color == DAG_BLACK) { // cross or forward
|
||||
@@ -1457,14 +1458,13 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
|
||||
|
||||
|
||||
// used to get the obs owning a datablock
|
||||
struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob)
|
||||
{
|
||||
DagNode * node, *node1;
|
||||
struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob){
|
||||
DagNode *node, *node1;
|
||||
DagNodeQueue *nqueue;
|
||||
DagAdjList *itA;
|
||||
|
||||
node = dag_find_node(dag, ob);
|
||||
if (node==NULL) {
|
||||
if (node == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
else if (node->ancestor_count == 1) { // simple case
|
||||
@@ -1491,9 +1491,8 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob)
|
||||
return nqueue;
|
||||
}
|
||||
|
||||
struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob)
|
||||
{
|
||||
DagNode * node, *node1;
|
||||
struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob){
|
||||
DagNode *node, *node1;
|
||||
DagNodeQueue *nqueue;
|
||||
DagAdjList *itA;
|
||||
|
||||
@@ -1520,8 +1519,7 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob)
|
||||
}
|
||||
|
||||
// standard DFS list
|
||||
struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
|
||||
{
|
||||
struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob){
|
||||
DagNode *node;
|
||||
DagNodeQueue *nqueue;
|
||||
DagNodeQueue *retqueue;
|
||||
@@ -1581,9 +1579,9 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
|
||||
|
||||
/* unused */
|
||||
#if 0
|
||||
short are_obs_related(struct DagForest *dag, void *ob1, void *ob2)
|
||||
short are_obs_related(struct DagForest *dag, void *ob1, void *ob2)
|
||||
{
|
||||
DagNode * node;
|
||||
DagNode *node;
|
||||
DagAdjList *itA;
|
||||
|
||||
node = dag_find_node(dag, ob1);
|
||||
@@ -1599,7 +1597,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2)
|
||||
}
|
||||
#endif
|
||||
|
||||
int is_acyclic(DagForest *dag)
|
||||
int is_acyclic(DagForest *dag)
|
||||
{
|
||||
return dag->is_acyclic;
|
||||
}
|
||||
@@ -1634,9 +1632,9 @@ void graph_print_queue_dist(DagNodeQueue *nqueue)
|
||||
count = 0;
|
||||
while (queueElem) {
|
||||
fprintf(stderr, "** %25s %2.2i-%2.2i ", ((ID *) queueElem->node->ob)->name, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm);
|
||||
while (count < queueElem->node->DFS_dvtm-1) { fputc(' ', stderr); count++;}
|
||||
while (count < queueElem->node->DFS_dvtm - 1) { fputc(' ', stderr); count++; }
|
||||
fputc('|', stderr);
|
||||
while (count < queueElem->node->DFS_fntm-2) { fputc('-', stderr); count++;}
|
||||
while (count < queueElem->node->DFS_fntm - 2) { fputc('-', stderr); count++; }
|
||||
fputc('|', stderr);
|
||||
fputc('\n', stderr);
|
||||
count = 0;
|
||||
@@ -1668,13 +1666,13 @@ void graph_print_adj_list(void)
|
||||
|
||||
/* mechanism to allow editors to be informed of depsgraph updates,
|
||||
* to do their own updates based on changes... */
|
||||
static void (*EditorsUpdateIDCb)(Main *bmain, ID *id)= NULL;
|
||||
static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated)= NULL;
|
||||
static void (*EditorsUpdateIDCb)(Main *bmain, ID *id) = NULL;
|
||||
static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated) = NULL;
|
||||
|
||||
void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated))
|
||||
{
|
||||
EditorsUpdateIDCb= id_func;
|
||||
EditorsUpdateSceneCb= scene_func;
|
||||
EditorsUpdateIDCb = id_func;
|
||||
EditorsUpdateSceneCb = scene_func;
|
||||
}
|
||||
|
||||
static void dag_editors_id_update(Main *bmain, ID *id)
|
||||
@@ -1698,37 +1696,37 @@ static void scene_sort_groups(Main *bmain, Scene *sce)
|
||||
Object *ob;
|
||||
|
||||
/* test; are group objects all in this scene? */
|
||||
for (ob= bmain->object.first; ob; ob= ob->id.next) {
|
||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||
ob->id.flag &= ~LIB_DOIT;
|
||||
ob->id.newid= NULL; /* newid abuse for GroupObject */
|
||||
ob->id.newid = NULL; /* newid abuse for GroupObject */
|
||||
}
|
||||
for (base = sce->base.first; base; base= base->next)
|
||||
for (base = sce->base.first; base; base = base->next)
|
||||
base->object->id.flag |= LIB_DOIT;
|
||||
|
||||
for (group= bmain->group.first; group; group= group->id.next) {
|
||||
for (go= group->gobject.first; go; go= go->next) {
|
||||
if ((go->ob->id.flag & LIB_DOIT)==0)
|
||||
for (group = bmain->group.first; group; group = group->id.next) {
|
||||
for (go = group->gobject.first; go; go = go->next) {
|
||||
if ((go->ob->id.flag & LIB_DOIT) == 0)
|
||||
break;
|
||||
}
|
||||
/* this group is entirely in this scene */
|
||||
if (go==NULL) {
|
||||
ListBase listb= {NULL, NULL};
|
||||
if (go == NULL) {
|
||||
ListBase listb = {NULL, NULL};
|
||||
|
||||
for (go= group->gobject.first; go; go= go->next)
|
||||
go->ob->id.newid= (ID *)go;
|
||||
for (go = group->gobject.first; go; go = go->next)
|
||||
go->ob->id.newid = (ID *)go;
|
||||
|
||||
/* in order of sorted bases we reinsert group objects */
|
||||
for (base = sce->base.first; base; base= base->next) {
|
||||
for (base = sce->base.first; base; base = base->next) {
|
||||
|
||||
if (base->object->id.newid) {
|
||||
go= (GroupObject *)base->object->id.newid;
|
||||
base->object->id.newid= NULL;
|
||||
go = (GroupObject *)base->object->id.newid;
|
||||
base->object->id.newid = NULL;
|
||||
BLI_remlink(&group->gobject, go);
|
||||
BLI_addtail(&listb, go);
|
||||
}
|
||||
}
|
||||
/* copy the newly sorted listbase */
|
||||
group->gobject= listb;
|
||||
group->gobject = listb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1744,7 +1742,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
|
||||
ListBase tempbase;
|
||||
Base *base;
|
||||
|
||||
tempbase.first= tempbase.last= NULL;
|
||||
tempbase.first = tempbase.last = NULL;
|
||||
|
||||
build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA);
|
||||
|
||||
@@ -1752,7 +1750,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
|
||||
|
||||
nqueue = queue_create(DAGQUEUEALLOC);
|
||||
|
||||
for (node = sce->theDag->DagNode.first; node; node= node->next) {
|
||||
for (node = sce->theDag->DagNode.first; node; node = node->next) {
|
||||
node->color = DAG_WHITE;
|
||||
}
|
||||
|
||||
@@ -1785,7 +1783,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
|
||||
if (!skip) {
|
||||
if (node) {
|
||||
node = pop_queue(nqueue);
|
||||
if (node->ob == sce) // we are done
|
||||
if (node->ob == sce) // we are done
|
||||
break;
|
||||
node->color = DAG_BLACK;
|
||||
|
||||
@@ -1807,7 +1805,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
|
||||
BLI_remlink(&sce->base, base);
|
||||
BLI_addhead(&tempbase, base);
|
||||
//if (G.debug & G_DEBUG)
|
||||
printf("cyclic %s\n", base->object->id.name);
|
||||
printf("cyclic %s\n", base->object->id.name);
|
||||
base = sce->base.first;
|
||||
}
|
||||
|
||||
@@ -1819,12 +1817,12 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
|
||||
|
||||
if (G.debug & G_DEBUG) {
|
||||
printf("\nordered\n");
|
||||
for (base = sce->base.first; base; base= base->next) {
|
||||
for (base = sce->base.first; base; base = base->next) {
|
||||
printf(" %s\n", base->object->id.name);
|
||||
}
|
||||
}
|
||||
/* temporal...? */
|
||||
sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */
|
||||
sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */
|
||||
}
|
||||
|
||||
static void lib_id_recalc_tag(Main *bmain, ID *id)
|
||||
@@ -1842,26 +1840,26 @@ static void lib_id_recalc_data_tag(Main *bmain, ID *id)
|
||||
/* node was checked to have lasttime != curtime and is if type ID_OB */
|
||||
static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
|
||||
{
|
||||
Main *bmain= G.main;
|
||||
Main *bmain = G.main;
|
||||
DagAdjList *itA;
|
||||
Object *ob, *obc;
|
||||
int oldflag, changed=0;
|
||||
int oldflag, changed = 0;
|
||||
unsigned int all_layer;
|
||||
|
||||
node->lasttime= curtime;
|
||||
node->lasttime = curtime;
|
||||
|
||||
ob= node->ob;
|
||||
ob = node->ob;
|
||||
if (ob && (ob->recalc & OB_RECALC_ALL)) {
|
||||
all_layer= node->scelay;
|
||||
all_layer = node->scelay;
|
||||
|
||||
/* got an object node that changes, now check relations */
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
all_layer |= itA->lay;
|
||||
/* the relationship is visible */
|
||||
if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
|
||||
if (itA->node->type==ID_OB) {
|
||||
obc= itA->node->ob;
|
||||
oldflag= obc->recalc;
|
||||
if (itA->node->type == ID_OB) {
|
||||
obc = itA->node->ob;
|
||||
oldflag = obc->recalc;
|
||||
|
||||
/* got a ob->obc relation, now check if flag needs flush */
|
||||
if (ob->recalc & OB_RECALC_OB) {
|
||||
@@ -1888,12 +1886,12 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
|
||||
lib_id_recalc_data_tag(bmain, &obc->id);
|
||||
}
|
||||
}
|
||||
if (oldflag!=obc->recalc) changed= 1;
|
||||
if (oldflag != obc->recalc) changed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* even nicer, we can clear recalc flags... */
|
||||
if ((all_layer & layer)==0) { // XXX && (ob != obedit)) {
|
||||
if ((all_layer & layer) == 0) { // XXX && (ob != obedit)) {
|
||||
/* but existing displaylists or derivedmesh should be freed */
|
||||
if (ob->recalc & OB_RECALC_DATA)
|
||||
BKE_object_free_display(ob);
|
||||
@@ -1905,15 +1903,15 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
|
||||
/* check case where child changes and parent forcing obdata to change */
|
||||
/* should be done regardless if this ob has recalc set */
|
||||
/* could merge this in with loop above...? (ton) */
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
/* the relationship is visible */
|
||||
if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
|
||||
if (itA->node->type==ID_OB) {
|
||||
obc= itA->node->ob;
|
||||
if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
|
||||
if (itA->node->type == ID_OB) {
|
||||
obc = itA->node->ob;
|
||||
/* child moves */
|
||||
if ((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) {
|
||||
if ((obc->recalc & OB_RECALC_ALL) == OB_RECALC_OB) {
|
||||
/* parent has deforming info */
|
||||
if (itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) {
|
||||
if (itA->type & (DAG_RL_OB_DATA | DAG_RL_DATA_DATA)) {
|
||||
// printf("parent %s changes ob %s\n", ob->id.name, obc->id.name);
|
||||
obc->recalc |= OB_RECALC_DATA;
|
||||
lib_id_recalc_data_tag(bmain, &obc->id);
|
||||
@@ -1924,8 +1922,8 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
|
||||
}
|
||||
|
||||
/* we only go deeper if node not checked or something changed */
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
if (changed || itA->node->lasttime!=curtime)
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
if (changed || itA->node->lasttime != curtime)
|
||||
flush_update_node(itA->node, layer, curtime);
|
||||
}
|
||||
|
||||
@@ -1936,15 +1934,15 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
|
||||
{
|
||||
DagAdjList *itA;
|
||||
|
||||
node->lasttime= curtime;
|
||||
node->lay= node->scelay;
|
||||
node->lasttime = curtime;
|
||||
node->lay = node->scelay;
|
||||
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
if (itA->node->type==ID_OB) {
|
||||
if (itA->node->lasttime!=curtime) {
|
||||
itA->lay= flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
if (itA->node->type == ID_OB) {
|
||||
if (itA->node->lasttime != curtime) {
|
||||
itA->lay = flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation
|
||||
}
|
||||
else itA->lay= itA->node->lay;
|
||||
else itA->lay = itA->node->lay;
|
||||
|
||||
node->lay |= itA->lay;
|
||||
}
|
||||
@@ -1956,16 +1954,16 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
|
||||
/* node was checked to have lasttime != curtime, and is of type ID_OB */
|
||||
static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset)
|
||||
{
|
||||
Main *bmain= G.main;
|
||||
Main *bmain = G.main;
|
||||
DagAdjList *itA;
|
||||
Object *ob;
|
||||
|
||||
node->lasttime= curtime;
|
||||
node->lasttime = curtime;
|
||||
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
if (itA->node->type==ID_OB) {
|
||||
if (itA->node->lasttime!=curtime) {
|
||||
ob= (Object*)(itA->node->ob);
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
if (itA->node->type == ID_OB) {
|
||||
if (itA->node->lasttime != curtime) {
|
||||
ob = (Object *)(itA->node->ob);
|
||||
|
||||
if (reset || (ob->recalc & OB_RECALC_ALL)) {
|
||||
if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) {
|
||||
@@ -1990,18 +1988,18 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
|
||||
Base *base;
|
||||
int lasttime;
|
||||
|
||||
firstnode= sce->theDag->DagNode.first; // always scene node
|
||||
firstnode = sce->theDag->DagNode.first; // always scene node
|
||||
|
||||
for (itA = firstnode->child; itA; itA= itA->next)
|
||||
itA->lay= 0;
|
||||
for (itA = firstnode->child; itA; itA = itA->next)
|
||||
itA->lay = 0;
|
||||
|
||||
sce->theDag->time++; // so we know which nodes were accessed
|
||||
lasttime= sce->theDag->time;
|
||||
sce->theDag->time++; // so we know which nodes were accessed
|
||||
lasttime = sce->theDag->time;
|
||||
|
||||
/* update layer flags in nodes */
|
||||
for (base= sce->base.first; base; base= base->next) {
|
||||
node= dag_get_node(sce->theDag, base->object);
|
||||
node->scelay= base->object->lay;
|
||||
for (base = sce->base.first; base; base = base->next) {
|
||||
node = dag_get_node(sce->theDag, base->object);
|
||||
node->scelay = base->object->lay;
|
||||
}
|
||||
|
||||
/* ensure cameras are set as if they are on a visible layer, because
|
||||
@@ -2009,7 +2007,7 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
|
||||
*
|
||||
* XXX, this wont work for local view / unlocked camera's */
|
||||
if (sce->camera) {
|
||||
node= dag_get_node(sce->theDag, sce->camera);
|
||||
node = dag_get_node(sce->theDag, sce->camera);
|
||||
node->scelay |= lay;
|
||||
}
|
||||
|
||||
@@ -2017,9 +2015,9 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
|
||||
{
|
||||
TimeMarker *m;
|
||||
|
||||
for (m= sce->markers.first; m; m= m->next) {
|
||||
for (m = sce->markers.first; m; m = m->next) {
|
||||
if (m->camera) {
|
||||
node= dag_get_node(sce->theDag, m->camera);
|
||||
node = dag_get_node(sce->theDag, m->camera);
|
||||
node->scelay |= lay;
|
||||
}
|
||||
}
|
||||
@@ -2027,8 +2025,8 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
|
||||
#endif
|
||||
|
||||
/* flush layer nodes to dependencies */
|
||||
for (itA = firstnode->child; itA; itA= itA->next)
|
||||
if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
|
||||
for (itA = firstnode->child; itA; itA = itA->next)
|
||||
if (itA->node->lasttime != lasttime && itA->node->type == ID_OB)
|
||||
flush_layer_node(sce, itA->node, lasttime);
|
||||
}
|
||||
|
||||
@@ -2037,16 +2035,16 @@ static void dag_tag_renderlayers(Scene *sce, unsigned int lay)
|
||||
if (sce->nodetree) {
|
||||
bNode *node;
|
||||
Base *base;
|
||||
unsigned int lay_changed= 0;
|
||||
unsigned int lay_changed = 0;
|
||||
|
||||
for (base= sce->base.first; base; base= base->next)
|
||||
for (base = sce->base.first; base; base = base->next)
|
||||
if (base->lay & lay)
|
||||
if (base->object->recalc)
|
||||
lay_changed |= base->lay;
|
||||
|
||||
for (node= sce->nodetree->nodes.first; node; node= node->next) {
|
||||
if (node->id==(ID *)sce) {
|
||||
SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1);
|
||||
for (node = sce->nodetree->nodes.first; node; node = node->next) {
|
||||
if (node->id == (ID *)sce) {
|
||||
SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1);
|
||||
if (srl && (srl->lay & lay_changed))
|
||||
nodeUpdate(sce->nodetree, node);
|
||||
}
|
||||
@@ -2062,30 +2060,30 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
|
||||
Object *ob;
|
||||
int lasttime;
|
||||
|
||||
if (sce->theDag==NULL) {
|
||||
if (sce->theDag == NULL) {
|
||||
printf("DAG zero... not allowed to happen!\n");
|
||||
DAG_scene_sort(bmain, sce);
|
||||
}
|
||||
|
||||
firstnode= sce->theDag->DagNode.first; // always scene node
|
||||
firstnode = sce->theDag->DagNode.first; // always scene node
|
||||
|
||||
/* first we flush the layer flags */
|
||||
dag_scene_flush_layers(sce, lay);
|
||||
|
||||
/* then we use the relationships + layer info to flush update events */
|
||||
sce->theDag->time++; // so we know which nodes were accessed
|
||||
lasttime= sce->theDag->time;
|
||||
for (itA = firstnode->child; itA; itA= itA->next)
|
||||
if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
|
||||
sce->theDag->time++; // so we know which nodes were accessed
|
||||
lasttime = sce->theDag->time;
|
||||
for (itA = firstnode->child; itA; itA = itA->next)
|
||||
if (itA->node->lasttime != lasttime && itA->node->type == ID_OB)
|
||||
flush_update_node(itA->node, lay, lasttime);
|
||||
|
||||
/* if update is not due to time change, do pointcache clears */
|
||||
if (!time) {
|
||||
sce->theDag->time++; // so we know which nodes were accessed
|
||||
lasttime= sce->theDag->time;
|
||||
for (itA = firstnode->child; itA; itA= itA->next) {
|
||||
if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) {
|
||||
ob= (Object*)(itA->node->ob);
|
||||
sce->theDag->time++; // so we know which nodes were accessed
|
||||
lasttime = sce->theDag->time;
|
||||
for (itA = firstnode->child; itA; itA = itA->next) {
|
||||
if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) {
|
||||
ob = (Object *)(itA->node->ob);
|
||||
|
||||
if (ob->recalc & OB_RECALC_ALL) {
|
||||
if (BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) {
|
||||
@@ -2109,7 +2107,7 @@ static int object_modifiers_use_time(Object *ob)
|
||||
ModifierData *md;
|
||||
|
||||
/* check if a modifier in modifier stack needs time input */
|
||||
for (md=ob->modifiers.first; md; md=md->next)
|
||||
for (md = ob->modifiers.first; md; md = md->next)
|
||||
if (modifier_dependsOnTime(md))
|
||||
return 1;
|
||||
|
||||
@@ -2148,14 +2146,14 @@ static short animdata_use_time(AnimData *adt)
|
||||
{
|
||||
NlaTrack *nlt;
|
||||
|
||||
if (adt==NULL) return 0;
|
||||
if (adt == NULL) return 0;
|
||||
|
||||
/* check action - only if assigned, and it has anim curves */
|
||||
if (adt->action && adt->action->curves.first)
|
||||
return 1;
|
||||
|
||||
/* check NLA tracks + strips */
|
||||
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
|
||||
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
||||
if (nlt->strips.first)
|
||||
return 1;
|
||||
}
|
||||
@@ -2184,8 +2182,8 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
{
|
||||
if (ob->constraints.first) {
|
||||
bConstraint *con;
|
||||
for (con = ob->constraints.first; con; con=con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = ob->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -2197,7 +2195,7 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
else if (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->recalc |= OB_RECALC_OB;
|
||||
break;
|
||||
@@ -2214,7 +2212,7 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
|
||||
if (ob->parent) {
|
||||
/* motion path or bone child */
|
||||
if (ob->parent->type==OB_CURVE || ob->parent->type==OB_ARMATURE) ob->recalc |= OB_RECALC_OB;
|
||||
if (ob->parent->type == OB_CURVE || ob->parent->type == OB_ARMATURE) ob->recalc |= OB_RECALC_OB;
|
||||
}
|
||||
|
||||
#if 0 // XXX old animation system
|
||||
@@ -2222,7 +2220,7 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
if (ob->dup_group) {
|
||||
bActionStrip *strip;
|
||||
/* this case is for groups with nla, whilst nla target has no action or nla */
|
||||
for (strip= ob->nlastrips.first; strip; strip= strip->next) {
|
||||
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
|
||||
if (strip->object)
|
||||
strip->object->recalc |= OB_RECALC_ALL;
|
||||
}
|
||||
@@ -2235,20 +2233,20 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
ob->adt->recalc |= ADT_RECALC_ANIM;
|
||||
}
|
||||
|
||||
if ((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA;
|
||||
if ((ob->adt) && (ob->type == OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA;
|
||||
|
||||
if (object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;
|
||||
if ((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA;
|
||||
|
||||
{
|
||||
AnimData *adt= BKE_animdata_from_id((ID *)ob->data);
|
||||
AnimData *adt = BKE_animdata_from_id((ID *)ob->data);
|
||||
Mesh *me;
|
||||
Curve *cu;
|
||||
Lattice *lt;
|
||||
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
me= ob->data;
|
||||
me = ob->data;
|
||||
if (me->key) {
|
||||
if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
|
||||
ob->recalc |= OB_RECALC_DATA;
|
||||
@@ -2259,7 +2257,7 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
break;
|
||||
case OB_CURVE:
|
||||
case OB_SURF:
|
||||
cu= ob->data;
|
||||
cu = ob->data;
|
||||
if (cu->key) {
|
||||
if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
|
||||
ob->recalc |= OB_RECALC_DATA;
|
||||
@@ -2267,18 +2265,18 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
}
|
||||
break;
|
||||
case OB_FONT:
|
||||
cu= ob->data;
|
||||
if (cu->nurb.first==NULL && cu->str && cu->vfont)
|
||||
cu = ob->data;
|
||||
if (cu->nurb.first == NULL && cu->str && cu->vfont)
|
||||
ob->recalc |= OB_RECALC_DATA;
|
||||
break;
|
||||
case OB_LATTICE:
|
||||
lt= ob->data;
|
||||
lt = ob->data;
|
||||
if (lt->key) {
|
||||
if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
|
||||
ob->recalc |= OB_RECALC_DATA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case OB_MBALL:
|
||||
if (ob->transflag & OB_DUPLI) ob->recalc |= OB_RECALC_DATA;
|
||||
break;
|
||||
@@ -2290,9 +2288,9 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
}
|
||||
|
||||
if (ob->particlesystem.first) {
|
||||
ParticleSystem *psys= ob->particlesystem.first;
|
||||
ParticleSystem *psys = ob->particlesystem.first;
|
||||
|
||||
for (; psys; psys=psys->next) {
|
||||
for (; psys; psys = psys->next) {
|
||||
if (psys_check_enabled(ob, psys)) {
|
||||
ob->recalc |= OB_RECALC_DATA;
|
||||
break;
|
||||
@@ -2319,7 +2317,7 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s
|
||||
|
||||
/* set ob flags where animated systems are */
|
||||
for (SETLOOPER(scene, sce_iter, base)) {
|
||||
ob= base->object;
|
||||
ob = base->object;
|
||||
|
||||
if (do_time) {
|
||||
/* now if DagNode were part of base, the node->lay could be checked... */
|
||||
@@ -2334,22 +2332,22 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s
|
||||
|
||||
if (do_time) {
|
||||
/* we do groups each once */
|
||||
for (group= bmain->group.first; group; group= group->id.next) {
|
||||
for (group = bmain->group.first; group; group = group->id.next) {
|
||||
if (group->id.flag & LIB_DOIT) {
|
||||
for (go= group->gobject.first; go; go= go->next) {
|
||||
for (go = group->gobject.first; go; go = go->next) {
|
||||
dag_object_time_update_flags(go->ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (sce_iter= scene; sce_iter; sce_iter= sce_iter->set)
|
||||
for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set)
|
||||
DAG_scene_flush_update(bmain, sce_iter, lay, 1);
|
||||
|
||||
if (do_time) {
|
||||
/* test: set time flag, to disable baked systems to update */
|
||||
for (SETLOOPER(scene, sce_iter, base)) {
|
||||
ob= base->object;
|
||||
ob = base->object;
|
||||
if (ob->recalc)
|
||||
ob->recalc |= OB_RECALC_TIME;
|
||||
}
|
||||
@@ -2360,10 +2358,10 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s
|
||||
}
|
||||
|
||||
/* and store the info in groupobject */
|
||||
for (group= bmain->group.first; group; group= group->id.next) {
|
||||
for (group = bmain->group.first; group; group = group->id.next) {
|
||||
if (group->id.flag & LIB_DOIT) {
|
||||
for (go= group->gobject.first; go; go= go->next) {
|
||||
go->recalc= go->ob->recalc;
|
||||
for (go = group->gobject.first; go; go = go->next) {
|
||||
go->recalc = go->ob->recalc;
|
||||
// printf("ob %s recalc %d\n", go->ob->id.name, go->recalc);
|
||||
}
|
||||
group->id.flag &= ~LIB_DOIT;
|
||||
@@ -2380,22 +2378,22 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay
|
||||
/* only one scene supported currently, making more scenes work
|
||||
* correctly requires changes beyond just the dependency graph */
|
||||
|
||||
*sce= NULL;
|
||||
*lay= 0;
|
||||
*sce = NULL;
|
||||
*lay = 0;
|
||||
|
||||
if ((wm= bmain->wm.first)) {
|
||||
if ((wm = bmain->wm.first)) {
|
||||
/* if we have a windowmanager, look into windows */
|
||||
for (win=wm->windows.first; win; win=win->next) {
|
||||
for (win = wm->windows.first; win; win = win->next) {
|
||||
if (win->screen) {
|
||||
if (!*sce) *sce= win->screen->scene;
|
||||
if (!*sce) *sce = win->screen->scene;
|
||||
*lay |= BKE_screen_visible_layers(win->screen, win->screen->scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* if not, use the first sce */
|
||||
*sce= bmain->scene.first;
|
||||
if (*sce) *lay= (*sce)->lay;
|
||||
*sce = bmain->scene.first;
|
||||
if (*sce) *lay = (*sce)->lay;
|
||||
|
||||
/* XXX for background mode, we should get the scene
|
||||
* from somewhere, for the -S option, but it's in
|
||||
@@ -2435,9 +2433,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time)
|
||||
dag_scene_flush_layers(scene, lay);
|
||||
|
||||
for (SETLOOPER(scene, sce_iter, base)) {
|
||||
ob= base->object;
|
||||
node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL;
|
||||
oblay= (node)? node->lay: ob->lay;
|
||||
ob = base->object;
|
||||
node = (sce_iter->theDag) ? dag_get_node(sce_iter->theDag, ob) : NULL;
|
||||
oblay = (node) ? node->lay : ob->lay;
|
||||
|
||||
if ((oblay & lay) & ~scene->lay_updated) {
|
||||
if (ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE))
|
||||
@@ -2447,9 +2445,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time)
|
||||
}
|
||||
}
|
||||
|
||||
for (group= bmain->group.first; group; group= group->id.next) {
|
||||
for (group = bmain->group.first; group; group = group->id.next) {
|
||||
if (group->id.flag & LIB_DOIT) {
|
||||
for (go= group->gobject.first; go; go= go->next) {
|
||||
for (go = group->gobject.first; go; go = go->next) {
|
||||
if (ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE))
|
||||
go->ob->recalc |= OB_RECALC_DATA;
|
||||
if (go->ob->proxy_from)
|
||||
@@ -2473,7 +2471,7 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS
|
||||
{
|
||||
struct { ID *id; int is_dependent; } *data = userData;
|
||||
|
||||
if (*idpoin && GS((*idpoin)->name)==ID_TE) {
|
||||
if (*idpoin && GS((*idpoin)->name) == ID_TE) {
|
||||
if (data->id == (*idpoin))
|
||||
data->is_dependent = 1;
|
||||
}
|
||||
@@ -2481,8 +2479,8 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS
|
||||
|
||||
static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
{
|
||||
Main *bmain= G.main;
|
||||
Object *obt, *ob= NULL;
|
||||
Main *bmain = G.main;
|
||||
Object *obt, *ob = NULL;
|
||||
short idtype;
|
||||
|
||||
/* here we flush a few things before actual scene wide flush, mostly
|
||||
@@ -2490,27 +2488,27 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
|
||||
/* set flags & pointcache for object */
|
||||
if (GS(id->name) == ID_OB) {
|
||||
ob= (Object*)id;
|
||||
ob = (Object *)id;
|
||||
BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
|
||||
|
||||
if (ob->recalc & OB_RECALC_DATA) {
|
||||
/* all users of this ob->data should be checked */
|
||||
id= ob->data;
|
||||
id = ob->data;
|
||||
|
||||
/* no point in trying in this cases */
|
||||
if (id && id->us <= 1) {
|
||||
dag_editors_id_update(bmain, id);
|
||||
id= NULL;
|
||||
id = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* set flags & pointcache for object data */
|
||||
if (id) {
|
||||
idtype= GS(id->name);
|
||||
idtype = GS(id->name);
|
||||
|
||||
if (ELEM8(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR, ID_SPK)) {
|
||||
for (obt=bmain->object.first; obt; obt= obt->id.next) {
|
||||
for (obt = bmain->object.first; obt; obt = obt->id.next) {
|
||||
if (!(ob && obt == ob) && obt->data == id) {
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
lib_id_recalc_data_tag(bmain, &obt->id);
|
||||
@@ -2521,10 +2519,10 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
|
||||
/* set flags based on textures - can influence depgraph via modifiers */
|
||||
if (idtype == ID_TE) {
|
||||
for (obt=bmain->object.first; obt; obt= obt->id.next) {
|
||||
for (obt = bmain->object.first; obt; obt = obt->id.next) {
|
||||
struct { ID *id; int is_dependent; } data;
|
||||
data.id= id;
|
||||
data.is_dependent= 0;
|
||||
data.id = id;
|
||||
data.is_dependent = 0;
|
||||
|
||||
modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data);
|
||||
if (data.is_dependent) {
|
||||
@@ -2537,11 +2535,11 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
ParticleSystem *psys = obt->particlesystem.first;
|
||||
MTex **mtexp, *mtex;
|
||||
int a;
|
||||
for (; psys; psys=psys->next) {
|
||||
for (; psys; psys = psys->next) {
|
||||
mtexp = psys->part->mtex;
|
||||
for (a=0; a<MAX_MTEX; a++, mtexp++) {
|
||||
for (a = 0; a < MAX_MTEX; a++, mtexp++) {
|
||||
mtex = *mtexp;
|
||||
if (mtex && mtex->tex == (Tex*)id) {
|
||||
if (mtex && mtex->tex == (Tex *)id) {
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
lib_id_recalc_data_tag(bmain, &obt->id);
|
||||
|
||||
@@ -2560,10 +2558,10 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
|
||||
/* set flags based on ShapeKey */
|
||||
if (idtype == ID_KE) {
|
||||
for (obt=bmain->object.first; obt; obt= obt->id.next) {
|
||||
Key *key= ob_get_key(obt);
|
||||
for (obt = bmain->object.first; obt; obt = obt->id.next) {
|
||||
Key *key = ob_get_key(obt);
|
||||
if (!(ob && obt == ob) && ((ID *)key == id)) {
|
||||
obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA);
|
||||
obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA);
|
||||
lib_id_recalc_tag(bmain, &obt->id);
|
||||
lib_id_recalc_data_tag(bmain, &obt->id);
|
||||
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
|
||||
@@ -2574,8 +2572,8 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
/* set flags based on particle settings */
|
||||
if (idtype == ID_PA) {
|
||||
ParticleSystem *psys;
|
||||
for (obt=bmain->object.first; obt; obt= obt->id.next)
|
||||
for (psys=obt->particlesystem.first; psys; psys=psys->next)
|
||||
for (obt = bmain->object.first; obt; obt = obt->id.next)
|
||||
for (psys = obt->particlesystem.first; psys; psys = psys->next)
|
||||
if (&psys->part->id == id)
|
||||
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
|
||||
}
|
||||
@@ -2585,12 +2583,12 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
|
||||
BKE_tracking_dopesheet_tag_update(&clip->tracking);
|
||||
|
||||
for (obt=bmain->object.first; obt; obt= obt->id.next) {
|
||||
for (obt = bmain->object.first; obt; obt = obt->id.next) {
|
||||
bConstraint *con;
|
||||
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);
|
||||
if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER,
|
||||
CONSTRAINT_TYPE_OBJECTSOLVER))
|
||||
CONSTRAINT_TYPE_OBJECTSOLVER))
|
||||
{
|
||||
obt->recalc |= OB_RECALC_OB;
|
||||
break;
|
||||
@@ -2601,8 +2599,8 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
if (sce->nodetree) {
|
||||
bNode *node;
|
||||
|
||||
for (node= sce->nodetree->nodes.first; node; node= node->next) {
|
||||
if (node->id==id) {
|
||||
for (node = sce->nodetree->nodes.first; node; node = node->next) {
|
||||
if (node->id == id) {
|
||||
nodeUpdate(sce->nodetree, node);
|
||||
}
|
||||
}
|
||||
@@ -2646,8 +2644,8 @@ void DAG_ids_flush_tagged(Main *bmain)
|
||||
/* we tag based on first ID type character to avoid
|
||||
* looping over all ID's in case there are no tags */
|
||||
if (id && bmain->id_tag_update[id->name[0]]) {
|
||||
for (; id; id=id->next) {
|
||||
if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) {
|
||||
for (; id; id = id->next) {
|
||||
if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) {
|
||||
dag_id_flush_update(sce, id);
|
||||
do_flush = 1;
|
||||
}
|
||||
@@ -2675,7 +2673,7 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time)
|
||||
/* we tag based on first ID type character to avoid
|
||||
* looping over all ID's in case there are no tags */
|
||||
if (id && bmain->id_tag_update[id->name[0]]) {
|
||||
updated= 1;
|
||||
updated = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2698,9 +2696,9 @@ void DAG_ids_clear_recalc(Main *bmain)
|
||||
/* we tag based on first ID type character to avoid
|
||||
* looping over all ID's in case there are no tags */
|
||||
if (id && bmain->id_tag_update[id->name[0]]) {
|
||||
for (; id; id=id->next)
|
||||
if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA))
|
||||
id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA);
|
||||
for (; id; id = id->next)
|
||||
if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA))
|
||||
id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2709,15 +2707,15 @@ void DAG_ids_clear_recalc(Main *bmain)
|
||||
|
||||
void DAG_id_tag_update(ID *id, short flag)
|
||||
{
|
||||
Main *bmain= G.main;
|
||||
Main *bmain = G.main;
|
||||
|
||||
if (id==NULL) return;
|
||||
if (id == NULL) return;
|
||||
|
||||
/* tag ID for update */
|
||||
if (flag) {
|
||||
if (flag & OB_RECALC_OB)
|
||||
lib_id_recalc_tag(bmain, id);
|
||||
if (flag & (OB_RECALC_DATA|PSYS_RECALC))
|
||||
if (flag & (OB_RECALC_DATA | PSYS_RECALC))
|
||||
lib_id_recalc_data_tag(bmain, id);
|
||||
}
|
||||
else
|
||||
@@ -2730,14 +2728,14 @@ void DAG_id_tag_update(ID *id, short flag)
|
||||
|
||||
if (idtype == ID_OB) {
|
||||
/* only quick tag */
|
||||
ob = (Object*)id;
|
||||
ob = (Object *)id;
|
||||
ob->recalc |= (flag & OB_RECALC_ALL);
|
||||
}
|
||||
else if (idtype == ID_PA) {
|
||||
ParticleSystem *psys;
|
||||
/* this is weak still, should be done delayed as well */
|
||||
for (ob=bmain->object.first; ob; ob=ob->id.next) {
|
||||
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
|
||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
|
||||
if (&psys->part->id == id) {
|
||||
ob->recalc |= (flag & OB_RECALC_ALL);
|
||||
psys->recalc |= (flag & PSYS_RECALC);
|
||||
@@ -2757,12 +2755,12 @@ void DAG_id_tag_update(ID *id, short flag)
|
||||
|
||||
void DAG_id_type_tag(struct Main *bmain, short idtype)
|
||||
{
|
||||
bmain->id_tag_update[((char*)&idtype)[0]] = 1;
|
||||
bmain->id_tag_update[((char *)&idtype)[0]] = 1;
|
||||
}
|
||||
|
||||
int DAG_id_type_tagged(Main *bmain, short idtype)
|
||||
{
|
||||
return bmain->id_tag_update[((char*)&idtype)[0]];
|
||||
return bmain->id_tag_update[((char *)&idtype)[0]];
|
||||
}
|
||||
|
||||
#if 0 // UNUSED
|
||||
@@ -2772,22 +2770,22 @@ static int parent_check_node(DagNode *node, int curtime)
|
||||
{
|
||||
DagAdjList *itA;
|
||||
|
||||
node->lasttime= curtime;
|
||||
node->lasttime = curtime;
|
||||
|
||||
if (node->color==DAG_GRAY)
|
||||
if (node->color == DAG_GRAY)
|
||||
return DAG_GRAY;
|
||||
|
||||
for (itA = node->child; itA; itA= itA->next) {
|
||||
if (itA->node->type==ID_OB) {
|
||||
for (itA = node->child; itA; itA = itA->next) {
|
||||
if (itA->node->type == ID_OB) {
|
||||
|
||||
if (itA->node->color==DAG_GRAY)
|
||||
if (itA->node->color == DAG_GRAY)
|
||||
return DAG_GRAY;
|
||||
|
||||
/* descend if not done */
|
||||
if (itA->node->lasttime!=curtime) {
|
||||
itA->node->color= parent_check_node(itA->node, curtime);
|
||||
if (itA->node->lasttime != curtime) {
|
||||
itA->node->color = parent_check_node(itA->node, curtime);
|
||||
|
||||
if (itA->node->color==DAG_GRAY)
|
||||
if (itA->node->color == DAG_GRAY)
|
||||
return DAG_GRAY;
|
||||
}
|
||||
}
|
||||
@@ -2802,7 +2800,7 @@ static int parent_check_node(DagNode *node, int curtime)
|
||||
/* we assume its an armature with pose */
|
||||
void DAG_pose_sort(Object *ob)
|
||||
{
|
||||
bPose *pose= ob->pose;
|
||||
bPose *pose = ob->pose;
|
||||
bPoseChannel *pchan;
|
||||
bConstraint *con;
|
||||
DagNode *node;
|
||||
@@ -2815,12 +2813,12 @@ void DAG_pose_sort(Object *ob)
|
||||
int skip = 0;
|
||||
|
||||
dag = dag_init();
|
||||
ugly_hack_sorry= 0; // no ID structs
|
||||
ugly_hack_sorry = 0; // no ID structs
|
||||
|
||||
rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL
|
||||
rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL
|
||||
|
||||
/* we add the hierarchy and the constraints */
|
||||
for (pchan = pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
int addtoroot = 1;
|
||||
|
||||
node = dag_get_node(dag, pchan);
|
||||
@@ -2830,40 +2828,40 @@ void DAG_pose_sort(Object *ob)
|
||||
dag_add_relation(dag, node2, node, 0, "Parent Relation");
|
||||
addtoroot = 0;
|
||||
}
|
||||
for (con = pchan->constraints.first; con; con=con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
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) {
|
||||
if (ct->tar==ob && ct->subtarget[0]) {
|
||||
bPoseChannel *target= BKE_pose_channel_find_name(ob->pose, ct->subtarget);
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if (ct->tar == ob && ct->subtarget[0]) {
|
||||
bPoseChannel *target = BKE_pose_channel_find_name(ob->pose, ct->subtarget);
|
||||
if (target) {
|
||||
node2= dag_get_node(dag, target);
|
||||
node2 = dag_get_node(dag, target);
|
||||
dag_add_relation(dag, node2, node, 0, "Pose Constraint");
|
||||
|
||||
if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
|
||||
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
|
||||
bKinematicConstraint *data = (bKinematicConstraint *)con->data;
|
||||
bPoseChannel *parchan;
|
||||
int segcount= 0;
|
||||
int segcount = 0;
|
||||
|
||||
/* exclude tip from chain? */
|
||||
if (!(data->flag & CONSTRAINT_IK_TIP))
|
||||
parchan= pchan->parent;
|
||||
parchan = pchan->parent;
|
||||
else
|
||||
parchan= pchan;
|
||||
parchan = pchan;
|
||||
|
||||
/* Walk to the chain's root */
|
||||
while (parchan) {
|
||||
node3= dag_get_node(dag, parchan);
|
||||
node3 = dag_get_node(dag, parchan);
|
||||
dag_add_relation(dag, node2, node3, 0, "IK Constraint");
|
||||
|
||||
segcount++;
|
||||
if (segcount==data->rootbone || segcount>255) break; // 255 is weak
|
||||
parchan= parchan->parent;
|
||||
if (segcount == data->rootbone || segcount > 255) break; // 255 is weak
|
||||
parchan = parchan->parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2874,7 +2872,7 @@ void DAG_pose_sort(Object *ob)
|
||||
cti->flush_constraint_targets(con, &targets, 1);
|
||||
}
|
||||
}
|
||||
if (addtoroot == 1 ) {
|
||||
if (addtoroot == 1) {
|
||||
dag_add_relation(dag, rootnode, node, 0, "Root Bone Relation");
|
||||
}
|
||||
}
|
||||
@@ -2882,12 +2880,12 @@ void DAG_pose_sort(Object *ob)
|
||||
dag_check_cycle(dag);
|
||||
|
||||
/* now we try to sort... */
|
||||
tempbase.first= tempbase.last= NULL;
|
||||
tempbase.first = tempbase.last = NULL;
|
||||
|
||||
nqueue = queue_create(DAGQUEUEALLOC);
|
||||
|
||||
/* tag nodes unchecked */
|
||||
for (node = dag->DagNode.first; node; node= node->next)
|
||||
for (node = dag->DagNode.first; node; node = node->next)
|
||||
node->color = DAG_WHITE;
|
||||
|
||||
rootnode->color = DAG_GRAY;
|
||||
@@ -2912,7 +2910,7 @@ void DAG_pose_sort(Object *ob)
|
||||
if (!skip) {
|
||||
if (node) {
|
||||
node = pop_queue(nqueue);
|
||||
if (node->ob == NULL) // we are done
|
||||
if (node->ob == NULL) // we are done
|
||||
break;
|
||||
node->color = DAG_BLACK;
|
||||
|
||||
@@ -2925,7 +2923,7 @@ void DAG_pose_sort(Object *ob)
|
||||
|
||||
/* temporal correction for circular dependencies */
|
||||
while (pose->chanbase.first) {
|
||||
pchan= pose->chanbase.first;
|
||||
pchan = pose->chanbase.first;
|
||||
BLI_remlink(&pose->chanbase, pchan);
|
||||
BLI_addhead(&tempbase, pchan);
|
||||
|
||||
@@ -2943,7 +2941,7 @@ void DAG_pose_sort(Object *ob)
|
||||
free_forest(dag);
|
||||
MEM_freeN(dag);
|
||||
|
||||
ugly_hack_sorry= 1;
|
||||
ugly_hack_sorry = 1;
|
||||
}
|
||||
|
||||
/* ************************ DAG DEBUGGING ********************* */
|
||||
@@ -2951,17 +2949,17 @@ void DAG_pose_sort(Object *ob)
|
||||
void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob)
|
||||
{
|
||||
/* utility for debugging dependencies */
|
||||
dag_print_dependencies= 1;
|
||||
dag_print_dependencies = 1;
|
||||
|
||||
if (ob && (ob->mode & OB_MODE_POSE)) {
|
||||
printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2);
|
||||
printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name + 2);
|
||||
DAG_pose_sort(ob);
|
||||
}
|
||||
else {
|
||||
printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name+2);
|
||||
printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name + 2);
|
||||
DAG_scene_sort(bmain, scene);
|
||||
}
|
||||
|
||||
dag_print_dependencies= 0;
|
||||
dag_print_dependencies = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,11 @@ void freedisplist(ListBase *lb)
|
||||
{
|
||||
DispList *dl;
|
||||
|
||||
dl= lb->first;
|
||||
dl = lb->first;
|
||||
while (dl) {
|
||||
BLI_remlink(lb, dl);
|
||||
free_disp_elem(dl);
|
||||
dl= lb->first;
|
||||
dl = lb->first;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ DispList *find_displist_create(ListBase *lb, int type)
|
||||
{
|
||||
DispList *dl;
|
||||
|
||||
dl= lb->first;
|
||||
dl = lb->first;
|
||||
while (dl) {
|
||||
if (dl->type==type) return dl;
|
||||
dl= dl->next;
|
||||
if (dl->type == type) return dl;
|
||||
dl = dl->next;
|
||||
}
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "find_disp");
|
||||
dl->type= type;
|
||||
dl = MEM_callocN(sizeof(DispList), "find_disp");
|
||||
dl->type = type;
|
||||
BLI_addtail(lb, dl);
|
||||
|
||||
return dl;
|
||||
@@ -110,10 +110,10 @@ DispList *find_displist(ListBase *lb, int type)
|
||||
{
|
||||
DispList *dl;
|
||||
|
||||
dl= lb->first;
|
||||
dl = lb->first;
|
||||
while (dl) {
|
||||
if (dl->type==type) return dl;
|
||||
dl= dl->next;
|
||||
if (dl->type == type) return dl;
|
||||
dl = dl->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -122,7 +122,7 @@ DispList *find_displist(ListBase *lb, int type)
|
||||
int displist_has_faces(ListBase *lb)
|
||||
{
|
||||
DispList *dl;
|
||||
for (dl= lb->first; dl; dl= dl->next) {
|
||||
for (dl = lb->first; dl; dl = dl->next) {
|
||||
if (ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
|
||||
return 1;
|
||||
}
|
||||
@@ -136,21 +136,21 @@ void copy_displist(ListBase *lbn, ListBase *lb)
|
||||
|
||||
freedisplist(lbn);
|
||||
|
||||
dl= lb->first;
|
||||
dl = lb->first;
|
||||
while (dl) {
|
||||
|
||||
dln= MEM_dupallocN(dl);
|
||||
dln = MEM_dupallocN(dl);
|
||||
BLI_addtail(lbn, dln);
|
||||
dln->verts= MEM_dupallocN(dl->verts);
|
||||
dln->nors= MEM_dupallocN(dl->nors);
|
||||
dln->index= MEM_dupallocN(dl->index);
|
||||
dln->col1= MEM_dupallocN(dl->col1);
|
||||
dln->col2= MEM_dupallocN(dl->col2);
|
||||
dln->verts = MEM_dupallocN(dl->verts);
|
||||
dln->nors = MEM_dupallocN(dl->nors);
|
||||
dln->index = MEM_dupallocN(dl->index);
|
||||
dln->col1 = MEM_dupallocN(dl->col1);
|
||||
dln->col2 = MEM_dupallocN(dl->col2);
|
||||
|
||||
if (dl->bevelSplitFlag)
|
||||
dln->bevelSplitFlag= MEM_dupallocN(dl->bevelSplitFlag);
|
||||
dln->bevelSplitFlag = MEM_dupallocN(dl->bevelSplitFlag);
|
||||
|
||||
dl= dl->next;
|
||||
dl = dl->next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,38 +163,38 @@ void addnormalsDispList(ListBase *lb)
|
||||
int a, b, p1, p2, p3, p4;
|
||||
|
||||
|
||||
dl= lb->first;
|
||||
dl = lb->first;
|
||||
|
||||
while (dl) {
|
||||
if (dl->type==DL_INDEX3) {
|
||||
if (dl->nors==NULL) {
|
||||
dl->nors= MEM_callocN(sizeof(float)*3, "dlnors");
|
||||
if (dl->verts[2] < 0.0f) dl->nors[2]= -1.0f;
|
||||
else dl->nors[2]= 1.0f;
|
||||
if (dl->type == DL_INDEX3) {
|
||||
if (dl->nors == NULL) {
|
||||
dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors");
|
||||
if (dl->verts[2] < 0.0f) dl->nors[2] = -1.0f;
|
||||
else dl->nors[2] = 1.0f;
|
||||
}
|
||||
}
|
||||
else if (dl->type==DL_SURF) {
|
||||
if (dl->nors==NULL) {
|
||||
dl->nors= MEM_callocN(sizeof(float)*3*dl->nr*dl->parts, "dlnors");
|
||||
else if (dl->type == DL_SURF) {
|
||||
if (dl->nors == NULL) {
|
||||
dl->nors = MEM_callocN(sizeof(float) * 3 * dl->nr * dl->parts, "dlnors");
|
||||
|
||||
vdata= dl->verts;
|
||||
ndata= dl->nors;
|
||||
vdata = dl->verts;
|
||||
ndata = dl->nors;
|
||||
|
||||
for (a=0; a<dl->parts; a++) {
|
||||
for (a = 0; a < dl->parts; a++) {
|
||||
|
||||
if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
|
||||
if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0)
|
||||
break;
|
||||
|
||||
v1= vdata+ 3*p1;
|
||||
n1= ndata+ 3*p1;
|
||||
v2= vdata+ 3*p2;
|
||||
n2= ndata+ 3*p2;
|
||||
v3= vdata+ 3*p3;
|
||||
n3= ndata+ 3*p3;
|
||||
v4= vdata+ 3*p4;
|
||||
n4= ndata+ 3*p4;
|
||||
v1 = vdata + 3 * p1;
|
||||
n1 = ndata + 3 * p1;
|
||||
v2 = vdata + 3 * p2;
|
||||
n2 = ndata + 3 * p2;
|
||||
v3 = vdata + 3 * p3;
|
||||
n3 = ndata + 3 * p3;
|
||||
v4 = vdata + 3 * p4;
|
||||
n4 = ndata + 3 * p4;
|
||||
|
||||
for (; b<dl->nr; b++) {
|
||||
for (; b < dl->nr; b++) {
|
||||
|
||||
normal_quad_v3(nor, v1, v3, v4, v2);
|
||||
|
||||
@@ -203,21 +203,21 @@ void addnormalsDispList(ListBase *lb)
|
||||
add_v3_v3(n3, nor);
|
||||
add_v3_v3(n4, nor);
|
||||
|
||||
v2= v1; v1+= 3;
|
||||
v4= v3; v3+= 3;
|
||||
n2= n1; n1+= 3;
|
||||
n4= n3; n3+= 3;
|
||||
v2 = v1; v1 += 3;
|
||||
v4 = v3; v3 += 3;
|
||||
n2 = n1; n1 += 3;
|
||||
n4 = n3; n3 += 3;
|
||||
}
|
||||
}
|
||||
a= dl->parts*dl->nr;
|
||||
v1= ndata;
|
||||
a = dl->parts * dl->nr;
|
||||
v1 = ndata;
|
||||
while (a--) {
|
||||
normalize_v3(v1);
|
||||
v1+= 3;
|
||||
v1 += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
dl= dl->next;
|
||||
dl = dl->next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,52 +225,52 @@ void count_displist(ListBase *lb, int *totvert, int *totface)
|
||||
{
|
||||
DispList *dl;
|
||||
|
||||
dl= lb->first;
|
||||
dl = lb->first;
|
||||
while (dl) {
|
||||
|
||||
switch (dl->type) {
|
||||
case DL_SURF:
|
||||
*totvert+= dl->nr*dl->parts;
|
||||
*totface+= (dl->nr-1)*(dl->parts-1);
|
||||
*totvert += dl->nr * dl->parts;
|
||||
*totface += (dl->nr - 1) * (dl->parts - 1);
|
||||
break;
|
||||
case DL_INDEX3:
|
||||
case DL_INDEX4:
|
||||
*totvert+= dl->nr;
|
||||
*totface+= dl->parts;
|
||||
*totvert += dl->nr;
|
||||
*totface += dl->parts;
|
||||
break;
|
||||
case DL_POLY:
|
||||
case DL_SEGM:
|
||||
*totvert+= dl->nr*dl->parts;
|
||||
*totvert += dl->nr * dl->parts;
|
||||
}
|
||||
|
||||
dl= dl->next;
|
||||
dl = dl->next;
|
||||
}
|
||||
}
|
||||
|
||||
int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
|
||||
{
|
||||
if ((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) {
|
||||
if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dl->flag & DL_CYCL_U) {
|
||||
(*p1)= dl->nr*a;
|
||||
(*p2)= (*p1)+ dl->nr-1;
|
||||
(*p3)= (*p1)+ dl->nr;
|
||||
(*p4)= (*p2)+ dl->nr;
|
||||
(*b)= 0;
|
||||
(*p1) = dl->nr * a;
|
||||
(*p2) = (*p1) + dl->nr - 1;
|
||||
(*p3) = (*p1) + dl->nr;
|
||||
(*p4) = (*p2) + dl->nr;
|
||||
(*b) = 0;
|
||||
}
|
||||
else {
|
||||
(*p2)= dl->nr*a;
|
||||
(*p1)= (*p2)+1;
|
||||
(*p4)= (*p2)+ dl->nr;
|
||||
(*p3)= (*p1)+ dl->nr;
|
||||
(*b)= 1;
|
||||
(*p2) = dl->nr * a;
|
||||
(*p1) = (*p2) + 1;
|
||||
(*p4) = (*p2) + dl->nr;
|
||||
(*p3) = (*p1) + dl->nr;
|
||||
(*b) = 1;
|
||||
}
|
||||
|
||||
if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) {
|
||||
(*p3)-= dl->nr*dl->parts;
|
||||
(*p4)-= dl->nr*dl->parts;
|
||||
if ( (dl->flag & DL_CYCL_V) && a == dl->parts - 1) {
|
||||
(*p3) -= dl->nr * dl->parts;
|
||||
(*p4) -= dl->nr * dl->parts;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -287,70 +287,70 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
|
||||
float *data;
|
||||
int a, len, resolu;
|
||||
|
||||
nu= nubase->first;
|
||||
nu = nubase->first;
|
||||
while (nu) {
|
||||
if (nu->hide==0) {
|
||||
if (nu->hide == 0) {
|
||||
|
||||
if (forRender && cu->resolu_ren!=0)
|
||||
resolu= cu->resolu_ren;
|
||||
if (forRender && cu->resolu_ren != 0)
|
||||
resolu = cu->resolu_ren;
|
||||
else
|
||||
resolu= nu->resolu;
|
||||
resolu = nu->resolu;
|
||||
|
||||
if (!BKE_nurb_check_valid_u(nu));
|
||||
if (!BKE_nurb_check_valid_u(nu)) ;
|
||||
else if (nu->type == CU_BEZIER) {
|
||||
|
||||
/* count */
|
||||
len= 0;
|
||||
a= nu->pntsu-1;
|
||||
len = 0;
|
||||
a = nu->pntsu - 1;
|
||||
if (nu->flagu & CU_NURB_CYCLIC) a++;
|
||||
|
||||
prevbezt= nu->bezt;
|
||||
bezt= prevbezt+1;
|
||||
prevbezt = nu->bezt;
|
||||
bezt = prevbezt + 1;
|
||||
while (a--) {
|
||||
if (a==0 && (nu->flagu & CU_NURB_CYCLIC)) bezt= nu->bezt;
|
||||
if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) bezt = nu->bezt;
|
||||
|
||||
if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++;
|
||||
else len+= resolu;
|
||||
if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) len++;
|
||||
else len += resolu;
|
||||
|
||||
if (a==0 && (nu->flagu & CU_NURB_CYCLIC)==0) len++;
|
||||
if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) len++;
|
||||
|
||||
prevbezt= bezt;
|
||||
prevbezt = bezt;
|
||||
bezt++;
|
||||
}
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListbez");
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListbez");
|
||||
/* len+1 because of 'forward_diff_bezier' function */
|
||||
dl->verts= MEM_callocN((len+1)*3*sizeof(float), "dlverts");
|
||||
dl->verts = MEM_callocN((len + 1) * 3 * sizeof(float), "dlverts");
|
||||
BLI_addtail(dispbase, dl);
|
||||
dl->parts= 1;
|
||||
dl->nr= len;
|
||||
dl->col= nu->mat_nr;
|
||||
dl->charidx= nu->charidx;
|
||||
dl->parts = 1;
|
||||
dl->nr = len;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
data= dl->verts;
|
||||
data = dl->verts;
|
||||
|
||||
if (nu->flagu & CU_NURB_CYCLIC) {
|
||||
dl->type= DL_POLY;
|
||||
a= nu->pntsu;
|
||||
dl->type = DL_POLY;
|
||||
a = nu->pntsu;
|
||||
}
|
||||
else {
|
||||
dl->type= DL_SEGM;
|
||||
a= nu->pntsu-1;
|
||||
dl->type = DL_SEGM;
|
||||
a = nu->pntsu - 1;
|
||||
}
|
||||
|
||||
prevbezt= nu->bezt;
|
||||
bezt= prevbezt+1;
|
||||
prevbezt = nu->bezt;
|
||||
bezt = prevbezt + 1;
|
||||
|
||||
while (a--) {
|
||||
if (a==0 && dl->type== DL_POLY) bezt= nu->bezt;
|
||||
if (a == 0 && dl->type == DL_POLY) bezt = nu->bezt;
|
||||
|
||||
if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
|
||||
if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
|
||||
copy_v3_v3(data, prevbezt->vec[1]);
|
||||
data+= 3;
|
||||
data += 3;
|
||||
}
|
||||
else {
|
||||
int j;
|
||||
for (j=0; j<3; j++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
|
||||
prevbezt->vec[2][j],
|
||||
bezt->vec[0][j],
|
||||
@@ -358,58 +358,58 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
|
||||
data + j, resolu, 3 * sizeof(float));
|
||||
}
|
||||
|
||||
data+= 3*resolu;
|
||||
data += 3 * resolu;
|
||||
}
|
||||
|
||||
if (a==0 && dl->type==DL_SEGM) {
|
||||
if (a == 0 && dl->type == DL_SEGM) {
|
||||
copy_v3_v3(data, bezt->vec[1]);
|
||||
}
|
||||
|
||||
prevbezt= bezt;
|
||||
prevbezt = bezt;
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
else if (nu->type == CU_NURBS) {
|
||||
len= (resolu*SEGMENTSU(nu));
|
||||
len = (resolu * SEGMENTSU(nu));
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
||||
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
||||
dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
|
||||
BLI_addtail(dispbase, dl);
|
||||
dl->parts= 1;
|
||||
dl->parts = 1;
|
||||
|
||||
dl->nr= len;
|
||||
dl->col= nu->mat_nr;
|
||||
dl->nr = len;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
data= dl->verts;
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
|
||||
else dl->type= DL_SEGM;
|
||||
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
|
||||
data = dl->verts;
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY;
|
||||
else dl->type = DL_SEGM;
|
||||
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float));
|
||||
}
|
||||
else if (nu->type == CU_POLY) {
|
||||
len= nu->pntsu;
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListpoly");
|
||||
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
||||
len = nu->pntsu;
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListpoly");
|
||||
dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
|
||||
BLI_addtail(dispbase, dl);
|
||||
dl->parts= 1;
|
||||
dl->nr= len;
|
||||
dl->col= nu->mat_nr;
|
||||
dl->parts = 1;
|
||||
dl->nr = len;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
data= dl->verts;
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
|
||||
else dl->type= DL_SEGM;
|
||||
data = dl->verts;
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY;
|
||||
else dl->type = DL_SEGM;
|
||||
|
||||
a= len;
|
||||
bp= nu->bp;
|
||||
a = len;
|
||||
bp = nu->bp;
|
||||
while (a--) {
|
||||
copy_v3_v3(data, bp->vec);
|
||||
bp++;
|
||||
data+= 3;
|
||||
data += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
nu= nu->next;
|
||||
nu = nu->next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,99 +419,99 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
|
||||
ScanFillContext sf_ctx;
|
||||
ScanFillVert *eve, *v1, *vlast;
|
||||
ScanFillFace *efa;
|
||||
DispList *dlnew=NULL, *dl;
|
||||
DispList *dlnew = NULL, *dl;
|
||||
float *f1;
|
||||
int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0;
|
||||
int colnr = 0, charidx = 0, cont = 1, tot, a, *index, nextcol = 0;
|
||||
intptr_t totvert;
|
||||
|
||||
if (dispbase==NULL) return;
|
||||
if (dispbase->first==NULL) return;
|
||||
if (dispbase == NULL) return;
|
||||
if (dispbase->first == NULL) return;
|
||||
|
||||
while (cont) {
|
||||
cont= 0;
|
||||
totvert= 0;
|
||||
nextcol= 0;
|
||||
cont = 0;
|
||||
totvert = 0;
|
||||
nextcol = 0;
|
||||
|
||||
BLI_scanfill_begin(&sf_ctx);
|
||||
|
||||
dl= dispbase->first;
|
||||
dl = dispbase->first;
|
||||
while (dl) {
|
||||
|
||||
if (dl->type==DL_POLY) {
|
||||
if (charidx<dl->charidx) cont= 1;
|
||||
else if (charidx==dl->charidx) { /* character with needed index */
|
||||
if (colnr==dl->col) {
|
||||
if (dl->type == DL_POLY) {
|
||||
if (charidx < dl->charidx) cont = 1;
|
||||
else if (charidx == dl->charidx) { /* character with needed index */
|
||||
if (colnr == dl->col) {
|
||||
/* make editverts and edges */
|
||||
f1= dl->verts;
|
||||
a= dl->nr;
|
||||
eve= v1= NULL;
|
||||
f1 = dl->verts;
|
||||
a = dl->nr;
|
||||
eve = v1 = NULL;
|
||||
|
||||
while (a--) {
|
||||
vlast= eve;
|
||||
vlast = eve;
|
||||
|
||||
eve = BLI_scanfill_vert_add(&sf_ctx, f1);
|
||||
totvert++;
|
||||
|
||||
if (vlast==NULL) v1= eve;
|
||||
if (vlast == NULL) v1 = eve;
|
||||
else {
|
||||
BLI_scanfill_edge_add(&sf_ctx, vlast, eve);
|
||||
}
|
||||
f1+=3;
|
||||
f1 += 3;
|
||||
}
|
||||
|
||||
if (eve!=NULL && v1!=NULL) {
|
||||
if (eve != NULL && v1 != NULL) {
|
||||
BLI_scanfill_edge_add(&sf_ctx, eve, v1);
|
||||
}
|
||||
}
|
||||
else if (colnr<dl->col) {
|
||||
else if (colnr < dl->col) {
|
||||
/* got poly with next material at current char */
|
||||
cont= 1;
|
||||
nextcol= 1;
|
||||
cont = 1;
|
||||
nextcol = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
dl= dl->next;
|
||||
dl = dl->next;
|
||||
}
|
||||
|
||||
if (totvert && (tot= BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) {
|
||||
if (totvert && (tot = BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) {
|
||||
if (tot) {
|
||||
dlnew= MEM_callocN(sizeof(DispList), "filldisplist");
|
||||
dlnew->type= DL_INDEX3;
|
||||
dlnew->col= colnr;
|
||||
dlnew->nr= totvert;
|
||||
dlnew->parts= tot;
|
||||
dlnew = MEM_callocN(sizeof(DispList), "filldisplist");
|
||||
dlnew->type = DL_INDEX3;
|
||||
dlnew->col = colnr;
|
||||
dlnew->nr = totvert;
|
||||
dlnew->parts = tot;
|
||||
|
||||
dlnew->index= MEM_mallocN(tot*3*sizeof(int), "dlindex");
|
||||
dlnew->verts= MEM_mallocN(totvert*3*sizeof(float), "dlverts");
|
||||
dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex");
|
||||
dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts");
|
||||
|
||||
/* vert data */
|
||||
f1= dlnew->verts;
|
||||
totvert= 0;
|
||||
eve= sf_ctx.fillvertbase.first;
|
||||
f1 = dlnew->verts;
|
||||
totvert = 0;
|
||||
eve = sf_ctx.fillvertbase.first;
|
||||
while (eve) {
|
||||
copy_v3_v3(f1, eve->co);
|
||||
f1+= 3;
|
||||
f1 += 3;
|
||||
|
||||
/* index number */
|
||||
eve->tmp.l = totvert;
|
||||
totvert++;
|
||||
|
||||
eve= eve->next;
|
||||
eve = eve->next;
|
||||
}
|
||||
|
||||
/* index data */
|
||||
efa = sf_ctx.fillfacebase.first;
|
||||
index= dlnew->index;
|
||||
index = dlnew->index;
|
||||
while (efa) {
|
||||
index[0]= (intptr_t)efa->v1->tmp.l;
|
||||
index[1]= (intptr_t)efa->v2->tmp.l;
|
||||
index[2]= (intptr_t)efa->v3->tmp.l;
|
||||
index[0] = (intptr_t)efa->v1->tmp.l;
|
||||
index[1] = (intptr_t)efa->v2->tmp.l;
|
||||
index[2] = (intptr_t)efa->v3->tmp.l;
|
||||
|
||||
if (flipnormal)
|
||||
SWAP(int, index[0], index[2]);
|
||||
|
||||
index+= 3;
|
||||
efa= efa->next;
|
||||
index += 3;
|
||||
efa = efa->next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
|
||||
else {
|
||||
/* switch to next char and start filling from first material */
|
||||
charidx++;
|
||||
colnr= 0;
|
||||
colnr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,55 +542,55 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
|
||||
float *fp, *fp1;
|
||||
int a, dpoly;
|
||||
|
||||
front.first= front.last= back.first= back.last= NULL;
|
||||
front.first = front.last = back.first = back.last = NULL;
|
||||
|
||||
dl= dispbase->first;
|
||||
dl = dispbase->first;
|
||||
while (dl) {
|
||||
if (dl->type==DL_SURF) {
|
||||
if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)==0 ) {
|
||||
if (dl->type == DL_SURF) {
|
||||
if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) {
|
||||
if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) {
|
||||
dlnew= MEM_callocN(sizeof(DispList), "filldisp");
|
||||
dlnew = MEM_callocN(sizeof(DispList), "filldisp");
|
||||
BLI_addtail(&front, dlnew);
|
||||
dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1");
|
||||
dlnew->nr= dl->parts;
|
||||
dlnew->parts= 1;
|
||||
dlnew->type= DL_POLY;
|
||||
dlnew->col= dl->col;
|
||||
dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1");
|
||||
dlnew->nr = dl->parts;
|
||||
dlnew->parts = 1;
|
||||
dlnew->type = DL_POLY;
|
||||
dlnew->col = dl->col;
|
||||
dlnew->charidx = dl->charidx;
|
||||
|
||||
fp= dl->verts;
|
||||
dpoly= 3*dl->nr;
|
||||
fp = dl->verts;
|
||||
dpoly = 3 * dl->nr;
|
||||
|
||||
a= dl->parts;
|
||||
a = dl->parts;
|
||||
while (a--) {
|
||||
copy_v3_v3(fp1, fp);
|
||||
fp1+= 3;
|
||||
fp+= dpoly;
|
||||
fp1 += 3;
|
||||
fp += dpoly;
|
||||
}
|
||||
}
|
||||
if ( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) {
|
||||
dlnew= MEM_callocN(sizeof(DispList), "filldisp");
|
||||
dlnew = MEM_callocN(sizeof(DispList), "filldisp");
|
||||
BLI_addtail(&back, dlnew);
|
||||
dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1");
|
||||
dlnew->nr= dl->parts;
|
||||
dlnew->parts= 1;
|
||||
dlnew->type= DL_POLY;
|
||||
dlnew->col= dl->col;
|
||||
dlnew->charidx= dl->charidx;
|
||||
dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1");
|
||||
dlnew->nr = dl->parts;
|
||||
dlnew->parts = 1;
|
||||
dlnew->type = DL_POLY;
|
||||
dlnew->col = dl->col;
|
||||
dlnew->charidx = dl->charidx;
|
||||
|
||||
fp= dl->verts+3*(dl->nr-1);
|
||||
dpoly= 3*dl->nr;
|
||||
fp = dl->verts + 3 * (dl->nr - 1);
|
||||
dpoly = 3 * dl->nr;
|
||||
|
||||
a= dl->parts;
|
||||
a = dl->parts;
|
||||
while (a--) {
|
||||
copy_v3_v3(fp1, fp);
|
||||
fp1+= 3;
|
||||
fp+= dpoly;
|
||||
fp1 += 3;
|
||||
fp += dpoly;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dl= dl->next;
|
||||
dl = dl->next;
|
||||
}
|
||||
|
||||
filldisplist(&front, dispbase, 1);
|
||||
@@ -607,7 +607,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis
|
||||
{
|
||||
if (cu->flag & CU_3D) return;
|
||||
|
||||
if (dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) {
|
||||
if (dispbase->first && ((DispList *) dispbase->first)->type == DL_SURF) {
|
||||
bevels_to_filledpoly(cu, dispbase);
|
||||
}
|
||||
else {
|
||||
@@ -624,37 +624,37 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
|
||||
{
|
||||
DispList *dl;
|
||||
|
||||
if (taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0;
|
||||
if (taperobj == NULL || taperobj->type != OB_CURVE) return 1.0;
|
||||
|
||||
dl= taperobj->disp.first;
|
||||
if (dl==NULL) {
|
||||
dl = taperobj->disp.first;
|
||||
if (dl == NULL) {
|
||||
makeDispListCurveTypes(scene, taperobj, 0);
|
||||
dl= taperobj->disp.first;
|
||||
dl = taperobj->disp.first;
|
||||
}
|
||||
if (dl) {
|
||||
float fac= ((float)cur)/(float)(tot-1);
|
||||
float fac = ((float)cur) / (float)(tot - 1);
|
||||
float minx, dx, *fp;
|
||||
int a;
|
||||
|
||||
/* horizontal size */
|
||||
minx= dl->verts[0];
|
||||
dx= dl->verts[3*(dl->nr-1)] - minx;
|
||||
minx = dl->verts[0];
|
||||
dx = dl->verts[3 * (dl->nr - 1)] - minx;
|
||||
if (dx > 0.0f) {
|
||||
|
||||
fp= dl->verts;
|
||||
for (a=0; a<dl->nr; a++, fp+=3) {
|
||||
if ( (fp[0]-minx)/dx >= fac) {
|
||||
fp = dl->verts;
|
||||
for (a = 0; a < dl->nr; a++, fp += 3) {
|
||||
if ( (fp[0] - minx) / dx >= fac) {
|
||||
/* interpolate with prev */
|
||||
if (a>0) {
|
||||
float fac1= (fp[-3]-minx)/dx;
|
||||
float fac2= (fp[0]-minx)/dx;
|
||||
if (fac1!=fac2)
|
||||
return fp[1]*(fac1-fac)/(fac1-fac2) + fp[-2]*(fac-fac2)/(fac1-fac2);
|
||||
if (a > 0) {
|
||||
float fac1 = (fp[-3] - minx) / dx;
|
||||
float fac2 = (fp[0] - minx) / dx;
|
||||
if (fac1 != fac2)
|
||||
return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2);
|
||||
}
|
||||
return fp[1];
|
||||
}
|
||||
}
|
||||
return fp[-2]; // last y coord
|
||||
return fp[-2]; // last y coord
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,7 +663,7 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
|
||||
|
||||
void makeDispListMBall(Scene *scene, Object *ob)
|
||||
{
|
||||
if (!ob || ob->type!=OB_MBALL) return;
|
||||
if (!ob || ob->type != OB_MBALL) return;
|
||||
|
||||
// XXX: mball stuff uses plenty of global variables
|
||||
// while this is unchanged updating during render is unsafe
|
||||
@@ -671,8 +671,8 @@ void makeDispListMBall(Scene *scene, Object *ob)
|
||||
|
||||
freedisplist(&(ob->disp));
|
||||
|
||||
if (ob->type==OB_MBALL) {
|
||||
if (ob==BKE_metaball_basis_find(scene, ob)) {
|
||||
if (ob->type == OB_MBALL) {
|
||||
if (ob == BKE_metaball_basis_find(scene, ob)) {
|
||||
BKE_metaball_polygonize(scene, ob, &ob->disp);
|
||||
BKE_metaball_texspace_calc(ob);
|
||||
|
||||
@@ -703,7 +703,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo
|
||||
if (editmode) required_mode |= eModifierMode_Editmode;
|
||||
|
||||
pretessellatePoint = NULL;
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (!modifier_isEnabled(scene, md, required_mode)) continue;
|
||||
@@ -717,7 +717,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo
|
||||
* for incformation button in modifier's header */
|
||||
md->mode |= eModifierMode_ApplyOnSpline;
|
||||
}
|
||||
else if (md->mode&eModifierMode_ApplyOnSpline) {
|
||||
else if (md->mode & eModifierMode_ApplyOnSpline) {
|
||||
pretessellatePoint = md;
|
||||
}
|
||||
}
|
||||
@@ -729,13 +729,13 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
ModifierData *pretessellatePoint;
|
||||
Curve *cu= ob->data;
|
||||
ListBase *nurb= BKE_curve_nurbs_get(cu);
|
||||
Curve *cu = ob->data;
|
||||
ListBase *nurb = BKE_curve_nurbs_get(cu);
|
||||
int numVerts = 0;
|
||||
int editmode = (!forRender && cu->editnurb);
|
||||
float (*originalVerts)[3] = NULL;
|
||||
float (*deformedVerts)[3] = NULL;
|
||||
float *keyVerts= NULL;
|
||||
float *keyVerts = NULL;
|
||||
int required_mode;
|
||||
|
||||
if (forRender) required_mode = eModifierMode_Render;
|
||||
@@ -745,29 +745,29 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
|
||||
|
||||
if (editmode) required_mode |= eModifierMode_Editmode;
|
||||
|
||||
if (cu->editnurb==NULL) {
|
||||
keyVerts= do_ob_key(scene, ob);
|
||||
if (cu->editnurb == NULL) {
|
||||
keyVerts = do_ob_key(scene, ob);
|
||||
|
||||
if (keyVerts) {
|
||||
/* split coords from key data, the latter also includes
|
||||
* tilts, which is passed through in the modifier stack.
|
||||
* this is also the reason curves do not use a virtual
|
||||
* shape key modifier yet. */
|
||||
deformedVerts= BKE_curve_keyVertexCos_get(cu, nurb, keyVerts);
|
||||
originalVerts= MEM_dupallocN(deformedVerts);
|
||||
deformedVerts = BKE_curve_keyVertexCos_get(cu, nurb, keyVerts);
|
||||
originalVerts = MEM_dupallocN(deformedVerts);
|
||||
numVerts = BKE_nurbList_verts_count_without_handles(nurb);
|
||||
}
|
||||
}
|
||||
|
||||
if (pretessellatePoint) {
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
if ((md->mode & required_mode) != required_mode) continue;
|
||||
if (mti->isDisabled && mti->isDisabled(md, forRender)) continue;
|
||||
if (mti->type!=eModifierTypeType_OnlyDeform) continue;
|
||||
if (mti->type != eModifierTypeType_OnlyDeform) continue;
|
||||
|
||||
if (!deformedVerts) {
|
||||
deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts);
|
||||
@@ -776,7 +776,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
|
||||
|
||||
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, forRender, editmode);
|
||||
|
||||
if (md==pretessellatePoint)
|
||||
if (md == pretessellatePoint)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -794,22 +794,22 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
|
||||
*numVerts_r = numVerts;
|
||||
}
|
||||
|
||||
static float (*displist_get_allverts (ListBase *dispbase, int *totvert))[3]
|
||||
static float (*displist_get_allverts(ListBase * dispbase, int *totvert))[3]
|
||||
{
|
||||
DispList *dl;
|
||||
float (*allverts)[3], *fp;
|
||||
|
||||
*totvert= 0;
|
||||
*totvert = 0;
|
||||
|
||||
for (dl=dispbase->first; dl; dl=dl->next)
|
||||
*totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr;
|
||||
for (dl = dispbase->first; dl; dl = dl->next)
|
||||
*totvert += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr;
|
||||
|
||||
allverts= MEM_mallocN((*totvert)*sizeof(float)*3, "displist_get_allverts allverts");
|
||||
fp= (float*)allverts;
|
||||
for (dl=dispbase->first; dl; dl=dl->next) {
|
||||
int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr);
|
||||
allverts = MEM_mallocN((*totvert) * sizeof(float) * 3, "displist_get_allverts allverts");
|
||||
fp = (float *)allverts;
|
||||
for (dl = dispbase->first; dl; dl = dl->next) {
|
||||
int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
|
||||
memcpy(fp, dl->verts, sizeof(float) * offs);
|
||||
fp+= offs;
|
||||
fp += offs;
|
||||
}
|
||||
|
||||
return allverts;
|
||||
@@ -820,24 +820,24 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
|
||||
DispList *dl;
|
||||
float *fp;
|
||||
|
||||
fp= (float*)allverts;
|
||||
for (dl=dispbase->first; dl; dl=dl->next) {
|
||||
int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr);
|
||||
fp = (float *)allverts;
|
||||
for (dl = dispbase->first; dl; dl = dl->next) {
|
||||
int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
|
||||
memcpy(dl->verts, fp, sizeof(float) * offs);
|
||||
fp+= offs;
|
||||
fp += offs;
|
||||
}
|
||||
}
|
||||
|
||||
static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase,
|
||||
DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3])
|
||||
DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3])
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
ModifierData *pretessellatePoint;
|
||||
Curve *cu= ob->data;
|
||||
ListBase *nurb= BKE_curve_nurbs_get(cu);
|
||||
Curve *cu = ob->data;
|
||||
ListBase *nurb = BKE_curve_nurbs_get(cu);
|
||||
int required_mode = 0, totvert = 0;
|
||||
int editmode = (!forRender && cu->editnurb);
|
||||
DerivedMesh *dm= NULL, *ndm;
|
||||
DerivedMesh *dm = NULL, *ndm;
|
||||
float (*vertCos)[3] = NULL;
|
||||
int useCache = !forRender;
|
||||
|
||||
@@ -853,19 +853,19 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
|
||||
}
|
||||
|
||||
if (derivedFinal && *derivedFinal) {
|
||||
(*derivedFinal)->release (*derivedFinal);
|
||||
(*derivedFinal)->release(*derivedFinal);
|
||||
}
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
if ((md->mode & required_mode) != required_mode) continue;
|
||||
if (mti->isDisabled && mti->isDisabled(md, forRender)) continue;
|
||||
|
||||
if (mti->type == eModifierTypeType_OnlyDeform ||
|
||||
(mti->type == eModifierTypeType_DeformOrConstruct && !dm)) {
|
||||
(mti->type == eModifierTypeType_DeformOrConstruct && !dm)) {
|
||||
if (dm) {
|
||||
if (!vertCos) {
|
||||
totvert = dm->getNumVerts(dm);
|
||||
@@ -877,7 +877,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
|
||||
}
|
||||
else {
|
||||
if (!vertCos) {
|
||||
vertCos= displist_get_allverts(dispbase, &totvert);
|
||||
vertCos = displist_get_allverts(dispbase, &totvert);
|
||||
}
|
||||
|
||||
mti->deformVerts(md, ob, NULL, vertCos, totvert, forRender, editmode);
|
||||
@@ -910,7 +910,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
|
||||
curve_to_filledpoly(cu, nurb, dispbase);
|
||||
}
|
||||
|
||||
dm= CDDM_from_curve_customDB(ob, dispbase);
|
||||
dm = CDDM_from_curve_customDB(ob, dispbase);
|
||||
|
||||
CDDM_calc_normals_mapping(dm);
|
||||
}
|
||||
@@ -918,7 +918,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
|
||||
if (vertCos) {
|
||||
/* Vertex coordinates were applied to necessary data, could free it */
|
||||
MEM_freeN(vertCos);
|
||||
vertCos= NULL;
|
||||
vertCos = NULL;
|
||||
}
|
||||
|
||||
ndm = mti->applyModifier(md, ob, dm, forRender, useCache);
|
||||
@@ -927,7 +927,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
|
||||
/* Modifier returned a new derived mesh */
|
||||
|
||||
if (dm && dm != ndm) /* Modifier */
|
||||
dm->release (dm);
|
||||
dm->release(dm);
|
||||
dm = ndm;
|
||||
}
|
||||
}
|
||||
@@ -946,12 +946,12 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
|
||||
else {
|
||||
displist_apply_allverts(dispbase, vertCos);
|
||||
MEM_freeN(vertCos);
|
||||
vertCos= NULL;
|
||||
vertCos = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (derivedFinal) {
|
||||
if (dm) DM_ensure_tessface(dm); /* needed for drawing */
|
||||
if (dm) DM_ensure_tessface(dm); /* needed for drawing */
|
||||
(*derivedFinal) = dm;
|
||||
}
|
||||
|
||||
@@ -967,25 +967,25 @@ static void displist_surf_indices(DispList *dl)
|
||||
int a, b, p1, p2, p3, p4;
|
||||
int *index;
|
||||
|
||||
dl->totindex= 0;
|
||||
dl->totindex = 0;
|
||||
|
||||
index=dl->index= MEM_mallocN(4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs");
|
||||
index = dl->index = MEM_mallocN(4 * sizeof(int) * (dl->parts + 1) * (dl->nr + 1), "index array nurbs");
|
||||
|
||||
for (a=0; a<dl->parts; a++) {
|
||||
for (a = 0; a < dl->parts; a++) {
|
||||
|
||||
if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
|
||||
if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0)
|
||||
break;
|
||||
|
||||
for (; b<dl->nr; b++, index+=4) {
|
||||
index[0]= p1;
|
||||
index[1]= p2;
|
||||
index[2]= p4;
|
||||
index[3]= p3;
|
||||
for (; b < dl->nr; b++, index += 4) {
|
||||
index[0] = p1;
|
||||
index[1] = p2;
|
||||
index[2] = p4;
|
||||
index[3] = p3;
|
||||
|
||||
dl->totindex++;
|
||||
|
||||
p2= p1; p1++;
|
||||
p4= p3; p3++;
|
||||
p2 = p1; p1++;
|
||||
p4 = p3; p3++;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -995,11 +995,11 @@ static void displist_surf_indices(DispList *dl)
|
||||
static DerivedMesh *create_orco_dm(Scene *scene, Object *ob)
|
||||
{
|
||||
DerivedMesh *dm;
|
||||
ListBase disp= {NULL, NULL};
|
||||
ListBase disp = {NULL, NULL};
|
||||
|
||||
/* OrcoDM should be created from underformed disp lists */
|
||||
makeDispListCurveTypes_forOrco(scene, ob, &disp);
|
||||
dm= CDDM_from_curve_customDB(ob, &disp);
|
||||
dm = CDDM_from_curve_customDB(ob, &disp);
|
||||
|
||||
freedisplist(&disp);
|
||||
|
||||
@@ -1010,12 +1010,12 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *
|
||||
{
|
||||
float (*orco)[3], (*layerorco)[3];
|
||||
int totvert, a;
|
||||
Curve *cu= ob->data;
|
||||
Curve *cu = ob->data;
|
||||
|
||||
totvert= dm->getNumVerts(dm);
|
||||
totvert = dm->getNumVerts(dm);
|
||||
|
||||
if (orcodm) {
|
||||
orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco");
|
||||
orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco");
|
||||
|
||||
if (orcodm->getNumVerts(orcodm) == totvert)
|
||||
orcodm->getVertCos(orcodm, orco);
|
||||
@@ -1023,18 +1023,18 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *
|
||||
dm->getVertCos(dm, orco);
|
||||
}
|
||||
else {
|
||||
orco= (float(*)[3])BKE_curve_make_orco(scene, ob);
|
||||
orco = (float(*)[3])BKE_curve_make_orco(scene, ob);
|
||||
}
|
||||
|
||||
for (a=0; a<totvert; a++) {
|
||||
for (a = 0; a < totvert; a++) {
|
||||
float *co = orco[a];
|
||||
co[0] = (co[0]-cu->loc[0])/cu->size[0];
|
||||
co[1] = (co[1]-cu->loc[1])/cu->size[1];
|
||||
co[2] = (co[2]-cu->loc[2])/cu->size[2];
|
||||
co[0] = (co[0] - cu->loc[0]) / cu->size[0];
|
||||
co[1] = (co[1] - cu->loc[1]) / cu->size[1];
|
||||
co[2] = (co[2] - cu->loc[2]) / cu->size[2];
|
||||
}
|
||||
|
||||
if ((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) {
|
||||
memcpy(layerorco, orco, sizeof(float)*totvert);
|
||||
memcpy(layerorco, orco, sizeof(float) * totvert);
|
||||
MEM_freeN(orco);
|
||||
}
|
||||
else
|
||||
@@ -1048,10 +1048,10 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
|
||||
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
ModifierData *pretessellatePoint;
|
||||
Curve *cu= ob->data;
|
||||
Curve *cu = ob->data;
|
||||
int required_mode;
|
||||
int editmode = (!forRender && cu->editnurb);
|
||||
DerivedMesh *ndm, *orcodm= NULL;
|
||||
DerivedMesh *ndm, *orcodm = NULL;
|
||||
|
||||
if (forRender) required_mode = eModifierMode_Render;
|
||||
else required_mode = eModifierMode_Realtime;
|
||||
@@ -1064,17 +1064,17 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
|
||||
md = pretessellatePoint->next;
|
||||
}
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
if ((md->mode & required_mode) != required_mode) continue;
|
||||
if (mti->isDisabled && mti->isDisabled(md, forRender)) continue;
|
||||
if (mti->type!=eModifierTypeType_Constructive) continue;
|
||||
if (mti->type != eModifierTypeType_Constructive) continue;
|
||||
|
||||
if (!orcodm)
|
||||
orcodm= create_orco_dm(scene, ob);
|
||||
orcodm = create_orco_dm(scene, ob);
|
||||
|
||||
ndm = mti->applyModifier(md, ob, orcodm, forRender, 0);
|
||||
|
||||
@@ -1095,7 +1095,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
|
||||
}
|
||||
|
||||
void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
|
||||
DerivedMesh **derivedFinal, int forRender, int forOrco)
|
||||
DerivedMesh **derivedFinal, int forRender, int forOrco)
|
||||
{
|
||||
ListBase *nubase;
|
||||
Nurb *nu;
|
||||
@@ -1108,65 +1108,65 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
|
||||
float (*deformedVerts)[3];
|
||||
|
||||
if (!forRender && cu->editnurb)
|
||||
nubase= BKE_curve_editNurbs_get(cu);
|
||||
nubase = BKE_curve_editNurbs_get(cu);
|
||||
else
|
||||
nubase= &cu->nurb;
|
||||
nubase = &cu->nurb;
|
||||
|
||||
if (!forOrco)
|
||||
curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
|
||||
|
||||
for (nu=nubase->first; nu; nu=nu->next) {
|
||||
if (forRender || nu->hide==0) {
|
||||
int resolu= nu->resolu, resolv= nu->resolv;
|
||||
for (nu = nubase->first; nu; nu = nu->next) {
|
||||
if (forRender || nu->hide == 0) {
|
||||
int resolu = nu->resolu, resolv = nu->resolv;
|
||||
|
||||
if (forRender) {
|
||||
if (cu->resolu_ren) resolu= cu->resolu_ren;
|
||||
if (cu->resolv_ren) resolv= cu->resolv_ren;
|
||||
if (cu->resolu_ren) resolu = cu->resolu_ren;
|
||||
if (cu->resolv_ren) resolv = cu->resolv_ren;
|
||||
}
|
||||
|
||||
if (nu->pntsv==1) {
|
||||
len= SEGMENTSU(nu)*resolu;
|
||||
if (nu->pntsv == 1) {
|
||||
len = SEGMENTSU(nu) * resolu;
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
||||
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
||||
dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
|
||||
|
||||
BLI_addtail(dispbase, dl);
|
||||
dl->parts= 1;
|
||||
dl->nr= len;
|
||||
dl->col= nu->mat_nr;
|
||||
dl->charidx= nu->charidx;
|
||||
dl->parts = 1;
|
||||
dl->nr = len;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
/* dl->rt will be used as flag for render face and */
|
||||
/* CU_2D conflicts with R_NOPUNOFLIP */
|
||||
dl->rt= nu->flag & ~CU_2D;
|
||||
dl->rt = nu->flag & ~CU_2D;
|
||||
|
||||
data= dl->verts;
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
|
||||
else dl->type= DL_SEGM;
|
||||
data = dl->verts;
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY;
|
||||
else dl->type = DL_SEGM;
|
||||
|
||||
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
|
||||
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float));
|
||||
}
|
||||
else {
|
||||
len= (nu->pntsu*resolu) * (nu->pntsv*resolv);
|
||||
len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
||||
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
||||
dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
|
||||
BLI_addtail(dispbase, dl);
|
||||
|
||||
dl->col= nu->mat_nr;
|
||||
dl->charidx= nu->charidx;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
/* dl->rt will be used as flag for render face and */
|
||||
/* CU_2D conflicts with R_NOPUNOFLIP */
|
||||
dl->rt= nu->flag & ~CU_2D;
|
||||
dl->rt = nu->flag & ~CU_2D;
|
||||
|
||||
data= dl->verts;
|
||||
dl->type= DL_SURF;
|
||||
data = dl->verts;
|
||||
dl->type = DL_SURF;
|
||||
|
||||
dl->parts= (nu->pntsu*resolu); /* in reverse, because makeNurbfaces works that way */
|
||||
dl->nr= (nu->pntsv*resolv);
|
||||
if (nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V;
|
||||
dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */
|
||||
dl->nr = (nu->pntsv * resolv);
|
||||
if (nu->flagv & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_U; /* reverse too! */
|
||||
if (nu->flagu & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_V;
|
||||
|
||||
BKE_nurb_makeFaces(nu, data, 0, resolu, resolv);
|
||||
|
||||
@@ -1187,7 +1187,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
|
||||
|
||||
if (!forOrco)
|
||||
curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal,
|
||||
forRender, originalVerts, deformedVerts);
|
||||
forRender, originalVerts, deformedVerts);
|
||||
}
|
||||
|
||||
static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r)
|
||||
@@ -1196,24 +1196,24 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid
|
||||
int b;
|
||||
|
||||
fp = dlb->verts;
|
||||
for (b = 0; b<dlb->nr; b++, fp += 3, data += 3) {
|
||||
for (b = 0; b < dlb->nr; b++, fp += 3, data += 3) {
|
||||
if (cu->flag & CU_3D) {
|
||||
float vec[3];
|
||||
|
||||
vec[0] = fp[1]+widfac;
|
||||
vec[0] = fp[1] + widfac;
|
||||
vec[1] = fp[2];
|
||||
vec[2 ]= 0.0;
|
||||
vec[2] = 0.0;
|
||||
|
||||
mul_qt_v3(bevp->quat, vec);
|
||||
|
||||
data[0] = bevp->vec[0] + fac*vec[0];
|
||||
data[1] = bevp->vec[1] + fac*vec[1];
|
||||
data[2] = bevp->vec[2] + fac*vec[2];
|
||||
data[0] = bevp->vec[0] + fac * vec[0];
|
||||
data[1] = bevp->vec[1] + fac * vec[1];
|
||||
data[2] = bevp->vec[2] + fac * vec[2];
|
||||
}
|
||||
else {
|
||||
data[0] = bevp->vec[0] + fac*(widfac+fp[1])*bevp->sina;
|
||||
data[1] = bevp->vec[1] + fac*(widfac+fp[1])*bevp->cosa;
|
||||
data[2] = bevp->vec[2] + fac*fp[2];
|
||||
data[0] = bevp->vec[0] + fac * (widfac + fp[1]) * bevp->sina;
|
||||
data[1] = bevp->vec[1] + fac * (widfac + fp[1]) * bevp->cosa;
|
||||
data[2] = bevp->vec[2] + fac * fp[2];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1226,19 +1226,19 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp
|
||||
float *data;
|
||||
int b;
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListbev2");
|
||||
dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts");
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListbev2");
|
||||
dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr, "dlverts");
|
||||
|
||||
dl->type= DL_POLY;
|
||||
dl->type = DL_POLY;
|
||||
|
||||
dl->parts= 1;
|
||||
dl->nr= dlb->nr;
|
||||
dl->col= nu->mat_nr;
|
||||
dl->charidx= nu->charidx;
|
||||
dl->parts = 1;
|
||||
dl->nr = dlb->nr;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
/* dl->rt will be used as flag for render face and */
|
||||
/* CU_2D conflicts with R_NOPUNOFLIP */
|
||||
dl->rt= nu->flag & ~CU_2D;
|
||||
dl->rt = nu->flag & ~CU_2D;
|
||||
|
||||
for (b = 0; b < dlb->nr; b++, prev_fp += 3, data += 3)
|
||||
copy_v3_v3(data, prev_fp);
|
||||
@@ -1247,14 +1247,14 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp
|
||||
}
|
||||
|
||||
static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase,
|
||||
DerivedMesh **derivedFinal, int forRender, int forOrco)
|
||||
DerivedMesh **derivedFinal, int forRender, int forOrco)
|
||||
{
|
||||
Curve *cu = ob->data;
|
||||
|
||||
/* we do allow duplis... this is only displist on curve level */
|
||||
if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
|
||||
|
||||
if (ob->type==OB_SURF) {
|
||||
if (ob->type == OB_SURF) {
|
||||
makeDispListSurf(scene, ob, dispbase, derivedFinal, forRender, forOrco);
|
||||
}
|
||||
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
|
||||
@@ -1264,14 +1264,14 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
float (*deformedVerts)[3];
|
||||
int numVerts;
|
||||
|
||||
nubase= BKE_curve_nurbs_get(cu);
|
||||
nubase = BKE_curve_nurbs_get(cu);
|
||||
|
||||
BLI_freelistN(&(cu->bev));
|
||||
|
||||
if (cu->path) free_path(cu->path);
|
||||
cu->path= NULL;
|
||||
cu->path = NULL;
|
||||
|
||||
if (ob->type==OB_FONT) BKE_vfont_to_curve(G.main, scene, ob, 0);
|
||||
if (ob->type == OB_FONT) BKE_vfont_to_curve(G.main, scene, ob, 0);
|
||||
|
||||
if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
|
||||
|
||||
@@ -1281,15 +1281,15 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
BKE_curve_bevel_make(scene, ob, &dlbev, forRender);
|
||||
|
||||
/* no bevel or extrude, and no width correction? */
|
||||
if (!dlbev.first && cu->width==1.0f) {
|
||||
if (!dlbev.first && cu->width == 1.0f) {
|
||||
curve_to_displist(cu, nubase, dispbase, forRender);
|
||||
}
|
||||
else {
|
||||
float widfac= cu->width - 1.0f;
|
||||
BevList *bl= cu->bev.first;
|
||||
Nurb *nu= nubase->first;
|
||||
float widfac = cu->width - 1.0f;
|
||||
BevList *bl = cu->bev.first;
|
||||
Nurb *nu = nubase->first;
|
||||
|
||||
for (; bl && nu; bl=bl->next, nu=nu->next) {
|
||||
for (; bl && nu; bl = bl->next, nu = nu->next) {
|
||||
DispList *dl;
|
||||
float *data;
|
||||
BevPoint *bevp;
|
||||
@@ -1298,34 +1298,34 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
if (bl->nr) { /* blank bevel lists can happen */
|
||||
|
||||
/* exception handling; curve without bevel or extrude, with width correction */
|
||||
if (dlbev.first==NULL) {
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListbev");
|
||||
dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts");
|
||||
if (dlbev.first == NULL) {
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListbev");
|
||||
dl->verts = MEM_callocN(3 * sizeof(float) * bl->nr, "dlverts");
|
||||
BLI_addtail(dispbase, dl);
|
||||
|
||||
if (bl->poly!= -1) dl->type= DL_POLY;
|
||||
else dl->type= DL_SEGM;
|
||||
if (bl->poly != -1) dl->type = DL_POLY;
|
||||
else dl->type = DL_SEGM;
|
||||
|
||||
if (dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE);
|
||||
if (dl->type == DL_SEGM) dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
|
||||
|
||||
dl->parts= 1;
|
||||
dl->nr= bl->nr;
|
||||
dl->col= nu->mat_nr;
|
||||
dl->charidx= nu->charidx;
|
||||
dl->parts = 1;
|
||||
dl->nr = bl->nr;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
/* dl->rt will be used as flag for render face and */
|
||||
/* CU_2D conflicts with R_NOPUNOFLIP */
|
||||
dl->rt= nu->flag & ~CU_2D;
|
||||
dl->rt = nu->flag & ~CU_2D;
|
||||
|
||||
a= dl->nr;
|
||||
bevp= (BevPoint *)(bl+1);
|
||||
data= dl->verts;
|
||||
a = dl->nr;
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
data = dl->verts;
|
||||
while (a--) {
|
||||
data[0]= bevp->vec[0]+widfac*bevp->sina;
|
||||
data[1]= bevp->vec[1]+widfac*bevp->cosa;
|
||||
data[2]= bevp->vec[2];
|
||||
data[0] = bevp->vec[0] + widfac * bevp->sina;
|
||||
data[1] = bevp->vec[1] + widfac * bevp->cosa;
|
||||
data[2] = bevp->vec[2];
|
||||
bevp++;
|
||||
data+=3;
|
||||
data += 3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1333,7 +1333,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
ListBase bottom_capbase = {NULL, NULL};
|
||||
ListBase top_capbase = {NULL, NULL};
|
||||
|
||||
for (dlb=dlbev.first; dlb; dlb=dlb->next) {
|
||||
for (dlb = dlbev.first; dlb; dlb = dlb->next) {
|
||||
int i, start, steps;
|
||||
float bevfac1 = MIN2(cu->bevfac1, cu->bevfac2), bevfac2 = MAX2(cu->bevfac1, cu->bevfac2);
|
||||
float firstblend = 0.0f, lastblend = 0.0f;
|
||||
@@ -1341,10 +1341,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
if (cu->bevfac1 - cu->bevfac2 == 0.0f)
|
||||
continue;
|
||||
|
||||
start = (int)(bevfac1*(bl->nr-1));
|
||||
steps = 2+(int)((bevfac2)*(bl->nr-1)) - start;
|
||||
firstblend = 1.0f - ((float)bevfac1*(bl->nr-1) - (int)((float)bevfac1*(bl->nr-1)));
|
||||
lastblend = (float)bevfac2*(bl->nr-1) - (int)((float)bevfac2*(bl->nr-1));
|
||||
start = (int)(bevfac1 * (bl->nr - 1));
|
||||
steps = 2 + (int)((bevfac2) * (bl->nr - 1)) - start;
|
||||
firstblend = 1.0f - ((float)bevfac1 * (bl->nr - 1) - (int)((float)bevfac1 * (bl->nr - 1)));
|
||||
lastblend = (float)bevfac2 * (bl->nr - 1) - (int)((float)bevfac2 * (bl->nr - 1));
|
||||
|
||||
if (steps > bl->nr) {
|
||||
steps = bl->nr;
|
||||
@@ -1352,35 +1352,35 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
}
|
||||
|
||||
/* for each part of the bevel use a separate displblock */
|
||||
dl= MEM_callocN(sizeof(DispList), "makeDispListbev1");
|
||||
dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*steps, "dlverts");
|
||||
dl = MEM_callocN(sizeof(DispList), "makeDispListbev1");
|
||||
dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr * steps, "dlverts");
|
||||
BLI_addtail(dispbase, dl);
|
||||
|
||||
dl->type= DL_SURF;
|
||||
dl->type = DL_SURF;
|
||||
|
||||
dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE);
|
||||
if (dlb->type==DL_POLY) dl->flag |= DL_CYCL_U;
|
||||
if (bl->poly>=0) dl->flag |= DL_CYCL_V;
|
||||
dl->flag = dlb->flag & (DL_FRONT_CURVE | DL_BACK_CURVE);
|
||||
if (dlb->type == DL_POLY) dl->flag |= DL_CYCL_U;
|
||||
if (bl->poly >= 0) dl->flag |= DL_CYCL_V;
|
||||
|
||||
dl->parts= steps;
|
||||
dl->nr= dlb->nr;
|
||||
dl->col= nu->mat_nr;
|
||||
dl->charidx= nu->charidx;
|
||||
dl->parts = steps;
|
||||
dl->nr = dlb->nr;
|
||||
dl->col = nu->mat_nr;
|
||||
dl->charidx = nu->charidx;
|
||||
|
||||
/* dl->rt will be used as flag for render face and */
|
||||
/* CU_2D conflicts with R_NOPUNOFLIP */
|
||||
dl->rt= nu->flag & ~CU_2D;
|
||||
dl->rt = nu->flag & ~CU_2D;
|
||||
|
||||
dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((steps+0x1F)>>5), "bevelSplitFlag");
|
||||
dl->bevelSplitFlag = MEM_callocN(sizeof(*dl->col2) * ((steps + 0x1F) >> 5), "bevelSplitFlag");
|
||||
|
||||
/* for each point of poly make a bevel piece */
|
||||
bevp= (BevPoint *)(bl+1) + start;
|
||||
for (i=start, a=0; a<steps; i++,bevp++,a++) {
|
||||
float fac=1.0;
|
||||
bevp = (BevPoint *)(bl + 1) + start;
|
||||
for (i = start, a = 0; a < steps; i++, bevp++, a++) {
|
||||
float fac = 1.0;
|
||||
float *cur_data = data;
|
||||
|
||||
if (cu->taperobj==NULL) {
|
||||
if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
|
||||
if (cu->taperobj == NULL) {
|
||||
if ( (cu->bevobj != NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
|
||||
fac = bevp->radius;
|
||||
}
|
||||
else {
|
||||
@@ -1388,14 +1388,14 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
}
|
||||
|
||||
if (bevp->split_tag) {
|
||||
dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F);
|
||||
dl->bevelSplitFlag[a >> 5] |= 1 << (a & 0x1F);
|
||||
}
|
||||
|
||||
/* rotate bevel piece and write in data */
|
||||
rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data);
|
||||
|
||||
if (a == 1 || a == steps - 1) {
|
||||
float *cur_fp = cur_data, *prev_fp = cur_data - 3*dlb->nr;
|
||||
float *cur_fp = cur_data, *prev_fp = cur_data - 3 * dlb->nr;
|
||||
int b;
|
||||
|
||||
for (b = 0; b < dlb->nr; b++, prev_fp += 3, cur_fp += 3) {
|
||||
@@ -1416,7 +1416,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
|
||||
if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) {
|
||||
if (a == 1)
|
||||
fillBevelCap(nu, dlb, cur_data - 3*dlb->nr, &bottom_capbase);
|
||||
fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase);
|
||||
if (a == steps - 1)
|
||||
fillBevelCap(nu, dlb, cur_data, &top_capbase);
|
||||
}
|
||||
@@ -1464,7 +1464,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
|
||||
void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
|
||||
{
|
||||
Curve *cu= ob->data;
|
||||
Curve *cu = ob->data;
|
||||
ListBase *dispbase;
|
||||
|
||||
/* The same check for duplis as in do_makeDispListCurveTypes.
|
||||
@@ -1473,7 +1473,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
|
||||
if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
|
||||
|
||||
freedisplist(&(ob->disp));
|
||||
dispbase= &(ob->disp);
|
||||
dispbase = &(ob->disp);
|
||||
freedisplist(dispbase);
|
||||
|
||||
/* free displist used for textspace */
|
||||
@@ -1482,21 +1482,21 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
|
||||
do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco);
|
||||
|
||||
if (ob->derivedFinal) {
|
||||
DM_set_object_boundbox (ob, ob->derivedFinal);
|
||||
DM_set_object_boundbox(ob, ob->derivedFinal);
|
||||
}
|
||||
else {
|
||||
boundbox_displist (ob);
|
||||
boundbox_displist(ob);
|
||||
|
||||
/* if there is no derivedMesh, object's boundbox is unneeded */
|
||||
if (ob->bb) {
|
||||
MEM_freeN(ob->bb);
|
||||
ob->bb= NULL;
|
||||
ob->bb = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void makeDispListCurveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase,
|
||||
DerivedMesh **derivedFinal, int forOrco)
|
||||
DerivedMesh **derivedFinal, int forOrco)
|
||||
{
|
||||
do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco);
|
||||
}
|
||||
@@ -1512,16 +1512,16 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int
|
||||
float *orco;
|
||||
|
||||
if (derivedFinal == NULL)
|
||||
derivedFinal= ob->derivedFinal;
|
||||
derivedFinal = ob->derivedFinal;
|
||||
|
||||
if (!derivedFinal->getVertDataArray(derivedFinal, CD_ORCO)) {
|
||||
curve_calc_orcodm(scene, ob, derivedFinal, forRender);
|
||||
}
|
||||
|
||||
orco= derivedFinal->getVertDataArray(derivedFinal, CD_ORCO);
|
||||
orco = derivedFinal->getVertDataArray(derivedFinal, CD_ORCO);
|
||||
|
||||
if (orco) {
|
||||
orco= MEM_dupallocN(orco);
|
||||
orco = MEM_dupallocN(orco);
|
||||
}
|
||||
|
||||
return orco;
|
||||
@@ -1530,34 +1530,34 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int
|
||||
/* this is confusing, there's also min_max_object, appplying the obmat... */
|
||||
static void boundbox_displist(Object *ob)
|
||||
{
|
||||
BoundBox *bb=NULL;
|
||||
BoundBox *bb = NULL;
|
||||
float min[3], max[3];
|
||||
DispList *dl;
|
||||
float *vert;
|
||||
int a, tot=0;
|
||||
int a, tot = 0;
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
|
||||
Curve *cu= ob->data;
|
||||
int doit= 0;
|
||||
Curve *cu = ob->data;
|
||||
int doit = 0;
|
||||
|
||||
if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
|
||||
bb= cu->bb;
|
||||
if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
|
||||
bb = cu->bb;
|
||||
|
||||
dl= ob->disp.first;
|
||||
dl = ob->disp.first;
|
||||
|
||||
while (dl) {
|
||||
if (dl->type==DL_INDEX3) tot= dl->nr;
|
||||
else tot= dl->nr*dl->parts;
|
||||
if (dl->type == DL_INDEX3) tot = dl->nr;
|
||||
else tot = dl->nr * dl->parts;
|
||||
|
||||
vert= dl->verts;
|
||||
for (a=0; a<tot; a++, vert+=3) {
|
||||
doit= 1;
|
||||
vert = dl->verts;
|
||||
for (a = 0; a < tot; a++, vert += 3) {
|
||||
doit = 1;
|
||||
DO_MINMAX(vert, min, max);
|
||||
}
|
||||
|
||||
dl= dl->next;
|
||||
dl = dl->next;
|
||||
}
|
||||
|
||||
if (!doit) {
|
||||
|
||||
@@ -107,19 +107,19 @@ void free_fcurves(ListBase *list)
|
||||
* as we store reference to next, and freeing only touches the curve
|
||||
* it's given
|
||||
*/
|
||||
for (fcu= list->first; fcu; fcu= fcn) {
|
||||
fcn= fcu->next;
|
||||
for (fcu = list->first; fcu; fcu = fcn) {
|
||||
fcn = fcu->next;
|
||||
free_fcurve(fcu);
|
||||
}
|
||||
|
||||
/* clear pointers just in case */
|
||||
list->first= list->last= NULL;
|
||||
list->first = list->last = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------- Copy --------------------------- */
|
||||
|
||||
/* duplicate an F-Curve */
|
||||
FCurve *copy_fcurve (FCurve *fcu)
|
||||
FCurve *copy_fcurve(FCurve *fcu)
|
||||
{
|
||||
FCurve *fcu_d;
|
||||
|
||||
@@ -128,20 +128,20 @@ FCurve *copy_fcurve (FCurve *fcu)
|
||||
return NULL;
|
||||
|
||||
/* make a copy */
|
||||
fcu_d= MEM_dupallocN(fcu);
|
||||
fcu_d = MEM_dupallocN(fcu);
|
||||
|
||||
fcu_d->next= fcu_d->prev= NULL;
|
||||
fcu_d->grp= NULL;
|
||||
fcu_d->next = fcu_d->prev = NULL;
|
||||
fcu_d->grp = NULL;
|
||||
|
||||
/* copy curve data */
|
||||
fcu_d->bezt= MEM_dupallocN(fcu_d->bezt);
|
||||
fcu_d->fpt= MEM_dupallocN(fcu_d->fpt);
|
||||
fcu_d->bezt = MEM_dupallocN(fcu_d->bezt);
|
||||
fcu_d->fpt = MEM_dupallocN(fcu_d->fpt);
|
||||
|
||||
/* copy rna-path */
|
||||
fcu_d->rna_path= MEM_dupallocN(fcu_d->rna_path);
|
||||
fcu_d->rna_path = MEM_dupallocN(fcu_d->rna_path);
|
||||
|
||||
/* copy driver */
|
||||
fcu_d->driver= fcurve_copy_driver(fcu_d->driver);
|
||||
fcu_d->driver = fcurve_copy_driver(fcu_d->driver);
|
||||
|
||||
/* copy modifiers */
|
||||
copy_fmodifiers(&fcu_d->modifiers, &fcu->modifiers);
|
||||
@@ -160,11 +160,11 @@ void copy_fcurves(ListBase *dst, ListBase *src)
|
||||
return;
|
||||
|
||||
/* clear destination list first */
|
||||
dst->first= dst->last= NULL;
|
||||
dst->first = dst->last = NULL;
|
||||
|
||||
/* copy one-by-one */
|
||||
for (sfcu= src->first; sfcu; sfcu= sfcu->next) {
|
||||
dfcu= copy_fcurve(sfcu);
|
||||
for (sfcu = src->first; sfcu; sfcu = sfcu->next) {
|
||||
dfcu = copy_fcurve(sfcu);
|
||||
BLI_addtail(dst, dfcu);
|
||||
}
|
||||
}
|
||||
@@ -175,8 +175,8 @@ void copy_fcurves(ListBase *dst, ListBase *src)
|
||||
FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index, char *driven)
|
||||
{
|
||||
/* anim vars */
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
FCurve *fcu= NULL;
|
||||
AnimData *adt = BKE_animdata_from_id(id);
|
||||
FCurve *fcu = NULL;
|
||||
|
||||
/* rna vars */
|
||||
PointerRNA ptr;
|
||||
@@ -194,16 +194,16 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro
|
||||
prop = RNA_struct_find_property(&ptr, prop_name);
|
||||
|
||||
if (prop) {
|
||||
path= RNA_path_from_ID_to_property(&ptr, prop);
|
||||
path = RNA_path_from_ID_to_property(&ptr, prop);
|
||||
|
||||
if (path) {
|
||||
/* animation takes priority over drivers */
|
||||
if ((adt->action) && (adt->action->curves.first))
|
||||
fcu= list_find_fcurve(&adt->action->curves, path, index);
|
||||
fcu = list_find_fcurve(&adt->action->curves, path, index);
|
||||
|
||||
/* if not animated, check if driven */
|
||||
if ((fcu == NULL) && (adt->drivers.first)) {
|
||||
fcu= list_find_fcurve(&adt->drivers, path, index);
|
||||
fcu = list_find_fcurve(&adt->drivers, path, index);
|
||||
if (fcu && driven)
|
||||
*driven = TRUE;
|
||||
fcu = NULL;
|
||||
@@ -218,16 +218,16 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro
|
||||
|
||||
|
||||
/* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */
|
||||
FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array_index)
|
||||
FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index)
|
||||
{
|
||||
FCurve *fcu;
|
||||
|
||||
/* sanity checks */
|
||||
if ( ELEM(NULL, list, rna_path) || (array_index < 0) )
|
||||
if (ELEM(NULL, list, rna_path) || (array_index < 0) )
|
||||
return NULL;
|
||||
|
||||
/* check paths of curves, then array indices... */
|
||||
for (fcu= list->first; fcu; fcu= fcu->next) {
|
||||
for (fcu = list->first; fcu; fcu = fcu->next) {
|
||||
/* simple string-compare (this assumes that they have the same root...) */
|
||||
if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) {
|
||||
/* now check indices */
|
||||
@@ -241,7 +241,7 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array
|
||||
}
|
||||
|
||||
/* quick way to loop over all fcurves of a given 'path' */
|
||||
FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[])
|
||||
FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[])
|
||||
{
|
||||
FCurve *fcu;
|
||||
|
||||
@@ -250,7 +250,7 @@ FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[])
|
||||
return NULL;
|
||||
|
||||
/* check paths of curves, then array indices... */
|
||||
for (fcu= fcu_iter; fcu; fcu= fcu->next) {
|
||||
for (fcu = fcu_iter; fcu; fcu = fcu->next) {
|
||||
/* simple string-compare (this assumes that they have the same root...) */
|
||||
if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) {
|
||||
return fcu;
|
||||
@@ -267,8 +267,8 @@ FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[])
|
||||
* List must be freed after use, and is assumed to be empty when passed.
|
||||
* - src: list of F-Curves to search through
|
||||
* Filters...
|
||||
* - dataPrefix: i.e. 'pose.bones[' or 'nodes['
|
||||
* - dataName: name of entity within "" immediately following the prefix
|
||||
* - dataPrefix: i.e. 'pose.bones[' or 'nodes['
|
||||
* - dataName: name of entity within "" immediately following the prefix
|
||||
*/
|
||||
int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName)
|
||||
{
|
||||
@@ -282,17 +282,17 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix,
|
||||
return 0;
|
||||
|
||||
/* search each F-Curve one by one */
|
||||
for (fcu= src->first; fcu; fcu= fcu->next) {
|
||||
for (fcu = src->first; fcu; fcu = fcu->next) {
|
||||
/* check if quoted string matches the path */
|
||||
if ((fcu->rna_path) && strstr(fcu->rna_path, dataPrefix)) {
|
||||
char *quotedName= BLI_getQuotedStr(fcu->rna_path, dataPrefix);
|
||||
char *quotedName = BLI_getQuotedStr(fcu->rna_path, dataPrefix);
|
||||
|
||||
if (quotedName) {
|
||||
/* check if the quoted name matches the required name */
|
||||
if (strcmp(quotedName, dataName) == 0) {
|
||||
LinkData *ld= MEM_callocN(sizeof(LinkData), "list_find_data_fcurves");
|
||||
LinkData *ld = MEM_callocN(sizeof(LinkData), "list_find_data_fcurves");
|
||||
|
||||
ld->data= fcu;
|
||||
ld->data = fcu;
|
||||
BLI_addtail(dst, ld);
|
||||
|
||||
matches++;
|
||||
@@ -308,37 +308,37 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix,
|
||||
return matches;
|
||||
}
|
||||
|
||||
FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven)
|
||||
FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven)
|
||||
{
|
||||
FCurve *fcu= NULL;
|
||||
FCurve *fcu = NULL;
|
||||
|
||||
*driven= 0;
|
||||
*driven = 0;
|
||||
|
||||
/* there must be some RNA-pointer + property combon */
|
||||
if (prop && ptr->id.data && RNA_property_animateable(ptr, prop)) {
|
||||
AnimData *adt= BKE_animdata_from_id(ptr->id.data);
|
||||
AnimData *adt = BKE_animdata_from_id(ptr->id.data);
|
||||
char *path;
|
||||
|
||||
if (adt) {
|
||||
if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
|
||||
/* XXX this function call can become a performance bottleneck */
|
||||
path= RNA_path_from_ID_to_property(ptr, prop);
|
||||
path = RNA_path_from_ID_to_property(ptr, prop);
|
||||
|
||||
if (path) {
|
||||
/* animation takes priority over drivers */
|
||||
if (adt->action && adt->action->curves.first)
|
||||
fcu= list_find_fcurve(&adt->action->curves, path, rnaindex);
|
||||
fcu = list_find_fcurve(&adt->action->curves, path, rnaindex);
|
||||
|
||||
/* if not animated, check if driven */
|
||||
if (!fcu && (adt->drivers.first)) {
|
||||
fcu= list_find_fcurve(&adt->drivers, path, rnaindex);
|
||||
fcu = list_find_fcurve(&adt->drivers, path, rnaindex);
|
||||
|
||||
if (fcu)
|
||||
*driven= 1;
|
||||
*driven = 1;
|
||||
}
|
||||
|
||||
if (fcu && action)
|
||||
*action= adt->action;
|
||||
*action = adt->action;
|
||||
|
||||
MEM_freeN(path);
|
||||
}
|
||||
@@ -352,18 +352,18 @@ FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bActio
|
||||
/* ----------------- Finding Keyframes/Extents -------------------------- */
|
||||
|
||||
/* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
|
||||
#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
|
||||
#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
|
||||
|
||||
/* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_fcurve)
|
||||
* Returns the index to insert at (data already at that index will be offset if replace is 0)
|
||||
*/
|
||||
int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short *replace)
|
||||
{
|
||||
int start=0, end=arraylen;
|
||||
int loopbreaker= 0, maxloop= arraylen * 2;
|
||||
int start = 0, end = arraylen;
|
||||
int loopbreaker = 0, maxloop = arraylen * 2;
|
||||
|
||||
/* initialize replace-flag first */
|
||||
*replace= 0;
|
||||
*replace = 0;
|
||||
|
||||
/* sneaky optimisations (don't go through searching process if...):
|
||||
* - keyframe to be added is to be added out of current bounds
|
||||
@@ -378,7 +378,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short
|
||||
float framenum;
|
||||
|
||||
/* 'First' Keyframe (when only one keyframe, this case is used) */
|
||||
framenum= array[0].vec[1][0];
|
||||
framenum = array[0].vec[1][0];
|
||||
if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) {
|
||||
*replace = 1;
|
||||
return 0;
|
||||
@@ -387,9 +387,9 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short
|
||||
return 0;
|
||||
|
||||
/* 'Last' Keyframe */
|
||||
framenum= array[(arraylen-1)].vec[1][0];
|
||||
framenum = array[(arraylen - 1)].vec[1][0];
|
||||
if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) {
|
||||
*replace= 1;
|
||||
*replace = 1;
|
||||
return (arraylen - 1);
|
||||
}
|
||||
else if (frame > framenum)
|
||||
@@ -400,10 +400,10 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short
|
||||
/* most of the time, this loop is just to find where to put it
|
||||
* 'loopbreaker' is just here to prevent infinite loops
|
||||
*/
|
||||
for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) {
|
||||
for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) {
|
||||
/* compute and get midpoint */
|
||||
int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */
|
||||
float midfra= array[mid].vec[1][0];
|
||||
int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */
|
||||
float midfra = array[mid].vec[1][0];
|
||||
|
||||
/* check if exactly equal to midpoint */
|
||||
if (IS_EQT(frame, midfra, BEZT_BINARYSEARCH_THRESH)) {
|
||||
@@ -413,13 +413,13 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short
|
||||
|
||||
/* repeat in upper/lower half */
|
||||
if (frame > midfra)
|
||||
start= mid + 1;
|
||||
start = mid + 1;
|
||||
else if (frame < midfra)
|
||||
end= mid - 1;
|
||||
end = mid - 1;
|
||||
}
|
||||
|
||||
/* print error if loop-limit exceeded */
|
||||
if (loopbreaker == (maxloop-1)) {
|
||||
if (loopbreaker == (maxloop - 1)) {
|
||||
printf("Error: binarysearch_bezt_index() was taking too long\n");
|
||||
|
||||
// include debug info
|
||||
@@ -433,8 +433,8 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short
|
||||
/* ...................................... */
|
||||
|
||||
/* helper for calc_fcurve_* functions -> find first and last BezTriple to be used */
|
||||
static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple **last,
|
||||
const short do_sel_only)
|
||||
static void get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple **last,
|
||||
const short do_sel_only)
|
||||
{
|
||||
/* init outputs */
|
||||
*first = NULL;
|
||||
@@ -451,18 +451,18 @@ static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple
|
||||
|
||||
/* find first selected */
|
||||
bezt = fcu->bezt;
|
||||
for (i=0; i < fcu->totvert; bezt++, i++) {
|
||||
for (i = 0; i < fcu->totvert; bezt++, i++) {
|
||||
if (BEZSELECTED(bezt)) {
|
||||
*first= bezt;
|
||||
*first = bezt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* find last selected */
|
||||
bezt = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, sizeof(BezTriple), fcu->totvert);
|
||||
for (i=0; i < fcu->totvert; bezt--, i++) {
|
||||
for (i = 0; i < fcu->totvert; bezt--, i++) {
|
||||
if (BEZSELECTED(bezt)) {
|
||||
*last= bezt;
|
||||
*last = bezt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -479,14 +479,14 @@ static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple
|
||||
void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax,
|
||||
const short do_sel_only)
|
||||
{
|
||||
float xminv=999999999.0f, xmaxv=-999999999.0f;
|
||||
float yminv=999999999.0f, ymaxv=-999999999.0f;
|
||||
short foundvert= FALSE;
|
||||
float xminv = 999999999.0f, xmaxv = -999999999.0f;
|
||||
float yminv = 999999999.0f, ymaxv = -999999999.0f;
|
||||
short foundvert = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
if (fcu->totvert) {
|
||||
if (fcu->bezt) {
|
||||
BezTriple *bezt_first= NULL, *bezt_last= NULL;
|
||||
BezTriple *bezt_first = NULL, *bezt_last = NULL;
|
||||
|
||||
if (xmin || xmax) {
|
||||
/* get endpoint keyframes */
|
||||
@@ -495,8 +495,8 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
if (bezt_first) {
|
||||
BLI_assert(bezt_last != NULL);
|
||||
|
||||
xminv= MIN2(xminv, bezt_first->vec[1][0]);
|
||||
xmaxv= MAX2(xmaxv, bezt_last->vec[1][0]);
|
||||
xminv = MIN2(xminv, bezt_first->vec[1][0]);
|
||||
xmaxv = MAX2(xmaxv, bezt_last->vec[1][0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,13 +504,13 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
if (ymin || ymax) {
|
||||
BezTriple *bezt;
|
||||
|
||||
for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
|
||||
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
|
||||
if ((do_sel_only == 0) || BEZSELECTED(bezt)) {
|
||||
if (bezt->vec[1][1] < yminv)
|
||||
yminv= bezt->vec[1][1];
|
||||
yminv = bezt->vec[1][1];
|
||||
if (bezt->vec[1][1] > ymaxv)
|
||||
ymaxv= bezt->vec[1][1];
|
||||
foundvert= TRUE;
|
||||
ymaxv = bezt->vec[1][1];
|
||||
foundvert = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,42 +518,42 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
else if (fcu->fpt) {
|
||||
/* frame range can be directly calculated from end verts */
|
||||
if (xmin || xmax) {
|
||||
xminv= MIN2(xminv, fcu->fpt[0].vec[0]);
|
||||
xmaxv= MAX2(xmaxv, fcu->fpt[fcu->totvert-1].vec[0]);
|
||||
xminv = MIN2(xminv, fcu->fpt[0].vec[0]);
|
||||
xmaxv = MAX2(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]);
|
||||
}
|
||||
|
||||
/* only loop over keyframes to find extents for values if needed */
|
||||
if (ymin || ymax) {
|
||||
FPoint *fpt;
|
||||
|
||||
for (fpt=fcu->fpt, i=0; i < fcu->totvert; fpt++, i++) {
|
||||
for (fpt = fcu->fpt, i = 0; i < fcu->totvert; fpt++, i++) {
|
||||
if (fpt->vec[1] < yminv)
|
||||
yminv= fpt->vec[1];
|
||||
yminv = fpt->vec[1];
|
||||
if (fpt->vec[1] > ymaxv)
|
||||
ymaxv= fpt->vec[1];
|
||||
ymaxv = fpt->vec[1];
|
||||
|
||||
foundvert= TRUE;
|
||||
foundvert = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundvert) {
|
||||
if (xmin) *xmin= xminv;
|
||||
if (xmax) *xmax= xmaxv;
|
||||
if (xmin) *xmin = xminv;
|
||||
if (xmax) *xmax = xmaxv;
|
||||
|
||||
if (ymin) *ymin= yminv;
|
||||
if (ymax) *ymax= ymaxv;
|
||||
if (ymin) *ymin = yminv;
|
||||
if (ymax) *ymax = ymaxv;
|
||||
}
|
||||
else {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("F-Curve calc bounds didn't find anything, so assuming minimum bounds of 1.0\n");
|
||||
|
||||
if (xmin) *xmin= 0.0f;
|
||||
if (xmax) *xmax= 1.0f;
|
||||
if (xmin) *xmin = 0.0f;
|
||||
if (xmax) *xmax = 1.0f;
|
||||
|
||||
if (ymin) *ymin= 0.0f;
|
||||
if (ymax) *ymax= 1.0f;
|
||||
if (ymin) *ymin = 0.0f;
|
||||
if (ymax) *ymax = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,12 +561,12 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
void calc_fcurve_range(FCurve *fcu, float *start, float *end,
|
||||
const short do_sel_only, const short do_min_length)
|
||||
{
|
||||
float min=999999999.0f, max=-999999999.0f;
|
||||
short foundvert= FALSE;
|
||||
float min = 999999999.0f, max = -999999999.0f;
|
||||
short foundvert = FALSE;
|
||||
|
||||
if (fcu->totvert) {
|
||||
if (fcu->bezt) {
|
||||
BezTriple *bezt_first= NULL, *bezt_last= NULL;
|
||||
BezTriple *bezt_first = NULL, *bezt_last = NULL;
|
||||
|
||||
/* get endpoint keyframes */
|
||||
get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
|
||||
@@ -574,23 +574,23 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end,
|
||||
if (bezt_first) {
|
||||
BLI_assert(bezt_last != NULL);
|
||||
|
||||
min= MIN2(min, bezt_first->vec[1][0]);
|
||||
max= MAX2(max, bezt_last->vec[1][0]);
|
||||
min = MIN2(min, bezt_first->vec[1][0]);
|
||||
max = MAX2(max, bezt_last->vec[1][0]);
|
||||
|
||||
foundvert= TRUE;
|
||||
foundvert = TRUE;
|
||||
}
|
||||
}
|
||||
else if (fcu->fpt) {
|
||||
min= MIN2(min, fcu->fpt[0].vec[0]);
|
||||
max= MAX2(max, fcu->fpt[fcu->totvert-1].vec[0]);
|
||||
min = MIN2(min, fcu->fpt[0].vec[0]);
|
||||
max = MAX2(max, fcu->fpt[fcu->totvert - 1].vec[0]);
|
||||
|
||||
foundvert= TRUE;
|
||||
foundvert = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (foundvert == FALSE) {
|
||||
min= max= 0.0f;
|
||||
min = max = 0.0f;
|
||||
}
|
||||
|
||||
if (do_min_length) {
|
||||
@@ -600,8 +600,8 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end,
|
||||
}
|
||||
}
|
||||
|
||||
*start= min;
|
||||
*end= max;
|
||||
*start = min;
|
||||
*end = max;
|
||||
}
|
||||
|
||||
/* ----------------- Status Checks -------------------------- */
|
||||
@@ -628,7 +628,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu)
|
||||
// TODO: optionally, only check modifier if it is the active one...
|
||||
for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) {
|
||||
/* ignore if muted/disabled */
|
||||
if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED))
|
||||
if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED))
|
||||
continue;
|
||||
|
||||
/* type checks */
|
||||
@@ -647,7 +647,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu)
|
||||
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case FMODIFIER_TYPE_FN_GENERATOR:
|
||||
{
|
||||
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
|
||||
@@ -655,7 +655,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu)
|
||||
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
/* always harmful - cannot allow */
|
||||
default:
|
||||
@@ -692,10 +692,10 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt)
|
||||
{
|
||||
CfraElem *ce, *cen;
|
||||
|
||||
for (ce= lb->first; ce; ce= ce->next) {
|
||||
for (ce = lb->first; ce; ce = ce->next) {
|
||||
/* double key? */
|
||||
if (ce->cfra == bezt->vec[1][0]) {
|
||||
if (bezt->f2 & SELECT) ce->sel= bezt->f2;
|
||||
if (bezt->f2 & SELECT) ce->sel = bezt->f2;
|
||||
return;
|
||||
}
|
||||
/* should key be inserted before this column? */
|
||||
@@ -703,12 +703,12 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt)
|
||||
}
|
||||
|
||||
/* create a new column */
|
||||
cen= MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
|
||||
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
|
||||
if (ce) BLI_insertlinkbefore(lb, ce, cen);
|
||||
else BLI_addtail(lb, cen);
|
||||
|
||||
cen->cfra= bezt->vec[1][0];
|
||||
cen->sel= bezt->f2;
|
||||
cen->cfra = bezt->vec[1][0];
|
||||
cen->sel = bezt->f2;
|
||||
}
|
||||
|
||||
/* ***************************** Samples Utilities ******************************* */
|
||||
@@ -748,12 +748,12 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
|
||||
}
|
||||
|
||||
/* set up sample data */
|
||||
fpt= new_fpt= MEM_callocN(sizeof(FPoint)*(end-start+1), "FPoint Samples");
|
||||
fpt = new_fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "FPoint Samples");
|
||||
|
||||
/* use the sampling callback at 1-frame intervals from start to end frames */
|
||||
for (cfra= start; cfra <= end; cfra++, fpt++) {
|
||||
fpt->vec[0]= (float)cfra;
|
||||
fpt->vec[1]= sample_cb(fcu, data, (float)cfra);
|
||||
for (cfra = start; cfra <= end; cfra++, fpt++) {
|
||||
fpt->vec[0] = (float)cfra;
|
||||
fpt->vec[1] = sample_cb(fcu, data, (float)cfra);
|
||||
}
|
||||
|
||||
/* free any existing sample/keyframe data on curve */
|
||||
@@ -761,9 +761,9 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
|
||||
if (fcu->fpt) MEM_freeN(fcu->fpt);
|
||||
|
||||
/* store the samples */
|
||||
fcu->bezt= NULL;
|
||||
fcu->fpt= new_fpt;
|
||||
fcu->totvert= end - start + 1;
|
||||
fcu->bezt = NULL;
|
||||
fcu->fpt = new_fpt;
|
||||
fcu->totvert = end - start + 1;
|
||||
}
|
||||
|
||||
/* ***************************** F-Curve Sanity ********************************* */
|
||||
@@ -778,7 +778,7 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
|
||||
void calchandles_fcurve(FCurve *fcu)
|
||||
{
|
||||
BezTriple *bezt, *prev, *next;
|
||||
int a= fcu->totvert;
|
||||
int a = fcu->totvert;
|
||||
|
||||
/* Error checking:
|
||||
* - need at least two points
|
||||
@@ -789,33 +789,33 @@ void calchandles_fcurve(FCurve *fcu)
|
||||
return;
|
||||
|
||||
/* get initial pointers */
|
||||
bezt= fcu->bezt;
|
||||
prev= NULL;
|
||||
next= (bezt + 1);
|
||||
bezt = fcu->bezt;
|
||||
prev = NULL;
|
||||
next = (bezt + 1);
|
||||
|
||||
/* loop over all beztriples, adjusting handles */
|
||||
while (a--) {
|
||||
/* clamp timing of handles to be on either side of beztriple */
|
||||
if (bezt->vec[0][0] > bezt->vec[1][0]) bezt->vec[0][0]= bezt->vec[1][0];
|
||||
if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0];
|
||||
if (bezt->vec[0][0] > bezt->vec[1][0]) bezt->vec[0][0] = bezt->vec[1][0];
|
||||
if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0] = bezt->vec[1][0];
|
||||
|
||||
/* calculate auto-handles */
|
||||
BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */
|
||||
BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */
|
||||
|
||||
/* for automatic ease in and out */
|
||||
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {
|
||||
/* only do this on first or last beztriple */
|
||||
if ((a == 0) || (a == fcu->totvert-1)) {
|
||||
if ((a == 0) || (a == fcu->totvert - 1)) {
|
||||
/* set both handles to have same horizontal value as keyframe */
|
||||
if (fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) {
|
||||
bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1];
|
||||
bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* advance pointers for next iteration */
|
||||
prev= bezt;
|
||||
if (a == 1) next= NULL;
|
||||
prev = bezt;
|
||||
if (a == 1) next = NULL;
|
||||
else next++;
|
||||
bezt++;
|
||||
}
|
||||
@@ -824,8 +824,8 @@ void calchandles_fcurve(FCurve *fcu)
|
||||
/* Use when F-Curve with handles has changed
|
||||
* It treats all BezTriples with the following rules:
|
||||
* - PHASE 1: do types have to be altered?
|
||||
* -> Auto handles: become aligned when selection status is NOT(000 || 111)
|
||||
* -> Vector handles: become 'nothing' when (one half selected AND other not)
|
||||
* -> Auto handles: become aligned when selection status is NOT(000 || 111)
|
||||
* -> Vector handles: become 'nothing' when (one half selected AND other not)
|
||||
* - PHASE 2: recalculate handles
|
||||
*/
|
||||
void testhandles_fcurve(FCurve *fcu, const short use_handle)
|
||||
@@ -838,41 +838,41 @@ void testhandles_fcurve(FCurve *fcu, const short use_handle)
|
||||
return;
|
||||
|
||||
/* loop over beztriples */
|
||||
for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) {
|
||||
short flag= 0;
|
||||
for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) {
|
||||
short flag = 0;
|
||||
|
||||
/* flag is initialized as selection status
|
||||
* of beztriple control-points (labelled 0,1,2)
|
||||
*/
|
||||
if (bezt->f2 & SELECT) flag |= (1<<1); // == 2
|
||||
if (bezt->f2 & SELECT) flag |= (1 << 1); // == 2
|
||||
if (use_handle == FALSE) {
|
||||
if (flag & 2) {
|
||||
flag |= (1<<0) | (1<<2);
|
||||
flag |= (1 << 0) | (1 << 2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (bezt->f1 & SELECT) flag |= (1<<0); // == 1
|
||||
if (bezt->f3 & SELECT) flag |= (1<<2); // == 4
|
||||
if (bezt->f1 & SELECT) flag |= (1 << 0); // == 1
|
||||
if (bezt->f3 & SELECT) flag |= (1 << 2); // == 4
|
||||
}
|
||||
|
||||
/* one or two handles selected only */
|
||||
if (ELEM(flag, 0, 7)==0) {
|
||||
if (ELEM(flag, 0, 7) == 0) {
|
||||
/* auto handles become aligned */
|
||||
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM))
|
||||
bezt->h1= HD_ALIGN;
|
||||
bezt->h1 = HD_ALIGN;
|
||||
if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM))
|
||||
bezt->h2= HD_ALIGN;
|
||||
bezt->h2 = HD_ALIGN;
|
||||
|
||||
/* vector handles become 'free' when only one half selected */
|
||||
if (bezt->h1==HD_VECT) {
|
||||
if (bezt->h1 == HD_VECT) {
|
||||
/* only left half (1 or 2 or 1+2) */
|
||||
if (flag < 4)
|
||||
bezt->h1= 0;
|
||||
bezt->h1 = 0;
|
||||
}
|
||||
if (bezt->h2==HD_VECT) {
|
||||
if (bezt->h2 == HD_VECT) {
|
||||
/* only right half (4 or 2+4) */
|
||||
if (flag > 3)
|
||||
bezt->h2= 0;
|
||||
bezt->h2 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -886,11 +886,11 @@ void testhandles_fcurve(FCurve *fcu, const short use_handle)
|
||||
*/
|
||||
void sort_time_fcurve(FCurve *fcu)
|
||||
{
|
||||
short ok= 1;
|
||||
short ok = 1;
|
||||
|
||||
/* keep adjusting order of beztriples until nothing moves (bubble-sort) */
|
||||
while (ok) {
|
||||
ok= 0;
|
||||
ok = 0;
|
||||
|
||||
/* currently, will only be needed when there are beztriples */
|
||||
if (fcu->bezt) {
|
||||
@@ -898,13 +898,13 @@ void sort_time_fcurve(FCurve *fcu)
|
||||
unsigned int a;
|
||||
|
||||
/* loop over ALL points to adjust position in array and recalculate handles */
|
||||
for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) {
|
||||
for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) {
|
||||
/* check if thee's a next beztriple which we could try to swap with current */
|
||||
if (a < (fcu->totvert-1)) {
|
||||
if (a < (fcu->totvert - 1)) {
|
||||
/* swap if one is after the other (and indicate that order has changed) */
|
||||
if (bezt->vec[1][0] > (bezt+1)->vec[1][0]) {
|
||||
SWAP(BezTriple, *bezt, *(bezt+1));
|
||||
ok= 1;
|
||||
if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) {
|
||||
SWAP(BezTriple, *bezt, *(bezt + 1));
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
/* if either one of both of the points exceeds crosses over the keyframe time... */
|
||||
@@ -916,9 +916,9 @@ void sort_time_fcurve(FCurve *fcu)
|
||||
else {
|
||||
/* clamp handles */
|
||||
if (bezt->vec[0][0] > bezt->vec[1][0])
|
||||
bezt->vec[0][0]= bezt->vec[1][0];
|
||||
bezt->vec[0][0] = bezt->vec[1][0];
|
||||
if (bezt->vec[2][0] < bezt->vec[1][0])
|
||||
bezt->vec[2][0]= bezt->vec[1][0];
|
||||
bezt->vec[2][0] = bezt->vec[1][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -940,8 +940,8 @@ short test_time_fcurve(FCurve *fcu)
|
||||
BezTriple *bezt;
|
||||
|
||||
/* loop through all BezTriples, stopping when one exceeds the one after it */
|
||||
for (a=0, bezt= fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) {
|
||||
if (bezt->vec[1][0] > (bezt+1)->vec[1][0])
|
||||
for (a = 0, bezt = fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) {
|
||||
if (bezt->vec[1][0] > (bezt + 1)->vec[1][0])
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -949,8 +949,8 @@ short test_time_fcurve(FCurve *fcu)
|
||||
FPoint *fpt;
|
||||
|
||||
/* loop through all FPoints, stopping when one exceeds the one after it */
|
||||
for (a=0, fpt= fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) {
|
||||
if (fpt->vec[0] > (fpt+1)->vec[0])
|
||||
for (a = 0, fpt = fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) {
|
||||
if (fpt->vec[0] > (fpt + 1)->vec[0])
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -969,9 +969,9 @@ typedef struct DriverVarTypeInfo {
|
||||
float (*get_value)(ChannelDriver *driver, DriverVar *dvar);
|
||||
|
||||
/* allocation of target slots */
|
||||
int num_targets; /* number of target slots required */
|
||||
const char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */
|
||||
int target_flags[MAX_DRIVER_TARGETS]; /* flags defining the requirements for each slot */
|
||||
int num_targets; /* number of target slots required */
|
||||
const char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */
|
||||
int target_flags[MAX_DRIVER_TARGETS]; /* flags defining the requirements for each slot */
|
||||
} DriverVarTypeInfo;
|
||||
|
||||
/* Macro to begin definitions */
|
||||
@@ -986,25 +986,25 @@ typedef struct DriverVarTypeInfo {
|
||||
|
||||
static ID *dtar_id_ensure_proxy_from(ID *id)
|
||||
{
|
||||
if (id && GS(id->name)==ID_OB && ((Object *)id)->proxy_from)
|
||||
if (id && GS(id->name) == ID_OB && ((Object *)id)->proxy_from)
|
||||
return (ID *)(((Object *)id)->proxy_from);
|
||||
return id;
|
||||
}
|
||||
|
||||
/* Helper function to obtain a value using RNA from the specified source (for evaluating drivers) */
|
||||
static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar)
|
||||
static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar)
|
||||
{
|
||||
PointerRNA id_ptr, ptr;
|
||||
PropertyRNA *prop;
|
||||
ID *id;
|
||||
int index;
|
||||
float value= 0.0f;
|
||||
float value = 0.0f;
|
||||
|
||||
/* sanity check */
|
||||
if (ELEM(NULL, driver, dtar))
|
||||
return 0.0f;
|
||||
|
||||
id= dtar_id_ensure_proxy_from(dtar->id);
|
||||
id = dtar_id_ensure_proxy_from(dtar->id);
|
||||
|
||||
/* error check for missing pointer... */
|
||||
// TODO: tag the specific target too as having issues
|
||||
@@ -1024,37 +1024,37 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar)
|
||||
/* array */
|
||||
if (index < RNA_property_array_length(&ptr, prop)) {
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_BOOLEAN:
|
||||
value= (float)RNA_property_boolean_get_index(&ptr, prop, index);
|
||||
break;
|
||||
case PROP_INT:
|
||||
value= (float)RNA_property_int_get_index(&ptr, prop, index);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
value= RNA_property_float_get_index(&ptr, prop, index);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case PROP_BOOLEAN:
|
||||
value = (float)RNA_property_boolean_get_index(&ptr, prop, index);
|
||||
break;
|
||||
case PROP_INT:
|
||||
value = (float)RNA_property_int_get_index(&ptr, prop, index);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
value = RNA_property_float_get_index(&ptr, prop, index);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* not an array */
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_BOOLEAN:
|
||||
value= (float)RNA_property_boolean_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_INT:
|
||||
value= (float)RNA_property_int_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
value= RNA_property_float_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_ENUM:
|
||||
value= (float)RNA_property_enum_get(&ptr, prop);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case PROP_BOOLEAN:
|
||||
value = (float)RNA_property_boolean_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_INT:
|
||||
value = (float)RNA_property_int_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
value = RNA_property_float_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_ENUM:
|
||||
value = (float)RNA_property_enum_get(&ptr, prop);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,18 +1071,18 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar)
|
||||
}
|
||||
|
||||
/* Helper function to obtain a pointer to a Pose Channel (for evaluating drivers) */
|
||||
static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dtar)
|
||||
static bPoseChannel *dtar_get_pchan_ptr(ChannelDriver *driver, DriverTarget *dtar)
|
||||
{
|
||||
ID *id;
|
||||
/* sanity check */
|
||||
if (ELEM(NULL, driver, dtar))
|
||||
return NULL;
|
||||
|
||||
id= dtar_id_ensure_proxy_from(dtar->id);
|
||||
id = dtar_id_ensure_proxy_from(dtar->id);
|
||||
|
||||
/* check if the ID here is a valid object */
|
||||
if (id && GS(id->name)) {
|
||||
Object *ob= (Object *)id;
|
||||
Object *ob = (Object *)id;
|
||||
|
||||
/* get pose, and subsequently, posechannel */
|
||||
return BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
|
||||
@@ -1096,21 +1096,21 @@ static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dt
|
||||
/* ......... */
|
||||
|
||||
/* evaluate 'single prop' driver variable */
|
||||
static float dvar_eval_singleProp (ChannelDriver *driver, DriverVar *dvar)
|
||||
static float dvar_eval_singleProp(ChannelDriver *driver, DriverVar *dvar)
|
||||
{
|
||||
/* just evaluate the first target slot */
|
||||
return dtar_get_prop_val(driver, &dvar->targets[0]);
|
||||
}
|
||||
|
||||
/* evaluate 'rotation difference' driver variable */
|
||||
static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar)
|
||||
static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar)
|
||||
{
|
||||
bPoseChannel *pchan, *pchan2;
|
||||
float q1[4], q2[4], quat[4], angle;
|
||||
|
||||
/* get pose channels, and check if we've got two */
|
||||
pchan= dtar_get_pchan_ptr(driver, &dvar->targets[0]);
|
||||
pchan2= dtar_get_pchan_ptr(driver, &dvar->targets[1]);
|
||||
pchan = dtar_get_pchan_ptr(driver, &dvar->targets[0]);
|
||||
pchan2 = dtar_get_pchan_ptr(driver, &dvar->targets[1]);
|
||||
|
||||
if (ELEM(NULL, pchan, pchan2)) {
|
||||
/* disable this driver, since it doesn't work correctly... */
|
||||
@@ -1135,14 +1135,14 @@ static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar)
|
||||
invert_qt(q1);
|
||||
mul_qt_qtqt(quat, q1, q2);
|
||||
angle = 2.0f * (saacos(quat[0]));
|
||||
angle= ABS(angle);
|
||||
angle = ABS(angle);
|
||||
|
||||
return (angle > (float)M_PI) ? (float)((2.0f * (float)M_PI) - angle) : (float)(angle);
|
||||
}
|
||||
|
||||
/* evaluate 'location difference' driver variable */
|
||||
// TODO: this needs to take into account space conversions...
|
||||
static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar)
|
||||
static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar)
|
||||
{
|
||||
float loc1[3] = {0.0f, 0.0f, 0.0f};
|
||||
float loc2[3] = {0.0f, 0.0f, 0.0f};
|
||||
@@ -1152,7 +1152,7 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar)
|
||||
DRIVER_TARGETS_USED_LOOPER(dvar)
|
||||
{
|
||||
/* get pointer to loc values to store in */
|
||||
Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id);
|
||||
Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id);
|
||||
bPoseChannel *pchan;
|
||||
float tmp_loc[3];
|
||||
|
||||
@@ -1164,7 +1164,7 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar)
|
||||
}
|
||||
|
||||
/* try to get posechannel */
|
||||
pchan= BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
|
||||
pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
|
||||
|
||||
/* check if object or bone */
|
||||
if (pchan) {
|
||||
@@ -1234,14 +1234,14 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar)
|
||||
}
|
||||
|
||||
/* evaluate 'transform channel' driver variable */
|
||||
static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
|
||||
static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar)
|
||||
{
|
||||
DriverTarget *dtar= &dvar->targets[0];
|
||||
Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id);
|
||||
DriverTarget *dtar = &dvar->targets[0];
|
||||
Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id);
|
||||
bPoseChannel *pchan;
|
||||
float mat[4][4];
|
||||
float oldEul[3] = {0.0f, 0.0f, 0.0f};
|
||||
short useEulers=0, rotOrder=ROT_MODE_EUL;
|
||||
short useEulers = 0, rotOrder = ROT_MODE_EUL;
|
||||
|
||||
/* check if this target has valid data */
|
||||
if ((ob == NULL) || (GS(ob->id.name) != ID_OB)) {
|
||||
@@ -1251,7 +1251,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
|
||||
}
|
||||
|
||||
/* try to get posechannel */
|
||||
pchan= BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
|
||||
pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
|
||||
|
||||
/* check if object or bone, and get transform matrix accordingly
|
||||
* - "useEulers" code is used to prevent the problems associated with non-uniqueness
|
||||
@@ -1263,7 +1263,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
|
||||
/* bone */
|
||||
if (pchan->rotmode > 0) {
|
||||
copy_v3_v3(oldEul, pchan->eul);
|
||||
rotOrder= pchan->rotmode;
|
||||
rotOrder = pchan->rotmode;
|
||||
useEulers = 1;
|
||||
}
|
||||
|
||||
@@ -1290,7 +1290,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
|
||||
/* object */
|
||||
if (ob->rotmode > 0) {
|
||||
copy_v3_v3(oldEul, ob->rot);
|
||||
rotOrder= ob->rotmode;
|
||||
rotOrder = ob->rotmode;
|
||||
useEulers = 1;
|
||||
}
|
||||
|
||||
@@ -1353,36 +1353,36 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
|
||||
/* Table of Driver Varaiable Type Info Data */
|
||||
static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
|
||||
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_SINGLE_PROP)
|
||||
dvar_eval_singleProp, /* eval callback */
|
||||
1, /* number of targets used */
|
||||
{"Property"}, /* UI names for targets */
|
||||
{0} /* flags */
|
||||
dvar_eval_singleProp, /* eval callback */
|
||||
1, /* number of targets used */
|
||||
{"Property"}, /* UI names for targets */
|
||||
{0} /* flags */
|
||||
END_DVAR_TYPEDEF,
|
||||
|
||||
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_ROT_DIFF)
|
||||
dvar_eval_rotDiff, /* eval callback */
|
||||
2, /* number of targets used */
|
||||
{"Bone 1", "Bone 2"}, /* UI names for targets */
|
||||
{DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */
|
||||
dvar_eval_rotDiff, /* eval callback */
|
||||
2, /* number of targets used */
|
||||
{"Bone 1", "Bone 2"}, /* UI names for targets */
|
||||
{DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */
|
||||
END_DVAR_TYPEDEF,
|
||||
|
||||
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_LOC_DIFF)
|
||||
dvar_eval_locDiff, /* eval callback */
|
||||
2, /* number of targets used */
|
||||
{"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */
|
||||
{DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */
|
||||
dvar_eval_locDiff, /* eval callback */
|
||||
2, /* number of targets used */
|
||||
{"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */
|
||||
{DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */
|
||||
END_DVAR_TYPEDEF,
|
||||
|
||||
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_TRANSFORM_CHAN)
|
||||
dvar_eval_transChan, /* eval callback */
|
||||
1, /* number of targets used */
|
||||
{"Object/Bone"}, /* UI names for targets */
|
||||
{DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */
|
||||
dvar_eval_transChan, /* eval callback */
|
||||
1, /* number of targets used */
|
||||
{"Object/Bone"}, /* UI names for targets */
|
||||
{DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */
|
||||
END_DVAR_TYPEDEF,
|
||||
};
|
||||
|
||||
/* Get driver variable typeinfo */
|
||||
static DriverVarTypeInfo *get_dvar_typeinfo (int type)
|
||||
static DriverVarTypeInfo *get_dvar_typeinfo(int type)
|
||||
{
|
||||
/* check if valid type */
|
||||
if ((type >= 0) && (type < MAX_DVAR_TYPES))
|
||||
@@ -1403,7 +1403,7 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar)
|
||||
/* free target vars
|
||||
* - need to go over all of them, not just up to the ones that are used
|
||||
* currently, since there may be some lingering RNA paths from
|
||||
* previous users needing freeing
|
||||
* previous users needing freeing
|
||||
*/
|
||||
DRIVER_TARGETS_LOOPER(dvar)
|
||||
{
|
||||
@@ -1418,7 +1418,7 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar)
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
/* since driver variables are cached, the expression needs re-compiling too */
|
||||
if (driver->type==DRIVER_TYPE_PYTHON)
|
||||
if (driver->type == DRIVER_TYPE_PYTHON)
|
||||
driver->flag |= DRIVER_FLAG_RENAMEVAR;
|
||||
#endif
|
||||
}
|
||||
@@ -1426,15 +1426,15 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar)
|
||||
/* Change the type of driver variable */
|
||||
void driver_change_variable_type(DriverVar *dvar, int type)
|
||||
{
|
||||
DriverVarTypeInfo *dvti= get_dvar_typeinfo(type);
|
||||
DriverVarTypeInfo *dvti = get_dvar_typeinfo(type);
|
||||
|
||||
/* sanity check */
|
||||
if (ELEM(NULL, dvar, dvti))
|
||||
return;
|
||||
|
||||
/* set the new settings */
|
||||
dvar->type= type;
|
||||
dvar->num_targets= dvti->num_targets;
|
||||
dvar->type = type;
|
||||
dvar->num_targets = dvti->num_targets;
|
||||
|
||||
/* make changes to the targets based on the defines for these types
|
||||
* NOTE: only need to make sure the ones we're using here are valid...
|
||||
@@ -1448,13 +1448,13 @@ void driver_change_variable_type(DriverVar *dvar, int type)
|
||||
|
||||
/* object ID types only, or idtype not yet initialized*/
|
||||
if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0))
|
||||
dtar->idtype= ID_OB;
|
||||
dtar->idtype = ID_OB;
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END
|
||||
}
|
||||
|
||||
/* Add a new driver variable */
|
||||
DriverVar *driver_add_new_variable (ChannelDriver *driver)
|
||||
DriverVar *driver_add_new_variable(ChannelDriver *driver)
|
||||
{
|
||||
DriverVar *dvar;
|
||||
|
||||
@@ -1463,7 +1463,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver)
|
||||
return NULL;
|
||||
|
||||
/* make a new variable */
|
||||
dvar= MEM_callocN(sizeof(DriverVar), "DriverVar");
|
||||
dvar = MEM_callocN(sizeof(DriverVar), "DriverVar");
|
||||
BLI_addtail(&driver->variables, dvar);
|
||||
|
||||
/* give the variable a 'unique' name */
|
||||
@@ -1475,7 +1475,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver)
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
/* since driver variables are cached, the expression needs re-compiling too */
|
||||
if (driver->type==DRIVER_TYPE_PYTHON)
|
||||
if (driver->type == DRIVER_TYPE_PYTHON)
|
||||
driver->flag |= DRIVER_FLAG_RENAMEVAR;
|
||||
#endif
|
||||
|
||||
@@ -1492,11 +1492,11 @@ void fcurve_free_driver(FCurve *fcu)
|
||||
/* sanity checks */
|
||||
if (ELEM(NULL, fcu, fcu->driver))
|
||||
return;
|
||||
driver= fcu->driver;
|
||||
driver = fcu->driver;
|
||||
|
||||
/* free driver targets */
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvarn) {
|
||||
dvarn= dvar->next;
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvarn) {
|
||||
dvarn = dvar->next;
|
||||
driver_free_variable(driver, dvar);
|
||||
}
|
||||
|
||||
@@ -1508,11 +1508,11 @@ void fcurve_free_driver(FCurve *fcu)
|
||||
|
||||
/* free driver itself, then set F-Curve's point to this to NULL (as the curve may still be used) */
|
||||
MEM_freeN(driver);
|
||||
fcu->driver= NULL;
|
||||
fcu->driver = NULL;
|
||||
}
|
||||
|
||||
/* This makes a copy of the given driver */
|
||||
ChannelDriver *fcurve_copy_driver (ChannelDriver *driver)
|
||||
ChannelDriver *fcurve_copy_driver(ChannelDriver *driver)
|
||||
{
|
||||
ChannelDriver *ndriver;
|
||||
DriverVar *dvar;
|
||||
@@ -1522,14 +1522,14 @@ ChannelDriver *fcurve_copy_driver (ChannelDriver *driver)
|
||||
return NULL;
|
||||
|
||||
/* copy all data */
|
||||
ndriver= MEM_dupallocN(driver);
|
||||
ndriver->expr_comp= NULL;
|
||||
ndriver = MEM_dupallocN(driver);
|
||||
ndriver->expr_comp = NULL;
|
||||
|
||||
/* copy variables */
|
||||
ndriver->variables.first= ndriver->variables.last= NULL;
|
||||
ndriver->variables.first = ndriver->variables.last = NULL;
|
||||
BLI_duplicatelist(&ndriver->variables, &driver->variables);
|
||||
|
||||
for (dvar= ndriver->variables.first; dvar; dvar= dvar->next) {
|
||||
for (dvar = ndriver->variables.first; dvar; dvar = dvar->next) {
|
||||
/* need to go over all targets so that we don't leave any dangling paths */
|
||||
DRIVER_TARGETS_LOOPER(dvar)
|
||||
{
|
||||
@@ -1559,21 +1559,21 @@ float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar)
|
||||
* using the variable type info, storing the obtained value
|
||||
* in dvar->curval so that drivers can be debugged
|
||||
*/
|
||||
dvti= get_dvar_typeinfo(dvar->type);
|
||||
dvti = get_dvar_typeinfo(dvar->type);
|
||||
|
||||
if (dvti && dvti->get_value)
|
||||
dvar->curval= dvti->get_value(driver, dvar);
|
||||
dvar->curval = dvti->get_value(driver, dvar);
|
||||
else
|
||||
dvar->curval= 0.0f;
|
||||
dvar->curval = 0.0f;
|
||||
|
||||
return dvar->curval;
|
||||
}
|
||||
|
||||
/* Evaluate an Channel-Driver to get a 'time' value to use instead of "evaltime"
|
||||
* - "evaltime" is the frame at which F-Curve is being evaluated
|
||||
* - has to return a float value
|
||||
* - has to return a float value
|
||||
*/
|
||||
static float evaluate_driver (ChannelDriver *driver, const float evaltime)
|
||||
static float evaluate_driver(ChannelDriver *driver, const float evaltime)
|
||||
{
|
||||
DriverVar *dvar;
|
||||
|
||||
@@ -1588,8 +1588,8 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime)
|
||||
/* check how many variables there are first (i.e. just one?) */
|
||||
if (driver->variables.first == driver->variables.last) {
|
||||
/* just one target, so just use that */
|
||||
dvar= driver->variables.first;
|
||||
driver->curval= driver_get_variable_value(driver, dvar);
|
||||
dvar = driver->variables.first;
|
||||
driver->curval = driver_get_variable_value(driver, dvar);
|
||||
}
|
||||
else {
|
||||
/* more than one target, so average the values of the targets */
|
||||
@@ -1597,19 +1597,19 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime)
|
||||
int tot = 0;
|
||||
|
||||
/* loop through targets, adding (hopefully we don't get any overflow!) */
|
||||
for (dvar= driver->variables.first; dvar; dvar=dvar->next) {
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
value += driver_get_variable_value(driver, dvar);
|
||||
tot++;
|
||||
}
|
||||
|
||||
/* perform operations on the total if appropriate */
|
||||
if (driver->type == DRIVER_TYPE_AVERAGE)
|
||||
driver->curval= (value / (float)tot);
|
||||
driver->curval = (value / (float)tot);
|
||||
else
|
||||
driver->curval= value;
|
||||
driver->curval = value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case DRIVER_TYPE_MIN: /* smallest value */
|
||||
case DRIVER_TYPE_MAX: /* largest value */
|
||||
@@ -1617,9 +1617,9 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime)
|
||||
float value = 0.0f;
|
||||
|
||||
/* loop through the variables, getting the values and comparing them to existing ones */
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
/* get value */
|
||||
float tmp_val= driver_get_variable_value(driver, dvar);
|
||||
float tmp_val = driver_get_variable_value(driver, dvar);
|
||||
|
||||
/* store this value if appropriate */
|
||||
if (dvar->prev) {
|
||||
@@ -1627,51 +1627,51 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime)
|
||||
if (driver->type == DRIVER_TYPE_MAX) {
|
||||
/* max? */
|
||||
if (tmp_val > value)
|
||||
value= tmp_val;
|
||||
value = tmp_val;
|
||||
}
|
||||
else {
|
||||
/* min? */
|
||||
if (tmp_val < value)
|
||||
value= tmp_val;
|
||||
value = tmp_val;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* first item - make this the baseline for comparisons */
|
||||
value= tmp_val;
|
||||
value = tmp_val;
|
||||
}
|
||||
}
|
||||
|
||||
/* store value in driver */
|
||||
driver->curval= value;
|
||||
driver->curval = value;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case DRIVER_TYPE_PYTHON: /* expression */
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
/* check for empty or invalid expression */
|
||||
if ( (driver->expression[0] == '\0') ||
|
||||
(driver->flag & DRIVER_FLAG_INVALID) )
|
||||
(driver->flag & DRIVER_FLAG_INVALID) )
|
||||
{
|
||||
driver->curval= 0.0f;
|
||||
driver->curval = 0.0f;
|
||||
}
|
||||
else {
|
||||
/* this evaluates the expression using Python, and returns its result:
|
||||
* - on errors it reports, then returns 0.0f
|
||||
* - on errors it reports, then returns 0.0f
|
||||
*/
|
||||
driver->curval= BPY_driver_exec(driver, evaltime);
|
||||
driver->curval = BPY_driver_exec(driver, evaltime);
|
||||
}
|
||||
#else /* WITH_PYTHON*/
|
||||
(void)evaltime;
|
||||
(void)evaltime;
|
||||
#endif /* WITH_PYTHON*/
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
/* special 'hack' - just use stored value
|
||||
* This is currently used as the mechanism which allows animated settings to be able
|
||||
* to be changed via the UI.
|
||||
* to be changed via the UI.
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -1691,127 +1691,127 @@ void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2])
|
||||
float h1[2], h2[2], len1, len2, len, fac;
|
||||
|
||||
/* calculate handle deltas */
|
||||
h1[0]= v1[0] - v2[0];
|
||||
h1[1]= v1[1] - v2[1];
|
||||
h1[0] = v1[0] - v2[0];
|
||||
h1[1] = v1[1] - v2[1];
|
||||
|
||||
h2[0]= v4[0] - v3[0];
|
||||
h2[1]= v4[1] - v3[1];
|
||||
h2[0] = v4[0] - v3[0];
|
||||
h2[1] = v4[1] - v3[1];
|
||||
|
||||
/* calculate distances:
|
||||
* - len = span of time between keyframes
|
||||
* - len = span of time between keyframes
|
||||
* - len1 = length of handle of start key
|
||||
* - len2 = length of handle of end key
|
||||
* - len2 = length of handle of end key
|
||||
*/
|
||||
len= v4[0]- v1[0];
|
||||
len1= fabsf(h1[0]);
|
||||
len2= fabsf(h2[0]);
|
||||
len = v4[0] - v1[0];
|
||||
len1 = fabsf(h1[0]);
|
||||
len2 = fabsf(h2[0]);
|
||||
|
||||
/* if the handles have no length, no need to do any corrections */
|
||||
if ((len1+len2) == 0.0f)
|
||||
if ((len1 + len2) == 0.0f)
|
||||
return;
|
||||
|
||||
/* the two handles cross over each other, so force them
|
||||
* apart using the proportion they overlap
|
||||
*/
|
||||
if ((len1+len2) > len) {
|
||||
fac= len / (len1+len2);
|
||||
if ((len1 + len2) > len) {
|
||||
fac = len / (len1 + len2);
|
||||
|
||||
v2[0]= (v1[0] - fac*h1[0]);
|
||||
v2[1]= (v1[1] - fac*h1[1]);
|
||||
v2[0] = (v1[0] - fac * h1[0]);
|
||||
v2[1] = (v1[1] - fac * h1[1]);
|
||||
|
||||
v3[0]= (v4[0] - fac*h2[0]);
|
||||
v3[1]= (v4[1] - fac*h2[1]);
|
||||
v3[0] = (v4[0] - fac * h2[0]);
|
||||
v3[1] = (v4[1] - fac * h2[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/* find root ('zero') */
|
||||
static int findzero (float x, float q0, float q1, float q2, float q3, float *o)
|
||||
static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
|
||||
{
|
||||
double c0, c1, c2, c3, a, b, c, p, q, d, t, phi;
|
||||
int nr= 0;
|
||||
int nr = 0;
|
||||
|
||||
c0= q0 - x;
|
||||
c1= 3.0f * (q1 - q0);
|
||||
c2= 3.0f * (q0 - 2.0f*q1 + q2);
|
||||
c3= q3 - q0 + 3.0f * (q1 - q2);
|
||||
c0 = q0 - x;
|
||||
c1 = 3.0f * (q1 - q0);
|
||||
c2 = 3.0f * (q0 - 2.0f * q1 + q2);
|
||||
c3 = q3 - q0 + 3.0f * (q1 - q2);
|
||||
|
||||
if (c3 != 0.0) {
|
||||
a= c2/c3;
|
||||
b= c1/c3;
|
||||
c= c0/c3;
|
||||
a= a/3;
|
||||
|
||||
p= b/3 - a*a;
|
||||
q= (2*a*a*a - a*b + c) / 2;
|
||||
d= q*q + p*p*p;
|
||||
a = c2 / c3;
|
||||
b = c1 / c3;
|
||||
c = c0 / c3;
|
||||
a = a / 3;
|
||||
|
||||
p = b / 3 - a * a;
|
||||
q = (2 * a * a * a - a * b + c) / 2;
|
||||
d = q * q + p * p * p;
|
||||
|
||||
if (d > 0.0) {
|
||||
t= sqrt(d);
|
||||
o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a);
|
||||
t = sqrt(d);
|
||||
o[0] = (float)(sqrt3d(-q + t) + sqrt3d(-q - t) - a);
|
||||
|
||||
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
else if (d == 0.0) {
|
||||
t= sqrt3d(-q);
|
||||
o[0]= (float)(2*t - a);
|
||||
t = sqrt3d(-q);
|
||||
o[0] = (float)(2 * t - a);
|
||||
|
||||
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++;
|
||||
o[nr]= (float)(-t-a);
|
||||
o[nr] = (float)(-t - a);
|
||||
|
||||
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1;
|
||||
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1;
|
||||
else return nr;
|
||||
}
|
||||
else {
|
||||
phi= acos(-q / sqrt(-(p*p*p)));
|
||||
t= sqrt(-p);
|
||||
p= cos(phi/3);
|
||||
q= sqrt(3 - 3*p*p);
|
||||
o[0]= (float)(2*t*p - a);
|
||||
phi = acos(-q / sqrt(-(p * p * p)));
|
||||
t = sqrt(-p);
|
||||
p = cos(phi / 3);
|
||||
q = sqrt(3 - 3 * p * p);
|
||||
o[0] = (float)(2 * t * p - a);
|
||||
|
||||
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++;
|
||||
o[nr]= (float)(-t * (p + q) - a);
|
||||
o[nr] = (float)(-t * (p + q) - a);
|
||||
|
||||
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) nr++;
|
||||
o[nr]= (float)(-t * (p - q) - a);
|
||||
o[nr] = (float)(-t * (p - q) - a);
|
||||
|
||||
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1;
|
||||
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1;
|
||||
else return nr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
a=c2;
|
||||
b=c1;
|
||||
c=c0;
|
||||
a = c2;
|
||||
b = c1;
|
||||
c = c0;
|
||||
|
||||
if (a != 0.0) {
|
||||
// discriminant
|
||||
p= b*b - 4*a*c;
|
||||
p = b * b - 4 * a * c;
|
||||
|
||||
if (p > 0) {
|
||||
p= sqrt(p);
|
||||
o[0]= (float)((-b-p) / (2 * a));
|
||||
p = sqrt(p);
|
||||
o[0] = (float)((-b - p) / (2 * a));
|
||||
|
||||
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++;
|
||||
o[nr]= (float)((-b+p)/(2*a));
|
||||
o[nr] = (float)((-b + p) / (2 * a));
|
||||
|
||||
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1;
|
||||
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1;
|
||||
else return nr;
|
||||
}
|
||||
else if (p == 0) {
|
||||
o[0]= (float)(-b / (2 * a));
|
||||
o[0] = (float)(-b / (2 * a));
|
||||
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
}
|
||||
else if (b != 0.0) {
|
||||
o[0]= (float)(-c/b);
|
||||
o[0] = (float)(-c / b);
|
||||
|
||||
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
else if (c == 0.0) {
|
||||
o[0]= 0.0;
|
||||
o[0] = 0.0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1819,36 +1819,36 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o)
|
||||
}
|
||||
}
|
||||
|
||||
static void berekeny (float f1, float f2, float f3, float f4, float *o, int b)
|
||||
static void berekeny(float f1, float f2, float f3, float f4, float *o, int b)
|
||||
{
|
||||
float t, c0, c1, c2, c3;
|
||||
int a;
|
||||
|
||||
c0= f1;
|
||||
c1= 3.0f * (f2 - f1);
|
||||
c2= 3.0f * (f1 - 2.0f*f2 + f3);
|
||||
c3= f4 - f1 + 3.0f * (f2 - f3);
|
||||
|
||||
for (a=0; a < b; a++) {
|
||||
t= o[a];
|
||||
o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3;
|
||||
c0 = f1;
|
||||
c1 = 3.0f * (f2 - f1);
|
||||
c2 = 3.0f * (f1 - 2.0f * f2 + f3);
|
||||
c3 = f4 - f1 + 3.0f * (f2 - f3);
|
||||
|
||||
for (a = 0; a < b; a++) {
|
||||
t = o[a];
|
||||
o[a] = c0 + t * c1 + t * t * c2 + t * t * t * c3;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void berekenx (float *f, float *o, int b)
|
||||
static void berekenx(float *f, float *o, int b)
|
||||
{
|
||||
float t, c0, c1, c2, c3;
|
||||
int a;
|
||||
|
||||
c0= f[0];
|
||||
c1= 3.0f * (f[3] - f[0]);
|
||||
c2= 3.0f * (f[0] - 2.0f*f[3] + f[6]);
|
||||
c3= f[9] - f[0] + 3.0f * (f[3] - f[6]);
|
||||
|
||||
for (a=0; a < b; a++) {
|
||||
t= o[a];
|
||||
o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3;
|
||||
c0 = f[0];
|
||||
c1 = 3.0f * (f[3] - f[0]);
|
||||
c2 = 3.0f * (f[0] - 2.0f * f[3] + f[6]);
|
||||
c3 = f[9] - f[0] + 3.0f * (f[3] - f[6]);
|
||||
|
||||
for (a = 0; a < b; a++) {
|
||||
t = o[a];
|
||||
o[a] = c0 + t * c1 + t * t * c2 + t * t * t * c3;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1857,7 +1857,7 @@ static void berekenx (float *f, float *o, int b)
|
||||
/* -------------------------- */
|
||||
|
||||
/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
|
||||
static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltime)
|
||||
static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime)
|
||||
{
|
||||
BezTriple *bezt, *prevbezt, *lastbezt;
|
||||
float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac;
|
||||
@@ -1866,37 +1866,37 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim
|
||||
float cvalue = 0.0f;
|
||||
|
||||
/* get pointers */
|
||||
a= fcu->totvert-1;
|
||||
prevbezt= bezts;
|
||||
bezt= prevbezt+1;
|
||||
lastbezt= prevbezt + a;
|
||||
a = fcu->totvert - 1;
|
||||
prevbezt = bezts;
|
||||
bezt = prevbezt + 1;
|
||||
lastbezt = prevbezt + a;
|
||||
|
||||
/* evaluation time at or past endpoints? */
|
||||
if (prevbezt->vec[1][0] >= evaltime) {
|
||||
/* before or on first keyframe */
|
||||
if ( (fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (prevbezt->ipo != BEZT_IPO_CONST) &&
|
||||
!(fcu->flag & FCURVE_DISCRETE_VALUES) )
|
||||
!(fcu->flag & FCURVE_DISCRETE_VALUES) )
|
||||
{
|
||||
/* linear or bezier interpolation */
|
||||
if (prevbezt->ipo==BEZT_IPO_LIN) {
|
||||
if (prevbezt->ipo == BEZT_IPO_LIN) {
|
||||
/* Use the next center point instead of our own handle for
|
||||
* linear interpolated extrapolate
|
||||
*/
|
||||
if (fcu->totvert == 1) {
|
||||
cvalue= prevbezt->vec[1][1];
|
||||
cvalue = prevbezt->vec[1][1];
|
||||
}
|
||||
else {
|
||||
bezt = prevbezt+1;
|
||||
dx= prevbezt->vec[1][0] - evaltime;
|
||||
fac= bezt->vec[1][0] - prevbezt->vec[1][0];
|
||||
bezt = prevbezt + 1;
|
||||
dx = prevbezt->vec[1][0] - evaltime;
|
||||
fac = bezt->vec[1][0] - prevbezt->vec[1][0];
|
||||
|
||||
/* prevent division by zero */
|
||||
if (fac) {
|
||||
fac= (bezt->vec[1][1] - prevbezt->vec[1][1]) / fac;
|
||||
cvalue= prevbezt->vec[1][1] - (fac * dx);
|
||||
fac = (bezt->vec[1][1] - prevbezt->vec[1][1]) / fac;
|
||||
cvalue = prevbezt->vec[1][1] - (fac * dx);
|
||||
}
|
||||
else {
|
||||
cvalue= prevbezt->vec[1][1];
|
||||
cvalue = prevbezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1904,16 +1904,16 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim
|
||||
/* Use the first handle (earlier) of first BezTriple to calculate the
|
||||
* gradient and thus the value of the curve at evaltime
|
||||
*/
|
||||
dx= prevbezt->vec[1][0] - evaltime;
|
||||
fac= prevbezt->vec[1][0] - prevbezt->vec[0][0];
|
||||
dx = prevbezt->vec[1][0] - evaltime;
|
||||
fac = prevbezt->vec[1][0] - prevbezt->vec[0][0];
|
||||
|
||||
/* prevent division by zero */
|
||||
if (fac) {
|
||||
fac= (prevbezt->vec[1][1] - prevbezt->vec[0][1]) / fac;
|
||||
cvalue= prevbezt->vec[1][1] - (fac * dx);
|
||||
fac = (prevbezt->vec[1][1] - prevbezt->vec[0][1]) / fac;
|
||||
cvalue = prevbezt->vec[1][1] - (fac * dx);
|
||||
}
|
||||
else {
|
||||
cvalue= prevbezt->vec[1][1];
|
||||
cvalue = prevbezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1921,34 +1921,34 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim
|
||||
/* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation,
|
||||
* so just extend first keyframe's value
|
||||
*/
|
||||
cvalue= prevbezt->vec[1][1];
|
||||
cvalue = prevbezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
else if (lastbezt->vec[1][0] <= evaltime) {
|
||||
/* after or on last keyframe */
|
||||
if ( (fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (lastbezt->ipo != BEZT_IPO_CONST) &&
|
||||
!(fcu->flag & FCURVE_DISCRETE_VALUES) )
|
||||
!(fcu->flag & FCURVE_DISCRETE_VALUES) )
|
||||
{
|
||||
/* linear or bezier interpolation */
|
||||
if (lastbezt->ipo==BEZT_IPO_LIN) {
|
||||
if (lastbezt->ipo == BEZT_IPO_LIN) {
|
||||
/* Use the next center point instead of our own handle for
|
||||
* linear interpolated extrapolate
|
||||
*/
|
||||
if (fcu->totvert == 1) {
|
||||
cvalue= lastbezt->vec[1][1];
|
||||
cvalue = lastbezt->vec[1][1];
|
||||
}
|
||||
else {
|
||||
prevbezt = lastbezt - 1;
|
||||
dx= evaltime - lastbezt->vec[1][0];
|
||||
fac= lastbezt->vec[1][0] - prevbezt->vec[1][0];
|
||||
dx = evaltime - lastbezt->vec[1][0];
|
||||
fac = lastbezt->vec[1][0] - prevbezt->vec[1][0];
|
||||
|
||||
/* prevent division by zero */
|
||||
if (fac) {
|
||||
fac= (lastbezt->vec[1][1] - prevbezt->vec[1][1]) / fac;
|
||||
cvalue= lastbezt->vec[1][1] + (fac * dx);
|
||||
fac = (lastbezt->vec[1][1] - prevbezt->vec[1][1]) / fac;
|
||||
cvalue = lastbezt->vec[1][1] + (fac * dx);
|
||||
}
|
||||
else {
|
||||
cvalue= lastbezt->vec[1][1];
|
||||
cvalue = lastbezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1956,16 +1956,16 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim
|
||||
/* Use the gradient of the second handle (later) of last BezTriple to calculate the
|
||||
* gradient and thus the value of the curve at evaltime
|
||||
*/
|
||||
dx= evaltime - lastbezt->vec[1][0];
|
||||
fac= lastbezt->vec[2][0] - lastbezt->vec[1][0];
|
||||
dx = evaltime - lastbezt->vec[1][0];
|
||||
fac = lastbezt->vec[2][0] - lastbezt->vec[1][0];
|
||||
|
||||
/* prevent division by zero */
|
||||
if (fac) {
|
||||
fac= (lastbezt->vec[2][1] - lastbezt->vec[1][1]) / fac;
|
||||
cvalue= lastbezt->vec[1][1] + (fac * dx);
|
||||
fac = (lastbezt->vec[2][1] - lastbezt->vec[1][1]) / fac;
|
||||
cvalue = lastbezt->vec[1][1] + (fac * dx);
|
||||
}
|
||||
else {
|
||||
cvalue= lastbezt->vec[1][1];
|
||||
cvalue = lastbezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1973,57 +1973,57 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim
|
||||
/* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation,
|
||||
* so just extend last keyframe's value
|
||||
*/
|
||||
cvalue= lastbezt->vec[1][1];
|
||||
cvalue = lastbezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* evaltime occurs somewhere in the middle of the curve */
|
||||
for (a=0; prevbezt && bezt && (a < fcu->totvert-1); a++, prevbezt=bezt, bezt++) {
|
||||
for (a = 0; prevbezt && bezt && (a < fcu->totvert - 1); a++, prevbezt = bezt, bezt++) {
|
||||
/* use if the key is directly on the frame, rare cases this is needed else we get 0.0 instead. */
|
||||
if (fabsf(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) {
|
||||
cvalue= bezt->vec[1][1];
|
||||
cvalue = bezt->vec[1][1];
|
||||
}
|
||||
/* evaltime occurs within the interval defined by these two keyframes */
|
||||
else if ((prevbezt->vec[1][0] <= evaltime) && (bezt->vec[1][0] >= evaltime)) {
|
||||
/* value depends on interpolation mode */
|
||||
if ((prevbezt->ipo == BEZT_IPO_CONST) || (fcu->flag & FCURVE_DISCRETE_VALUES)) {
|
||||
/* constant (evaltime not relevant, so no interpolation needed) */
|
||||
cvalue= prevbezt->vec[1][1];
|
||||
cvalue = prevbezt->vec[1][1];
|
||||
}
|
||||
else if (prevbezt->ipo == BEZT_IPO_LIN) {
|
||||
/* linear - interpolate between values of the two keyframes */
|
||||
fac= bezt->vec[1][0] - prevbezt->vec[1][0];
|
||||
fac = bezt->vec[1][0] - prevbezt->vec[1][0];
|
||||
|
||||
/* prevent division by zero */
|
||||
if (fac) {
|
||||
fac= (evaltime - prevbezt->vec[1][0]) / fac;
|
||||
cvalue= prevbezt->vec[1][1] + (fac * (bezt->vec[1][1] - prevbezt->vec[1][1]));
|
||||
fac = (evaltime - prevbezt->vec[1][0]) / fac;
|
||||
cvalue = prevbezt->vec[1][1] + (fac * (bezt->vec[1][1] - prevbezt->vec[1][1]));
|
||||
}
|
||||
else {
|
||||
cvalue= prevbezt->vec[1][1];
|
||||
cvalue = prevbezt->vec[1][1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* bezier interpolation */
|
||||
/* v1,v2 are the first keyframe and its 2nd handle */
|
||||
v1[0]= prevbezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v2[0]= prevbezt->vec[2][0];
|
||||
v2[1]= prevbezt->vec[2][1];
|
||||
/* v3,v4 are the last keyframe's 1st handle + the last keyframe */
|
||||
v3[0]= bezt->vec[0][0];
|
||||
v3[1]= bezt->vec[0][1];
|
||||
v4[0]= bezt->vec[1][0];
|
||||
v4[1]= bezt->vec[1][1];
|
||||
/* v1,v2 are the first keyframe and its 2nd handle */
|
||||
v1[0] = prevbezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
v2[0] = prevbezt->vec[2][0];
|
||||
v2[1] = prevbezt->vec[2][1];
|
||||
/* v3,v4 are the last keyframe's 1st handle + the last keyframe */
|
||||
v3[0] = bezt->vec[0][0];
|
||||
v3[1] = bezt->vec[0][1];
|
||||
v4[0] = bezt->vec[1][0];
|
||||
v4[1] = bezt->vec[1][1];
|
||||
|
||||
/* adjust handles so that they don't overlap (forming a loop) */
|
||||
correct_bezpart(v1, v2, v3, v4);
|
||||
|
||||
/* try to get a value for this position - if failure, try another set of points */
|
||||
b= findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl);
|
||||
b = findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl);
|
||||
if (b) {
|
||||
berekeny(v1[1], v2[1], v3[1], v4[1], opl, 1);
|
||||
cvalue= opl[0];
|
||||
cvalue = opl[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2036,35 +2036,35 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim
|
||||
}
|
||||
|
||||
/* Calculate F-Curve value for 'evaltime' using FPoint samples */
|
||||
static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime)
|
||||
static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime)
|
||||
{
|
||||
FPoint *prevfpt, *lastfpt, *fpt;
|
||||
float cvalue= 0.0f;
|
||||
float cvalue = 0.0f;
|
||||
|
||||
/* get pointers */
|
||||
prevfpt= fpts;
|
||||
lastfpt= prevfpt + fcu->totvert-1;
|
||||
prevfpt = fpts;
|
||||
lastfpt = prevfpt + fcu->totvert - 1;
|
||||
|
||||
/* evaluation time at or past endpoints? */
|
||||
if (prevfpt->vec[0] >= evaltime) {
|
||||
/* before or on first sample, so just extend value */
|
||||
cvalue= prevfpt->vec[1];
|
||||
cvalue = prevfpt->vec[1];
|
||||
}
|
||||
else if (lastfpt->vec[0] <= evaltime) {
|
||||
/* after or on last sample, so just extend value */
|
||||
cvalue= lastfpt->vec[1];
|
||||
cvalue = lastfpt->vec[1];
|
||||
}
|
||||
else {
|
||||
float t= (float)abs(evaltime - (int)evaltime);
|
||||
float t = (float)abs(evaltime - (int)evaltime);
|
||||
|
||||
/* find the one on the right frame (assume that these are spaced on 1-frame intervals) */
|
||||
fpt= prevfpt + (int)(evaltime - prevfpt->vec[0]);
|
||||
fpt = prevfpt + (int)(evaltime - prevfpt->vec[0]);
|
||||
|
||||
/* if not exactly on the frame, perform linear interpolation with the next one */
|
||||
if (t != 0.0f)
|
||||
cvalue= interpf(fpt->vec[1], (fpt+1)->vec[1], t);
|
||||
cvalue = interpf(fpt->vec[1], (fpt + 1)->vec[1], t);
|
||||
else
|
||||
cvalue= fpt->vec[1];
|
||||
cvalue = fpt->vec[1];
|
||||
}
|
||||
|
||||
/* return value */
|
||||
@@ -2078,7 +2078,7 @@ static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime)
|
||||
*/
|
||||
float evaluate_fcurve(FCurve *fcu, float evaltime)
|
||||
{
|
||||
float cvalue= 0.0f;
|
||||
float cvalue = 0.0f;
|
||||
float devaltime;
|
||||
|
||||
/* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime"
|
||||
@@ -2087,20 +2087,20 @@ float evaluate_fcurve(FCurve *fcu, float evaltime)
|
||||
*/
|
||||
if (fcu->driver) {
|
||||
/* evaltime now serves as input for the curve */
|
||||
evaltime= cvalue= evaluate_driver(fcu->driver, evaltime);
|
||||
evaltime = cvalue = evaluate_driver(fcu->driver, evaltime);
|
||||
}
|
||||
|
||||
/* evaluate modifiers which modify time to evaluate the base curve at */
|
||||
devaltime= evaluate_time_fmodifiers(&fcu->modifiers, fcu, cvalue, evaltime);
|
||||
devaltime = evaluate_time_fmodifiers(&fcu->modifiers, fcu, cvalue, evaltime);
|
||||
|
||||
/* evaluate curve-data
|
||||
* - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying
|
||||
* F-Curve modifier on the stack requested the curve to be evaluated at
|
||||
*/
|
||||
if (fcu->bezt)
|
||||
cvalue= fcurve_eval_keyframes(fcu, fcu->bezt, devaltime);
|
||||
cvalue = fcurve_eval_keyframes(fcu, fcu->bezt, devaltime);
|
||||
else if (fcu->fpt)
|
||||
cvalue= fcurve_eval_samples(fcu, fcu->fpt, devaltime);
|
||||
cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime);
|
||||
|
||||
/* evaluate modifiers */
|
||||
evaluate_value_fmodifiers(&fcu->modifiers, fcu, &cvalue, evaltime);
|
||||
@@ -2109,7 +2109,7 @@ float evaluate_fcurve(FCurve *fcu, float evaltime)
|
||||
* here so that the curve can be sampled correctly
|
||||
*/
|
||||
if (fcu->flag & FCURVE_INT_VALUES)
|
||||
cvalue= floorf(cvalue + 0.5f);
|
||||
cvalue = floorf(cvalue + 0.5f);
|
||||
|
||||
/* return evaluated value */
|
||||
return cvalue;
|
||||
@@ -2125,7 +2125,7 @@ void calculate_fcurve(FCurve *fcu, float ctime)
|
||||
list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE))
|
||||
{
|
||||
/* calculate and set curval (evaluates driver too if necessary) */
|
||||
fcu->curval= evaluate_fcurve(fcu, ctime);
|
||||
fcu->curval = evaluate_fcurve(fcu, ctime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,14 +68,14 @@
|
||||
*/
|
||||
|
||||
/* Template for type-info data:
|
||||
* - make a copy of this when creating new modifiers, and just change the functions
|
||||
* pointed to as necessary
|
||||
* - although the naming of functions doesn't matter, it would help for code
|
||||
* readability, to follow the same naming convention as is presented here
|
||||
* - any functions that a constraint doesn't need to define, don't define
|
||||
* for such cases, just use NULL
|
||||
* - these should be defined after all the functions have been defined, so that
|
||||
* forward-definitions/prototypes don't need to be used!
|
||||
* - make a copy of this when creating new modifiers, and just change the functions
|
||||
* pointed to as necessary
|
||||
* - although the naming of functions doesn't matter, it would help for code
|
||||
* readability, to follow the same naming convention as is presented here
|
||||
* - any functions that a constraint doesn't need to define, don't define
|
||||
* for such cases, just use NULL
|
||||
* - these should be defined after all the functions have been defined, so that
|
||||
* forward-definitions/prototypes don't need to be used!
|
||||
* - keep this copy #if-def'd so that future constraints can get based off this
|
||||
*/
|
||||
#if 0
|
||||
@@ -99,74 +99,74 @@ static FModifierTypeInfo FMI_MODNAME = {
|
||||
/* Generator F-Curve Modifier --------------------------- */
|
||||
|
||||
/* Generators available:
|
||||
* 1) simple polynomial generator:
|
||||
* 1) simple polynomial generator:
|
||||
* - Exanded form - (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n])
|
||||
* - Factorized form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
|
||||
*/
|
||||
|
||||
static void fcm_generator_free (FModifier *fcm)
|
||||
static void fcm_generator_free(FModifier *fcm)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *data = (FMod_Generator *)fcm->data;
|
||||
|
||||
/* free polynomial coefficients array */
|
||||
if (data->coefficients)
|
||||
MEM_freeN(data->coefficients);
|
||||
}
|
||||
|
||||
static void fcm_generator_copy (FModifier *fcm, FModifier *src)
|
||||
static void fcm_generator_copy(FModifier *fcm, FModifier *src)
|
||||
{
|
||||
FMod_Generator *gen= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *ogen= (FMod_Generator *)src->data;
|
||||
FMod_Generator *gen = (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *ogen = (FMod_Generator *)src->data;
|
||||
|
||||
/* copy coefficients array? */
|
||||
if (ogen->coefficients)
|
||||
gen->coefficients= MEM_dupallocN(ogen->coefficients);
|
||||
gen->coefficients = MEM_dupallocN(ogen->coefficients);
|
||||
}
|
||||
|
||||
static void fcm_generator_new_data (void *mdata)
|
||||
static void fcm_generator_new_data(void *mdata)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)mdata;
|
||||
FMod_Generator *data = (FMod_Generator *)mdata;
|
||||
float *cp;
|
||||
|
||||
/* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */
|
||||
data->poly_order= 1;
|
||||
data->arraysize= 2;
|
||||
cp= data->coefficients= MEM_callocN(sizeof(float)*2, "FMod_Generator_Coefs");
|
||||
data->poly_order = 1;
|
||||
data->arraysize = 2;
|
||||
cp = data->coefficients = MEM_callocN(sizeof(float) * 2, "FMod_Generator_Coefs");
|
||||
cp[0] = 0; // y-offset
|
||||
cp[1] = 1; // gradient
|
||||
}
|
||||
|
||||
static void fcm_generator_verify (FModifier *fcm)
|
||||
static void fcm_generator_verify(FModifier *fcm)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *data = (FMod_Generator *)fcm->data;
|
||||
|
||||
/* requirements depend on mode */
|
||||
switch (data->mode) {
|
||||
case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
|
||||
{
|
||||
/* arraysize needs to be order+1, so resize if not */
|
||||
if (data->arraysize != (data->poly_order+1)) {
|
||||
if (data->arraysize != (data->poly_order + 1)) {
|
||||
float *nc;
|
||||
|
||||
/* make new coefficients array, and copy over as much data as can fit */
|
||||
nc= MEM_callocN(sizeof(float)*(data->poly_order+1), "FMod_Generator_Coefs");
|
||||
nc = MEM_callocN(sizeof(float) * (data->poly_order + 1), "FMod_Generator_Coefs");
|
||||
|
||||
if (data->coefficients) {
|
||||
if ((int)data->arraysize > (data->poly_order+1))
|
||||
memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order+1));
|
||||
if ((int)data->arraysize > (data->poly_order + 1))
|
||||
memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order + 1));
|
||||
else
|
||||
memcpy(nc, data->coefficients, sizeof(float)*data->arraysize);
|
||||
memcpy(nc, data->coefficients, sizeof(float) * data->arraysize);
|
||||
|
||||
/* free the old data */
|
||||
MEM_freeN(data->coefficients);
|
||||
}
|
||||
|
||||
/* set the new data */
|
||||
data->coefficients= nc;
|
||||
data->arraysize= data->poly_order+1;
|
||||
data->coefficients = nc;
|
||||
data->arraysize = data->poly_order + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* expanded polynomial expression */
|
||||
{
|
||||
@@ -175,30 +175,30 @@ static void fcm_generator_verify (FModifier *fcm)
|
||||
float *nc;
|
||||
|
||||
/* make new coefficients array, and copy over as much data as can fit */
|
||||
nc= MEM_callocN(sizeof(float)*(data->poly_order*2), "FMod_Generator_Coefs");
|
||||
nc = MEM_callocN(sizeof(float) * (data->poly_order * 2), "FMod_Generator_Coefs");
|
||||
|
||||
if (data->coefficients) {
|
||||
if (data->arraysize > (unsigned int)(data->poly_order * 2))
|
||||
memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order * 2));
|
||||
memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order * 2));
|
||||
else
|
||||
memcpy(nc, data->coefficients, sizeof(float)*data->arraysize);
|
||||
memcpy(nc, data->coefficients, sizeof(float) * data->arraysize);
|
||||
|
||||
/* free the old data */
|
||||
MEM_freeN(data->coefficients);
|
||||
}
|
||||
|
||||
/* set the new data */
|
||||
data->coefficients= nc;
|
||||
data->arraysize= data->poly_order * 2;
|
||||
data->coefficients = nc;
|
||||
data->arraysize = data->poly_order * 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *data = (FMod_Generator *)fcm->data;
|
||||
|
||||
/* behavior depends on mode
|
||||
* NOTE: the data in its default state is fine too
|
||||
@@ -207,23 +207,23 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *
|
||||
case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
|
||||
{
|
||||
/* we overwrite cvalue with the sum of the polynomial */
|
||||
float *powers = MEM_callocN(sizeof(float)*data->arraysize, "Poly Powers");
|
||||
float value= 0.0f;
|
||||
float *powers = MEM_callocN(sizeof(float) * data->arraysize, "Poly Powers");
|
||||
float value = 0.0f;
|
||||
unsigned int i;
|
||||
|
||||
/* for each x^n, precalculate value based on previous one first... this should be
|
||||
* faster that calling pow() for each entry
|
||||
*/
|
||||
for (i=0; i < data->arraysize; i++) {
|
||||
for (i = 0; i < data->arraysize; i++) {
|
||||
/* first entry is x^0 = 1, otherwise, calculate based on previous */
|
||||
if (i)
|
||||
powers[i]= powers[i-1] * evaltime;
|
||||
powers[i] = powers[i - 1] * evaltime;
|
||||
else
|
||||
powers[0]= 1;
|
||||
powers[0] = 1;
|
||||
}
|
||||
|
||||
/* for each coefficient, add to value, which we'll write to *cvalue in one go */
|
||||
for (i=0; i < data->arraysize; i++)
|
||||
for (i = 0; i < data->arraysize; i++)
|
||||
value += data->coefficients[i] * powers[i];
|
||||
|
||||
/* only if something changed, write *cvalue in one go */
|
||||
@@ -231,33 +231,33 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *
|
||||
if (data->flag & FCM_GENERATOR_ADDITIVE)
|
||||
*cvalue += value;
|
||||
else
|
||||
*cvalue= value;
|
||||
*cvalue = value;
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
if (powers)
|
||||
MEM_freeN(powers);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial */
|
||||
{
|
||||
float value= 1.0f, *cp=NULL;
|
||||
float value = 1.0f, *cp = NULL;
|
||||
unsigned int i;
|
||||
|
||||
/* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */
|
||||
for (cp=data->coefficients, i=0; (cp) && (i < (unsigned int)data->poly_order); cp+=2, i++)
|
||||
value *= (cp[0]*evaltime + cp[1]);
|
||||
for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order); cp += 2, i++)
|
||||
value *= (cp[0] * evaltime + cp[1]);
|
||||
|
||||
/* only if something changed, write *cvalue in one go */
|
||||
if (data->poly_order) {
|
||||
if (data->flag & FCM_GENERATOR_ADDITIVE)
|
||||
*cvalue += value;
|
||||
else
|
||||
*cvalue= value;
|
||||
*cvalue = value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ static FModifierTypeInfo FMI_GENERATOR = {
|
||||
/* Built-In Function Generator F-Curve Modifier --------------------------- */
|
||||
|
||||
/* This uses the general equation for equations:
|
||||
* y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
|
||||
* y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
|
||||
*
|
||||
* where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients,
|
||||
* x is the evaluation 'time', and 'y' is the resultant value
|
||||
@@ -288,20 +288,20 @@ static FModifierTypeInfo FMI_GENERATOR = {
|
||||
* sin, cos, tan, sinc (normalised sin), natural log, square root
|
||||
*/
|
||||
|
||||
static void fcm_fn_generator_new_data (void *mdata)
|
||||
static void fcm_fn_generator_new_data(void *mdata)
|
||||
{
|
||||
FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)mdata;
|
||||
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)mdata;
|
||||
|
||||
/* set amplitude and phase multiplier to 1.0f so that something is generated */
|
||||
data->amplitude= 1.0f;
|
||||
data->phase_multiplier= 1.0f;
|
||||
data->amplitude = 1.0f;
|
||||
data->phase_multiplier = 1.0f;
|
||||
}
|
||||
|
||||
/* Unary 'normalised sine' function
|
||||
* y = sin(PI + x) / (PI * x),
|
||||
* y = sin(PI + x) / (PI * x),
|
||||
* except for x = 0 when y = 1.
|
||||
*/
|
||||
static double sinc (double x)
|
||||
static double sinc(double x)
|
||||
{
|
||||
if (fabs(x) < 0.0001)
|
||||
return 1.0;
|
||||
@@ -309,10 +309,10 @@ static double sinc (double x)
|
||||
return sin(M_PI * x) / (M_PI * x);
|
||||
}
|
||||
|
||||
static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data;
|
||||
double arg= data->phase_multiplier*evaltime + data->phase_offset;
|
||||
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
|
||||
double arg = data->phase_multiplier * evaltime + data->phase_offset;
|
||||
double (*fn)(double v) = NULL;
|
||||
|
||||
/* get function pointer to the func to use:
|
||||
@@ -321,13 +321,13 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
switch (data->type) {
|
||||
/* simple ones */
|
||||
case FCM_GENERATOR_FN_SIN: /* sine wave */
|
||||
fn= sin;
|
||||
fn = sin;
|
||||
break;
|
||||
case FCM_GENERATOR_FN_COS: /* cosine wave */
|
||||
fn= cos;
|
||||
fn = cos;
|
||||
break;
|
||||
case FCM_GENERATOR_FN_SINC: /* normalised sine wave */
|
||||
fn= sinc;
|
||||
fn = sinc;
|
||||
break;
|
||||
|
||||
/* validation required */
|
||||
@@ -336,36 +336,36 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
/* check that argument is not on one of the discontinuities (i.e. 90deg, 270 deg, etc) */
|
||||
if (IS_EQ(fmod((arg - M_PI_2), M_PI), 0.0)) {
|
||||
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
|
||||
*cvalue = 0.0f; /* no value possible here */
|
||||
*cvalue = 0.0f; /* no value possible here */
|
||||
}
|
||||
else
|
||||
fn= tan;
|
||||
fn = tan;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case FCM_GENERATOR_FN_LN: /* natural log */
|
||||
{
|
||||
/* check that value is greater than 1? */
|
||||
if (arg > 1.0) {
|
||||
fn= log;
|
||||
fn = log;
|
||||
}
|
||||
else {
|
||||
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
|
||||
*cvalue = 0.0f; /* no value possible here */
|
||||
*cvalue = 0.0f; /* no value possible here */
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case FCM_GENERATOR_FN_SQRT: /* square root */
|
||||
{
|
||||
/* no negative numbers */
|
||||
if (arg > 0.0) {
|
||||
fn= sqrt;
|
||||
fn = sqrt;
|
||||
}
|
||||
else {
|
||||
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
|
||||
*cvalue = 0.0f; /* no value possible here */
|
||||
*cvalue = 0.0f; /* no value possible here */
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid Function-Generator for F-Modifier - %d\n", data->type);
|
||||
@@ -373,12 +373,12 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
|
||||
/* execute function callback to set value if appropriate */
|
||||
if (fn) {
|
||||
float value= (float)(data->amplitude*(float)fn(arg) + data->value_offset);
|
||||
float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset);
|
||||
|
||||
if (data->flag & FCM_GENERATOR_ADDITIVE)
|
||||
*cvalue += value;
|
||||
else
|
||||
*cvalue= value;
|
||||
*cvalue = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,37 +399,37 @@ static FModifierTypeInfo FMI_FN_GENERATOR = {
|
||||
|
||||
/* Envelope F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_envelope_free (FModifier *fcm)
|
||||
static void fcm_envelope_free(FModifier *fcm)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
|
||||
/* free envelope data array */
|
||||
if (env->data)
|
||||
MEM_freeN(env->data);
|
||||
}
|
||||
|
||||
static void fcm_envelope_copy (FModifier *fcm, FModifier *src)
|
||||
static void fcm_envelope_copy(FModifier *fcm, FModifier *src)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *oenv= (FMod_Envelope *)src->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *oenv = (FMod_Envelope *)src->data;
|
||||
|
||||
/* copy envelope data array */
|
||||
if (oenv->data)
|
||||
env->data= MEM_dupallocN(oenv->data);
|
||||
env->data = MEM_dupallocN(oenv->data);
|
||||
}
|
||||
|
||||
static void fcm_envelope_new_data (void *mdata)
|
||||
static void fcm_envelope_new_data(void *mdata)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)mdata;
|
||||
FMod_Envelope *env = (FMod_Envelope *)mdata;
|
||||
|
||||
/* set default min/max ranges */
|
||||
env->min= -1.0f;
|
||||
env->max= 1.0f;
|
||||
env->min = -1.0f;
|
||||
env->max = 1.0f;
|
||||
}
|
||||
|
||||
static void fcm_envelope_verify (FModifier *fcm)
|
||||
static void fcm_envelope_verify(FModifier *fcm)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
|
||||
/* if the are points, perform bubble-sort on them, as user may have changed the order */
|
||||
if (env->data) {
|
||||
@@ -437,44 +437,44 @@ static void fcm_envelope_verify (FModifier *fcm)
|
||||
}
|
||||
}
|
||||
|
||||
static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
FCM_EnvelopeData *fed, *prevfed, *lastfed;
|
||||
float min=0.0f, max=0.0f, fac=0.0f;
|
||||
float min = 0.0f, max = 0.0f, fac = 0.0f;
|
||||
int a;
|
||||
|
||||
/* get pointers */
|
||||
if (env->data == NULL) return;
|
||||
prevfed= env->data;
|
||||
fed= prevfed + 1;
|
||||
lastfed= prevfed + (env->totvert-1);
|
||||
prevfed = env->data;
|
||||
fed = prevfed + 1;
|
||||
lastfed = prevfed + (env->totvert - 1);
|
||||
|
||||
/* get min/max values for envelope at evaluation time (relative to mid-value) */
|
||||
if (prevfed->time >= evaltime) {
|
||||
/* before or on first sample, so just extend value */
|
||||
min= prevfed->min;
|
||||
max= prevfed->max;
|
||||
min = prevfed->min;
|
||||
max = prevfed->max;
|
||||
}
|
||||
else if (lastfed->time <= evaltime) {
|
||||
/* after or on last sample, so just extend value */
|
||||
min= lastfed->min;
|
||||
max= lastfed->max;
|
||||
min = lastfed->min;
|
||||
max = lastfed->max;
|
||||
}
|
||||
else {
|
||||
/* evaltime occurs somewhere between segments */
|
||||
// TODO: implement binary search for this to make it faster?
|
||||
for (a=0; prevfed && fed && (a < env->totvert-1); a++, prevfed=fed, fed++) {
|
||||
for (a = 0; prevfed && fed && (a < env->totvert - 1); a++, prevfed = fed, fed++) {
|
||||
/* evaltime occurs within the interval defined by these two envelope points */
|
||||
if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) {
|
||||
float afac, bfac, diff;
|
||||
|
||||
diff= fed->time - prevfed->time;
|
||||
afac= (evaltime - prevfed->time) / diff;
|
||||
bfac= (fed->time - evaltime) / diff;
|
||||
diff = fed->time - prevfed->time;
|
||||
afac = (evaltime - prevfed->time) / diff;
|
||||
bfac = (fed->time - evaltime) / diff;
|
||||
|
||||
min= bfac*prevfed->min + afac*fed->min;
|
||||
max= bfac*prevfed->max + afac*fed->max;
|
||||
min = bfac * prevfed->min + afac * fed->min;
|
||||
max = bfac * prevfed->max + afac * fed->max;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -485,8 +485,8 @@ static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *c
|
||||
* - fac is the ratio of how the current y-value corresponds to the reference range
|
||||
* - thus, the new value is found by mapping the old range to the new!
|
||||
*/
|
||||
fac= (*cvalue - (env->midval + env->min)) / (env->max - env->min);
|
||||
*cvalue= min + fac*(max - min);
|
||||
fac = (*cvalue - (env->midval + env->min)) / (env->max - env->min);
|
||||
*cvalue = min + fac * (max - min);
|
||||
}
|
||||
|
||||
static FModifierTypeInfo FMI_ENVELOPE = {
|
||||
@@ -520,23 +520,23 @@ static FModifierTypeInfo FMI_ENVELOPE = {
|
||||
|
||||
/* temp data used during evaluation */
|
||||
typedef struct tFCMED_Cycles {
|
||||
float cycyofs; /* y-offset to apply */
|
||||
float cycyofs; /* y-offset to apply */
|
||||
} tFCMED_Cycles;
|
||||
|
||||
static void fcm_cycles_new_data (void *mdata)
|
||||
static void fcm_cycles_new_data(void *mdata)
|
||||
{
|
||||
FMod_Cycles *data= (FMod_Cycles *)mdata;
|
||||
FMod_Cycles *data = (FMod_Cycles *)mdata;
|
||||
|
||||
/* turn on cycles by default */
|
||||
data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC;
|
||||
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
|
||||
}
|
||||
|
||||
static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
{
|
||||
FMod_Cycles *data= (FMod_Cycles *)fcm->data;
|
||||
float prevkey[2], lastkey[2], cycyofs=0.0f;
|
||||
short side=0, mode=0;
|
||||
int cycles=0, ofs=0;
|
||||
FMod_Cycles *data = (FMod_Cycles *)fcm->data;
|
||||
float prevkey[2], lastkey[2], cycyofs = 0.0f;
|
||||
short side = 0, mode = 0;
|
||||
int cycles = 0, ofs = 0;
|
||||
|
||||
/* check if modifier is first in stack, otherwise disable ourself... */
|
||||
// FIXME...
|
||||
@@ -547,24 +547,24 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
|
||||
/* calculate new evaltime due to cyclic interpolation */
|
||||
if (fcu && fcu->bezt) {
|
||||
BezTriple *prevbezt= fcu->bezt;
|
||||
BezTriple *lastbezt= prevbezt + fcu->totvert-1;
|
||||
BezTriple *prevbezt = fcu->bezt;
|
||||
BezTriple *lastbezt = prevbezt + fcu->totvert - 1;
|
||||
|
||||
prevkey[0]= prevbezt->vec[1][0];
|
||||
prevkey[1]= prevbezt->vec[1][1];
|
||||
prevkey[0] = prevbezt->vec[1][0];
|
||||
prevkey[1] = prevbezt->vec[1][1];
|
||||
|
||||
lastkey[0]= lastbezt->vec[1][0];
|
||||
lastkey[1]= lastbezt->vec[1][1];
|
||||
lastkey[0] = lastbezt->vec[1][0];
|
||||
lastkey[1] = lastbezt->vec[1][1];
|
||||
}
|
||||
else if (fcu && fcu->fpt) {
|
||||
FPoint *prevfpt= fcu->fpt;
|
||||
FPoint *lastfpt= prevfpt + fcu->totvert-1;
|
||||
FPoint *prevfpt = fcu->fpt;
|
||||
FPoint *lastfpt = prevfpt + fcu->totvert - 1;
|
||||
|
||||
prevkey[0]= prevfpt->vec[0];
|
||||
prevkey[1]= prevfpt->vec[1];
|
||||
prevkey[0] = prevfpt->vec[0];
|
||||
prevkey[1] = prevfpt->vec[1];
|
||||
|
||||
lastkey[0]= lastfpt->vec[0];
|
||||
lastkey[1]= lastfpt->vec[1];
|
||||
lastkey[0] = lastfpt->vec[0];
|
||||
lastkey[1] = lastfpt->vec[1];
|
||||
}
|
||||
else
|
||||
return evaltime;
|
||||
@@ -575,18 +575,18 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
*/
|
||||
if (evaltime < prevkey[0]) {
|
||||
if (data->before_mode) {
|
||||
side= -1;
|
||||
mode= data->before_mode;
|
||||
cycles= data->before_cycles;
|
||||
ofs= prevkey[0];
|
||||
side = -1;
|
||||
mode = data->before_mode;
|
||||
cycles = data->before_cycles;
|
||||
ofs = prevkey[0];
|
||||
}
|
||||
}
|
||||
else if (evaltime > lastkey[0]) {
|
||||
if (data->after_mode) {
|
||||
side= 1;
|
||||
mode= data->after_mode;
|
||||
cycles= data->after_cycles;
|
||||
ofs= lastkey[0];
|
||||
side = 1;
|
||||
mode = data->after_mode;
|
||||
cycles = data->after_cycles;
|
||||
ofs = lastkey[0];
|
||||
}
|
||||
}
|
||||
if ((ELEM(0, side, mode)))
|
||||
@@ -594,22 +594,22 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
|
||||
/* find relative place within a cycle */
|
||||
{
|
||||
float cycdx=0, cycdy=0;
|
||||
float cycle= 0, cyct=0;
|
||||
float cycdx = 0, cycdy = 0;
|
||||
float cycle = 0, cyct = 0;
|
||||
|
||||
/* calculate period and amplitude (total height) of a cycle */
|
||||
cycdx= lastkey[0] - prevkey[0];
|
||||
cycdy= lastkey[1] - prevkey[1];
|
||||
cycdx = lastkey[0] - prevkey[0];
|
||||
cycdy = lastkey[1] - prevkey[1];
|
||||
|
||||
/* check if cycle is infinitely small, to be point of being impossible to use */
|
||||
if (cycdx == 0)
|
||||
return evaltime;
|
||||
|
||||
/* calculate the 'number' of the cycle */
|
||||
cycle= ((float)side * (evaltime - ofs) / cycdx);
|
||||
cycle = ((float)side * (evaltime - ofs) / cycdx);
|
||||
|
||||
/* calculate the time inside the cycle */
|
||||
cyct= fmod(evaltime - ofs, cycdx);
|
||||
cyct = fmod(evaltime - ofs, cycdx);
|
||||
|
||||
/* check that cyclic is still enabled for the specified time */
|
||||
if (cycles == 0) {
|
||||
@@ -641,19 +641,19 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
|
||||
}
|
||||
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
|
||||
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle+1) % 2)) {
|
||||
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) {
|
||||
/* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse
|
||||
* - for 'before' extrapolation, we need to flip in a different way, otherwise values past
|
||||
* then end of the curve get referenced (result of fmod will be negative, and with different phase)
|
||||
*/
|
||||
if (side < 0)
|
||||
evaltime= prevkey[0] - cyct;
|
||||
evaltime = prevkey[0] - cyct;
|
||||
else
|
||||
evaltime= lastkey[0] - cyct;
|
||||
evaltime = lastkey[0] - cyct;
|
||||
}
|
||||
else {
|
||||
/* the cycle is played normally... */
|
||||
evaltime= prevkey[0] + cyct;
|
||||
evaltime = prevkey[0] + cyct;
|
||||
}
|
||||
if (evaltime < prevkey[0]) evaltime += cycdx;
|
||||
}
|
||||
@@ -663,17 +663,17 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
tFCMED_Cycles *edata;
|
||||
|
||||
/* for now, this is just a float, but we could get more stuff... */
|
||||
fcm->edata= edata= MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles");
|
||||
edata->cycyofs= cycyofs;
|
||||
fcm->edata = edata = MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles");
|
||||
edata->cycyofs = cycyofs;
|
||||
}
|
||||
|
||||
/* return the new frame to evaluate */
|
||||
return evaltime;
|
||||
}
|
||||
|
||||
static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
static void fcm_cycles_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
{
|
||||
tFCMED_Cycles *edata= (tFCMED_Cycles *)fcm->edata;
|
||||
tFCMED_Cycles *edata = (tFCMED_Cycles *)fcm->edata;
|
||||
|
||||
/* use temp data */
|
||||
if (edata) {
|
||||
@@ -682,7 +682,7 @@ static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cva
|
||||
|
||||
/* free temp data */
|
||||
MEM_freeN(edata);
|
||||
fcm->edata= NULL;
|
||||
fcm->edata = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,21 +703,21 @@ static FModifierTypeInfo FMI_CYCLES = {
|
||||
|
||||
/* Noise F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_noise_new_data (void *mdata)
|
||||
static void fcm_noise_new_data(void *mdata)
|
||||
{
|
||||
FMod_Noise *data= (FMod_Noise *)mdata;
|
||||
FMod_Noise *data = (FMod_Noise *)mdata;
|
||||
|
||||
/* defaults */
|
||||
data->size= 1.0f;
|
||||
data->strength= 1.0f;
|
||||
data->phase= 1.0f;
|
||||
data->size = 1.0f;
|
||||
data->strength = 1.0f;
|
||||
data->phase = 1.0f;
|
||||
data->depth = 0;
|
||||
data->modification = FCM_NOISE_MODIF_REPLACE;
|
||||
}
|
||||
|
||||
static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_Noise *data= (FMod_Noise *)fcm->data;
|
||||
FMod_Noise *data = (FMod_Noise *)fcm->data;
|
||||
float noise;
|
||||
|
||||
/* generate noise using good ol' Blender Noise
|
||||
@@ -729,17 +729,17 @@ static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cval
|
||||
/* combine the noise with existing motion data */
|
||||
switch (data->modification) {
|
||||
case FCM_NOISE_MODIF_ADD:
|
||||
*cvalue= *cvalue + noise * data->strength;
|
||||
*cvalue = *cvalue + noise * data->strength;
|
||||
break;
|
||||
case FCM_NOISE_MODIF_SUBTRACT:
|
||||
*cvalue= *cvalue - noise * data->strength;
|
||||
*cvalue = *cvalue - noise * data->strength;
|
||||
break;
|
||||
case FCM_NOISE_MODIF_MULTIPLY:
|
||||
*cvalue= *cvalue * noise * data->strength;
|
||||
*cvalue = *cvalue * noise * data->strength;
|
||||
break;
|
||||
case FCM_NOISE_MODIF_REPLACE:
|
||||
default:
|
||||
*cvalue= *cvalue + (noise - 0.5f) * data->strength;
|
||||
*cvalue = *cvalue + (noise - 0.5f) * data->strength;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -781,25 +781,25 @@ static FModifierTypeInfo FMI_FILTER = {
|
||||
|
||||
/* Python F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_python_free (FModifier *fcm)
|
||||
static void fcm_python_free(FModifier *fcm)
|
||||
{
|
||||
FMod_Python *data= (FMod_Python *)fcm->data;
|
||||
FMod_Python *data = (FMod_Python *)fcm->data;
|
||||
|
||||
/* id-properties */
|
||||
IDP_FreeProperty(data->prop);
|
||||
MEM_freeN(data->prop);
|
||||
}
|
||||
|
||||
static void fcm_python_new_data (void *mdata)
|
||||
static void fcm_python_new_data(void *mdata)
|
||||
{
|
||||
FMod_Python *data= (FMod_Python *)mdata;
|
||||
FMod_Python *data = (FMod_Python *)mdata;
|
||||
|
||||
/* everything should be set correctly by calloc, except for the prop->type constant.*/
|
||||
data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps");
|
||||
data->prop->type = IDP_GROUP;
|
||||
}
|
||||
|
||||
static void fcm_python_copy (FModifier *fcm, FModifier *src)
|
||||
static void fcm_python_copy(FModifier *fcm, FModifier *src)
|
||||
{
|
||||
FMod_Python *pymod = (FMod_Python *)fcm->data;
|
||||
FMod_Python *opymod = (FMod_Python *)src->data;
|
||||
@@ -807,7 +807,7 @@ static void fcm_python_copy (FModifier *fcm, FModifier *src)
|
||||
pymod->prop = IDP_CopyProperty(opymod->prop);
|
||||
}
|
||||
|
||||
static void fcm_python_evaluate (FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime))
|
||||
static void fcm_python_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime))
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
//FMod_Python *data= (FMod_Python *)fcm->data;
|
||||
@@ -836,9 +836,9 @@ static FModifierTypeInfo FMI_PYTHON = {
|
||||
|
||||
/* Limits F-Curve Modifier --------------------------- */
|
||||
|
||||
static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
{
|
||||
FMod_Limits *data= (FMod_Limits *)fcm->data;
|
||||
FMod_Limits *data = (FMod_Limits *)fcm->data;
|
||||
|
||||
/* check for the time limits */
|
||||
if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin))
|
||||
@@ -850,15 +850,15 @@ static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(
|
||||
return evaltime;
|
||||
}
|
||||
|
||||
static void fcm_limits_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
{
|
||||
FMod_Limits *data= (FMod_Limits *)fcm->data;
|
||||
FMod_Limits *data = (FMod_Limits *)fcm->data;
|
||||
|
||||
/* value limits now */
|
||||
if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin))
|
||||
*cvalue= data->rect.ymin;
|
||||
*cvalue = data->rect.ymin;
|
||||
if ((data->flag & FCM_LIMIT_YMAX) && (*cvalue > data->rect.ymax))
|
||||
*cvalue= data->rect.ymax;
|
||||
*cvalue = data->rect.ymax;
|
||||
}
|
||||
|
||||
static FModifierTypeInfo FMI_LIMITS = {
|
||||
@@ -878,18 +878,18 @@ static FModifierTypeInfo FMI_LIMITS = {
|
||||
|
||||
/* Stepped F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_stepped_new_data (void *mdata)
|
||||
static void fcm_stepped_new_data(void *mdata)
|
||||
{
|
||||
FMod_Stepped *data= (FMod_Stepped *)mdata;
|
||||
FMod_Stepped *data = (FMod_Stepped *)mdata;
|
||||
|
||||
/* just need to set the step-size to 2-frames by default */
|
||||
// XXX: or would 5 be more normal?
|
||||
data->step_size = 2.0f;
|
||||
}
|
||||
|
||||
static float fcm_stepped_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
{
|
||||
FMod_Stepped *data= (FMod_Stepped *)fcm->data;
|
||||
FMod_Stepped *data = (FMod_Stepped *)fcm->data;
|
||||
int snapblock;
|
||||
|
||||
/* check range clamping to see if we should alter the timing to achieve the desired results */
|
||||
@@ -936,27 +936,27 @@ static FModifierTypeInfo FMI_STEPPED = {
|
||||
|
||||
/* These globals only ever get directly accessed in this file */
|
||||
static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES];
|
||||
static short FMI_INIT= 1; /* when non-zero, the list needs to be updated */
|
||||
static short FMI_INIT = 1; /* when non-zero, the list needs to be updated */
|
||||
|
||||
/* This function only gets called when FMI_INIT is non-zero */
|
||||
static void fmods_init_typeinfo (void)
|
||||
static void fmods_init_typeinfo(void)
|
||||
{
|
||||
fmodifiersTypeInfo[0]= NULL; /* 'Null' F-Curve Modifier */
|
||||
fmodifiersTypeInfo[1]= &FMI_GENERATOR; /* Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[2]= &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[3]= &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
|
||||
fmodifiersTypeInfo[4]= &FMI_CYCLES; /* Cycles F-Curve Modifier */
|
||||
fmodifiersTypeInfo[5]= &FMI_NOISE; /* Apply-Noise F-Curve Modifier */
|
||||
fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
|
||||
fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */
|
||||
fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */
|
||||
fmodifiersTypeInfo[9]= &FMI_STEPPED; /* Stepped F-Curve Modifier */
|
||||
fmodifiersTypeInfo[0] = NULL; /* 'Null' F-Curve Modifier */
|
||||
fmodifiersTypeInfo[1] = &FMI_GENERATOR; /* Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[2] = &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[3] = &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
|
||||
fmodifiersTypeInfo[4] = &FMI_CYCLES; /* Cycles F-Curve Modifier */
|
||||
fmodifiersTypeInfo[5] = &FMI_NOISE; /* Apply-Noise F-Curve Modifier */
|
||||
fmodifiersTypeInfo[6] = NULL /*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
|
||||
fmodifiersTypeInfo[7] = &FMI_PYTHON; /* Custom Python F-Curve Modifier */
|
||||
fmodifiersTypeInfo[8] = &FMI_LIMITS; /* Limits F-Curve Modifier */
|
||||
fmodifiersTypeInfo[9] = &FMI_STEPPED; /* Stepped F-Curve Modifier */
|
||||
}
|
||||
|
||||
/* This function should be used for getting the appropriate type-info when only
|
||||
* a F-Curve modifier type is known
|
||||
*/
|
||||
FModifierTypeInfo *get_fmodifier_typeinfo (int type)
|
||||
FModifierTypeInfo *get_fmodifier_typeinfo(int type)
|
||||
{
|
||||
/* initialize the type-info list? */
|
||||
if (FMI_INIT) {
|
||||
@@ -966,7 +966,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type)
|
||||
|
||||
/* only return for valid types */
|
||||
if ( (type >= FMODIFIER_TYPE_NULL) &&
|
||||
(type <= FMODIFIER_NUM_TYPES ) )
|
||||
(type <= FMODIFIER_NUM_TYPES) )
|
||||
{
|
||||
/* there shouldn't be any segfaults here... */
|
||||
return fmodifiersTypeInfo[type];
|
||||
@@ -981,7 +981,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type)
|
||||
/* This function should always be used to get the appropriate type-info, as it
|
||||
* has checks which prevent segfaults in some weird cases.
|
||||
*/
|
||||
FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm)
|
||||
FModifierTypeInfo *fmodifier_get_typeinfo(FModifier *fcm)
|
||||
{
|
||||
/* only return typeinfo for valid modifiers */
|
||||
if (fcm)
|
||||
@@ -993,9 +993,9 @@ FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm)
|
||||
/* API --------------------------- */
|
||||
|
||||
/* Add a new F-Curve Modifier to the given F-Curve of a certain type */
|
||||
FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
FModifier *add_fmodifier(ListBase *modifiers, int type)
|
||||
{
|
||||
FModifierTypeInfo *fmi= get_fmodifier_typeinfo(type);
|
||||
FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
|
||||
FModifier *fcm;
|
||||
|
||||
/* sanity checks */
|
||||
@@ -1011,7 +1011,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
}
|
||||
|
||||
/* add modifier itself */
|
||||
fcm= MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
|
||||
fcm = MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
|
||||
fcm->type = type;
|
||||
fcm->flag = FMODIFIER_FLAG_EXPANDED;
|
||||
fcm->influence = 1.0f;
|
||||
@@ -1022,7 +1022,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
fcm->flag |= FMODIFIER_FLAG_ACTIVE;
|
||||
|
||||
/* add modifier's data */
|
||||
fcm->data= MEM_callocN(fmi->size, fmi->structName);
|
||||
fcm->data = MEM_callocN(fmi->size, fmi->structName);
|
||||
|
||||
/* init custom settings if necessary */
|
||||
if (fmi->new_data)
|
||||
@@ -1033,9 +1033,9 @@ FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
}
|
||||
|
||||
/* Make a copy of the specified F-Modifier */
|
||||
FModifier *copy_fmodifier (FModifier *src)
|
||||
FModifier *copy_fmodifier(FModifier *src)
|
||||
{
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(src);
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src);
|
||||
FModifier *dst;
|
||||
|
||||
/* sanity check */
|
||||
@@ -1065,11 +1065,11 @@ void copy_fmodifiers(ListBase *dst, ListBase *src)
|
||||
if (ELEM(NULL, dst, src))
|
||||
return;
|
||||
|
||||
dst->first= dst->last= NULL;
|
||||
dst->first = dst->last = NULL;
|
||||
BLI_duplicatelist(dst, src);
|
||||
|
||||
for (fcm=dst->first, srcfcm=src->first; fcm && srcfcm; srcfcm=srcfcm->next, fcm=fcm->next) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
for (fcm = dst->first, srcfcm = src->first; fcm && srcfcm; srcfcm = srcfcm->next, fcm = fcm->next) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
/* make a new copy of the F-Modifier's data */
|
||||
fcm->data = MEM_dupallocN(fcm->data);
|
||||
@@ -1083,7 +1083,7 @@ void copy_fmodifiers(ListBase *dst, ListBase *src)
|
||||
/* Remove and free the given F-Modifier from the given stack */
|
||||
int remove_fmodifier(ListBase *modifiers, FModifier *fcm)
|
||||
{
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
/* sanity check */
|
||||
if (fcm == NULL)
|
||||
@@ -1121,14 +1121,14 @@ void free_fmodifiers(ListBase *modifiers)
|
||||
return;
|
||||
|
||||
/* free each modifier in order - modifier is unlinked from list and freed */
|
||||
for (fcm= modifiers->first; fcm; fcm= fmn) {
|
||||
fmn= fcm->next;
|
||||
for (fcm = modifiers->first; fcm; fcm = fmn) {
|
||||
fmn = fcm->next;
|
||||
remove_fmodifier(modifiers, fcm);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the active F-Modifier */
|
||||
FModifier *find_active_fmodifier (ListBase *modifiers)
|
||||
FModifier *find_active_fmodifier(ListBase *modifiers)
|
||||
{
|
||||
FModifier *fcm;
|
||||
|
||||
@@ -1137,7 +1137,7 @@ FModifier *find_active_fmodifier (ListBase *modifiers)
|
||||
return NULL;
|
||||
|
||||
/* loop over modifiers until 'active' one is found */
|
||||
for (fcm= modifiers->first; fcm; fcm= fcm->next) {
|
||||
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
|
||||
if (fcm->flag & FMODIFIER_FLAG_ACTIVE)
|
||||
return fcm;
|
||||
}
|
||||
@@ -1156,7 +1156,7 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
|
||||
return;
|
||||
|
||||
/* deactivate all, and set current one active */
|
||||
for (fm= modifiers->first; fm; fm= fm->next)
|
||||
for (fm = modifiers->first; fm; fm = fm->next)
|
||||
fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
|
||||
|
||||
/* make given modifier active */
|
||||
@@ -1181,15 +1181,15 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
|
||||
return 0;
|
||||
|
||||
/* find the first mdifier fitting these criteria */
|
||||
for (fcm= modifiers->first; fcm; fcm= fcm->next) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
short mOk=1, aOk=1; /* by default 1, so that when only one test, won't fail */
|
||||
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */
|
||||
|
||||
/* check if applicable ones are fullfilled */
|
||||
if (mtype)
|
||||
mOk= (fcm->type == mtype);
|
||||
mOk = (fcm->type == mtype);
|
||||
if (acttype > -1)
|
||||
aOk= (fmi->acttype == acttype);
|
||||
aOk = (fmi->acttype == acttype);
|
||||
|
||||
/* if both are ok, we've found a hit */
|
||||
if (mOk && aOk)
|
||||
@@ -1203,7 +1203,7 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
|
||||
/* Evaluation API --------------------------- */
|
||||
|
||||
/* helper function - calculate influence of FModifier */
|
||||
static float eval_fmodifier_influence (FModifier *fcm, float evaltime)
|
||||
static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
|
||||
{
|
||||
float influence;
|
||||
|
||||
@@ -1270,8 +1270,8 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f
|
||||
* effect, which should get us the desired effects when using layered time manipulations
|
||||
* (such as multiple 'stepped' modifiers in sequence, causing different stepping rates)
|
||||
*/
|
||||
for (fcm= modifiers->last; fcm; fcm= fcm->prev) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
for (fcm = modifiers->last; fcm; fcm = fcm->prev) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
if (fmi == NULL)
|
||||
continue;
|
||||
@@ -1279,12 +1279,12 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f
|
||||
/* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results)
|
||||
* hence we shouldn't bother seeing what it would do given the chance
|
||||
*/
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 ||
|
||||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
|
||||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
|
||||
{
|
||||
/* only evaluate if there's a callback for this */
|
||||
if (fmi->evaluate_modifier_time) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
float influence = eval_fmodifier_influence(fcm, evaltime);
|
||||
float nval = fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime);
|
||||
|
||||
@@ -1310,18 +1310,18 @@ void evaluate_value_fmodifiers(ListBase *modifiers, FCurve *fcu, float *cvalue,
|
||||
return;
|
||||
|
||||
/* evaluate modifiers */
|
||||
for (fcm= modifiers->first; fcm; fcm= fcm->next) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
if (fmi == NULL)
|
||||
continue;
|
||||
|
||||
/* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 ||
|
||||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
|
||||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
|
||||
{
|
||||
if (fmi->evaluate_modifier) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
float influence = eval_fmodifier_influence(fcm, evaltime);
|
||||
float nval = *cvalue;
|
||||
|
||||
@@ -1350,8 +1350,8 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
|
||||
}
|
||||
|
||||
/* temporarily, disable driver while we sample, so that they don't influence the outcome */
|
||||
driver= fcu->driver;
|
||||
fcu->driver= NULL;
|
||||
driver = fcu->driver;
|
||||
fcu->driver = NULL;
|
||||
|
||||
/* bake the modifiers, by sampling the curve at each frame */
|
||||
fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
|
||||
@@ -1360,5 +1360,5 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
|
||||
free_fmodifiers(&fcu->modifiers);
|
||||
|
||||
/* restore driver */
|
||||
fcu->driver= driver;
|
||||
fcu->driver = driver;
|
||||
}
|
||||
|
||||
@@ -47,16 +47,16 @@ static char idp_size_table[] = {
|
||||
1, /*strings*/
|
||||
sizeof(int),
|
||||
sizeof(float),
|
||||
sizeof(float)*3, /*Vector type, deprecated*/
|
||||
sizeof(float)*16, /*Matrix type, deprecated*/
|
||||
sizeof(float) * 3, /*Vector type, deprecated*/
|
||||
sizeof(float) * 16, /*Matrix type, deprecated*/
|
||||
0, /*arrays don't have a fixed size*/
|
||||
sizeof(ListBase), /*Group type*/
|
||||
sizeof(void*),
|
||||
sizeof(void *),
|
||||
sizeof(double)
|
||||
};
|
||||
|
||||
/* ------------Property Array Type ----------- */
|
||||
#define GETPROP(prop, i) (((IDProperty*)(prop)->data.pointer)+(i))
|
||||
#define GETPROP(prop, i) (((IDProperty *)(prop)->data.pointer) + (i))
|
||||
|
||||
/* --------- property array type -------------*/
|
||||
|
||||
@@ -78,10 +78,10 @@ IDProperty *IDP_CopyIDPArray(IDProperty *array)
|
||||
IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp;
|
||||
int i;
|
||||
|
||||
*narray= *array;
|
||||
*narray = *array;
|
||||
|
||||
narray->data.pointer = MEM_dupallocN(array->data.pointer);
|
||||
for (i=0; i<narray->len; i++) {
|
||||
for (i = 0; i < narray->len; i++) {
|
||||
/* ok, the copy functions always allocate a new structure,
|
||||
* which doesn't work here. instead, simply copy the
|
||||
* contents of the new structure into the array cell,
|
||||
@@ -100,7 +100,7 @@ void IDP_FreeIDPArray(IDProperty *prop)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<prop->len; i++)
|
||||
for (i = 0; i < prop->len; i++)
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
|
||||
if (prop->data.pointer)
|
||||
@@ -124,22 +124,22 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index)
|
||||
|
||||
IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item)
|
||||
{
|
||||
IDP_ResizeIDPArray(prop, prop->len+1);
|
||||
IDP_SetIndexArray(prop, prop->len-1, item);
|
||||
IDP_ResizeIDPArray(prop, prop->len + 1);
|
||||
IDP_SetIndexArray(prop, prop->len - 1, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
|
||||
{
|
||||
void *newarr;
|
||||
int newsize=newlen;
|
||||
int newsize = newlen;
|
||||
|
||||
/*first check if the array buffer size has room*/
|
||||
/*if newlen is 200 chars less then totallen, reallocate anyway*/
|
||||
if (newlen <= prop->totallen && prop->totallen - newlen < 200) {
|
||||
int i;
|
||||
|
||||
for (i=newlen; i<prop->len; i++)
|
||||
for (i = newlen; i < prop->len; i++)
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
|
||||
prop->len = newlen;
|
||||
@@ -156,18 +156,18 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
|
||||
*/
|
||||
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
|
||||
|
||||
newarr = MEM_callocN(sizeof(IDProperty)*newsize, "idproperty array resized");
|
||||
newarr = MEM_callocN(sizeof(IDProperty) * newsize, "idproperty array resized");
|
||||
if (newlen >= prop->len) {
|
||||
/* newlen is bigger*/
|
||||
memcpy(newarr, prop->data.pointer, prop->len*sizeof(IDProperty));
|
||||
memcpy(newarr, prop->data.pointer, prop->len * sizeof(IDProperty));
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
/* newlen is smaller*/
|
||||
for (i=newlen; i<prop->len; i++) {
|
||||
for (i = newlen; i < prop->len; i++) {
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
}
|
||||
memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty));
|
||||
memcpy(newarr, prop->data.pointer, newlen * sizeof(IDProperty));
|
||||
}
|
||||
|
||||
if (prop->data.pointer)
|
||||
@@ -185,21 +185,21 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
|
||||
|
||||
if (newlen >= prop->len) {
|
||||
/* bigger */
|
||||
IDProperty **array= newarr;
|
||||
IDProperty **array = newarr;
|
||||
IDPropertyTemplate val;
|
||||
int a;
|
||||
|
||||
for (a=prop->len; a<newlen; a++) {
|
||||
for (a = prop->len; a < newlen; a++) {
|
||||
val.i = 0; /* silence MSVC warning about uninitialized var when debugging */
|
||||
array[a]= IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
|
||||
array[a] = IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* smaller */
|
||||
IDProperty **array= prop->data.pointer;
|
||||
IDProperty **array = prop->data.pointer;
|
||||
int a;
|
||||
|
||||
for (a=newlen; a<prop->len; a++) {
|
||||
for (a = newlen; a < prop->len; a++) {
|
||||
IDP_FreeProperty(array[a]);
|
||||
MEM_freeN(array[a]);
|
||||
}
|
||||
@@ -210,7 +210,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
|
||||
void IDP_ResizeArray(IDProperty *prop, int newlen)
|
||||
{
|
||||
void *newarr;
|
||||
int newsize=newlen;
|
||||
int newsize = newlen;
|
||||
|
||||
/*first check if the array buffer size has room*/
|
||||
/*if newlen is 200 chars less then totallen, reallocate anyway*/
|
||||
@@ -230,16 +230,16 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
|
||||
*/
|
||||
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
|
||||
|
||||
newarr = MEM_callocN(idp_size_table[(int)prop->subtype]*newsize, "idproperty array resized");
|
||||
newarr = MEM_callocN(idp_size_table[(int)prop->subtype] * newsize, "idproperty array resized");
|
||||
if (newlen >= prop->len) {
|
||||
/* newlen is bigger*/
|
||||
memcpy(newarr, prop->data.pointer, prop->len*idp_size_table[(int)prop->subtype]);
|
||||
memcpy(newarr, prop->data.pointer, prop->len * idp_size_table[(int)prop->subtype]);
|
||||
idp_resize_group_array(prop, newlen, newarr);
|
||||
}
|
||||
else {
|
||||
/* newlen is smaller*/
|
||||
idp_resize_group_array(prop, newlen, newarr);
|
||||
memcpy(newarr, prop->data.pointer, newlen*idp_size_table[(int)prop->subtype]);
|
||||
memcpy(newarr, prop->data.pointer, newlen * idp_size_table[(int)prop->subtype]);
|
||||
}
|
||||
|
||||
MEM_freeN(prop->data.pointer);
|
||||
@@ -257,8 +257,8 @@ void IDP_FreeArray(IDProperty *prop)
|
||||
}
|
||||
|
||||
|
||||
static IDProperty *idp_generic_copy(IDProperty *prop)
|
||||
{
|
||||
static IDProperty *idp_generic_copy(IDProperty *prop)
|
||||
{
|
||||
IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup");
|
||||
|
||||
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
|
||||
@@ -268,7 +268,7 @@ void IDP_FreeArray(IDProperty *prop)
|
||||
newp->data.val2 = prop->data.val2;
|
||||
|
||||
return newp;
|
||||
}
|
||||
}
|
||||
|
||||
static IDProperty *IDP_CopyArray(IDProperty *prop)
|
||||
{
|
||||
@@ -278,11 +278,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
|
||||
newp->data.pointer = MEM_dupallocN(prop->data.pointer);
|
||||
|
||||
if (prop->type == IDP_GROUP) {
|
||||
IDProperty **array= newp->data.pointer;
|
||||
IDProperty **array = newp->data.pointer;
|
||||
int a;
|
||||
|
||||
for (a=0; a<prop->len; a++)
|
||||
array[a]= IDP_CopyProperty(array[a]);
|
||||
for (a = 0; a < prop->len; a++)
|
||||
array[a] = IDP_CopyProperty(array[a]);
|
||||
}
|
||||
}
|
||||
newp->len = prop->len;
|
||||
@@ -294,12 +294,12 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
|
||||
|
||||
/*taken from readfile.c*/
|
||||
#define SWITCH_LONGINT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
|
||||
s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
|
||||
s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
|
||||
s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
|
||||
char s_i, *p_i; \
|
||||
p_i = (char *)& (a); \
|
||||
s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \
|
||||
s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \
|
||||
s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \
|
||||
s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; }
|
||||
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen)
|
||||
int stlen = strlen(st);
|
||||
|
||||
if (maxlen > 0 && maxlen < stlen)
|
||||
stlen= maxlen;
|
||||
stlen = maxlen;
|
||||
|
||||
if (prop->subtype == IDP_STRING_SUB_BYTE) {
|
||||
IDP_ResizeArray(prop, stlen);
|
||||
@@ -396,14 +396,14 @@ void IDP_FreeString(IDProperty *prop)
|
||||
|
||||
void IDP_LinkID(IDProperty *prop, ID *id)
|
||||
{
|
||||
if (prop->data.pointer) ((ID*)prop->data.pointer)->us--;
|
||||
if (prop->data.pointer) ((ID *)prop->data.pointer)->us--;
|
||||
prop->data.pointer = id;
|
||||
id_us_plus(id);
|
||||
}
|
||||
|
||||
void IDP_UnlinkID(IDProperty *prop)
|
||||
{
|
||||
((ID*)prop->data.pointer)->us--;
|
||||
((ID *)prop->data.pointer)->us--;
|
||||
}
|
||||
|
||||
/*-------- Group Functions -------*/
|
||||
@@ -414,7 +414,7 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
|
||||
IDProperty *newp = idp_generic_copy(prop), *link;
|
||||
newp->len = prop->len;
|
||||
|
||||
for (link=prop->data.group.first; link; link=link->next) {
|
||||
for (link = prop->data.group.first; link; link = link->next) {
|
||||
BLI_addtail(&newp->data.group, IDP_CopyProperty(link));
|
||||
}
|
||||
|
||||
@@ -426,22 +426,22 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
|
||||
void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
|
||||
{
|
||||
IDProperty *other, *prop;
|
||||
for (prop=src->data.group.first; prop; prop=prop->next) {
|
||||
other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
|
||||
if (other && prop->type==other->type) {
|
||||
for (prop = src->data.group.first; prop; prop = prop->next) {
|
||||
other = BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
|
||||
if (other && prop->type == other->type) {
|
||||
switch (prop->type) {
|
||||
case IDP_INT:
|
||||
case IDP_FLOAT:
|
||||
case IDP_DOUBLE:
|
||||
other->data= prop->data;
|
||||
other->data = prop->data;
|
||||
break;
|
||||
case IDP_GROUP:
|
||||
IDP_SyncGroupValues(other, prop);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
IDProperty *tmp= other;
|
||||
IDProperty *copy= IDP_CopyProperty(prop);
|
||||
IDProperty *tmp = other;
|
||||
IDProperty *copy = IDP_CopyProperty(prop);
|
||||
|
||||
BLI_insertlinkafter(&dest->data.group, other, copy);
|
||||
BLI_remlink(&dest->data.group, tmp);
|
||||
@@ -460,8 +460,8 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
|
||||
void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
|
||||
{
|
||||
IDProperty *loop, *prop;
|
||||
for (prop=src->data.group.first; prop; prop=prop->next) {
|
||||
for (loop=dest->data.group.first; loop; loop=loop->next) {
|
||||
for (prop = src->data.group.first; prop; prop = prop->next) {
|
||||
for (loop = dest->data.group.first; loop; loop = loop->next) {
|
||||
if (strcmp(loop->name, prop->name) == 0) {
|
||||
IDProperty *copy = IDP_CopyProperty(prop);
|
||||
|
||||
@@ -489,7 +489,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
|
||||
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
|
||||
{
|
||||
IDProperty *loop;
|
||||
if ((loop= IDP_GetPropertyFromGroup(group, prop->name))) {
|
||||
if ((loop = IDP_GetPropertyFromGroup(group, prop->name))) {
|
||||
BLI_insertlink(&group->data.group, loop, prop);
|
||||
|
||||
BLI_remlink(&group->data.group, loop);
|
||||
@@ -539,7 +539,7 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
|
||||
|
||||
IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type)
|
||||
{
|
||||
IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name);
|
||||
IDProperty *idprop = IDP_GetPropertyFromGroup(prop, name);
|
||||
return (idprop && idprop->type == type) ? idprop : NULL;
|
||||
}
|
||||
|
||||
@@ -553,20 +553,20 @@ void *IDP_GetGroupIterator(IDProperty *prop)
|
||||
IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter");
|
||||
iter->next = prop->data.group.first;
|
||||
iter->parent = prop;
|
||||
return (void*) iter;
|
||||
return (void *) iter;
|
||||
}
|
||||
|
||||
IDProperty *IDP_GroupIterNext(void *vself)
|
||||
{
|
||||
IDPIter *self = (IDPIter*) vself;
|
||||
Link *next = (Link*) self->next;
|
||||
IDPIter *self = (IDPIter *) vself;
|
||||
Link *next = (Link *) self->next;
|
||||
if (self->next == NULL) {
|
||||
MEM_freeN(self);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
self->next = next->next;
|
||||
return (void*) next;
|
||||
return (void *) next;
|
||||
}
|
||||
|
||||
void IDP_FreeIterBeforeEnd(void *vself)
|
||||
@@ -581,7 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself)
|
||||
static void IDP_FreeGroup(IDProperty *prop)
|
||||
{
|
||||
IDProperty *loop;
|
||||
for (loop=prop->data.group.first; loop; loop=loop->next) {
|
||||
for (loop = prop->data.group.first; loop; loop = loop->next) {
|
||||
IDP_FreeProperty(loop);
|
||||
}
|
||||
BLI_freelistN(&prop->data.group);
|
||||
@@ -635,7 +635,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0);
|
||||
else if (prop1->type == IDP_ARRAY) {
|
||||
if (prop1->len == prop2->len && prop1->subtype == prop2->subtype)
|
||||
return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype]*prop1->len);
|
||||
return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -645,8 +645,8 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
|
||||
return 0;
|
||||
|
||||
for (link1=prop1->data.group.first; link1; link1=link1->next) {
|
||||
link2= IDP_GetPropertyFromGroup(prop2, link1->name);
|
||||
for (link1 = prop1->data.group.first; link1; link1 = link1->next) {
|
||||
link2 = IDP_GetPropertyFromGroup(prop2, link1->name);
|
||||
|
||||
if (!IDP_EqualsProperties(link1, link2))
|
||||
return 0;
|
||||
@@ -655,14 +655,14 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
return 1;
|
||||
}
|
||||
else if (prop1->type == IDP_IDPARRAY) {
|
||||
IDProperty *array1= IDP_IDPArray(prop1);
|
||||
IDProperty *array2= IDP_IDPArray(prop2);
|
||||
IDProperty *array1 = IDP_IDPArray(prop1);
|
||||
IDProperty *array2 = IDP_IDPArray(prop2);
|
||||
int i;
|
||||
|
||||
if (prop1->len != prop2->len)
|
||||
return 0;
|
||||
|
||||
for (i=0; i<prop1->len; i++)
|
||||
for (i = 0; i < prop1->len; i++)
|
||||
if (!IDP_EqualsProperties(&array1[i], &array2[i]))
|
||||
return 0;
|
||||
}
|
||||
@@ -673,7 +673,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
/* 'val' is never NULL, don't check */
|
||||
IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
|
||||
{
|
||||
IDProperty *prop=NULL;
|
||||
IDProperty *prop = NULL;
|
||||
|
||||
switch (type) {
|
||||
case IDP_INT:
|
||||
@@ -682,11 +682,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
|
||||
break;
|
||||
case IDP_FLOAT:
|
||||
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
|
||||
*(float*)&prop->data.val = val->f;
|
||||
*(float *)&prop->data.val = val->f;
|
||||
break;
|
||||
case IDP_DOUBLE:
|
||||
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
|
||||
*(double*)&prop->data.val = val->d;
|
||||
*(double *)&prop->data.val = val->d;
|
||||
break;
|
||||
case IDP_ARRAY:
|
||||
{
|
||||
@@ -699,7 +699,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
|
||||
prop = MEM_callocN(sizeof(IDProperty), "IDProperty array");
|
||||
prop->subtype = val->array.type;
|
||||
if (val->array.len)
|
||||
prop->data.pointer = MEM_callocN(idp_size_table[val->array.type]*val->array.len, "id property array");
|
||||
prop->data.pointer = MEM_callocN(idp_size_table[val->array.type] * val->array.len, "id property array");
|
||||
prop->len = prop->totallen = val->array.len;
|
||||
break;
|
||||
}
|
||||
@@ -724,7 +724,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
|
||||
prop->len = prop->totallen = val->string.len;
|
||||
memcpy(prop->data.pointer, st, val->string.len);
|
||||
}
|
||||
prop->subtype= IDP_STRING_SUB_BYTE;
|
||||
prop->subtype = IDP_STRING_SUB_BYTE;
|
||||
}
|
||||
else {
|
||||
if (st == NULL) {
|
||||
@@ -738,7 +738,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
|
||||
prop->len = prop->totallen = stlen;
|
||||
memcpy(prop->data.pointer, st, stlen);
|
||||
}
|
||||
prop->subtype= IDP_STRING_SUB_UTF8;
|
||||
prop->subtype = IDP_STRING_SUB_UTF8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
|
||||
|
||||
/* blank image */
|
||||
if (rect_float) {
|
||||
for (y= 0; y<height; y++) {
|
||||
for (x= 0; x<width; x++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
copy_v4_v4(rect_float, color);
|
||||
rect_float+= 4;
|
||||
rect_float += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,14 +52,14 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
|
||||
|
||||
rgba_float_to_uchar(ccol, color);
|
||||
|
||||
for (y= 0; y<height; y++) {
|
||||
for (x= 0; x<width; x++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
|
||||
rect[0]= ccol[0];
|
||||
rect[1]= ccol[1];
|
||||
rect[2]= ccol[2];
|
||||
rect[3]= ccol[3];
|
||||
rect+= 4;
|
||||
rect[0] = ccol[0];
|
||||
rect[1] = ccol[1];
|
||||
rect[2] = ccol[2];
|
||||
rect[3] = ccol[3];
|
||||
rect += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,84 +71,84 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
|
||||
/* these two passes could be combined into one, but it's more readable and
|
||||
* easy to tweak like this, speed isn't really that much of an issue in this situation... */
|
||||
|
||||
int checkerwidth= 32, dark= 1;
|
||||
int checkerwidth = 32, dark = 1;
|
||||
int x, y;
|
||||
|
||||
unsigned char *rect_orig= rect;
|
||||
float *rect_float_orig= rect_float;
|
||||
unsigned char *rect_orig = rect;
|
||||
float *rect_float_orig = rect_float;
|
||||
|
||||
|
||||
float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b;
|
||||
float h = 0.0, hoffs = 0.0, hue = 0.0, s = 0.9, v = 0.9, r, g, b;
|
||||
|
||||
/* checkers */
|
||||
for (y= 0; y<height; y++) {
|
||||
dark= powf(-1.0f, floorf(y / checkerwidth));
|
||||
for (y = 0; y < height; y++) {
|
||||
dark = powf(-1.0f, floorf(y / checkerwidth));
|
||||
|
||||
for (x= 0; x<width; x++) {
|
||||
if (x % checkerwidth == 0) dark= -dark;
|
||||
for (x = 0; x < width; x++) {
|
||||
if (x % checkerwidth == 0) dark = -dark;
|
||||
|
||||
if (rect_float) {
|
||||
if (dark > 0) {
|
||||
rect_float[0]= rect_float[1]= rect_float[2]= 0.25f;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = rect_float[1] = rect_float[2] = 0.25f;
|
||||
rect_float[3] = 1.0f;
|
||||
}
|
||||
else {
|
||||
rect_float[0]= rect_float[1]= rect_float[2]= 0.58f;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = rect_float[1] = rect_float[2] = 0.58f;
|
||||
rect_float[3] = 1.0f;
|
||||
}
|
||||
rect_float+= 4;
|
||||
rect_float += 4;
|
||||
}
|
||||
else {
|
||||
if (dark > 0) {
|
||||
rect[0]= rect[1]= rect[2]= 64;
|
||||
rect[3]= 255;
|
||||
rect[0] = rect[1] = rect[2] = 64;
|
||||
rect[3] = 255;
|
||||
}
|
||||
else {
|
||||
rect[0]= rect[1]= rect[2]= 150;
|
||||
rect[3]= 255;
|
||||
rect[0] = rect[1] = rect[2] = 150;
|
||||
rect[3] = 255;
|
||||
}
|
||||
rect+= 4;
|
||||
rect += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rect= rect_orig;
|
||||
rect_float= rect_float_orig;
|
||||
rect = rect_orig;
|
||||
rect_float = rect_float_orig;
|
||||
|
||||
/* 2nd pass, colored + */
|
||||
for (y= 0; y<height; y++) {
|
||||
hoffs= 0.125f * floorf(y / checkerwidth);
|
||||
for (y = 0; y < height; y++) {
|
||||
hoffs = 0.125f * floorf(y / checkerwidth);
|
||||
|
||||
for (x= 0; x<width; x++) {
|
||||
h= 0.125f * floorf(x / checkerwidth);
|
||||
for (x = 0; x < width; x++) {
|
||||
h = 0.125f * floorf(x / checkerwidth);
|
||||
|
||||
if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 4) &&
|
||||
(fabs((y % checkerwidth) - (checkerwidth / 2)) < 4)) {
|
||||
(fabs((y % checkerwidth) - (checkerwidth / 2)) < 4)) {
|
||||
|
||||
if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 1) ||
|
||||
(fabs((y % checkerwidth) - (checkerwidth / 2)) < 1)) {
|
||||
(fabs((y % checkerwidth) - (checkerwidth / 2)) < 1)) {
|
||||
|
||||
hue= fmodf(fabs(h-hoffs), 1.0f);
|
||||
hue = fmodf(fabs(h - hoffs), 1.0f);
|
||||
hsv_to_rgb(hue, s, v, &r, &g, &b);
|
||||
|
||||
if (rect) {
|
||||
rect[0]= (char)(r * 255.0f);
|
||||
rect[1]= (char)(g * 255.0f);
|
||||
rect[2]= (char)(b * 255.0f);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)(r * 255.0f);
|
||||
rect[1] = (char)(g * 255.0f);
|
||||
rect[2] = (char)(b * 255.0f);
|
||||
rect[3] = 255;
|
||||
}
|
||||
|
||||
if (rect_float) {
|
||||
rect_float[0]= r;
|
||||
rect_float[1]= g;
|
||||
rect_float[2]= b;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = r;
|
||||
rect_float[1] = g;
|
||||
rect_float[2] = b;
|
||||
rect_float[3] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rect_float) rect_float+= 4;
|
||||
if (rect) rect+= 4;
|
||||
if (rect_float) rect_float += 4;
|
||||
if (rect) rect += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
|
||||
|
||||
/* Utility functions for BKE_image_buf_fill_checker_color */
|
||||
|
||||
#define BLEND_FLOAT(real, add) (real+add <= 1.0f) ? (real+add) : 1.0f
|
||||
#define BLEND_FLOAT(real, add) (real + add <= 1.0f) ? (real + add) : 1.0f
|
||||
#define BLEND_CHAR(real, add) ((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255
|
||||
|
||||
static void checker_board_color_fill(unsigned char *rect, float *rect_float, int width, int height)
|
||||
@@ -164,32 +164,32 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
|
||||
int hue_step, y, x;
|
||||
float hue, val, sat, r, g, b;
|
||||
|
||||
sat= 1.0;
|
||||
sat = 1.0;
|
||||
|
||||
hue_step= power_of_2_max_i(width / 8);
|
||||
if (hue_step < 8) hue_step= 8;
|
||||
hue_step = power_of_2_max_i(width / 8);
|
||||
if (hue_step < 8) hue_step = 8;
|
||||
|
||||
for (y= 0; y < height; y++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
|
||||
val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
|
||||
for (x= 0; x < width; x++) {
|
||||
hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step);
|
||||
val = 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
|
||||
for (x = 0; x < width; x++) {
|
||||
hue = (float)((double)(x / hue_step) * 1.0 / width * hue_step);
|
||||
hsv_to_rgb(hue, sat, val, &r, &g, &b);
|
||||
|
||||
if (rect) {
|
||||
rect[0]= (char)(r * 255.0f);
|
||||
rect[1]= (char)(g * 255.0f);
|
||||
rect[2]= (char)(b * 255.0f);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)(r * 255.0f);
|
||||
rect[1] = (char)(g * 255.0f);
|
||||
rect[2] = (char)(b * 255.0f);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
|
||||
if (rect_float) {
|
||||
rect_float[0]= r;
|
||||
rect_float[1]= g;
|
||||
rect_float[2]= b;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = r;
|
||||
rect_float[1] = g;
|
||||
rect_float[2] = b;
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
rect_float += 4;
|
||||
}
|
||||
@@ -200,42 +200,42 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
|
||||
static void checker_board_color_tint(unsigned char *rect, float *rect_float, int width, int height, int size, float blend)
|
||||
{
|
||||
int x, y;
|
||||
float blend_half= blend * 0.5f;
|
||||
float blend_half = blend * 0.5f;
|
||||
|
||||
for (y= 0; y < height; y++) {
|
||||
for (x= 0; x < width; x++) {
|
||||
if (((y / size) % 2 == 1 && (x / size) % 2 == 1 ) || ( (y / size) % 2 == 0 && (x / size) % 2 == 0 )) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (((y / size) % 2 == 1 && (x / size) % 2 == 1) || ( (y / size) % 2 == 0 && (x / size) % 2 == 0)) {
|
||||
if (rect) {
|
||||
rect[0]= (char)BLEND_CHAR(rect[0], blend);
|
||||
rect[1]= (char)BLEND_CHAR(rect[1], blend);
|
||||
rect[2]= (char)BLEND_CHAR(rect[2], blend);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)BLEND_CHAR(rect[0], blend);
|
||||
rect[1] = (char)BLEND_CHAR(rect[1], blend);
|
||||
rect[2] = (char)BLEND_CHAR(rect[2], blend);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
if (rect_float) {
|
||||
rect_float[0]= BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1]= BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2]= BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1] = BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2] = BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
rect_float += 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rect) {
|
||||
rect[0]= (char)BLEND_CHAR(rect[0], blend_half);
|
||||
rect[1]= (char)BLEND_CHAR(rect[1], blend_half);
|
||||
rect[2]= (char)BLEND_CHAR(rect[2], blend_half);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)BLEND_CHAR(rect[0], blend_half);
|
||||
rect[1] = (char)BLEND_CHAR(rect[1], blend_half);
|
||||
rect[2] = (char)BLEND_CHAR(rect[2], blend_half);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
if (rect_float) {
|
||||
rect_float[0]= BLEND_FLOAT(rect_float[0], blend_half);
|
||||
rect_float[1]= BLEND_FLOAT(rect_float[1], blend_half);
|
||||
rect_float[2]= BLEND_FLOAT(rect_float[2], blend_half);
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = BLEND_FLOAT(rect_float[0], blend_half);
|
||||
rect_float[1] = BLEND_FLOAT(rect_float[1], blend_half);
|
||||
rect_float[2] = BLEND_FLOAT(rect_float[2], blend_half);
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
rect_float += 4;
|
||||
}
|
||||
@@ -248,22 +248,22 @@ static void checker_board_color_tint(unsigned char *rect, float *rect_float, int
|
||||
static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int width, int height, float blend)
|
||||
{
|
||||
int x, y;
|
||||
for (y= 0; y < height; y++) {
|
||||
for (x= 0; x < width; x++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (((y % 32) == 0) || ((x % 32) == 0) || x == 0) {
|
||||
if (rect) {
|
||||
rect[0]= BLEND_CHAR(rect[0], blend);
|
||||
rect[1]= BLEND_CHAR(rect[1], blend);
|
||||
rect[2]= BLEND_CHAR(rect[2], blend);
|
||||
rect[3]= 255;
|
||||
rect[0] = BLEND_CHAR(rect[0], blend);
|
||||
rect[1] = BLEND_CHAR(rect[1], blend);
|
||||
rect[2] = BLEND_CHAR(rect[2], blend);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
if (rect_float) {
|
||||
rect_float[0]= BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1]= BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2]= BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1] = BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2] = BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
rect_float += 4;
|
||||
}
|
||||
@@ -282,17 +282,17 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
{
|
||||
int x, y;
|
||||
int pen_x, pen_y;
|
||||
char text[3]= {'A', '1', '\0'};
|
||||
const int mono= blf_mono_font;
|
||||
char text[3] = {'A', '1', '\0'};
|
||||
const int mono = blf_mono_font;
|
||||
|
||||
BLF_size(mono, 54, 72); /* hard coded size! */
|
||||
|
||||
BLF_buffer(mono, rect_float, rect, width, height, 4);
|
||||
|
||||
for (y= 0; y < height; y+=step) {
|
||||
text[1]= '1';
|
||||
for (y = 0; y < height; y += step) {
|
||||
text[1] = '1';
|
||||
|
||||
for (x= 0; x < width; x+=step) {
|
||||
for (x = 0; x < width; x += step) {
|
||||
/* hard coded offset */
|
||||
pen_x = x + 33;
|
||||
pen_y = y + 44;
|
||||
@@ -300,22 +300,22 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
/* terribly crappy outline font! */
|
||||
BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
BLF_position(mono, pen_x-outline, pen_y, 0.0);
|
||||
BLF_position(mono, pen_x - outline, pen_y, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
BLF_position(mono, pen_x+outline, pen_y, 0.0);
|
||||
BLF_position(mono, pen_x + outline, pen_y, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
BLF_position(mono, pen_x, pen_y-outline, 0.0);
|
||||
BLF_position(mono, pen_x, pen_y - outline, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
BLF_position(mono, pen_x, pen_y+outline, 0.0);
|
||||
BLF_position(mono, pen_x, pen_y + outline, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
|
||||
BLF_position(mono, pen_x-outline, pen_y-outline, 0.0);
|
||||
BLF_position(mono, pen_x - outline, pen_y - outline, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
BLF_position(mono, pen_x+outline, pen_y+outline, 0.0);
|
||||
BLF_position(mono, pen_x + outline, pen_y + outline, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
BLF_position(mono, pen_x-outline, pen_y+outline, 0.0);
|
||||
BLF_position(mono, pen_x - outline, pen_y + outline, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
BLF_position(mono, pen_x+outline, pen_y-outline, 0.0);
|
||||
BLF_position(mono, pen_x + outline, pen_y - outline, 0.0);
|
||||
BLF_draw_buffer(mono, text);
|
||||
|
||||
BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0);
|
||||
@@ -338,7 +338,7 @@ void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, in
|
||||
checker_board_color_tint(rect, rect_float, width, height, 4, 0.05f);
|
||||
checker_board_color_tint(rect, rect_float, width, height, 32, 0.07f);
|
||||
checker_board_color_tint(rect, rect_float, width, height, 128, 0.15f);
|
||||
checker_board_grid_fill(rect, rect_float, width, height, 1.0f/4.0f);
|
||||
checker_board_grid_fill(rect, rect_float, width, height, 1.0f / 4.0f);
|
||||
|
||||
checker_board_text(rect, rect_float, width, height, 128, 2);
|
||||
}
|
||||
|
||||
@@ -115,14 +115,14 @@
|
||||
#include "BPY_extern.h"
|
||||
#endif
|
||||
|
||||
#define MAX_IDPUP 60 /* was 24 */
|
||||
#define MAX_IDPUP 60 /* was 24 */
|
||||
|
||||
/* GS reads the memory pointed at in a specific ordering.
|
||||
* only use this definition, makes little and big endian systems
|
||||
* work fine, in conjunction with MAKE_ID */
|
||||
|
||||
/* from blendef: */
|
||||
#define GS(a) (*((short *)(a)))
|
||||
#define GS(a) (*((short *)(a)))
|
||||
|
||||
/* ************* general ************************ */
|
||||
|
||||
@@ -133,12 +133,12 @@
|
||||
* also note that the id _must_ have a library - campbell */
|
||||
void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id)
|
||||
{
|
||||
char *bpath_user_data[2]= {bmain->name, lib->filepath};
|
||||
char *bpath_user_data[2] = {bmain->name, lib->filepath};
|
||||
|
||||
BLI_bpath_traverse_id(bmain, id,
|
||||
BLI_bpath_relocate_visitor,
|
||||
BLI_BPATH_TRAVERSE_SKIP_MULTIFILE,
|
||||
bpath_user_data);
|
||||
BLI_bpath_relocate_visitor,
|
||||
BLI_BPATH_TRAVERSE_SKIP_MULTIFILE,
|
||||
bpath_user_data);
|
||||
}
|
||||
|
||||
void id_lib_extern(ID *id)
|
||||
@@ -166,7 +166,7 @@ void id_us_min(ID *id)
|
||||
{
|
||||
if (id) {
|
||||
if (id->us < 2 && (id->flag & LIB_FAKEUSER)) {
|
||||
id->us= 1;
|
||||
id->us = 1;
|
||||
}
|
||||
else if (id->us <= 0) {
|
||||
printf("ID user decrement error: %s\n", id->name);
|
||||
@@ -274,7 +274,7 @@ int id_make_local(ID *id, int test)
|
||||
|
||||
int id_copy(ID *id, ID **newid, int test)
|
||||
{
|
||||
if (!test) *newid= NULL;
|
||||
if (!test) *newid = NULL;
|
||||
|
||||
/* conventions:
|
||||
* - make shallow copy, only this ID block
|
||||
@@ -285,74 +285,74 @@ int id_copy(ID *id, ID **newid, int test)
|
||||
case ID_LI:
|
||||
return 0; /* can't be copied from here */
|
||||
case ID_OB:
|
||||
if (!test) *newid = (ID *)BKE_object_copy((Object*)id);
|
||||
if (!test) *newid = (ID *)BKE_object_copy((Object *)id);
|
||||
return 1;
|
||||
case ID_ME:
|
||||
if (!test) *newid = (ID *)BKE_mesh_copy((Mesh*)id);
|
||||
if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id);
|
||||
return 1;
|
||||
case ID_CU:
|
||||
if (!test) *newid = (ID *)BKE_curve_copy((Curve*)id);
|
||||
if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id);
|
||||
return 1;
|
||||
case ID_MB:
|
||||
if (!test) *newid = (ID *)BKE_metaball_copy((MetaBall*)id);
|
||||
if (!test) *newid = (ID *)BKE_metaball_copy((MetaBall *)id);
|
||||
return 1;
|
||||
case ID_MA:
|
||||
if (!test) *newid = (ID *)BKE_material_copy((Material*)id);
|
||||
if (!test) *newid = (ID *)BKE_material_copy((Material *)id);
|
||||
return 1;
|
||||
case ID_TE:
|
||||
if (!test) *newid = (ID *)BKE_texture_copy((Tex*)id);
|
||||
if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id);
|
||||
return 1;
|
||||
case ID_IM:
|
||||
if (!test) *newid = (ID *)BKE_image_copy((Image*)id);
|
||||
if (!test) *newid = (ID *)BKE_image_copy((Image *)id);
|
||||
return 1;
|
||||
case ID_LT:
|
||||
if (!test) *newid = (ID *)BKE_lattice_copy((Lattice*)id);
|
||||
if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id);
|
||||
return 1;
|
||||
case ID_LA:
|
||||
if (!test) *newid = (ID *)BKE_lamp_copy((Lamp*)id);
|
||||
if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id);
|
||||
return 1;
|
||||
case ID_SPK:
|
||||
if (!test) *newid = (ID *)BKE_speaker_copy((Speaker*)id);
|
||||
if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id);
|
||||
return 1;
|
||||
case ID_CA:
|
||||
if (!test) *newid = (ID *)BKE_camera_copy((Camera*)id);
|
||||
if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id);
|
||||
return 1;
|
||||
case ID_IP:
|
||||
return 0; /* deprecated */
|
||||
case ID_KE:
|
||||
if (!test) *newid = (ID *)BKE_key_copy((Key*)id);
|
||||
if (!test) *newid = (ID *)BKE_key_copy((Key *)id);
|
||||
return 1;
|
||||
case ID_WO:
|
||||
if (!test) *newid = (ID *)BKE_world_copy((World*)id);
|
||||
if (!test) *newid = (ID *)BKE_world_copy((World *)id);
|
||||
return 1;
|
||||
case ID_SCR:
|
||||
return 0; /* can't be copied from here */
|
||||
case ID_VF:
|
||||
return 0; /* not implemented */
|
||||
case ID_TXT:
|
||||
if (!test) *newid = (ID *)BKE_text_copy((Text*)id);
|
||||
if (!test) *newid = (ID *)BKE_text_copy((Text *)id);
|
||||
return 1;
|
||||
case ID_SCRIPT:
|
||||
return 0; /* deprecated */
|
||||
case ID_SO:
|
||||
return 0; /* not implemented */
|
||||
case ID_GR:
|
||||
if (!test) *newid = (ID *)BKE_group_copy((Group*)id);
|
||||
if (!test) *newid = (ID *)BKE_group_copy((Group *)id);
|
||||
return 1;
|
||||
case ID_AR:
|
||||
if (!test) *newid = (ID *)BKE_armature_copy((bArmature*)id);
|
||||
if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id);
|
||||
return 1;
|
||||
case ID_AC:
|
||||
if (!test) *newid = (ID *)BKE_action_copy((bAction*)id);
|
||||
if (!test) *newid = (ID *)BKE_action_copy((bAction *)id);
|
||||
return 1;
|
||||
case ID_NT:
|
||||
if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree*)id);
|
||||
if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id);
|
||||
return 1;
|
||||
case ID_BR:
|
||||
if (!test) *newid = (ID *)BKE_brush_copy((Brush*)id);
|
||||
if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id);
|
||||
return 1;
|
||||
case ID_PA:
|
||||
if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings*)id);
|
||||
if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id);
|
||||
return 1;
|
||||
case ID_WM:
|
||||
return 0; /* can't be copied from here */
|
||||
@@ -365,7 +365,7 @@ int id_copy(ID *id, ID **newid, int test)
|
||||
|
||||
int id_unlink(ID *id, int test)
|
||||
{
|
||||
Main *mainlib= G.main;
|
||||
Main *mainlib = G.main;
|
||||
ListBase *lb;
|
||||
|
||||
switch (GS(id->name)) {
|
||||
@@ -386,7 +386,7 @@ int id_unlink(ID *id, int test)
|
||||
if (id->us == 0) {
|
||||
if (test) return 1;
|
||||
|
||||
lb= which_libbase(mainlib, GS(id->name));
|
||||
lb = which_libbase(mainlib, GS(id->name));
|
||||
BKE_libblock_free(lb, id);
|
||||
|
||||
return 1;
|
||||
@@ -425,7 +425,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
|
||||
|
||||
ListBase *which_libbase(Main *mainlib, short type)
|
||||
{
|
||||
switch ( type ) {
|
||||
switch (type) {
|
||||
case ID_SCE:
|
||||
return &(mainlib->scene);
|
||||
case ID_LI:
|
||||
@@ -495,11 +495,11 @@ void flag_listbase_ids(ListBase *lb, short flag, short value)
|
||||
{
|
||||
ID *id;
|
||||
if (value) {
|
||||
for (id= lb->first; id; id= id->next) id->flag |= flag;
|
||||
for (id = lb->first; id; id = id->next) id->flag |= flag;
|
||||
}
|
||||
else {
|
||||
flag = ~flag;
|
||||
for (id= lb->first; id; id= id->next) id->flag &= flag;
|
||||
for (id = lb->first; id; id = id->next) id->flag &= flag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,8 +508,8 @@ void flag_all_listbases_ids(short flag, short value)
|
||||
{
|
||||
ListBase *lbarray[MAX_LIBARRAY];
|
||||
int a;
|
||||
a= set_listbasepointers(G.main, lbarray);
|
||||
while (a--) flag_listbase_ids(lbarray[a], flag, value);
|
||||
a = set_listbasepointers(G.main, lbarray);
|
||||
while (a--) flag_listbase_ids(lbarray[a], flag, value);
|
||||
}
|
||||
|
||||
void recalc_all_library_objects(Main *main)
|
||||
@@ -517,9 +517,9 @@ void recalc_all_library_objects(Main *main)
|
||||
Object *ob;
|
||||
|
||||
/* flag for full recalc */
|
||||
for (ob=main->object.first; ob; ob=ob->id.next)
|
||||
for (ob = main->object.first; ob; ob = ob->id.next)
|
||||
if (ob->id.lib)
|
||||
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
|
||||
ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
|
||||
}
|
||||
|
||||
/* note: MAX_LIBARRAY define should match this code */
|
||||
@@ -530,47 +530,47 @@ int set_listbasepointers(Main *main, ListBase **lb)
|
||||
/* BACKWARDS! also watch order of free-ing! (mesh<->mat), first items freed last.
|
||||
* This is important because freeing data decreases usercounts of other datablocks,
|
||||
* if this data is its self freed it can crash. */
|
||||
lb[a++]= &(main->ipo);
|
||||
lb[a++]= &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith)
|
||||
lb[a++]= &(main->key);
|
||||
lb[a++]= &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */
|
||||
lb[a++]= &(main->nodetree);
|
||||
lb[a++]= &(main->image);
|
||||
lb[a++]= &(main->tex);
|
||||
lb[a++]= &(main->mat);
|
||||
lb[a++]= &(main->vfont);
|
||||
lb[a++] = &(main->ipo);
|
||||
lb[a++] = &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith)
|
||||
lb[a++] = &(main->key);
|
||||
lb[a++] = &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */
|
||||
lb[a++] = &(main->nodetree);
|
||||
lb[a++] = &(main->image);
|
||||
lb[a++] = &(main->tex);
|
||||
lb[a++] = &(main->mat);
|
||||
lb[a++] = &(main->vfont);
|
||||
|
||||
/* Important!: When adding a new object type,
|
||||
* the specific data should be inserted here
|
||||
*/
|
||||
|
||||
lb[a++]= &(main->armature);
|
||||
lb[a++] = &(main->armature);
|
||||
|
||||
lb[a++]= &(main->mesh);
|
||||
lb[a++]= &(main->curve);
|
||||
lb[a++]= &(main->mball);
|
||||
lb[a++] = &(main->mesh);
|
||||
lb[a++] = &(main->curve);
|
||||
lb[a++] = &(main->mball);
|
||||
|
||||
lb[a++]= &(main->latt);
|
||||
lb[a++]= &(main->lamp);
|
||||
lb[a++]= &(main->camera);
|
||||
lb[a++] = &(main->latt);
|
||||
lb[a++] = &(main->lamp);
|
||||
lb[a++] = &(main->camera);
|
||||
|
||||
lb[a++]= &(main->text);
|
||||
lb[a++]= &(main->sound);
|
||||
lb[a++]= &(main->group);
|
||||
lb[a++]= &(main->brush);
|
||||
lb[a++]= &(main->script);
|
||||
lb[a++]= &(main->particle);
|
||||
lb[a++]= &(main->speaker);
|
||||
lb[a++] = &(main->text);
|
||||
lb[a++] = &(main->sound);
|
||||
lb[a++] = &(main->group);
|
||||
lb[a++] = &(main->brush);
|
||||
lb[a++] = &(main->script);
|
||||
lb[a++] = &(main->particle);
|
||||
lb[a++] = &(main->speaker);
|
||||
|
||||
lb[a++]= &(main->world);
|
||||
lb[a++]= &(main->screen);
|
||||
lb[a++]= &(main->object);
|
||||
lb[a++]= &(main->scene);
|
||||
lb[a++]= &(main->library);
|
||||
lb[a++]= &(main->wm);
|
||||
lb[a++]= &(main->movieclip);
|
||||
lb[a++] = &(main->world);
|
||||
lb[a++] = &(main->screen);
|
||||
lb[a++] = &(main->object);
|
||||
lb[a++] = &(main->scene);
|
||||
lb[a++] = &(main->library);
|
||||
lb[a++] = &(main->wm);
|
||||
lb[a++] = &(main->movieclip);
|
||||
|
||||
lb[a]= NULL;
|
||||
lb[a] = NULL;
|
||||
|
||||
return a;
|
||||
}
|
||||
@@ -587,74 +587,74 @@ int set_listbasepointers(Main *main, ListBase **lb)
|
||||
|
||||
static ID *alloc_libblock_notest(short type)
|
||||
{
|
||||
ID *id= NULL;
|
||||
ID *id = NULL;
|
||||
|
||||
switch ( type ) {
|
||||
switch (type) {
|
||||
case ID_SCE:
|
||||
id= MEM_callocN(sizeof(Scene), "scene");
|
||||
id = MEM_callocN(sizeof(Scene), "scene");
|
||||
break;
|
||||
case ID_LI:
|
||||
id= MEM_callocN(sizeof(Library), "library");
|
||||
id = MEM_callocN(sizeof(Library), "library");
|
||||
break;
|
||||
case ID_OB:
|
||||
id= MEM_callocN(sizeof(Object), "object");
|
||||
id = MEM_callocN(sizeof(Object), "object");
|
||||
break;
|
||||
case ID_ME:
|
||||
id= MEM_callocN(sizeof(Mesh), "mesh");
|
||||
id = MEM_callocN(sizeof(Mesh), "mesh");
|
||||
break;
|
||||
case ID_CU:
|
||||
id= MEM_callocN(sizeof(Curve), "curve");
|
||||
id = MEM_callocN(sizeof(Curve), "curve");
|
||||
break;
|
||||
case ID_MB:
|
||||
id= MEM_callocN(sizeof(MetaBall), "mball");
|
||||
id = MEM_callocN(sizeof(MetaBall), "mball");
|
||||
break;
|
||||
case ID_MA:
|
||||
id= MEM_callocN(sizeof(Material), "mat");
|
||||
id = MEM_callocN(sizeof(Material), "mat");
|
||||
break;
|
||||
case ID_TE:
|
||||
id= MEM_callocN(sizeof(Tex), "tex");
|
||||
id = MEM_callocN(sizeof(Tex), "tex");
|
||||
break;
|
||||
case ID_IM:
|
||||
id= MEM_callocN(sizeof(Image), "image");
|
||||
id = MEM_callocN(sizeof(Image), "image");
|
||||
break;
|
||||
case ID_LT:
|
||||
id= MEM_callocN(sizeof(Lattice), "latt");
|
||||
id = MEM_callocN(sizeof(Lattice), "latt");
|
||||
break;
|
||||
case ID_LA:
|
||||
id= MEM_callocN(sizeof(Lamp), "lamp");
|
||||
id = MEM_callocN(sizeof(Lamp), "lamp");
|
||||
break;
|
||||
case ID_CA:
|
||||
id= MEM_callocN(sizeof(Camera), "camera");
|
||||
id = MEM_callocN(sizeof(Camera), "camera");
|
||||
break;
|
||||
case ID_IP:
|
||||
id= MEM_callocN(sizeof(Ipo), "ipo");
|
||||
id = MEM_callocN(sizeof(Ipo), "ipo");
|
||||
break;
|
||||
case ID_KE:
|
||||
id= MEM_callocN(sizeof(Key), "key");
|
||||
id = MEM_callocN(sizeof(Key), "key");
|
||||
break;
|
||||
case ID_WO:
|
||||
id= MEM_callocN(sizeof(World), "world");
|
||||
id = MEM_callocN(sizeof(World), "world");
|
||||
break;
|
||||
case ID_SCR:
|
||||
id= MEM_callocN(sizeof(bScreen), "screen");
|
||||
id = MEM_callocN(sizeof(bScreen), "screen");
|
||||
break;
|
||||
case ID_VF:
|
||||
id= MEM_callocN(sizeof(VFont), "vfont");
|
||||
id = MEM_callocN(sizeof(VFont), "vfont");
|
||||
break;
|
||||
case ID_TXT:
|
||||
id= MEM_callocN(sizeof(Text), "text");
|
||||
id = MEM_callocN(sizeof(Text), "text");
|
||||
break;
|
||||
case ID_SCRIPT:
|
||||
//XXX id= MEM_callocN(sizeof(Script), "script");
|
||||
break;
|
||||
case ID_SPK:
|
||||
id= MEM_callocN(sizeof(Speaker), "speaker");
|
||||
id = MEM_callocN(sizeof(Speaker), "speaker");
|
||||
break;
|
||||
case ID_SO:
|
||||
id= MEM_callocN(sizeof(bSound), "sound");
|
||||
id = MEM_callocN(sizeof(bSound), "sound");
|
||||
break;
|
||||
case ID_GR:
|
||||
id= MEM_callocN(sizeof(Group), "group");
|
||||
id = MEM_callocN(sizeof(Group), "group");
|
||||
break;
|
||||
case ID_AR:
|
||||
id = MEM_callocN(sizeof(bArmature), "armature");
|
||||
@@ -687,14 +687,14 @@ static ID *alloc_libblock_notest(short type)
|
||||
/* used everywhere in blenkernel and text.c */
|
||||
void *BKE_libblock_alloc(ListBase *lb, short type, const char *name)
|
||||
{
|
||||
ID *id= NULL;
|
||||
ID *id = NULL;
|
||||
|
||||
id= alloc_libblock_notest(type);
|
||||
id = alloc_libblock_notest(type);
|
||||
if (id) {
|
||||
BLI_addtail(lb, id);
|
||||
id->us= 1;
|
||||
id->us = 1;
|
||||
id->icon_id = 0;
|
||||
*( (short *)id->name )= type;
|
||||
*( (short *)id->name) = type;
|
||||
new_id(lb, id, name);
|
||||
/* alphabetic insterion: is in new_id */
|
||||
}
|
||||
@@ -705,11 +705,11 @@ void *BKE_libblock_alloc(ListBase *lb, short type, const char *name)
|
||||
/* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */
|
||||
static void id_copy_animdata(ID *id, const short do_action)
|
||||
{
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
AnimData *adt = BKE_animdata_from_id(id);
|
||||
|
||||
if (adt) {
|
||||
IdAdtTemplate *iat = (IdAdtTemplate *)id;
|
||||
iat->adt= BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */
|
||||
iat->adt = BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,20 +730,20 @@ void *BKE_libblock_copy(ID *id)
|
||||
ListBase *lb;
|
||||
size_t idn_len;
|
||||
|
||||
lb= which_libbase(G.main, GS(id->name));
|
||||
idn= BKE_libblock_alloc(lb, GS(id->name), id->name+2);
|
||||
lb = which_libbase(G.main, GS(id->name));
|
||||
idn = BKE_libblock_alloc(lb, GS(id->name), id->name + 2);
|
||||
|
||||
assert(idn != NULL);
|
||||
|
||||
idn_len= MEM_allocN_len(idn);
|
||||
idn_len = MEM_allocN_len(idn);
|
||||
if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
|
||||
const char *cp= (const char *)id;
|
||||
char *cpn= (char *)idn;
|
||||
const char *cp = (const char *)id;
|
||||
char *cpn = (char *)idn;
|
||||
|
||||
memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID));
|
||||
memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID));
|
||||
}
|
||||
|
||||
id->newid= idn;
|
||||
id->newid = idn;
|
||||
idn->flag |= LIB_NEW;
|
||||
|
||||
BKE_libblock_copy_data(idn, id, FALSE);
|
||||
@@ -756,11 +756,11 @@ static void BKE_library_free(Library *UNUSED(lib))
|
||||
/* no freeing needed for libraries yet */
|
||||
}
|
||||
|
||||
static void (*free_windowmanager_cb)(bContext *, wmWindowManager *)= NULL;
|
||||
static void (*free_windowmanager_cb)(bContext *, wmWindowManager *) = NULL;
|
||||
|
||||
void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) )
|
||||
{
|
||||
free_windowmanager_cb= func;
|
||||
free_windowmanager_cb = func;
|
||||
}
|
||||
|
||||
static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata)
|
||||
@@ -769,16 +769,16 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata
|
||||
FCurve *fcu;
|
||||
|
||||
/* find the driver this belongs to and update it */
|
||||
for (fcu=adt->drivers.first; fcu; fcu=fcu->next) {
|
||||
driver= fcu->driver;
|
||||
for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
|
||||
driver = fcu->driver;
|
||||
|
||||
if (driver) {
|
||||
DriverVar *dvar;
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
DRIVER_TARGETS_USED_LOOPER(dvar)
|
||||
{
|
||||
if (dtar->id == userdata)
|
||||
dtar->id= NULL;
|
||||
dtar->id = NULL;
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END
|
||||
}
|
||||
@@ -790,13 +790,13 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata
|
||||
/* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */
|
||||
void BKE_libblock_free(ListBase *lb, void *idv)
|
||||
{
|
||||
ID *id= idv;
|
||||
ID *id = idv;
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
BPY_id_release(id);
|
||||
#endif
|
||||
|
||||
switch ( GS(id->name) ) { /* GetShort from util.h */
|
||||
switch (GS(id->name) ) { /* GetShort from util.h */
|
||||
case ID_SCE:
|
||||
BKE_scene_free((Scene *)id);
|
||||
break;
|
||||
@@ -903,18 +903,18 @@ void BKE_libblock_free(ListBase *lb, void *idv)
|
||||
MEM_freeN(id);
|
||||
}
|
||||
|
||||
void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */
|
||||
void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */
|
||||
{
|
||||
ID *id= idv;
|
||||
ID *id = idv;
|
||||
|
||||
id->us--;
|
||||
|
||||
if (id->us<0) {
|
||||
if (id->us < 0) {
|
||||
if (id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us);
|
||||
else printf("ERROR block %s users %d\n", id->name, id->us);
|
||||
}
|
||||
if (id->us==0) {
|
||||
if ( GS(id->name)==ID_OB ) BKE_object_unlink((Object *)id);
|
||||
if (id->us == 0) {
|
||||
if (GS(id->name) == ID_OB) BKE_object_unlink((Object *)id);
|
||||
|
||||
BKE_libblock_free(lb, id);
|
||||
}
|
||||
@@ -927,12 +927,12 @@ void free_main(Main *mainvar)
|
||||
ListBase *lbarray[MAX_LIBARRAY];
|
||||
int a;
|
||||
|
||||
a= set_listbasepointers(mainvar, lbarray);
|
||||
a = set_listbasepointers(mainvar, lbarray);
|
||||
while (a--) {
|
||||
ListBase *lb= lbarray[a];
|
||||
ListBase *lb = lbarray[a];
|
||||
ID *id;
|
||||
|
||||
while ( (id= lb->first) ) {
|
||||
while ( (id = lb->first) ) {
|
||||
BKE_libblock_free(lb, id);
|
||||
}
|
||||
}
|
||||
@@ -943,7 +943,7 @@ void free_main(Main *mainvar)
|
||||
/* ***************** ID ************************ */
|
||||
|
||||
|
||||
ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or "MA" etc */
|
||||
ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or "MA" etc */
|
||||
{
|
||||
ListBase *lb = which_libbase(G.main, type);
|
||||
BLI_assert(lb != NULL);
|
||||
@@ -952,76 +952,76 @@ ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or
|
||||
|
||||
static void get_flags_for_id(ID *id, char *buf)
|
||||
{
|
||||
int isfake= id->flag & LIB_FAKEUSER;
|
||||
int isnode=0;
|
||||
/* Writeout the flags for the entry, note there
|
||||
* is a small hack that writes 5 spaces instead
|
||||
* of 4 if no flags are displayed... this makes
|
||||
* things usually line up ok - better would be
|
||||
* to have that explicit, oh well - zr
|
||||
*/
|
||||
int isfake = id->flag & LIB_FAKEUSER;
|
||||
int isnode = 0;
|
||||
/* Writeout the flags for the entry, note there
|
||||
* is a small hack that writes 5 spaces instead
|
||||
* of 4 if no flags are displayed... this makes
|
||||
* things usually line up ok - better would be
|
||||
* to have that explicit, oh well - zr
|
||||
*/
|
||||
|
||||
if (GS(id->name)==ID_MA)
|
||||
isnode= ((Material *)id)->use_nodes;
|
||||
if (GS(id->name)==ID_TE)
|
||||
isnode= ((Tex *)id)->use_nodes;
|
||||
if (GS(id->name) == ID_MA)
|
||||
isnode = ((Material *)id)->use_nodes;
|
||||
if (GS(id->name) == ID_TE)
|
||||
isnode = ((Tex *)id)->use_nodes;
|
||||
|
||||
if (id->us<0)
|
||||
if (id->us < 0)
|
||||
strcpy(buf, "-1W ");
|
||||
else if (!id->lib && !isfake && id->us && !isnode)
|
||||
strcpy(buf, " ");
|
||||
else if (isnode)
|
||||
sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
|
||||
sprintf(buf, "%c%cN%c ", id->lib ? 'L' : ' ', isfake ? 'F' : ' ', (id->us == 0) ? 'O' : ' ');
|
||||
else
|
||||
sprintf(buf, "%c%c%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
|
||||
sprintf(buf, "%c%c%c ", id->lib ? 'L' : ' ', isfake ? 'F' : ' ', (id->us == 0) ? 'O' : ' ');
|
||||
}
|
||||
|
||||
#define IDPUP_NO_VIEWER 1
|
||||
|
||||
static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, short *nr, int hideflag)
|
||||
{
|
||||
int i, nids= BLI_countlist(lb);
|
||||
int i, nids = BLI_countlist(lb);
|
||||
|
||||
if (nr) *nr= -1;
|
||||
if (nr) *nr = -1;
|
||||
|
||||
if (nr && nids>MAX_IDPUP) {
|
||||
if (nr && nids > MAX_IDPUP) {
|
||||
BLI_dynstr_append(pupds, "DataBrowse %x-2");
|
||||
*nr= -2;
|
||||
*nr = -2;
|
||||
}
|
||||
else {
|
||||
ID *id;
|
||||
|
||||
for (i=0, id= lb->first; id; id= id->next, i++) {
|
||||
for (i = 0, id = lb->first; id; id = id->next, i++) {
|
||||
char numstr[32];
|
||||
|
||||
if (nr && id==link) *nr= i+1;
|
||||
if (nr && id == link) *nr = i + 1;
|
||||
|
||||
if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.')
|
||||
if (U.uiflag & USER_HIDE_DOT && id->name[2] == '.')
|
||||
continue;
|
||||
if (hideflag & IDPUP_NO_VIEWER)
|
||||
if (GS(id->name)==ID_IM)
|
||||
if ( ((Image *)id)->source==IMA_SRC_VIEWER )
|
||||
if (GS(id->name) == ID_IM)
|
||||
if ( ((Image *)id)->source == IMA_SRC_VIEWER)
|
||||
continue;
|
||||
|
||||
get_flags_for_id(id, numstr);
|
||||
|
||||
BLI_dynstr_append(pupds, numstr);
|
||||
BLI_dynstr_append(pupds, id->name+2);
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i+1);
|
||||
BLI_dynstr_append(pupds, id->name + 2);
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i + 1);
|
||||
BLI_dynstr_append(pupds, numstr);
|
||||
|
||||
/* icon */
|
||||
switch (GS(id->name)) {
|
||||
case ID_MA: /* fall through */
|
||||
case ID_TE: /* fall through */
|
||||
case ID_IM: /* fall through */
|
||||
case ID_WO: /* fall through */
|
||||
case ID_LA: /* fall through */
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id));
|
||||
BLI_dynstr_append(pupds, numstr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case ID_MA: /* fall through */
|
||||
case ID_TE: /* fall through */
|
||||
case ID_IM: /* fall through */
|
||||
case ID_WO: /* fall through */
|
||||
case ID_LA: /* fall through */
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id));
|
||||
BLI_dynstr_append(pupds, numstr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (id->next)
|
||||
@@ -1035,7 +1035,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
|
||||
/* if nr==NULL no MAX_IDPUP, this for non-header browsing */
|
||||
void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr)
|
||||
{
|
||||
DynStr *pupds= BLI_dynstr_new();
|
||||
DynStr *pupds = BLI_dynstr_new();
|
||||
|
||||
if (title) {
|
||||
BLI_dynstr_append(pupds, title);
|
||||
@@ -1050,7 +1050,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra
|
||||
|
||||
IDnames_to_dyn_pupstring(pupds, lb, link, nr, 0);
|
||||
|
||||
*str= BLI_dynstr_get_cstring(pupds);
|
||||
*str = BLI_dynstr_get_cstring(pupds);
|
||||
BLI_dynstr_free(pupds);
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra
|
||||
#if 0 /* unused */
|
||||
void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr)
|
||||
{
|
||||
DynStr *pupds= BLI_dynstr_new();
|
||||
DynStr *pupds = BLI_dynstr_new();
|
||||
|
||||
if (title) {
|
||||
BLI_dynstr_append(pupds, title);
|
||||
@@ -1073,7 +1073,7 @@ void IMAnames_to_pupstring(const char **str, const char *title, const char *extr
|
||||
|
||||
IDnames_to_dyn_pupstring(pupds, lb, link, nr, IDPUP_NO_VIEWER);
|
||||
|
||||
*str= BLI_dynstr_get_cstring(pupds);
|
||||
*str = BLI_dynstr_get_cstring(pupds);
|
||||
BLI_dynstr_free(pupds);
|
||||
}
|
||||
#endif
|
||||
@@ -1083,19 +1083,19 @@ void id_sort_by_name(ListBase *lb, ID *id)
|
||||
ID *idtest;
|
||||
|
||||
/* insert alphabetically */
|
||||
if (lb->first!=lb->last) {
|
||||
if (lb->first != lb->last) {
|
||||
BLI_remlink(lb, id);
|
||||
|
||||
idtest= lb->first;
|
||||
idtest = lb->first;
|
||||
while (idtest) {
|
||||
if (BLI_strcasecmp(idtest->name, id->name)>0 || (idtest->lib && !id->lib)) {
|
||||
if (BLI_strcasecmp(idtest->name, id->name) > 0 || (idtest->lib && !id->lib)) {
|
||||
BLI_insertlinkbefore(lb, idtest, id);
|
||||
break;
|
||||
}
|
||||
idtest= idtest->next;
|
||||
idtest = idtest->next;
|
||||
}
|
||||
/* as last */
|
||||
if (idtest==NULL) {
|
||||
if (idtest == NULL) {
|
||||
BLI_addtail(lb, id);
|
||||
}
|
||||
}
|
||||
@@ -1108,15 +1108,15 @@ void id_sort_by_name(ListBase *lb, ID *id)
|
||||
*/
|
||||
static ID *is_dupid(ListBase *lb, ID *id, const char *name)
|
||||
{
|
||||
ID *idtest=NULL;
|
||||
ID *idtest = NULL;
|
||||
|
||||
for ( idtest = lb->first; idtest; idtest = idtest->next ) {
|
||||
for (idtest = lb->first; idtest; idtest = idtest->next) {
|
||||
/* if idtest is not a lib */
|
||||
if ( id != idtest && idtest->lib == NULL ) {
|
||||
if (id != idtest && idtest->lib == NULL) {
|
||||
/* do not test alphabetic! */
|
||||
/* optimized */
|
||||
if ( idtest->name[2] == name[0] ) {
|
||||
if (strcmp(name, idtest->name+2)==0) break;
|
||||
if (idtest->name[2] == name[0]) {
|
||||
if (strcmp(name, idtest->name + 2) == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1137,7 +1137,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name)
|
||||
static int check_for_dupid(ListBase *lb, ID *id, char *name)
|
||||
{
|
||||
ID *idtest;
|
||||
int nr= 0, nrtest, a, left_len;
|
||||
int nr = 0, nrtest, a, left_len;
|
||||
char in_use[64]; /* use as a boolean array, unrelated to name length */
|
||||
|
||||
char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8];
|
||||
@@ -1152,43 +1152,44 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
|
||||
idtest = is_dupid(lb, id, name);
|
||||
|
||||
/* if there is no double, done */
|
||||
if ( idtest == NULL ) return 0;
|
||||
if (idtest == NULL) return 0;
|
||||
|
||||
/* we have a dup; need to make a new name */
|
||||
/* quick check so we can reuse one of first 64 ids if vacant */
|
||||
memset(in_use, 0, sizeof(in_use));
|
||||
|
||||
/* get name portion, number portion ("name.number") */
|
||||
left_len= BLI_split_name_num(left, &nr, name, '.');
|
||||
left_len = BLI_split_name_num(left, &nr, name, '.');
|
||||
|
||||
/* if new name will be too long, truncate it */
|
||||
if (nr > 999 && left_len > (MAX_ID_NAME - 8)) {
|
||||
left[MAX_ID_NAME - 8]= 0;
|
||||
left_len= MAX_ID_NAME - 8;
|
||||
left[MAX_ID_NAME - 8] = 0;
|
||||
left_len = MAX_ID_NAME - 8;
|
||||
}
|
||||
else if (left_len > (MAX_ID_NAME - 7)) {
|
||||
left[MAX_ID_NAME - 7]= 0;
|
||||
left_len= MAX_ID_NAME - 7;
|
||||
left[MAX_ID_NAME - 7] = 0;
|
||||
left_len = MAX_ID_NAME - 7;
|
||||
}
|
||||
|
||||
for (idtest= lb->first; idtest; idtest= idtest->next) {
|
||||
if ( (id != idtest) &&
|
||||
(idtest->lib == NULL) &&
|
||||
(*name == *(idtest->name+2)) &&
|
||||
(strncmp(name, idtest->name+2, left_len)==0) &&
|
||||
(BLI_split_name_num(leftest, &nrtest, idtest->name+2, '.') == left_len)
|
||||
) {
|
||||
for (idtest = lb->first; idtest; idtest = idtest->next) {
|
||||
if ( (id != idtest) &&
|
||||
(idtest->lib == NULL) &&
|
||||
(*name == *(idtest->name + 2)) &&
|
||||
(strncmp(name, idtest->name + 2, left_len) == 0) &&
|
||||
(BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len)
|
||||
)
|
||||
{
|
||||
if (nrtest < sizeof(in_use))
|
||||
in_use[nrtest]= 1; /* mark as used */
|
||||
in_use[nrtest] = 1; /* mark as used */
|
||||
if (nr <= nrtest)
|
||||
nr= nrtest+1; /* track largest unused */
|
||||
nr = nrtest + 1; /* track largest unused */
|
||||
}
|
||||
}
|
||||
|
||||
/* decide which value of nr to use */
|
||||
for (a=0; a < sizeof(in_use); a++) {
|
||||
if (a>=nr) break; /* stop when we've check up to biggest */
|
||||
if ( in_use[a]==0 ) { /* found an unused value */
|
||||
for (a = 0; a < sizeof(in_use); a++) {
|
||||
if (a >= nr) break; /* stop when we've check up to biggest */
|
||||
if (in_use[a] == 0) { /* found an unused value */
|
||||
nr = a;
|
||||
break;
|
||||
}
|
||||
@@ -1198,13 +1199,13 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
|
||||
* rather than just chopping and adding numbers,
|
||||
* shave off the end chars until we have a unique name.
|
||||
* Check the null terminators match as well so we don't get Cube.000 -> Cube.00 */
|
||||
if (nr==0 && name[left_len]== '\0') {
|
||||
int len = left_len-1;
|
||||
idtest= is_dupid(lb, id, name);
|
||||
if (nr == 0 && name[left_len] == '\0') {
|
||||
int len = left_len - 1;
|
||||
idtest = is_dupid(lb, id, name);
|
||||
|
||||
while (idtest && len> 1) {
|
||||
while (idtest && len > 1) {
|
||||
name[len--] = '\0';
|
||||
idtest= is_dupid(lb, id, name);
|
||||
idtest = is_dupid(lb, id, name);
|
||||
}
|
||||
if (idtest == NULL) return 1;
|
||||
/* otherwise just continue and use a number suffix */
|
||||
@@ -1234,24 +1235,24 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
|
||||
int new_id(ListBase *lb, ID *id, const char *tname)
|
||||
{
|
||||
int result;
|
||||
char name[MAX_ID_NAME-2];
|
||||
char name[MAX_ID_NAME - 2];
|
||||
|
||||
/* if library, don't rename */
|
||||
if (id->lib) return 0;
|
||||
|
||||
/* if no libdata given, look up based on ID */
|
||||
if (lb==NULL) lb= which_libbase(G.main, GS(id->name));
|
||||
if (lb == NULL) lb = which_libbase(G.main, GS(id->name));
|
||||
|
||||
/* if no name given, use name of current ID
|
||||
* else make a copy (tname args can be const) */
|
||||
if (tname==NULL)
|
||||
tname= id->name+2;
|
||||
if (tname == NULL)
|
||||
tname = id->name + 2;
|
||||
|
||||
strncpy(name, tname, sizeof(name)-1);
|
||||
strncpy(name, tname, sizeof(name) - 1);
|
||||
|
||||
/* if result > MAX_ID_NAME-3, strncpy don't put the final '\0' to name.
|
||||
* easier to assign each time then to check if its needed */
|
||||
name[sizeof(name)-1]= 0;
|
||||
name[sizeof(name) - 1] = 0;
|
||||
|
||||
if (name[0] == '\0') {
|
||||
/* disallow empty names */
|
||||
@@ -1264,14 +1265,14 @@ int new_id(ListBase *lb, ID *id, const char *tname)
|
||||
}
|
||||
|
||||
result = check_for_dupid(lb, id, name);
|
||||
strcpy(id->name+2, name);
|
||||
strcpy(id->name + 2, name);
|
||||
|
||||
/* This was in 2.43 and previous releases
|
||||
* however all data in blender should be sorted, not just duplicate names
|
||||
* sorting should not hurt, but noting just incause it alters the way other
|
||||
* functions work, so sort every time */
|
||||
#if 0
|
||||
if ( result )
|
||||
if (result)
|
||||
id_sort_by_name(lb, id);
|
||||
#endif
|
||||
|
||||
@@ -1286,8 +1287,8 @@ void id_clear_lib_data(Main *bmain, ID *id)
|
||||
{
|
||||
BKE_id_lib_local_paths(bmain, id->lib, id);
|
||||
|
||||
id->lib= NULL;
|
||||
id->flag= LIB_LOCAL;
|
||||
id->lib = NULL;
|
||||
id->flag = LIB_LOCAL;
|
||||
new_id(which_libbase(bmain, GS(id->name)), id, NULL);
|
||||
}
|
||||
|
||||
@@ -1298,18 +1299,18 @@ void clear_id_newpoins(void)
|
||||
ID *id;
|
||||
int a;
|
||||
|
||||
a= set_listbasepointers(G.main, lbarray);
|
||||
a = set_listbasepointers(G.main, lbarray);
|
||||
while (a--) {
|
||||
id= lbarray[a]->first;
|
||||
id = lbarray[a]->first;
|
||||
while (id) {
|
||||
id->newid= NULL;
|
||||
id->newid = NULL;
|
||||
id->flag &= ~LIB_NEW;
|
||||
id= id->next;
|
||||
id = id->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;}
|
||||
#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; }
|
||||
|
||||
static void lib_indirect_test_id(ID *id, Library *lib)
|
||||
{
|
||||
@@ -1323,17 +1324,17 @@ static void lib_indirect_test_id(ID *id, Library *lib)
|
||||
return;
|
||||
}
|
||||
|
||||
if (GS(id->name)==ID_OB) {
|
||||
Object *ob= (Object *)id;
|
||||
if (GS(id->name) == ID_OB) {
|
||||
Object *ob = (Object *)id;
|
||||
Mesh *me;
|
||||
|
||||
int a;
|
||||
|
||||
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
|
||||
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
|
||||
// XXX old animation system! --------------------------------------
|
||||
{
|
||||
bActionStrip *strip;
|
||||
for (strip=ob->nlastrips.first; strip; strip=strip->next) {
|
||||
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
|
||||
LIBTAG(strip->object);
|
||||
LIBTAG(strip->act);
|
||||
LIBTAG(strip->ipo);
|
||||
@@ -1342,14 +1343,14 @@ static void lib_indirect_test_id(ID *id, Library *lib)
|
||||
// XXX: new animation system needs something like this?
|
||||
#endif
|
||||
|
||||
for (a=0; a<ob->totcol; a++) {
|
||||
for (a = 0; a < ob->totcol; a++) {
|
||||
LIBTAG(ob->mat[a]);
|
||||
}
|
||||
|
||||
LIBTAG(ob->dup_group);
|
||||
LIBTAG(ob->proxy);
|
||||
|
||||
me= ob->data;
|
||||
me = ob->data;
|
||||
LIBTAG(me);
|
||||
}
|
||||
}
|
||||
@@ -1358,12 +1359,12 @@ void tag_main_lb(ListBase *lb, const short tag)
|
||||
{
|
||||
ID *id;
|
||||
if (tag) {
|
||||
for (id= lb->first; id; id= id->next) {
|
||||
for (id = lb->first; id; id = id->next) {
|
||||
id->flag |= LIB_DOIT;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (id= lb->first; id; id= id->next) {
|
||||
for (id = lb->first; id; id = id->next) {
|
||||
id->flag &= ~LIB_DOIT;
|
||||
}
|
||||
}
|
||||
@@ -1371,7 +1372,7 @@ void tag_main_lb(ListBase *lb, const short tag)
|
||||
|
||||
void tag_main_idcode(struct Main *mainvar, const short type, const short tag)
|
||||
{
|
||||
ListBase *lb= which_libbase(mainvar, type);
|
||||
ListBase *lb = which_libbase(mainvar, type);
|
||||
|
||||
tag_main_lb(lb, tag);
|
||||
}
|
||||
@@ -1381,7 +1382,7 @@ void tag_main(struct Main *mainvar, const short tag)
|
||||
ListBase *lbarray[MAX_LIBARRAY];
|
||||
int a;
|
||||
|
||||
a= set_listbasepointers(mainvar, lbarray);
|
||||
a = set_listbasepointers(mainvar, lbarray);
|
||||
while (a--) {
|
||||
tag_main_lb(lbarray[a], tag);
|
||||
}
|
||||
@@ -1391,27 +1392,27 @@ void tag_main(struct Main *mainvar, const short tag)
|
||||
* bmain is almost certainly G.main */
|
||||
void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
|
||||
{
|
||||
ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL};
|
||||
ListBase *lbarray[MAX_LIBARRAY], tempbase = {NULL, NULL};
|
||||
ID *id, *idn;
|
||||
int a;
|
||||
|
||||
a= set_listbasepointers(bmain, lbarray);
|
||||
a = set_listbasepointers(bmain, lbarray);
|
||||
while (a--) {
|
||||
id= lbarray[a]->first;
|
||||
id = lbarray[a]->first;
|
||||
|
||||
while (id) {
|
||||
id->newid= NULL;
|
||||
idn= id->next; /* id is possibly being inserted again */
|
||||
id->newid = NULL;
|
||||
idn = id->next; /* id is possibly being inserted again */
|
||||
|
||||
/* The check on the second line (LIB_PRE_EXISTING) is done so its
|
||||
* possible to tag data you don't want to be made local, used for
|
||||
* appending data, so any libdata already linked wont become local
|
||||
* (very nasty to discover all your links are lost after appending)
|
||||
* */
|
||||
if (id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
|
||||
(untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
|
||||
if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) &&
|
||||
(untagged_only == 0 || !(id->flag & LIB_PRE_EXISTING)))
|
||||
{
|
||||
if (lib==NULL || id->lib==lib) {
|
||||
if (lib == NULL || id->lib == lib) {
|
||||
if (id->lib) {
|
||||
id_clear_lib_data(bmain, id); /* sets 'id->flag' */
|
||||
|
||||
@@ -1420,15 +1421,15 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
|
||||
id_sort_by_name(lbarray[a], id);
|
||||
}
|
||||
else {
|
||||
id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
|
||||
id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW);
|
||||
}
|
||||
}
|
||||
}
|
||||
id= idn;
|
||||
id = idn;
|
||||
}
|
||||
|
||||
/* patch2: make it aphabetically */
|
||||
while ( (id=tempbase.first) ) {
|
||||
while ( (id = tempbase.first) ) {
|
||||
BLI_remlink(&tempbase, id);
|
||||
BLI_addtail(lbarray[a], id);
|
||||
new_id(lbarray[a], id, NULL);
|
||||
@@ -1436,9 +1437,9 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
|
||||
}
|
||||
|
||||
/* patch 3: make sure library data isn't indirect falsely... */
|
||||
a= set_listbasepointers(bmain, lbarray);
|
||||
a = set_listbasepointers(bmain, lbarray);
|
||||
while (a--) {
|
||||
for (id= lbarray[a]->first; id; id=id->next)
|
||||
for (id = lbarray[a]->first; id; id = id->next)
|
||||
lib_indirect_test_id(id, lib);
|
||||
}
|
||||
}
|
||||
@@ -1451,34 +1452,34 @@ void test_idbutton(char *name)
|
||||
ID *idtest;
|
||||
|
||||
|
||||
lb= which_libbase(G.main, GS(name-2) );
|
||||
if (lb==NULL) return;
|
||||
lb = which_libbase(G.main, GS(name - 2) );
|
||||
if (lb == NULL) return;
|
||||
|
||||
/* search for id */
|
||||
idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2);
|
||||
idtest = BLI_findstring(lb, name, offsetof(ID, name) + 2);
|
||||
|
||||
if (idtest) if ( new_id(lb, idtest, name)==0 ) id_sort_by_name(lb, idtest);
|
||||
if (idtest) if (new_id(lb, idtest, name) == 0) id_sort_by_name(lb, idtest);
|
||||
}
|
||||
|
||||
void text_idbutton(struct ID *id, char *text)
|
||||
{
|
||||
if (id) {
|
||||
if (GS(id->name)==ID_SCE)
|
||||
if (GS(id->name) == ID_SCE)
|
||||
strcpy(text, "SCE: ");
|
||||
else if (GS(id->name)==ID_SCR)
|
||||
else if (GS(id->name) == ID_SCR)
|
||||
strcpy(text, "SCR: ");
|
||||
else if (GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
|
||||
else if (GS(id->name) == ID_MA && ((Material *)id)->use_nodes)
|
||||
strcpy(text, "NT: ");
|
||||
else {
|
||||
text[0]= id->name[0];
|
||||
text[1]= id->name[1];
|
||||
text[2]= ':';
|
||||
text[3]= ' ';
|
||||
text[4]= 0;
|
||||
text[0] = id->name[0];
|
||||
text[1] = id->name[1];
|
||||
text[2] = ':';
|
||||
text[3] = ' ';
|
||||
text[4] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
text[0]= '\0';
|
||||
text[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1486,19 +1487,19 @@ void rename_id(ID *id, const char *name)
|
||||
{
|
||||
ListBase *lb;
|
||||
|
||||
BLI_strncpy(id->name+2, name, sizeof(id->name)-2);
|
||||
lb= which_libbase(G.main, GS(id->name) );
|
||||
BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
|
||||
lb = which_libbase(G.main, GS(id->name) );
|
||||
|
||||
new_id(lb, id, name);
|
||||
}
|
||||
|
||||
void name_uiprefix_id(char *name, ID *id)
|
||||
{
|
||||
name[0] = id->lib ? 'L':' ';
|
||||
name[1] = id->flag & LIB_FAKEUSER ? 'F': (id->us==0)?'0':' ';
|
||||
name[0] = id->lib ? 'L' : ' ';
|
||||
name[1] = id->flag & LIB_FAKEUSER ? 'F' : (id->us == 0) ? '0' : ' ';
|
||||
name[2] = ' ';
|
||||
|
||||
strcpy(name+3, id->name+2);
|
||||
strcpy(name + 3, id->name + 2);
|
||||
}
|
||||
|
||||
void BKE_library_filepath_set(Library *lib, const char *filepath)
|
||||
@@ -1519,7 +1520,7 @@ void BKE_library_filepath_set(Library *lib, const char *filepath)
|
||||
* outliner, and its not really supported but allow from here for now
|
||||
* since making local could cause this to be directly linked - campbell
|
||||
*/
|
||||
const char *basepath= lib->parent ? lib->parent->filepath : G.main->name;
|
||||
const char *basepath = lib->parent ? lib->parent->filepath : G.main->name;
|
||||
BLI_path_abs(lib->filepath, basepath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,12 +68,12 @@
|
||||
|
||||
ModifierTypeInfo *modifierType_getInfo(ModifierType type)
|
||||
{
|
||||
static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {NULL};
|
||||
static ModifierTypeInfo *types[NUM_MODIFIER_TYPES] = {NULL};
|
||||
static int types_init = 1;
|
||||
|
||||
if (types_init) {
|
||||
modifier_type_init(types); /* MOD_utils.c */
|
||||
types_init= 0;
|
||||
types_init = 0;
|
||||
}
|
||||
|
||||
/* type unsigned, no need to check < 0 */
|
||||
@@ -97,7 +97,7 @@ ModifierData *modifier_new(int type)
|
||||
|
||||
md->type = type;
|
||||
md->mode = eModifierMode_Realtime
|
||||
| eModifierMode_Render | eModifierMode_Expanded;
|
||||
| eModifierMode_Render | eModifierMode_Expanded;
|
||||
|
||||
if (mti->flags & eModifierTypeFlag_EnableInEditmode)
|
||||
md->mode |= eModifierMode_Editmode;
|
||||
@@ -137,8 +137,8 @@ int modifier_supportsMapping(ModifierData *md)
|
||||
{
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
return (mti->type==eModifierTypeType_OnlyDeform ||
|
||||
(mti->flags & eModifierTypeFlag_SupportsMapping));
|
||||
return (mti->type == eModifierTypeType_OnlyDeform ||
|
||||
(mti->flags & eModifierTypeFlag_SupportsMapping));
|
||||
}
|
||||
|
||||
int modifier_isPreview(ModifierData *md)
|
||||
@@ -158,8 +158,8 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type)
|
||||
{
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
|
||||
for (; md; md=md->next)
|
||||
if (md->type==type)
|
||||
for (; md; md = md->next)
|
||||
if (md->type == type)
|
||||
break;
|
||||
|
||||
return md;
|
||||
@@ -175,7 +175,7 @@ void modifiers_clearErrors(Object *ob)
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
/* int qRedraw = 0; */
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
if (md->error) {
|
||||
MEM_freeN(md->error);
|
||||
md->error = NULL;
|
||||
@@ -186,11 +186,11 @@ void modifiers_clearErrors(Object *ob)
|
||||
}
|
||||
|
||||
void modifiers_foreachObjectLink(Object *ob, ObjectWalkFunc walk,
|
||||
void *userData)
|
||||
void *userData)
|
||||
{
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (mti->foreachObjectLink)
|
||||
@@ -202,7 +202,7 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData)
|
||||
{
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (mti->foreachIDLink) mti->foreachIDLink(md, ob, walk, userData);
|
||||
@@ -218,7 +218,7 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData)
|
||||
{
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (mti->foreachTexLink)
|
||||
@@ -240,12 +240,12 @@ int modifier_couldBeCage(struct Scene *scene, ModifierData *md)
|
||||
{
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
return ( (md->mode & eModifierMode_Realtime) &&
|
||||
(md->mode & eModifierMode_Editmode) &&
|
||||
(!mti->isDisabled || !mti->isDisabled(md, 0)) &&
|
||||
modifier_supportsMapping(md));
|
||||
return ((md->mode & eModifierMode_Realtime) &&
|
||||
(md->mode & eModifierMode_Editmode) &&
|
||||
(!mti->isDisabled || !mti->isDisabled(md, 0)) &&
|
||||
modifier_supportsMapping(md));
|
||||
}
|
||||
|
||||
int modifier_sameTopology(ModifierData *md)
|
||||
@@ -269,7 +269,7 @@ void modifier_setError(ModifierData *md, const char *format, ...)
|
||||
va_start(ap, format);
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
va_end(ap);
|
||||
buffer[sizeof(buffer) - 1]= '\0';
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
|
||||
if (md->error)
|
||||
MEM_freeN(md->error);
|
||||
@@ -287,19 +287,19 @@ void modifier_setError(ModifierData *md, const char *format, ...)
|
||||
*/
|
||||
int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_)
|
||||
{
|
||||
ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first;
|
||||
ModifierData *md = (virtual_) ? modifiers_getVirtualModifierList(ob) : ob->modifiers.first;
|
||||
int i, cageIndex = -1;
|
||||
|
||||
if (lastPossibleCageIndex_r) {
|
||||
/* ensure the value is initialized */
|
||||
*lastPossibleCageIndex_r= -1;
|
||||
*lastPossibleCageIndex_r = -1;
|
||||
}
|
||||
|
||||
/* Find the last modifier acting on the cage. */
|
||||
for (i=0; md; i++, md=md->next) {
|
||||
for (i = 0; md; i++, md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
if (!(md->mode & eModifierMode_Realtime)) continue;
|
||||
if (!(md->mode & eModifierMode_Editmode)) continue;
|
||||
@@ -344,7 +344,7 @@ int modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode)
|
||||
{
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
if ((md->mode & required_mode) != required_mode) return 0;
|
||||
if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0;
|
||||
@@ -396,7 +396,7 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierDat
|
||||
}
|
||||
|
||||
/* reverse the list so it's in the correct order */
|
||||
BLI_linklist_reverse((LinkNode**)&dataMasks);
|
||||
BLI_linklist_reverse((LinkNode **)&dataMasks);
|
||||
|
||||
return dataMasks;
|
||||
}
|
||||
@@ -431,19 +431,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
|
||||
if (init) {
|
||||
md = modifier_new(eModifierType_Armature);
|
||||
amd = *((ArmatureModifierData*) md);
|
||||
amd = *((ArmatureModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
md = modifier_new(eModifierType_Curve);
|
||||
cmd = *((CurveModifierData*) md);
|
||||
cmd = *((CurveModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
md = modifier_new(eModifierType_Lattice);
|
||||
lmd = *((LatticeModifierData*) md);
|
||||
lmd = *((LatticeModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
md = modifier_new(eModifierType_ShapeKey);
|
||||
smd = *((ShapeKeyModifierData*) md);
|
||||
smd = *((ShapeKeyModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
amd.modifier.mode |= eModifierMode_Virtual;
|
||||
@@ -457,19 +457,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
md = ob->modifiers.first;
|
||||
|
||||
if (ob->parent) {
|
||||
if (ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) {
|
||||
if (ob->parent->type == OB_ARMATURE && ob->partype == PARSKEL) {
|
||||
amd.object = ob->parent;
|
||||
amd.modifier.next = md;
|
||||
amd.deformflag= ((bArmature *)(ob->parent->data))->deformflag;
|
||||
amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag;
|
||||
md = &amd.modifier;
|
||||
}
|
||||
else if (ob->parent->type==OB_CURVE && ob->partype==PARSKEL) {
|
||||
else if (ob->parent->type == OB_CURVE && ob->partype == PARSKEL) {
|
||||
cmd.object = ob->parent;
|
||||
cmd.defaxis = ob->trackflag + 1;
|
||||
cmd.modifier.next = md;
|
||||
md = &cmd.modifier;
|
||||
}
|
||||
else if (ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) {
|
||||
else if (ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) {
|
||||
lmd.object = ob->parent;
|
||||
lmd.modifier.next = md;
|
||||
md = &lmd.modifier;
|
||||
@@ -479,9 +479,9 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
/* shape key modifier, not yet for curves */
|
||||
if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
|
||||
if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE))
|
||||
smd.modifier.mode |= eModifierMode_Editmode|eModifierMode_OnCage;
|
||||
smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage;
|
||||
else
|
||||
smd.modifier.mode &= ~eModifierMode_Editmode|eModifierMode_OnCage;
|
||||
smd.modifier.mode &= ~eModifierMode_Editmode | eModifierMode_OnCage;
|
||||
|
||||
smd.modifier.next = md;
|
||||
md = &smd.modifier;
|
||||
@@ -496,12 +496,12 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
Object *modifiers_isDeformedByArmature(Object *ob)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
ArmatureModifierData *amd= NULL;
|
||||
ArmatureModifierData *amd = NULL;
|
||||
|
||||
/* return the first selected armature, this lets us use multiple armatures */
|
||||
for (; md; md=md->next) {
|
||||
if (md->type==eModifierType_Armature) {
|
||||
amd = (ArmatureModifierData*) md;
|
||||
for (; md; md = md->next) {
|
||||
if (md->type == eModifierType_Armature) {
|
||||
amd = (ArmatureModifierData *) md;
|
||||
if (amd->object && (amd->object->flag & SELECT))
|
||||
return amd->object;
|
||||
}
|
||||
@@ -520,12 +520,12 @@ Object *modifiers_isDeformedByArmature(Object *ob)
|
||||
Object *modifiers_isDeformedByLattice(Object *ob)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
LatticeModifierData *lmd= NULL;
|
||||
LatticeModifierData *lmd = NULL;
|
||||
|
||||
/* return the first selected lattice, this lets us use multiple lattices */
|
||||
for (; md; md=md->next) {
|
||||
if (md->type==eModifierType_Lattice) {
|
||||
lmd = (LatticeModifierData*) md;
|
||||
for (; md; md = md->next) {
|
||||
if (md->type == eModifierType_Lattice) {
|
||||
lmd = (LatticeModifierData *) md;
|
||||
if (lmd->object && (lmd->object->flag & SELECT))
|
||||
return lmd->object;
|
||||
}
|
||||
@@ -543,10 +543,10 @@ int modifiers_usesArmature(Object *ob, bArmature *arm)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
|
||||
for (; md; md=md->next) {
|
||||
if (md->type==eModifierType_Armature) {
|
||||
ArmatureModifierData *amd = (ArmatureModifierData*) md;
|
||||
if (amd->object && amd->object->data==arm)
|
||||
for (; md; md = md->next) {
|
||||
if (md->type == eModifierType_Armature) {
|
||||
ArmatureModifierData *amd = (ArmatureModifierData *) md;
|
||||
if (amd->object && amd->object->data == arm)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -556,9 +556,9 @@ int modifiers_usesArmature(Object *ob, bArmature *arm)
|
||||
|
||||
int modifier_isCorrectableDeformed(ModifierData *md)
|
||||
{
|
||||
if (md->type==eModifierType_Armature)
|
||||
if (md->type == eModifierType_Armature)
|
||||
return 1;
|
||||
if (md->type==eModifierType_ShapeKey)
|
||||
if (md->type == eModifierType_ShapeKey)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -568,11 +568,11 @@ int modifiers_isCorrectableDeformed(Object *ob)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
|
||||
for (; md; md=md->next) {
|
||||
if (ob->mode==OB_MODE_EDIT && (md->mode & eModifierMode_Editmode)==0);
|
||||
for (; md; md = md->next) {
|
||||
if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) ;
|
||||
else
|
||||
if (modifier_isCorrectableDeformed(md))
|
||||
return 1;
|
||||
if (modifier_isCorrectableDeformed(md))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -593,22 +593,22 @@ int modifiers_isPreview(Object *ob)
|
||||
|
||||
int modifiers_indexInObject(Object *ob, ModifierData *md_seek)
|
||||
{
|
||||
int i= 0;
|
||||
int i = 0;
|
||||
ModifierData *md;
|
||||
|
||||
for (md=ob->modifiers.first; (md && md_seek!=md); md=md->next, i++);
|
||||
if (!md) return -1; /* modifier isn't in the object */
|
||||
for (md = ob->modifiers.first; (md && md_seek != md); md = md->next, i++) ;
|
||||
if (!md) return -1; /* modifier isn't in the object */
|
||||
return i;
|
||||
}
|
||||
|
||||
void modifier_freeTemporaryData(ModifierData *md)
|
||||
{
|
||||
if (md->type == eModifierType_Armature) {
|
||||
ArmatureModifierData *amd= (ArmatureModifierData*)md;
|
||||
ArmatureModifierData *amd = (ArmatureModifierData *)md;
|
||||
|
||||
if (amd->prevCos) {
|
||||
MEM_freeN(amd->prevCos);
|
||||
amd->prevCos= NULL;
|
||||
amd->prevCos = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -625,7 +625,7 @@ void test_object_modifiers(Object *ob)
|
||||
|
||||
for (md = ob->modifiers.first; md; md = md->next) {
|
||||
if (md->type == eModifierType_Multires) {
|
||||
MultiresModifierData *mmd = (MultiresModifierData*)md;
|
||||
MultiresModifierData *mmd = (MultiresModifierData *)md;
|
||||
|
||||
multiresModifier_set_levels_from_disps(mmd, ob);
|
||||
}
|
||||
|
||||
@@ -82,30 +82,30 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
void multires_customdata_delete(Mesh *me)
|
||||
{
|
||||
if (me->edit_btmesh) {
|
||||
BMEditMesh *em= me->edit_btmesh;
|
||||
BMEditMesh *em = me->edit_btmesh;
|
||||
/* CustomData_external_remove is used here only to mark layer
|
||||
* as non-external for further free-ing, so zero element count
|
||||
* looks safer than em->totface */
|
||||
CustomData_external_remove(&em->bm->ldata, &me->id,
|
||||
CD_MDISPS, 0);
|
||||
CD_MDISPS, 0);
|
||||
BM_data_layer_free(em->bm, &em->bm->ldata, CD_MDISPS);
|
||||
}
|
||||
else {
|
||||
CustomData_external_remove(&me->ldata, &me->id,
|
||||
CD_MDISPS, me->totloop);
|
||||
CD_MDISPS, me->totloop);
|
||||
CustomData_free_layer_active(&me->ldata, CD_MDISPS,
|
||||
me->totloop);
|
||||
me->totloop);
|
||||
}
|
||||
}
|
||||
|
||||
/** Grid hiding **/
|
||||
static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
|
||||
int lo_level,
|
||||
int hi_level,
|
||||
int lo_level,
|
||||
int hi_level,
|
||||
|
||||
/* assumed to be at hi_level (or
|
||||
* null) */
|
||||
BLI_bitmap prev_hidden)
|
||||
/* assumed to be at hi_level (or
|
||||
* null) */
|
||||
BLI_bitmap prev_hidden)
|
||||
{
|
||||
BLI_bitmap subd;
|
||||
int hi_gridsize = ccg_gridsize(hi_level);
|
||||
@@ -163,8 +163,8 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
|
||||
}
|
||||
|
||||
static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden,
|
||||
int old_level,
|
||||
int new_level)
|
||||
int old_level,
|
||||
int new_level)
|
||||
{
|
||||
BLI_bitmap new_hidden;
|
||||
int new_gridsize = ccg_gridsize(new_level);
|
||||
@@ -174,16 +174,16 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden,
|
||||
BLI_assert(new_level <= old_level);
|
||||
factor = ccg_factor(new_level, old_level);
|
||||
new_hidden = BLI_BITMAP_NEW(new_gridsize * new_gridsize,
|
||||
"downsample hidden");
|
||||
"downsample hidden");
|
||||
|
||||
|
||||
|
||||
for (y = 0; y < new_gridsize; y++) {
|
||||
for (x = 0; x < new_gridsize; x++) {
|
||||
old_value = BLI_BITMAP_GET(old_hidden,
|
||||
factor*y*old_gridsize + x*factor);
|
||||
factor * y * old_gridsize + x * factor);
|
||||
|
||||
BLI_BITMAP_MODIFY(new_hidden, y*new_gridsize + x, old_value);
|
||||
BLI_BITMAP_MODIFY(new_hidden, y * new_gridsize + x, old_value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden,
|
||||
}
|
||||
|
||||
static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
|
||||
Mesh *me, int level)
|
||||
Mesh *me, int level)
|
||||
{
|
||||
const MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
BLI_bitmap *grid_hidden = ccgdm->gridHidden;
|
||||
@@ -208,7 +208,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
|
||||
|
||||
if (gh) {
|
||||
grid_hidden[g] =
|
||||
multires_mdisps_downsample_hidden(gh, md->level, level);
|
||||
multires_mdisps_downsample_hidden(gh, md->level, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,9 +227,9 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
|
||||
return;
|
||||
|
||||
subd = multires_mdisps_upsample_hidden(md->hidden,
|
||||
md->level,
|
||||
new_level,
|
||||
NULL);
|
||||
md->level,
|
||||
new_level,
|
||||
NULL);
|
||||
|
||||
/* swap in the subdivided data */
|
||||
MEM_freeN(md->hidden);
|
||||
@@ -239,7 +239,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
|
||||
static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
|
||||
{
|
||||
MDisps *mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS,
|
||||
CD_CALLOC, 0, me->totloop);
|
||||
CD_CALLOC, 0, me->totloop);
|
||||
int gridsize = ccg_gridsize(level);
|
||||
int gridarea = gridsize * gridsize;
|
||||
int i, j, k;
|
||||
@@ -274,7 +274,7 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
|
||||
|
||||
DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob)
|
||||
{
|
||||
ModifierData *md= (ModifierData *)mmd;
|
||||
ModifierData *md = (ModifierData *)mmd;
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
||||
DerivedMesh *dm;
|
||||
@@ -294,7 +294,7 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *
|
||||
for (md = lastmd; md; md = md->prev) {
|
||||
if (md->type == eModifierType_Multires) {
|
||||
if (modifier_isEnabled(scene, md, eModifierMode_Realtime))
|
||||
return (MultiresModifierData*)md;
|
||||
return (MultiresModifierData *)md;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,16 +307,16 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *
|
||||
MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_first)
|
||||
{
|
||||
ModifierData *md;
|
||||
MultiresModifierData *mmd= NULL, *firstmmd= NULL;
|
||||
MultiresModifierData *mmd = NULL, *firstmmd = NULL;
|
||||
|
||||
/* find first active multires modifier */
|
||||
for (md = ob->modifiers.first; md; md = md->next) {
|
||||
if (md->type == eModifierType_Multires) {
|
||||
if (!firstmmd)
|
||||
firstmmd= (MultiresModifierData*)md;
|
||||
firstmmd = (MultiresModifierData *)md;
|
||||
|
||||
if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
|
||||
mmd= (MultiresModifierData*)md;
|
||||
mmd = (MultiresModifierData *)md;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -334,11 +334,11 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_fi
|
||||
static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render)
|
||||
{
|
||||
if (render)
|
||||
return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl): mmd->renderlvl;
|
||||
return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl) : mmd->renderlvl;
|
||||
else if (ob->mode == OB_MODE_SCULPT)
|
||||
return mmd->sculptlvl;
|
||||
else
|
||||
return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl): mmd->lvl;
|
||||
return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl) : mmd->lvl;
|
||||
}
|
||||
|
||||
static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl)
|
||||
@@ -354,7 +354,7 @@ static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lv
|
||||
|
||||
static void multires_dm_mark_as_modified(DerivedMesh *dm, MultiresModifiedFlags flags)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
ccgdm->multires.modified_flags |= flags;
|
||||
}
|
||||
|
||||
@@ -368,13 +368,13 @@ void multires_force_update(Object *ob)
|
||||
{
|
||||
if (ob) {
|
||||
if (ob->derivedFinal) {
|
||||
ob->derivedFinal->needsFree =1;
|
||||
ob->derivedFinal->needsFree = 1;
|
||||
ob->derivedFinal->release(ob->derivedFinal);
|
||||
ob->derivedFinal = NULL;
|
||||
}
|
||||
if (ob->sculpt && ob->sculpt->pbvh) {
|
||||
BLI_pbvh_free(ob->sculpt->pbvh);
|
||||
ob->sculpt->pbvh= NULL;
|
||||
ob->sculpt->pbvh = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,9 +394,9 @@ void multires_force_render_update(Object *ob)
|
||||
}
|
||||
|
||||
int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
|
||||
Object *ob, DerivedMesh *srcdm)
|
||||
Object *ob, DerivedMesh *srcdm)
|
||||
{
|
||||
DerivedMesh *mrdm = get_multires_dm (scene, mmd, ob);
|
||||
DerivedMesh *mrdm = get_multires_dm(scene, mmd, ob);
|
||||
|
||||
if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
|
||||
multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm));
|
||||
@@ -422,7 +422,7 @@ int multiresModifier_reshape(Scene *scene, MultiresModifierData *mmd, Object *ds
|
||||
}
|
||||
|
||||
int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mmd,
|
||||
Object *ob, ModifierData *md)
|
||||
Object *ob, ModifierData *md)
|
||||
{
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
DerivedMesh *dm, *ndm;
|
||||
@@ -434,20 +434,20 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
|
||||
|
||||
/* Create DerivedMesh for deformation modifier */
|
||||
dm = get_multires_dm(scene, mmd, ob);
|
||||
numVerts= dm->getNumVerts(dm);
|
||||
deformedVerts= MEM_callocN(sizeof(float)*numVerts*3, "multiresReshape_deformVerts");
|
||||
numVerts = dm->getNumVerts(dm);
|
||||
deformedVerts = MEM_callocN(sizeof(float) * numVerts * 3, "multiresReshape_deformVerts");
|
||||
|
||||
dm->getVertCos(dm, deformedVerts);
|
||||
mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0);
|
||||
|
||||
ndm= CDDM_copy(dm);
|
||||
ndm = CDDM_copy(dm);
|
||||
CDDM_apply_vert_coords(ndm, deformedVerts);
|
||||
|
||||
MEM_freeN(deformedVerts);
|
||||
dm->release(dm);
|
||||
|
||||
/* Reshaping */
|
||||
result= multiresModifier_reshapeFromDM(scene, mmd, ob, ndm);
|
||||
result = multiresModifier_reshapeFromDM(scene, mmd, ob, ndm);
|
||||
|
||||
/* Cleanup */
|
||||
ndm->release(ndm);
|
||||
@@ -460,19 +460,19 @@ static int get_levels_from_disps(Object *ob)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
MDisps *mdisp, *md;
|
||||
int i, j, totlvl= 0;
|
||||
int i, j, totlvl = 0;
|
||||
|
||||
mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
for (i = 0; i < me->totpoly; ++i) {
|
||||
md = mdisp + me->mpoly[i].loopstart;
|
||||
|
||||
for (j=0; j<me->mpoly[i].totloop; j++, md++) {
|
||||
for (j = 0; j < me->mpoly[i].totloop; j++, md++) {
|
||||
if (md->totdisp == 0) continue;
|
||||
|
||||
while (1) {
|
||||
int side = (1 << (totlvl-1)) + 1;
|
||||
int lvl_totdisp = side*side;
|
||||
int side = (1 << (totlvl - 1)) + 1;
|
||||
int lvl_totdisp = side * side;
|
||||
if (md->totdisp == lvl_totdisp)
|
||||
break;
|
||||
else if (md->totdisp < lvl_totdisp)
|
||||
@@ -510,7 +510,7 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o
|
||||
|
||||
static void multires_set_tot_mdisps(Mesh *me, int lvl)
|
||||
{
|
||||
MDisps *mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
int i;
|
||||
|
||||
if (mdisps) {
|
||||
@@ -554,18 +554,18 @@ static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA,
|
||||
int x, y, j, skip;
|
||||
|
||||
if (sizeA > sizeB) {
|
||||
skip = (sizeA-1)/(sizeB-1);
|
||||
skip = (sizeA - 1) / (sizeB - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeB; y++)
|
||||
for (x = 0; x < sizeB; x++, j++)
|
||||
copy_v3_v3(gridA[y*skip*sizeA + x*skip], gridB[j]);
|
||||
copy_v3_v3(gridA[y * skip * sizeA + x * skip], gridB[j]);
|
||||
}
|
||||
else {
|
||||
skip = (sizeB-1)/(sizeA-1);
|
||||
skip = (sizeB - 1) / (sizeA - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeA; y++)
|
||||
for (x = 0; x < sizeA; x++, j++)
|
||||
copy_v3_v3(gridA[j], gridB[y*skip*sizeB + x*skip]);
|
||||
copy_v3_v3(gridA[j], gridB[y * skip * sizeB + x * skip]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,30 +574,30 @@ static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, int size
|
||||
int x, y, j, skip;
|
||||
|
||||
if (sizeA > sizeB) {
|
||||
skip = (sizeA-1)/(sizeB-1);
|
||||
skip = (sizeA - 1) / (sizeB - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeB; y++)
|
||||
for (x = 0; x < sizeB; x++, j++)
|
||||
copy_v3_v3(gridA[y*skip*sizeA + x*skip].co, gridB[j].co);
|
||||
copy_v3_v3(gridA[y * skip * sizeA + x * skip].co, gridB[j].co);
|
||||
}
|
||||
else {
|
||||
skip = (sizeB-1)/(sizeA-1);
|
||||
skip = (sizeB - 1) / (sizeA - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeA; y++)
|
||||
for (x = 0; x < sizeA; x++, j++)
|
||||
copy_v3_v3(gridA[j].co, gridB[y*skip*sizeB + x*skip].co);
|
||||
copy_v3_v3(gridA[j].co, gridB[y * skip * sizeB + x * skip].co);
|
||||
}
|
||||
}
|
||||
|
||||
static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
|
||||
{
|
||||
Mesh *me = (Mesh*)ob->data;
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
int levels = mmd->totlvl - lvl;
|
||||
MDisps *mdisps;
|
||||
|
||||
multires_set_tot_mdisps(me, mmd->totlvl);
|
||||
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
|
||||
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
multires_force_update(ob);
|
||||
|
||||
@@ -609,8 +609,8 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < me->totpoly; ++i) {
|
||||
for (j=0; j<me->mpoly[i].totloop; j++) {
|
||||
MDisps *mdisp= &mdisps[me->mpoly[i].loopstart+j];
|
||||
for (j = 0; j < me->mpoly[i].totloop; j++) {
|
||||
MDisps *mdisp = &mdisps[me->mpoly[i].loopstart + j];
|
||||
float (*disps)[3], (*ndisps)[3], (*hdisps)[3];
|
||||
int totdisp = multires_grid_tot[lvl];
|
||||
|
||||
@@ -622,15 +622,15 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
|
||||
multires_copy_grid(ndisps, hdisps, nsize, hsize);
|
||||
if (mdisp->hidden) {
|
||||
BLI_bitmap gh =
|
||||
multires_mdisps_downsample_hidden(mdisp->hidden,
|
||||
mdisp->level,
|
||||
lvl);
|
||||
multires_mdisps_downsample_hidden(mdisp->hidden,
|
||||
mdisp->level,
|
||||
lvl);
|
||||
MEM_freeN(mdisp->hidden);
|
||||
mdisp->hidden = gh;
|
||||
}
|
||||
|
||||
ndisps += nsize*nsize;
|
||||
hdisps += hsize*hsize;
|
||||
ndisps += nsize * nsize;
|
||||
hdisps += hsize * hsize;
|
||||
|
||||
MEM_freeN(mdisp->disps);
|
||||
mdisp->disps = disps;
|
||||
@@ -657,7 +657,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
|
||||
|
||||
multires_set_tot_mdisps(me, mmd->totlvl);
|
||||
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
|
||||
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
multires_force_update(ob);
|
||||
|
||||
@@ -670,7 +670,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
|
||||
|
||||
static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple)
|
||||
{
|
||||
MultiresModifierData mmd= {{NULL}};
|
||||
MultiresModifierData mmd = {{NULL}};
|
||||
|
||||
mmd.lvl = lvl;
|
||||
mmd.sculptlvl = lvl;
|
||||
@@ -683,7 +683,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv
|
||||
|
||||
static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv)
|
||||
{
|
||||
SubsurfModifierData smd= {{NULL}};
|
||||
SubsurfModifierData smd = {{NULL}};
|
||||
|
||||
smd.levels = smd.renderLevels = lvl;
|
||||
if (!plain_uv)
|
||||
@@ -742,8 +742,8 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
|
||||
|
||||
cddm = CDDM_from_mesh(me, NULL);
|
||||
pmap = cddm->getPolyMap(ob, cddm);
|
||||
origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco");
|
||||
for (i = 0; i < me->totvert ;++i)
|
||||
origco = MEM_callocN(sizeof(float) * 3 * me->totvert, "multires apply base origco");
|
||||
for (i = 0; i < me->totvert; ++i)
|
||||
copy_v3_v3(origco[i], me->mvert[i].co);
|
||||
|
||||
for (i = 0; i < me->totvert; ++i) {
|
||||
@@ -833,7 +833,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
MDisps *mdisps;
|
||||
int lvl= mmd->totlvl;
|
||||
int lvl = mmd->totlvl;
|
||||
|
||||
if ((totlvl > multires_max_levels) || (me->totpoly == 0))
|
||||
return;
|
||||
@@ -867,12 +867,12 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
lowGridSize = lowdm->getGridSize(lowdm);
|
||||
lowGridData = lowdm->getGridData(lowdm);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(float*)*numGrids, "subGridData*");
|
||||
subGridData = MEM_callocN(sizeof(float *) * numGrids, "subGridData*");
|
||||
|
||||
for (i = 0; i < numGrids; ++i) {
|
||||
/* backup subsurf grids */
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * highGridSize * highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData) * highGridSize * highGridSize);
|
||||
|
||||
/* overwrite with current displaced grids */
|
||||
multires_copy_dm_grid(highGridData[i], lowGridData[i], highGridSize, lowGridSize);
|
||||
@@ -882,7 +882,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
lowdm->release(lowdm);
|
||||
|
||||
/* subsurf higher levels again with displaced data */
|
||||
ss= ((CCGDerivedMesh*)highdm)->ss;
|
||||
ss = ((CCGDerivedMesh *)highdm)->ss;
|
||||
ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0);
|
||||
ccgSubSurf_updateLevels(ss, lvl, NULL, 0);
|
||||
|
||||
@@ -908,7 +908,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
|
||||
void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple)
|
||||
{
|
||||
multires_subdivide(mmd, ob, mmd->totlvl+1, updateblock, simple);
|
||||
multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple);
|
||||
}
|
||||
|
||||
void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3])
|
||||
@@ -916,28 +916,28 @@ void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **
|
||||
if (axis == 0) {
|
||||
if (x == gridSize - 1) {
|
||||
if (y == gridSize - 1)
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*(y - 1)].co, gridData[index][x - 1 + gridSize*(y - 1)].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * (y - 1)].co, gridData[index][x - 1 + gridSize * (y - 1)].co);
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x - 1 + gridSize*y].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * y].co, gridData[index][x - 1 + gridSize * y].co);
|
||||
}
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + 1 + gridSize*y].co, gridData[index][x + gridSize*y].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + 1 + gridSize * y].co, gridData[index][x + gridSize * y].co);
|
||||
}
|
||||
else if (axis == 1) {
|
||||
if (y == gridSize - 1) {
|
||||
if (x == gridSize - 1)
|
||||
sub_v3_v3v3(t, gridData[index][x - 1 + gridSize*y].co, gridData[index][x - 1 + gridSize*(y - 1)].co);
|
||||
sub_v3_v3v3(t, gridData[index][x - 1 + gridSize * y].co, gridData[index][x - 1 + gridSize * (y - 1)].co);
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x + gridSize*(y - 1)].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * y].co, gridData[index][x + gridSize * (y - 1)].co);
|
||||
}
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*(y + 1)].co, gridData[index][x + gridSize*y].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * (y + 1)].co, gridData[index][x + gridSize * y].co);
|
||||
}
|
||||
}
|
||||
|
||||
static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
DMGridData **gridData, **subGridData;
|
||||
MPoly *mpoly = me->mpoly;
|
||||
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
@@ -968,10 +968,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
gridSize = dm->getGridSize(dm);
|
||||
gridData = dm->getGridData(dm);
|
||||
gridOffset = dm->getGridOffset(dm);
|
||||
subGridData = (oldGridData)? oldGridData: gridData;
|
||||
subGridData = (oldGridData) ? oldGridData : gridData;
|
||||
|
||||
dGridSize = multires_side_tot[totlvl];
|
||||
dSkip = (dGridSize-1)/(gridSize-1);
|
||||
dSkip = (dGridSize - 1) / (gridSize - 1);
|
||||
|
||||
k = 0; /*current loop/mdisp index within the mloop array*/
|
||||
|
||||
@@ -982,7 +982,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
int S, x, y, gIndex = gridOffset[i];
|
||||
|
||||
for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart+S];
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart + S];
|
||||
DMGridData *grid = gridData[gIndex];
|
||||
DMGridData *subgrid = subGridData[gIndex];
|
||||
float (*dispgrid)[3] = NULL;
|
||||
@@ -998,10 +998,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
|
||||
for (y = 0; y < gridSize; y++) {
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
float *co = grid[x + y*gridSize].co;
|
||||
float *sco = subgrid[x + y*gridSize].co;
|
||||
float *no = subgrid[x + y*gridSize].no;
|
||||
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip];
|
||||
float *co = grid[x + y * gridSize].co;
|
||||
float *sco = subgrid[x + y * gridSize].co;
|
||||
float *no = subgrid[x + y * gridSize].no;
|
||||
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
|
||||
float mat[3][3], tx[3], ty[3], disp[3], d[3];
|
||||
|
||||
/* construct tangent space matrix */
|
||||
@@ -1018,26 +1018,26 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
column_vectors_to_mat3(mat, tx, ty, no);
|
||||
|
||||
switch (op) {
|
||||
case APPLY_DISPLACEMENTS:
|
||||
/* Convert displacement to object space
|
||||
* and add to grid points */
|
||||
mul_v3_m3v3(disp, mat, data);
|
||||
add_v3_v3v3(co, sco, disp);
|
||||
break;
|
||||
case CALC_DISPLACEMENTS:
|
||||
/* Calculate displacement between new and old
|
||||
* grid points and convert to tangent space */
|
||||
sub_v3_v3v3(disp, co, sco);
|
||||
invert_m3(mat);
|
||||
mul_v3_m3v3(data, mat, disp);
|
||||
break;
|
||||
case ADD_DISPLACEMENTS:
|
||||
/* Convert subdivided displacements to tangent
|
||||
* space and add to the original displacements */
|
||||
invert_m3(mat);
|
||||
mul_v3_m3v3(d, mat, co);
|
||||
add_v3_v3(data, d);
|
||||
break;
|
||||
case APPLY_DISPLACEMENTS:
|
||||
/* Convert displacement to object space
|
||||
* and add to grid points */
|
||||
mul_v3_m3v3(disp, mat, data);
|
||||
add_v3_v3v3(co, sco, disp);
|
||||
break;
|
||||
case CALC_DISPLACEMENTS:
|
||||
/* Calculate displacement between new and old
|
||||
* grid points and convert to tangent space */
|
||||
sub_v3_v3v3(disp, co, sco);
|
||||
invert_m3(mat);
|
||||
mul_v3_m3v3(data, mat, disp);
|
||||
break;
|
||||
case ADD_DISPLACEMENTS:
|
||||
/* Convert subdivided displacements to tangent
|
||||
* space and add to the original displacements */
|
||||
invert_m3(mat);
|
||||
mul_v3_m3v3(d, mat, co);
|
||||
add_v3_v3(data, d);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1052,7 +1052,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
|
||||
void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
Object *ob;
|
||||
Mesh *me;
|
||||
MDisps *mdisps;
|
||||
@@ -1095,16 +1095,16 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
lowGridData = lowdm->getGridData(lowdm);
|
||||
gridData = dm->getGridData(dm);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
|
||||
diffGrid = MEM_callocN(sizeof(DMGridData)*lowGridSize*lowGridSize, "diff");
|
||||
subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*");
|
||||
diffGrid = MEM_callocN(sizeof(DMGridData) * lowGridSize * lowGridSize, "diff");
|
||||
|
||||
for (i = 0; i < numGrids; ++i) {
|
||||
/* backup subsurf grids */
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * highGridSize * highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData) * highGridSize * highGridSize);
|
||||
|
||||
/* write difference of subsurf and displaced low level into high subsurf */
|
||||
for (j = 0; j < lowGridSize*lowGridSize; ++j)
|
||||
for (j = 0; j < lowGridSize * lowGridSize; ++j)
|
||||
sub_v3_v3v3(diffGrid[j].co, gridData[i][j].co, lowGridData[i][j].co);
|
||||
|
||||
multires_copy_dm_grid(highGridData[i], diffGrid, highGridSize, lowGridSize);
|
||||
@@ -1115,7 +1115,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
lowdm->release(lowdm);
|
||||
|
||||
/* subsurf higher levels again with difference of coordinates */
|
||||
ss= ((CCGDerivedMesh*)highdm)->ss;
|
||||
ss = ((CCGDerivedMesh *)highdm)->ss;
|
||||
ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0);
|
||||
ccgSubSurf_updateLevels(ss, lvl, NULL, 0);
|
||||
|
||||
@@ -1147,8 +1147,8 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
|
||||
void multires_modifier_update_hidden(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
BLI_bitmap *grid_hidden= ccgdm->gridHidden;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
BLI_bitmap *grid_hidden = ccgdm->gridHidden;
|
||||
Mesh *me = ccgdm->multires.ob->data;
|
||||
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
int totlvl = ccgdm->multires.totlvl;
|
||||
@@ -1167,7 +1167,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
|
||||
}
|
||||
else if (gh) {
|
||||
gh = multires_mdisps_upsample_hidden(gh, lvl, totlvl,
|
||||
md->hidden);
|
||||
md->hidden);
|
||||
if (md->hidden)
|
||||
MEM_freeN(md->hidden);
|
||||
|
||||
@@ -1180,7 +1180,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
|
||||
void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
|
||||
{
|
||||
DerivedMesh *ccgdm = NULL, *subsurf = NULL;
|
||||
DMGridData **gridData, **subGridData=NULL;
|
||||
DMGridData **gridData, **subGridData = NULL;
|
||||
MPoly *mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
|
||||
MDisps *mdisps;
|
||||
MultiresModifierData *mmd = get_multires_modifier(NULL, ob, 1);
|
||||
@@ -1200,26 +1200,26 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
|
||||
ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple);
|
||||
|
||||
subsurf = subsurf_dm_create_local(ob, dm, totlvl,
|
||||
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
|
||||
numGrids = subsurf->getNumGrids(subsurf);
|
||||
gridSize = subsurf->getGridSize(subsurf);
|
||||
gridData = subsurf->getGridData(subsurf);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
|
||||
subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*");
|
||||
|
||||
for (i = 0; i < numGrids; i++) {
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * gridSize * gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData) * gridSize * gridSize);
|
||||
}
|
||||
|
||||
/*numGrids = ccgdm->dm->getNumGrids((DerivedMesh*)ccgdm);*/ /*UNUSED*/
|
||||
gridSize = ccgdm->getGridSize((DerivedMesh*)ccgdm);
|
||||
gridData = ccgdm->getGridData((DerivedMesh*)ccgdm);
|
||||
gridOffset = ccgdm->getGridOffset((DerivedMesh*)ccgdm);
|
||||
gridSize = ccgdm->getGridSize((DerivedMesh *)ccgdm);
|
||||
gridData = ccgdm->getGridData((DerivedMesh *)ccgdm);
|
||||
gridOffset = ccgdm->getGridOffset((DerivedMesh *)ccgdm);
|
||||
|
||||
dGridSize = multires_side_tot[totlvl];
|
||||
dSkip = (dGridSize-1)/(gridSize-1);
|
||||
dSkip = (dGridSize - 1) / (gridSize - 1);
|
||||
|
||||
k = 0; /*current loop/mdisp index within the mloop array*/
|
||||
|
||||
@@ -1230,25 +1230,25 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
|
||||
int S, x, y, gIndex = gridOffset[i];
|
||||
|
||||
for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart+S];
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart + S];
|
||||
/* DMGridData *grid = gridData[gIndex]; */ /* UNUSED */
|
||||
DMGridData *subgrid = subGridData[gIndex];
|
||||
float (*dispgrid)[3] = NULL;
|
||||
|
||||
/* when adding new faces in edit mode, need to allocate disps */
|
||||
if (!mdisp->disps) {
|
||||
mdisp->totdisp = gridSize*gridSize;
|
||||
mdisp->totdisp = gridSize * gridSize;
|
||||
mdisp->level = totlvl;
|
||||
mdisp->disps = MEM_callocN(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space");
|
||||
mdisp->disps = MEM_callocN(sizeof(float) * 3 * mdisp->totdisp, "disp in multires_set_space");
|
||||
}
|
||||
|
||||
dispgrid = mdisp->disps;
|
||||
|
||||
for (y = 0; y < gridSize; y++) {
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip];
|
||||
float *no = subgrid[x + y*gridSize].no;
|
||||
float *co = subgrid[x + y*gridSize].co;
|
||||
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
|
||||
float *no = subgrid[x + y * gridSize].no;
|
||||
float *co = subgrid[x + y * gridSize].co;
|
||||
float mat[3][3], tx[3], ty[3], dco[3];
|
||||
|
||||
/* construct tangent space matrix */
|
||||
@@ -1308,12 +1308,12 @@ void multires_stitch_grids(Object *ob)
|
||||
{
|
||||
/* utility for smooth brush */
|
||||
if (ob && ob->derivedFinal) {
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)ob->derivedFinal;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)ob->derivedFinal;
|
||||
CCGFace **faces;
|
||||
int totface;
|
||||
|
||||
if (ccgdm->pbvh) {
|
||||
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void***)&faces, &totface);
|
||||
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void ***)&faces, &totface);
|
||||
|
||||
if (totface) {
|
||||
ccgSubSurf_stitchFaces(ccgdm->ss, 0, faces, totface);
|
||||
@@ -1324,25 +1324,25 @@ void multires_stitch_grids(Object *ob)
|
||||
}
|
||||
|
||||
DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd,
|
||||
int local_mmd, DerivedMesh *dm,
|
||||
Object *ob, int useRenderParams)
|
||||
int local_mmd, DerivedMesh *dm,
|
||||
Object *ob, int useRenderParams)
|
||||
{
|
||||
Mesh *me= ob->data;
|
||||
Mesh *me = ob->data;
|
||||
DerivedMesh *result;
|
||||
CCGDerivedMesh *ccgdm = NULL;
|
||||
DMGridData **gridData, **subGridData;
|
||||
int lvl= multires_get_level(ob, mmd, useRenderParams);
|
||||
int lvl = multires_get_level(ob, mmd, useRenderParams);
|
||||
int i, gridSize, numGrids;
|
||||
|
||||
if (lvl == 0)
|
||||
return dm;
|
||||
|
||||
result = subsurf_dm_create_local(ob, dm, lvl,
|
||||
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges,
|
||||
mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges,
|
||||
mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
|
||||
if (!local_mmd) {
|
||||
ccgdm = (CCGDerivedMesh*)result;
|
||||
ccgdm = (CCGDerivedMesh *)result;
|
||||
|
||||
ccgdm->multires.ob = ob;
|
||||
ccgdm->multires.mmd = mmd;
|
||||
@@ -1356,11 +1356,11 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd,
|
||||
gridSize = result->getGridSize(result);
|
||||
gridData = result->getGridData(result);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
|
||||
subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*");
|
||||
|
||||
for (i = 0; i < numGrids; i++) {
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * gridSize * gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData) * gridSize * gridSize);
|
||||
}
|
||||
|
||||
multires_set_tot_mdisps(me, mmd->totlvl);
|
||||
@@ -1430,22 +1430,22 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
|
||||
|
||||
static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, int y, float *u, float *v)
|
||||
{
|
||||
float offset = oldside*0.5f - 0.5f;
|
||||
float offset = oldside * 0.5f - 0.5f;
|
||||
|
||||
if (S == 1) { *u= offset + x; *v = offset - y; }
|
||||
if (S == 2) { *u= offset + y; *v = offset + x; }
|
||||
if (S == 3) { *u= offset - x; *v = offset + y; }
|
||||
if (S == 0) { *u= offset - y; *v = offset - x; }
|
||||
if (S == 1) { *u = offset + x; *v = offset - y; }
|
||||
if (S == 2) { *u = offset + y; *v = offset + x; }
|
||||
if (S == 3) { *u = offset - x; *v = offset + y; }
|
||||
if (S == 0) { *u = offset - y; *v = offset - x; }
|
||||
}
|
||||
|
||||
static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
|
||||
{
|
||||
int newlvl = log(sqrt(mdisp->totdisp)-1)/M_LN2;
|
||||
int oldlvl = newlvl+1;
|
||||
int newlvl = log(sqrt(mdisp->totdisp) - 1) / M_LN2;
|
||||
int oldlvl = newlvl + 1;
|
||||
int oldside = multires_side_tot[oldlvl];
|
||||
int newside = multires_side_tot[newlvl];
|
||||
int nvert = (mface->v4)? 4: 3;
|
||||
int newtotdisp = multires_grid_tot[newlvl]*nvert;
|
||||
int nvert = (mface->v4) ? 4 : 3;
|
||||
int newtotdisp = multires_grid_tot[newlvl] * nvert;
|
||||
int x, y, S;
|
||||
float (*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */
|
||||
|
||||
@@ -1458,19 +1458,19 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
|
||||
old_mdisps_rotate(S, newside, oldside, x, y, &u, &v);
|
||||
old_mdisps_bilinear(*out, mdisp->disps, oldside, u, v);
|
||||
|
||||
if (S == 1) { (*out)[1]= -(*out)[1]; }
|
||||
if (S == 1) { (*out)[1] = -(*out)[1]; }
|
||||
else if (S == 2) { SWAP(float, (*out)[0], (*out)[1]); }
|
||||
else if (S == 3) { (*out)[0]= -(*out)[0]; }
|
||||
else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0]= -(*out)[0]; (*out)[1]= -(*out)[1]; };
|
||||
else if (S == 3) { (*out)[0] = -(*out)[0]; }
|
||||
else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0] = -(*out)[0]; (*out)[1] = -(*out)[1]; };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(mdisp->disps);
|
||||
|
||||
mdisp->totdisp= newtotdisp;
|
||||
mdisp->level= newlvl;
|
||||
mdisp->disps= disps;
|
||||
mdisp->totdisp = newtotdisp;
|
||||
mdisp->level = newlvl;
|
||||
mdisp->disps = disps;
|
||||
}
|
||||
|
||||
void multires_load_old_250(Mesh *me)
|
||||
@@ -1479,10 +1479,10 @@ void multires_load_old_250(Mesh *me)
|
||||
MFace *mf;
|
||||
int i, j, k;
|
||||
|
||||
mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS);
|
||||
|
||||
if (mdisps) {
|
||||
for (i=0; i<me->totface; i++)
|
||||
for (i = 0; i < me->totface; i++)
|
||||
if (mdisps[i].totdisp)
|
||||
old_mdisps_convert(&me->mface[i], &mdisps[i]);
|
||||
|
||||
@@ -1491,15 +1491,15 @@ void multires_load_old_250(Mesh *me)
|
||||
|
||||
k = 0;
|
||||
mf = me->mface;
|
||||
for (i=0; i<me->totface; i++, mf++) {
|
||||
for (i = 0; i < me->totface; i++, mf++) {
|
||||
int nvert = mf->v4 ? 4 : 3;
|
||||
int totdisp = mdisps[i].totdisp / nvert;
|
||||
|
||||
for (j=0; j < mf->v4 ? 4 : 3; j++, k++) {
|
||||
mdisps2[k].disps = MEM_callocN(sizeof(float)*3*totdisp, "multires disp in conversion");
|
||||
for (j = 0; j < mf->v4 ? 4 : 3; j++, k++) {
|
||||
mdisps2[k].disps = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disp in conversion");
|
||||
mdisps2[k].totdisp = totdisp;
|
||||
mdisps2[k].level = mdisps[i].level;
|
||||
memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp*j, totdisp);
|
||||
memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp * j, totdisp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1519,7 +1519,7 @@ static void multires_free_level(MultiresLevel *lvl)
|
||||
void multires_free(Multires *mr)
|
||||
{
|
||||
if (mr) {
|
||||
MultiresLevel* lvl= mr->levels.first;
|
||||
MultiresLevel *lvl = mr->levels.first;
|
||||
|
||||
/* Free the first-level data */
|
||||
if (lvl) {
|
||||
@@ -1533,7 +1533,7 @@ void multires_free(Multires *mr)
|
||||
|
||||
while (lvl) {
|
||||
multires_free_level(lvl);
|
||||
lvl= lvl->next;
|
||||
lvl = lvl->next;
|
||||
}
|
||||
|
||||
MEM_freeN(mr->verts);
|
||||
@@ -1551,12 +1551,12 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult
|
||||
IndexNode *node = NULL;
|
||||
|
||||
(*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert face map");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totface*4, "vert face map mem");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totface * 4, "vert face map mem");
|
||||
node = *mem;
|
||||
|
||||
/* Find the users */
|
||||
for (i = 0; i < totface; ++i) {
|
||||
for (j = 0; j < (mface[i].v[3]?4:3); ++j, ++node) {
|
||||
for (j = 0; j < (mface[i].v[3] ? 4 : 3); ++j, ++node) {
|
||||
node->index = i;
|
||||
BLI_addtail(&(*map)[mface[i].v[j]], node);
|
||||
}
|
||||
@@ -1564,13 +1564,13 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult
|
||||
}
|
||||
|
||||
static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const MultiresEdge *medge,
|
||||
const int totvert, const int totedge)
|
||||
const int totvert, const int totedge)
|
||||
{
|
||||
int i, j;
|
||||
IndexNode *node = NULL;
|
||||
|
||||
(*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert edge map");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totedge*2, "vert edge map mem");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totedge * 2, "vert edge map mem");
|
||||
node = *mem;
|
||||
|
||||
/* Find the users */
|
||||
@@ -1587,10 +1587,10 @@ static MultiresFace *find_old_face(ListBase *map, MultiresFace *faces, int v1, i
|
||||
IndexNode *n1;
|
||||
int v[4], i, j;
|
||||
|
||||
v[0]= v1;
|
||||
v[1]= v2;
|
||||
v[2]= v3;
|
||||
v[3]= v4;
|
||||
v[0] = v1;
|
||||
v[1] = v2;
|
||||
v[2] = v3;
|
||||
v[3] = v4;
|
||||
|
||||
for (n1 = map[v1].first; n1; n1 = n1->next) {
|
||||
int fnd[4] = {0, 0, 0, 0};
|
||||
@@ -1635,7 +1635,7 @@ static void multires_load_old_edges(ListBase **emap, MultiresLevel *lvl, int *vv
|
||||
}
|
||||
|
||||
static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLevel *lvl, int *vvmap, int dst,
|
||||
int v1, int v2, int v3, int v4, int st2, int st3)
|
||||
int v1, int v2, int v3, int v4, int st2, int st3)
|
||||
{
|
||||
int fmid;
|
||||
int emid13, emid14, emid23, emid24;
|
||||
@@ -1651,16 +1651,16 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe
|
||||
|
||||
|
||||
multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst + st2 * st3 + st3,
|
||||
fmid, v2, emid23, emid24, st2, st3 / 2);
|
||||
fmid, v2, emid23, emid24, st2, st3 / 2);
|
||||
|
||||
multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst - st2 * st3 + st3,
|
||||
emid14, emid24, fmid, v4, st2, st3 / 2);
|
||||
emid14, emid24, fmid, v4, st2, st3 / 2);
|
||||
|
||||
multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst + st2 * st3 - st3,
|
||||
emid13, emid23, v3, fmid, st2, st3 / 2);
|
||||
emid13, emid23, v3, fmid, st2, st3 / 2);
|
||||
|
||||
multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst - st2 * st3 - st3,
|
||||
v1, fmid, emid13, emid14, st2, st3 / 2);
|
||||
v1, fmid, emid13, emid14, st2, st3 / 2);
|
||||
|
||||
if (lvl->next->next) {
|
||||
multires_load_old_edges(emap, lvl->next, vvmap, dst, emid24, fmid, st3);
|
||||
@@ -1673,7 +1673,7 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe
|
||||
|
||||
static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
DMGridData *vd;
|
||||
int index;
|
||||
@@ -1687,13 +1687,13 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
vd= ccgSubSurf_getFaceCenterData(f);
|
||||
vd = ccgSubSurf_getFaceCenterData(f);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
i++;
|
||||
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (x = 1; x < gridSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
|
||||
vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
}
|
||||
}
|
||||
@@ -1701,7 +1701,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 1; y < gridSize - 1; y++) {
|
||||
for (x = 1; x < gridSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getFaceGridData(ss, f, S, x, y);
|
||||
vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
}
|
||||
}
|
||||
@@ -1714,7 +1714,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
int x;
|
||||
|
||||
for (x = 1; x < edgeSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getEdgeData(ss, e, x);
|
||||
vd = ccgSubSurf_getEdgeData(ss, e, x);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
}
|
||||
}
|
||||
@@ -1723,7 +1723,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
for (index = 0; index < totvert; index++) {
|
||||
CCGVert *v = ccgdm->vertMap[index].vert;
|
||||
|
||||
vd= ccgSubSurf_getVertData(ss, v);
|
||||
vd = ccgSubSurf_getVertData(ss, v);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
i++;
|
||||
}
|
||||
@@ -1735,7 +1735,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
|
||||
{
|
||||
MultiresLevel *lvl, *lvl1;
|
||||
Multires *mr= me->mr;
|
||||
Multires *mr = me->mr;
|
||||
MVert *vsrc, *vdst;
|
||||
unsigned int src, dst;
|
||||
int st = multires_side_tot[totlvl - 1] - 1;
|
||||
@@ -1834,10 +1834,10 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
|
||||
}
|
||||
|
||||
/* calculate vert to edge/face maps for each level (except the last) */
|
||||
fmap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires fmap");
|
||||
emap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires emap");
|
||||
fmem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires fmem");
|
||||
emem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires emem");
|
||||
fmap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires fmap");
|
||||
emap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires emap");
|
||||
fmem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires fmem");
|
||||
emem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires emem");
|
||||
lvl = lvl1;
|
||||
for (i = 0; i < (unsigned int)mr->level_count - 1; ++i) {
|
||||
create_old_vert_face_map(fmap + i, fmem + i, lvl->faces, lvl->totvert, lvl->totface);
|
||||
@@ -1862,10 +1862,10 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
|
||||
int pv = lvl1->faces[j].v[s == 0 ? sides - 1 : s - 1];
|
||||
|
||||
multires_load_old_faces(fmap, emap, lvl1->next, vvmap, mid,
|
||||
vvmap[dst], cv,
|
||||
find_old_edge(emap[0], lvl1->edges, pv, cv)->mid,
|
||||
find_old_edge(emap[0], lvl1->edges, cv, nv)->mid,
|
||||
st2, st4);
|
||||
vvmap[dst], cv,
|
||||
find_old_edge(emap[0], lvl1->edges, pv, cv)->mid,
|
||||
find_old_edge(emap[0], lvl1->edges, cv, nv)->mid,
|
||||
st2, st4);
|
||||
|
||||
ldst += (st - 1) * (st - 1);
|
||||
}
|
||||
@@ -1920,10 +1920,10 @@ static void multires_load_old_vcols(Mesh *me)
|
||||
|
||||
for (i = 0; i < me->totface; ++i) {
|
||||
for (j = 0; j < 4; ++j) {
|
||||
mcol[i*4 + j].a = colface[i].col[j].a;
|
||||
mcol[i*4 + j].r = colface[i].col[j].r;
|
||||
mcol[i*4 + j].g = colface[i].col[j].g;
|
||||
mcol[i*4 + j].b = colface[i].col[j].b;
|
||||
mcol[i * 4 + j].a = colface[i].col[j].a;
|
||||
mcol[i * 4 + j].r = colface[i].col[j].r;
|
||||
mcol[i * 4 + j].g = colface[i].col[j].g;
|
||||
mcol[i * 4 + j].b = colface[i].col[j].b;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1982,7 +1982,7 @@ void multires_load_old(Object *ob, Mesh *me)
|
||||
md = ob->modifiers.first;
|
||||
while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
|
||||
md = md->next;
|
||||
mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires);
|
||||
mmd = (MultiresModifierData *)modifier_new(eModifierType_Multires);
|
||||
BLI_insertlinkbefore(&ob->modifiers, md, mmd);
|
||||
|
||||
for (i = 0; i < me->mr->level_count - 1; ++i)
|
||||
@@ -1992,7 +1992,7 @@ void multires_load_old(Object *ob, Mesh *me)
|
||||
orig = CDDM_from_mesh(me, NULL);
|
||||
dm = multires_dm_create_from_derived(mmd, 0, orig, ob, 0);
|
||||
|
||||
multires_load_old_dm(dm, me, mmd->totlvl+1);
|
||||
multires_load_old_dm(dm, me, mmd->totlvl + 1);
|
||||
|
||||
multires_dm_mark_as_modified(dm, MULTIRES_COORDS_MODIFIED);
|
||||
dm->release(dm);
|
||||
@@ -2011,13 +2011,13 @@ void multires_load_old(Object *ob, Mesh *me)
|
||||
|
||||
/* Remove the old multires */
|
||||
multires_free(me->mr);
|
||||
me->mr= NULL;
|
||||
me->mr = NULL;
|
||||
}
|
||||
|
||||
static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
|
||||
{
|
||||
MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob, 1);
|
||||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData *to_mmd = get_multires_modifier(scene, to_ob, 1);
|
||||
|
||||
if (!mmd) {
|
||||
/* object could have MDISP even when there is no multires modifier
|
||||
@@ -2030,77 +2030,77 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
|
||||
|
||||
if (!mmd || !to_mmd) return;
|
||||
|
||||
if (mmd->totlvl>to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl);
|
||||
if (mmd->totlvl > to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl);
|
||||
else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple);
|
||||
}
|
||||
|
||||
static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
|
||||
{
|
||||
DerivedMesh *dm= NULL, *cddm= NULL, *subdm= NULL;
|
||||
DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
|
||||
DMGridData **gridData, **subGridData;
|
||||
Mesh *me= (Mesh*)ob->data;
|
||||
MPoly *mpoly= me->mpoly;
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
MPoly *mpoly = me->mpoly;
|
||||
/* MLoop *mloop = me->mloop; */ /* UNUSED */
|
||||
MDisps *mdisps;
|
||||
int *gridOffset;
|
||||
int i, /*numGrids, */ gridSize, dGridSize, dSkip, totvert;
|
||||
float (*vertCos)[3] = NULL;
|
||||
MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData high_mmd;
|
||||
|
||||
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
|
||||
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
if (!mdisps || !mmd || !mmd->totlvl) return;
|
||||
|
||||
/* we need derived mesh created from highest resolution */
|
||||
high_mmd= *mmd;
|
||||
high_mmd.lvl= high_mmd.totlvl;
|
||||
high_mmd = *mmd;
|
||||
high_mmd.lvl = high_mmd.totlvl;
|
||||
|
||||
/* unscaled multires with applied displacement */
|
||||
subdm= get_multires_dm(scene, &high_mmd, ob);
|
||||
subdm = get_multires_dm(scene, &high_mmd, ob);
|
||||
|
||||
/* prepare scaled CDDM to create ccgDN */
|
||||
cddm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
||||
cddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
||||
|
||||
totvert= cddm->getNumVerts(cddm);
|
||||
vertCos= MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
|
||||
totvert = cddm->getNumVerts(cddm);
|
||||
vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
|
||||
cddm->getVertCos(cddm, vertCos);
|
||||
for (i=0; i<totvert; i++)
|
||||
for (i = 0; i < totvert; i++)
|
||||
mul_m3_v3(smat, vertCos[i]);
|
||||
CDDM_apply_vert_coords(cddm, vertCos);
|
||||
MEM_freeN(vertCos);
|
||||
|
||||
/* scaled ccgDM for tangent space of object with applied scale */
|
||||
dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
cddm->release(cddm);
|
||||
|
||||
/*numGrids= dm->getNumGrids(dm);*/ /*UNUSED*/
|
||||
gridSize= dm->getGridSize(dm);
|
||||
gridData= dm->getGridData(dm);
|
||||
gridOffset= dm->getGridOffset(dm);
|
||||
subGridData= subdm->getGridData(subdm);
|
||||
gridSize = dm->getGridSize(dm);
|
||||
gridData = dm->getGridData(dm);
|
||||
gridOffset = dm->getGridOffset(dm);
|
||||
subGridData = subdm->getGridData(subdm);
|
||||
|
||||
dGridSize= multires_side_tot[high_mmd.totlvl];
|
||||
dSkip= (dGridSize-1)/(gridSize-1);
|
||||
dGridSize = multires_side_tot[high_mmd.totlvl];
|
||||
dSkip = (dGridSize - 1) / (gridSize - 1);
|
||||
|
||||
#pragma omp parallel for private(i) if (me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT)
|
||||
for (i = 0; i < me->totpoly; ++i) {
|
||||
const int numVerts= mpoly[i].totloop;
|
||||
MDisps *mdisp= &mdisps[mpoly[i].loopstart];
|
||||
const int numVerts = mpoly[i].totloop;
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart];
|
||||
int S, x, y, gIndex = gridOffset[i];
|
||||
|
||||
for (S = 0; S < numVerts; ++S, ++gIndex, mdisp++) {
|
||||
DMGridData *grid= gridData[gIndex];
|
||||
DMGridData *subgrid= subGridData[gIndex];
|
||||
float (*dispgrid)[3]= mdisp->disps;
|
||||
DMGridData *grid = gridData[gIndex];
|
||||
DMGridData *subgrid = subGridData[gIndex];
|
||||
float (*dispgrid)[3] = mdisp->disps;
|
||||
|
||||
for (y = 0; y < gridSize; y++) {
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
float *co= grid[x + y*gridSize].co;
|
||||
float *sco= subgrid[x + y*gridSize].co;
|
||||
float *no= grid[x + y*gridSize].no;
|
||||
float *data= dispgrid[dGridSize*y*dSkip + x*dSkip];
|
||||
float *co = grid[x + y * gridSize].co;
|
||||
float *sco = subgrid[x + y * gridSize].co;
|
||||
float *no = grid[x + y * gridSize].no;
|
||||
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
|
||||
float mat[3][3], tx[3], ty[3], disp[3];
|
||||
|
||||
/* construct tangent space matrix */
|
||||
@@ -2130,11 +2130,11 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
|
||||
|
||||
int multires_mdisp_corners(MDisps *s)
|
||||
{
|
||||
int lvl= 13;
|
||||
int lvl = 13;
|
||||
|
||||
while (lvl > 0) {
|
||||
int side = (1 << (lvl-1)) + 1;
|
||||
if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side);
|
||||
int side = (1 << (lvl - 1)) + 1;
|
||||
if ((s->totdisp % (side * side)) == 0) return s->totdisp / (side * side);
|
||||
lvl--;
|
||||
}
|
||||
|
||||
@@ -2204,14 +2204,14 @@ void multires_topology_changed(Mesh *me)
|
||||
/* Find per-corner coordinate with given per-face UV coord */
|
||||
int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y)
|
||||
{
|
||||
const float offset = face_side*0.5f - 0.5f;
|
||||
const float offset = face_side * 0.5f - 0.5f;
|
||||
int S = 0;
|
||||
|
||||
if (corners == 4) {
|
||||
if (u <= offset && v <= offset) S = 0;
|
||||
else if (u > offset && v <= offset) S = 1;
|
||||
else if (u > offset && v > offset) S = 2;
|
||||
else if (u <= offset && v >= offset) S = 3;
|
||||
else if (u <= offset && v >= offset) S = 3;
|
||||
|
||||
if (S == 0) {
|
||||
*y = offset - u;
|
||||
@@ -2226,7 +2226,7 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u,
|
||||
*x = v - offset;
|
||||
}
|
||||
else if (S == 3) {
|
||||
*x= offset - u;
|
||||
*x = offset - u;
|
||||
*y = v - offset;
|
||||
}
|
||||
}
|
||||
@@ -2235,15 +2235,15 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u,
|
||||
float w = (face_side - 1) - u - v;
|
||||
float W1, W2;
|
||||
|
||||
if (u >= v && u >= w) {S = 0; W1= w; W2= v;}
|
||||
else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w;}
|
||||
else {S = 2; W1 = v; W2 = u;}
|
||||
if (u >= v && u >= w) {S = 0; W1 = w; W2 = v; }
|
||||
else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w; }
|
||||
else {S = 2; W1 = v; W2 = u; }
|
||||
|
||||
W1 /= (face_side-1);
|
||||
W2 /= (face_side-1);
|
||||
W1 /= (face_side - 1);
|
||||
W2 /= (face_side - 1);
|
||||
|
||||
*x = (1-(2*W1)/(1-W2)) * grid_size;
|
||||
*y = (1-(2*W2)/(1-W1)) * grid_size;
|
||||
*x = (1 - (2 * W1) / (1 - W2)) * grid_size;
|
||||
*y = (1 - (2 * W2) / (1 - W1)) * grid_size;
|
||||
}
|
||||
|
||||
return S;
|
||||
|
||||
@@ -73,17 +73,17 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
|
||||
if (pf) {
|
||||
oldseek = pf->seek;
|
||||
switch (whence) {
|
||||
case SEEK_CUR:
|
||||
seek = oldseek + offset;
|
||||
break;
|
||||
case SEEK_END:
|
||||
seek = pf->size + offset;
|
||||
break;
|
||||
case SEEK_SET:
|
||||
seek = offset;
|
||||
break;
|
||||
default:
|
||||
oldseek = -1;
|
||||
case SEEK_CUR:
|
||||
seek = oldseek + offset;
|
||||
break;
|
||||
case SEEK_END:
|
||||
seek = pf->size + offset;
|
||||
break;
|
||||
case SEEK_SET:
|
||||
seek = offset;
|
||||
break;
|
||||
default:
|
||||
oldseek = -1;
|
||||
}
|
||||
if (seek < 0) {
|
||||
seek = 0;
|
||||
@@ -133,15 +133,15 @@ int countPackedFiles(Main *bmain)
|
||||
int count = 0;
|
||||
|
||||
// let's check if there are packed files...
|
||||
for (ima=bmain->image.first; ima; ima=ima->id.next)
|
||||
for (ima = bmain->image.first; ima; ima = ima->id.next)
|
||||
if (ima->packedfile)
|
||||
count++;
|
||||
|
||||
for (vf=bmain->vfont.first; vf; vf=vf->id.next)
|
||||
for (vf = bmain->vfont.first; vf; vf = vf->id.next)
|
||||
if (vf->packedfile)
|
||||
count++;
|
||||
|
||||
for (sound=bmain->sound.first; sound; sound=sound->id.next)
|
||||
for (sound = bmain->sound.first; sound; sound = sound->id.next)
|
||||
if (sound->packedfile)
|
||||
count++;
|
||||
|
||||
@@ -176,7 +176,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
|
||||
|
||||
/* render result has no filename and can be ignored
|
||||
* any other files with no name can be ignored too */
|
||||
if (filename[0]=='\0')
|
||||
if (filename[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
//XXX waitcursor(1);
|
||||
@@ -189,7 +189,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
|
||||
// open the file
|
||||
// and create a PackedFile structure
|
||||
|
||||
file= BLI_open(name, O_BINARY|O_RDONLY, 0);
|
||||
file = BLI_open(name, O_BINARY | O_RDONLY, 0);
|
||||
if (file <= 0) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name);
|
||||
}
|
||||
@@ -222,23 +222,23 @@ void packAll(Main *bmain, ReportList *reports)
|
||||
VFont *vf;
|
||||
bSound *sound;
|
||||
|
||||
for (ima=bmain->image.first; ima; ima=ima->id.next) {
|
||||
if (ima->packedfile == NULL && ima->id.lib==NULL) {
|
||||
if (ima->source==IMA_SRC_FILE) {
|
||||
for (ima = bmain->image.first; ima; ima = ima->id.next) {
|
||||
if (ima->packedfile == NULL && ima->id.lib == NULL) {
|
||||
if (ima->source == IMA_SRC_FILE) {
|
||||
ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
|
||||
}
|
||||
else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
|
||||
BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name+2);
|
||||
BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (vf=bmain->vfont.first; vf; vf=vf->id.next)
|
||||
if (vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0)
|
||||
for (vf = bmain->vfont.first; vf; vf = vf->id.next)
|
||||
if (vf->packedfile == NULL && vf->id.lib == NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0)
|
||||
vf->packedfile = newPackedFile(reports, vf->name, bmain->name);
|
||||
|
||||
for (sound=bmain->sound.first; sound; sound=sound->id.next)
|
||||
if (sound->packedfile == NULL && sound->id.lib==NULL)
|
||||
for (sound = bmain->sound.first; sound; sound = sound->id.next)
|
||||
if (sound->packedfile == NULL && sound->id.lib == NULL)
|
||||
sound->packedfile = newPackedFile(reports, sound->name, bmain->name);
|
||||
}
|
||||
|
||||
@@ -257,12 +257,12 @@ static char *find_new_name(char *name)
|
||||
if (fop_exists(name)) {
|
||||
for (number = 1; number <= 999; number++) {
|
||||
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number);
|
||||
if (! fop_exists(tempname)) {
|
||||
if (!fop_exists(tempname)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
len= strlen(tempname) + 1;
|
||||
len = strlen(tempname) + 1;
|
||||
newname = MEM_mallocN(len, "find_new_name");
|
||||
memcpy(newname, tempname, len * sizeof(char));
|
||||
return newname;
|
||||
@@ -275,7 +275,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
|
||||
int ret_value = RET_OK;
|
||||
char name[FILE_MAX];
|
||||
char tempname[FILE_MAX];
|
||||
/* void *data; */
|
||||
/* void *data; */
|
||||
|
||||
if (guimode) {} //XXX waitcursor(1);
|
||||
|
||||
@@ -285,7 +285,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
|
||||
if (BLI_exists(name)) {
|
||||
for (number = 1; number <= 999; number++) {
|
||||
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number);
|
||||
if (! BLI_exists(tempname)) {
|
||||
if (!BLI_exists(tempname)) {
|
||||
if (BLI_copy(name, tempname) == RET_OK) {
|
||||
remove_tmp = TRUE;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
|
||||
case PF_KEEP:
|
||||
break;
|
||||
case PF_REMOVE:
|
||||
temp= abs_name;
|
||||
temp = abs_name;
|
||||
break;
|
||||
case PF_USE_LOCAL:
|
||||
// if file exists use it
|
||||
@@ -417,7 +417,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
|
||||
temp = local_name;
|
||||
break;
|
||||
}
|
||||
// else fall through and create it
|
||||
// else fall through and create it
|
||||
case PF_WRITE_LOCAL:
|
||||
if (writePackedFile(reports, local_name, pf, 1) == RET_OK) {
|
||||
temp = local_name;
|
||||
@@ -429,7 +429,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
|
||||
temp = abs_name;
|
||||
break;
|
||||
}
|
||||
// else fall through and create it
|
||||
// else fall through and create it
|
||||
case PF_WRITE_ORIGINAL:
|
||||
if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) {
|
||||
temp = abs_name;
|
||||
@@ -441,7 +441,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
|
||||
}
|
||||
|
||||
if (temp) {
|
||||
newname= BLI_strdup(temp);
|
||||
newname = BLI_strdup(temp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,15 +533,15 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
|
||||
VFont *vf;
|
||||
bSound *sound;
|
||||
|
||||
for (ima=bmain->image.first; ima; ima=ima->id.next)
|
||||
for (ima = bmain->image.first; ima; ima = ima->id.next)
|
||||
if (ima->packedfile)
|
||||
unpackImage(reports, ima, how);
|
||||
|
||||
for (vf=bmain->vfont.first; vf; vf=vf->id.next)
|
||||
for (vf = bmain->vfont.first; vf; vf = vf->id.next)
|
||||
if (vf->packedfile)
|
||||
unpackVFont(reports, vf, how);
|
||||
|
||||
for (sound=bmain->sound.first; sound; sound=sound->id.next)
|
||||
for (sound = bmain->sound.first; sound; sound = sound->id.next)
|
||||
if (sound->packedfile)
|
||||
unpackSound(bmain, reports, sound, how);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void free_properties(ListBase *lb)
|
||||
{
|
||||
bProperty *prop;
|
||||
|
||||
while ( (prop= lb->first) ) {
|
||||
while ( (prop = lb->first) ) {
|
||||
BLI_remlink(lb, prop);
|
||||
free_property(prop);
|
||||
}
|
||||
@@ -67,11 +67,11 @@ bProperty *copy_property(bProperty *prop)
|
||||
{
|
||||
bProperty *propn;
|
||||
|
||||
propn= MEM_dupallocN(prop);
|
||||
propn = MEM_dupallocN(prop);
|
||||
if (prop->poin && prop->poin != &prop->data) {
|
||||
propn->poin= MEM_dupallocN(prop->poin);
|
||||
propn->poin = MEM_dupallocN(prop->poin);
|
||||
}
|
||||
else propn->poin= &propn->data;
|
||||
else propn->poin = &propn->data;
|
||||
|
||||
return propn;
|
||||
}
|
||||
@@ -80,11 +80,11 @@ void copy_properties(ListBase *lbn, ListBase *lbo)
|
||||
{
|
||||
bProperty *prop, *propn;
|
||||
free_properties(lbn); /* in case we are copying to an object with props */
|
||||
prop= lbo->first;
|
||||
prop = lbo->first;
|
||||
while (prop) {
|
||||
propn= copy_property(prop);
|
||||
propn = copy_property(prop);
|
||||
BLI_addtail(lbn, propn);
|
||||
prop= prop->next;
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,20 +95,20 @@ void init_property(bProperty *prop)
|
||||
/* also use when property changes type */
|
||||
|
||||
if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
|
||||
prop->poin= NULL;
|
||||
prop->poin = NULL;
|
||||
|
||||
prop->data= 0;
|
||||
prop->data = 0;
|
||||
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
prop->poin= &prop->data;
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
prop->poin= MEM_callocN(MAX_PROPSTRING, "property string");
|
||||
break;
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
prop->poin = &prop->data;
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
prop->poin = MEM_callocN(MAX_PROPSTRING, "property string");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ bProperty *new_property(int type)
|
||||
{
|
||||
bProperty *prop;
|
||||
|
||||
prop= MEM_callocN(sizeof(bProperty), "property");
|
||||
prop->type= type;
|
||||
prop = MEM_callocN(sizeof(bProperty), "property");
|
||||
prop->type = type;
|
||||
|
||||
init_property(prop);
|
||||
|
||||
@@ -131,8 +131,8 @@ bProperty *new_property(int type)
|
||||
static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name)
|
||||
{
|
||||
bProperty *p;
|
||||
for (p= first; p; p= p->next) {
|
||||
if (p!=self && (strcmp(p->name, name)==0))
|
||||
for (p = first; p; p = p->next) {
|
||||
if (p != self && (strcmp(p->name, name) == 0))
|
||||
return p;
|
||||
}
|
||||
return NULL;
|
||||
@@ -142,10 +142,10 @@ void unique_property(bProperty *first, bProperty *prop, int force)
|
||||
bProperty *p;
|
||||
|
||||
/* set the first if its not set */
|
||||
if (first==NULL) {
|
||||
first= prop;
|
||||
if (first == NULL) {
|
||||
first = prop;
|
||||
while (first->prev) {
|
||||
first= first->prev;
|
||||
first = first->prev;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,14 +162,14 @@ void unique_property(bProperty *first, bProperty *prop, int force)
|
||||
char new_name[sizeof(prop->name)];
|
||||
char base_name[sizeof(prop->name)];
|
||||
char num[sizeof(prop->name)];
|
||||
int i= 0;
|
||||
int i = 0;
|
||||
|
||||
/* strip numbers */
|
||||
BLI_strncpy(base_name, prop->name, sizeof(base_name));
|
||||
for (i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) {
|
||||
base_name[i]= '\0';
|
||||
for (i = strlen(base_name) - 1; (i >= 0 && isdigit(base_name[i])); i--) {
|
||||
base_name[i] = '\0';
|
||||
}
|
||||
i= 0;
|
||||
i = 0;
|
||||
|
||||
do { /* ensure we have enough chars for the new number in the name */
|
||||
BLI_snprintf(num, sizeof(num), "%d", i++);
|
||||
@@ -190,7 +190,7 @@ bProperty *get_ob_property(Object *ob, const char *name)
|
||||
void set_ob_property(Object *ob, bProperty *propc)
|
||||
{
|
||||
bProperty *prop;
|
||||
prop= get_ob_property(ob, propc->name);
|
||||
prop = get_ob_property(ob, propc->name);
|
||||
if (prop) {
|
||||
free_property(prop);
|
||||
BLI_remlink(&ob->prop, prop);
|
||||
@@ -207,32 +207,32 @@ int compare_property(bProperty *prop, const char *str)
|
||||
float fvalue, ftest;
|
||||
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true")==0) {
|
||||
if (prop->data==1) return 0;
|
||||
else return 1;
|
||||
}
|
||||
else if (BLI_strcasecmp(str, "false")==0) {
|
||||
if (prop->data==0) return 0;
|
||||
else return 1;
|
||||
}
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true") == 0) {
|
||||
if (prop->data == 1) return 0;
|
||||
else return 1;
|
||||
}
|
||||
else if (BLI_strcasecmp(str, "false") == 0) {
|
||||
if (prop->data == 0) return 0;
|
||||
else return 1;
|
||||
}
|
||||
/* no break, do GPROP_int too! */
|
||||
|
||||
case GPROP_INT:
|
||||
return prop->data - atoi(str);
|
||||
case GPROP_INT:
|
||||
return prop->data - atoi(str);
|
||||
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
// WARNING: untested for GPROP_TIME
|
||||
// function isn't used currently
|
||||
fvalue= *((float *)&prop->data);
|
||||
ftest= (float)atof(str);
|
||||
if ( fvalue > ftest) return 1;
|
||||
else if ( fvalue < ftest) return -1;
|
||||
return 0;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
// WARNING: untested for GPROP_TIME
|
||||
// function isn't used currently
|
||||
fvalue = *((float *)&prop->data);
|
||||
ftest = (float)atof(str);
|
||||
if (fvalue > ftest) return 1;
|
||||
else if (fvalue < ftest) return -1;
|
||||
return 0;
|
||||
|
||||
case GPROP_STRING:
|
||||
return strcmp(prop->poin, str);
|
||||
case GPROP_STRING:
|
||||
return strcmp(prop->poin, str);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -243,21 +243,21 @@ void set_property(bProperty *prop, const char *str)
|
||||
// extern int Gdfra; /* sector.c */
|
||||
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true")==0) prop->data= 1;
|
||||
else if (BLI_strcasecmp(str, "false")==0) prop->data= 0;
|
||||
else prop->data= (atoi(str)!=0);
|
||||
break;
|
||||
case GPROP_INT:
|
||||
prop->data= atoi(str);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
*((float *)&prop->data)= (float)atof(str);
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
strcpy(prop->poin, str); /* TODO - check size? */
|
||||
break;
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true") == 0) prop->data = 1;
|
||||
else if (BLI_strcasecmp(str, "false") == 0) prop->data = 0;
|
||||
else prop->data = (atoi(str) != 0);
|
||||
break;
|
||||
case GPROP_INT:
|
||||
prop->data = atoi(str);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
*((float *)&prop->data) = (float)atof(str);
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
strcpy(prop->poin, str); /* TODO - check size? */
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -267,17 +267,17 @@ void add_property(bProperty *prop, const char *str)
|
||||
// extern int Gdfra; /* sector.c */
|
||||
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
prop->data+= atoi(str);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
*((float *)&prop->data)+= (float)atof(str);
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
/* strcpy(prop->poin, str); */
|
||||
break;
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
prop->data += atoi(str);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
*((float *)&prop->data) += (float)atof(str);
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
/* strcpy(prop->poin, str); */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,17 +289,17 @@ void set_property_valstr(bProperty *prop, char *str)
|
||||
if (str == NULL) return;
|
||||
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
sprintf(str, "%d", prop->data);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
sprintf(str, "%f", *((float *)&prop->data));
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
BLI_strncpy(str, prop->poin, MAX_PROPSTRING);
|
||||
break;
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
sprintf(str, "%d", prop->data);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
sprintf(str, "%f", *((float *)&prop->data));
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
BLI_strncpy(str, prop->poin, MAX_PROPSTRING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1492,7 +1492,7 @@ void BKE_free_pointdensity(PointDensity *pd)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void BKE_free_voxeldatadata(struct VoxelData *vd)
|
||||
void BKE_free_voxeldatadata(VoxelData *vd)
|
||||
{
|
||||
if (vd->dataset) {
|
||||
MEM_freeN(vd->dataset);
|
||||
@@ -1501,17 +1501,17 @@ void BKE_free_voxeldatadata(struct VoxelData *vd)
|
||||
|
||||
}
|
||||
|
||||
void BKE_free_voxeldata(struct VoxelData *vd)
|
||||
void BKE_free_voxeldata(VoxelData *vd)
|
||||
{
|
||||
BKE_free_voxeldatadata(vd);
|
||||
MEM_freeN(vd);
|
||||
}
|
||||
|
||||
struct VoxelData *BKE_add_voxeldata(void)
|
||||
VoxelData *BKE_add_voxeldata(void)
|
||||
{
|
||||
VoxelData *vd;
|
||||
|
||||
vd = MEM_callocN(sizeof(struct VoxelData), "voxeldata");
|
||||
vd = MEM_callocN(sizeof(VoxelData), "voxeldata");
|
||||
vd->dataset = NULL;
|
||||
vd->resol[0] = vd->resol[1] = vd->resol[2] = 1;
|
||||
vd->interp_type = TEX_VD_LINEAR;
|
||||
@@ -1525,7 +1525,7 @@ struct VoxelData *BKE_add_voxeldata(void)
|
||||
return vd;
|
||||
}
|
||||
|
||||
struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd)
|
||||
VoxelData *BKE_copy_voxeldata(VoxelData *vd)
|
||||
{
|
||||
VoxelData *vdn;
|
||||
|
||||
@@ -1537,7 +1537,7 @@ struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct OceanTex *BKE_add_oceantex(void)
|
||||
OceanTex *BKE_add_oceantex(void)
|
||||
{
|
||||
OceanTex *ot;
|
||||
|
||||
@@ -1548,7 +1548,7 @@ struct OceanTex *BKE_add_oceantex(void)
|
||||
return ot;
|
||||
}
|
||||
|
||||
struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot)
|
||||
OceanTex *BKE_copy_oceantex(struct OceanTex *ot)
|
||||
{
|
||||
OceanTex *otn = MEM_dupallocN(ot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user