style cleanup: BKE_*.c files which deal with library functions

This commit is contained in:
Campbell Barton 2012-05-06 15:15:33 +00:00
parent 53b221960a
commit c93d7a193a
25 changed files with 9260 additions and 9255 deletions

File diff suppressed because it is too large Load Diff

View File

@ -79,8 +79,8 @@ bArmature *BKE_armature_add(const char *name)
{
bArmature *arm;
arm = BKE_libblock_alloc (&G.main->armature, ID_AR, name);
arm->deformflag = ARM_DEF_VGROUP|ARM_DEF_ENVELOPE;
arm = BKE_libblock_alloc(&G.main->armature, ID_AR, name);
arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE;
arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */
arm->layer = 1;
return arm;
@ -179,7 +179,7 @@ void BKE_armature_make_local(bArmature *arm)
}
}
static void copy_bonechildren(Bone* newBone, Bone* oldBone, Bone* actBone, Bone **newActBone)
static void copy_bonechildren(Bone *newBone, Bone *oldBone, Bone *actBone, Bone **newActBone)
{
Bone *curBone, *newChildBone;
@ -205,7 +205,7 @@ bArmature *BKE_armature_copy(bArmature *arm)
{
bArmature *newArm;
Bone *oldBone, *newBone;
Bone *newActBone= NULL;
Bone *newActBone = NULL;
newArm = BKE_libblock_copy(&arm->id);
BLI_duplicatelist(&newArm->bonebase, &arm->bonebase);
@ -340,27 +340,27 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
while (change) { /* remove extensions */
change = 0;
if (len > 2 && basename[len-2] == '.') {
if (basename[len-1] == 'L' || basename[len-1] == 'R') { /* L R */
basename[len-2] = '\0';
if (len > 2 && basename[len - 2] == '.') {
if (basename[len - 1] == 'L' || basename[len - 1] == 'R') { /* L R */
basename[len - 2] = '\0';
len -= 2;
change = 1;
}
}
else if (len > 3 && basename[len-3] == '.') {
if ((basename[len-2] == 'F' && basename[len-1] == 'r') || /* Fr */
(basename[len-2] == 'B' && basename[len-1] == 'k')) /* Bk */
else if (len > 3 && basename[len - 3] == '.') {
if ((basename[len - 2] == 'F' && basename[len - 1] == 'r') || /* Fr */
(basename[len - 2] == 'B' && basename[len - 1] == 'k')) /* Bk */
{
basename[len-3] = '\0';
basename[len - 3] = '\0';
len -= 3;
change = 1;
}
}
else if (len > 4 && basename[len-4] == '.') {
if ((basename[len-3] == 'T' && basename[len-2] == 'o' && basename[len-1] == 'p') || /* Top */
(basename[len-3] == 'B' && basename[len-2] == 'o' && basename[len-1] == 't')) /* Bot */
else if (len > 4 && basename[len - 4] == '.') {
if ((basename[len - 3] == 'T' && basename[len - 2] == 'o' && basename[len - 1] == 'p') || /* Top */
(basename[len - 3] == 'B' && basename[len - 2] == 'o' && basename[len - 1] == 't')) /* Bot */
{
basename[len-4] = '\0';
basename[len - 4] = '\0';
len -= 4;
change = 1;
}
@ -368,7 +368,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
}
if ((MAXBONENAME - len) < strlen(extension) + 1) { /* add 1 for the '.' */
strncpy(name, basename, len-strlen(extension));
strncpy(name, basename, len - strlen(extension));
}
BLI_snprintf(name, MAXBONENAME, "%s.%s", basename, extension);
@ -382,44 +382,44 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
/* ************* B-Bone support ******************* */
#define MAX_BBONE_SUBDIV 32
#define MAX_BBONE_SUBDIV 32
/* data has MAX_BBONE_SUBDIV+1 interpolated points, will become desired amount with equal distances */
static void equalize_bezier(float *data, int desired)
{
float *fp, totdist, ddist, dist, fac1, fac2;
float pdist[MAX_BBONE_SUBDIV+1];
float temp[MAX_BBONE_SUBDIV+1][4];
float pdist[MAX_BBONE_SUBDIV + 1];
float temp[MAX_BBONE_SUBDIV + 1][4];
int a, nr;
pdist[0] = 0.0f;
for (a = 0, fp = data; a < MAX_BBONE_SUBDIV; a++, fp += 4) {
copy_qt_qt(temp[a], fp);
pdist[a+1] = pdist[a] + len_v3v3(fp, fp+4);
pdist[a + 1] = pdist[a] + len_v3v3(fp, fp + 4);
}
/* do last point */
copy_qt_qt(temp[a], fp);
totdist = pdist[a];
/* go over distances and calculate new points */
ddist = totdist/((float)desired);
ddist = totdist / ((float)desired);
nr = 1;
for (a = 1, fp = data+4; a < desired; a++, fp += 4) {
dist = ((float)a)*ddist;
for (a = 1, fp = data + 4; a < desired; a++, fp += 4) {
dist = ((float)a) * ddist;
/* we're looking for location (distance) 'dist' in the array */
while ((dist >= pdist[nr]) && nr < MAX_BBONE_SUBDIV)
nr++;
fac1 = pdist[nr] - pdist[nr-1];
fac1 = pdist[nr] - pdist[nr - 1];
fac2 = pdist[nr] - dist;
fac1 = fac2 / fac1;
fac2 = 1.0f - fac1;
fp[0] = fac1*temp[nr-1][0] + fac2*temp[nr][0];
fp[1] = fac1*temp[nr-1][1] + fac2*temp[nr][1];
fp[2] = fac1*temp[nr-1][2] + fac2*temp[nr][2];
fp[3] = fac1*temp[nr-1][3] + fac2*temp[nr][3];
fp[0] = fac1 * temp[nr - 1][0] + fac2 * temp[nr][0];
fp[1] = fac1 * temp[nr - 1][1] + fac2 * temp[nr][1];
fp[2] = fac1 * temp[nr - 1][2] + fac2 * temp[nr][2];
fp[3] = fac1 * temp[nr - 1][3] + fac2 * temp[nr][3];
}
/* set last point, needed for orientation calculus */
copy_qt_qt(fp, temp[MAX_BBONE_SUBDIV]);
@ -436,7 +436,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
Bone *bone = pchan->bone;
float h1[3], h2[3], scale[3], length, hlength1, hlength2, roll1 = 0.0f, roll2;
float mat3[3][3], imat[4][4], posemat[4][4], scalemat[4][4], iscalemat[4][4];
float data[MAX_BBONE_SUBDIV+1][4], *fp;
float data[MAX_BBONE_SUBDIV + 1][4], *fp;
int a, doscale = 0;
length = bone->length;
@ -459,8 +459,8 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
}
}
hlength1 = bone->ease1*length*0.390464f; /* 0.5*sqrt(2)*kappa, the handle length for near-perfect circles */
hlength2 = bone->ease2*length*0.390464f;
hlength1 = bone->ease1 * length * 0.390464f; /* 0.5*sqrt(2)*kappa, the handle length for near-perfect circles */
hlength2 = bone->ease2 * length * 0.390464f;
/* evaluate next and prev bones */
if (bone->flag & BONE_CONNECTED)
@ -494,7 +494,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
copy_v3_v3(h1, prev->pose_head);
mul_m4_v3(imat, h1);
if (prev->bone->segments>1) {
if (prev->bone->segments > 1) {
/* if previous bone is B-bone too, use average handle direction */
h1[1] -= length;
roll1 = 0.0f;
@ -534,10 +534,10 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
mul_m4_v3(imat, h2);
/* if next bone is B-bone too, use average handle direction */
if (next->bone->segments>1)
if (next->bone->segments > 1)
;
else
h2[1]-= length;
h2[1] -= length;
normalize_v3(h2);
/* find the next roll to interpolate as well */
@ -579,7 +579,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
/* make transformation matrices for the segments for drawing */
for (a = 0, fp = data[0]; a < bone->segments; a++, fp += 4) {
sub_v3_v3v3(h1, fp+4, fp);
sub_v3_v3v3(h1, fp + 4, fp);
vec_roll_to_mat3(h1, fp[3], mat3); /* fp[3] is roll */
copy_m4_m3(result_array[a].mat, mat3);
@ -613,11 +613,11 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info
int a;
/* allocate b_bone matrices and dual quats */
b_bone_mats = MEM_mallocN((1+bone->segments)*sizeof(Mat4), "BBone defmats");
b_bone_mats = MEM_mallocN((1 + bone->segments) * sizeof(Mat4), "BBone defmats");
pdef_info->b_bone_mats = b_bone_mats;
if (use_quaternion) {
b_bone_dual_quats = MEM_mallocN((bone->segments)*sizeof(DualQuat), "BBone dqs");
b_bone_dual_quats = MEM_mallocN((bone->segments) * sizeof(DualQuat), "BBone dqs");
pdef_info->b_bone_dual_quats = b_bone_dual_quats;
}
@ -634,11 +634,11 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info
for (a = 0; a < bone->segments; a++) {
invert_m4_m4(tmat, b_bone_rest[a].mat);
mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat,
mul_serie_m4(b_bone_mats[a + 1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat,
NULL, NULL, NULL);
if (use_quaternion)
mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a+1].mat);
mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a + 1].mat);
}
}
@ -650,24 +650,24 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D
int a;
/* need to transform co back to bonespace, only need y */
y = mat[0][1]*co[0] + mat[1][1]*co[1] + mat[2][1]*co[2] + mat[3][1];
y = mat[0][1] * co[0] + mat[1][1] * co[1] + mat[2][1] * co[2] + mat[3][1];
/* now calculate which of the b_bones are deforming this */
segment = bone->length/((float)bone->segments);
a = (int)(y/segment);
segment = bone->length / ((float)bone->segments);
a = (int)(y / segment);
/* note; by clamping it extends deform at endpoints, goes best with
* straight joints in restpos. */
CLAMP(a, 0, bone->segments-1);
CLAMP(a, 0, bone->segments - 1);
if (dq) {
copy_dq_dq(dq, &(pdef_info->b_bone_dual_quats)[a]);
}
else {
mul_m4_v3(b_bone[a+1].mat, co);
mul_m4_v3(b_bone[a + 1].mat, co);
if (defmat) {
copy_m3_m4(defmat, b_bone[a+1].mat);
copy_m3_m4(defmat, b_bone[a + 1].mat);
}
}
}
@ -699,27 +699,27 @@ float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3
rad = rad2;
}
else {
dist = (hsqr - (a*a));
dist = (hsqr - (a * a));
if (l != 0.0f) {
rad = a/l;
rad = rad*rad2 + (1.0f-rad)*rad1;
rad = a / l;
rad = rad * rad2 + (1.0f - rad) * rad1;
}
else
rad = rad1;
}
a = rad*rad;
a = rad * rad;
if (dist < a)
return 1.0f;
else {
l = rad+rdist;
l = rad + rdist;
l *= l;
if (rdist == 0.0f || dist >= l)
return 0.0f;
else {
a = sqrtf(dist)-rad;
return 1.0f-( a*a )/( rdist*rdist );
a = sqrtf(dist) - rad;
return 1.0f - (a * a) / (rdist * rdist);
}
}
}
@ -796,15 +796,15 @@ static void pchan_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, f
copy_v3_v3(cop, co);
if (vec) {
if (pchan->bone->segments>1)
if (pchan->bone->segments > 1)
/* applies on cop and bbonemat */
b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat) ? bbonemat : NULL);
else
mul_m4_v3(pchan->chan_mat, cop);
vec[0] += (cop[0]-co[0])*weight;
vec[1] += (cop[1]-co[1])*weight;
vec[2] += (cop[2]-co[2])*weight;
vec[0] += (cop[0] - co[0]) * weight;
vec[1] += (cop[1] - co[1]) * weight;
vec[2] += (cop[2] - co[2]) * weight;
if (mat)
pchan_deform_mat_add(pchan, weight, bbonemat, mat);
@ -856,10 +856,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
totchan = BLI_countlist(&armOb->pose->chanbase);
if (use_quaternion) {
dualquats = MEM_callocN(sizeof(DualQuat)*totchan, "dualquats");
dualquats = MEM_callocN(sizeof(DualQuat) * totchan, "dualquats");
}
pdef_info_array = MEM_callocN(sizeof(bPoseChanDeform)*totchan, "bPoseChanDeform");
pdef_info_array = MEM_callocN(sizeof(bPoseChanDeform) * totchan, "bPoseChanDeform");
totchan = 0;
pdef_info = pdef_info_array;
@ -891,7 +891,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
Lattice *lt = target->data;
dverts = lt->dvert;
if (dverts)
target_totvert = lt->pntsu*lt->pntsv*lt->pntsw;
target_totvert = lt->pntsu * lt->pntsv * lt->pntsw;
}
}
@ -963,7 +963,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
armature_weight = defvert_find_weight(dvert, armature_def_nr);
if (invert_vgroup)
armature_weight = 1.0f-armature_weight;
armature_weight = 1.0f - armature_weight;
/* hackish: the blending factor can be used for blending with prevCos too */
if (prevCos) {
@ -1039,7 +1039,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
smat = summat;
}
else {
mul_v3_fl(vec, armature_weight/contrib);
mul_v3_fl(vec, armature_weight / contrib);
add_v3_v3v3(co, vec, co);
}
@ -1051,7 +1051,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
copy_m3_m3(tmpmat, defMats[i]);
if (!use_quaternion) /* quaternion already is scale corrected */
mul_m3_fl(smat, armature_weight/contrib);
mul_m3_fl(smat, armature_weight / contrib);
mul_serie_m3(defMats[i], tmpmat, pre, smat, post, NULL, NULL, NULL, NULL);
}
@ -1063,9 +1063,9 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
/* interpolate with previous modifier position using weight group */
if (prevCos) {
float mw = 1.0f - prevco_weight;
vertexCos[i][0] = prevco_weight*vertexCos[i][0] + mw*co[0];
vertexCos[i][1] = prevco_weight*vertexCos[i][1] + mw*co[1];
vertexCos[i][2] = prevco_weight*vertexCos[i][2] + mw*co[2];
vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0];
vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1];
vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2];
}
}
@ -1090,7 +1090,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
/* ************ END Armature Deform ******************* */
void get_objectspace_bone_matrix(struct Bone* bone, float M_accumulatedMatrix[][4], int UNUSED(root),
void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[][4], int UNUSED(root),
int UNUSED(posed))
{
copy_m4_m4(M_accumulatedMatrix, bone->arm_mat);
@ -1229,7 +1229,7 @@ void BKE_pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float l
mult_m4_m4m4(loc_mat, bone_loc, tmat4);
}
/* Those flags do not affect position, use plain parent transform space! */
else if (bone->flag & (BONE_HINGE|BONE_NO_SCALE)) {
else if (bone->flag & (BONE_HINGE | BONE_NO_SCALE)) {
mult_m4_m4m4(loc_mat, parchan->pose_mat, offs_bone);
}
/* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */
@ -1576,10 +1576,10 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
BKE_pose_rest(frompose);
/* copy over all of the proxy's bone groups */
/* TODO for later
* - implement 'local' bone groups as for constraints
* Note: this isn't trivial, as bones reference groups by index not by pointer,
* so syncing things correctly needs careful attention */
/* TODO for later
* - implement 'local' bone groups as for constraints
* Note: this isn't trivial, as bones reference groups by index not by pointer,
* so syncing things correctly needs careful attention */
BLI_freelistN(&pose->agroups);
BLI_duplicatelist(&pose->agroups, &frompose->agroups);
pose->active_group = frompose->active_group;
@ -1739,7 +1739,7 @@ void BKE_pose_rebuild(Object *ob, bArmature *arm)
BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */
/* the sorting */
if (counter>1)
if (counter > 1)
DAG_pose_sort(ob);
ob->pose->flag &= ~POSE_RECALC;
@ -1792,7 +1792,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
if ((ikData->tar == NULL) || (ikData->tar->type != OB_CURVE))
continue;
/* skip if disabled */
if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF)))
if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)))
continue;
/* otherwise, constraint is ok... */
@ -1831,7 +1831,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
if (segcount == 0)
return;
else
pchanRoot = pchanChain[segcount-1];
pchanRoot = pchanChain[segcount - 1];
/* perform binding step if required */
if ((ikData->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) {
@ -1841,8 +1841,8 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
/* setup new empty array for the points list */
if (ikData->points)
MEM_freeN(ikData->points);
ikData->numpoints = ikData->chainlen+1;
ikData->points = MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding");
ikData->numpoints = ikData->chainlen + 1;
ikData->points = MEM_callocN(sizeof(float) * ikData->numpoints, "Spline IK Binding");
/* bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint) */
ikData->points[0] = 1.0f;
@ -1856,13 +1856,13 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
*/
if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) {
/* 1) equi-spaced joints */
ikData->points[i+1] = ikData->points[i] - segmentLen;
ikData->points[i + 1] = ikData->points[i] - segmentLen;
}
else {
/* 2) to find this point on the curve, we take a step from the previous joint
* a distance given by the proportion that this bone takes
*/
ikData->points[i+1] = ikData->points[i] - (boneLengths[i] / totLength);
ikData->points[i + 1] = ikData->points[i] - (boneLengths[i] / totLength);
}
}
@ -1916,8 +1916,8 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
tree->chainlen = segcount;
/* copy over the array of links to bones in the chain (from tip to root) */
tree->chain = MEM_callocN(sizeof(bPoseChannel*)*segcount, "SplineIK Chain");
memcpy(tree->chain, pchanChain, sizeof(bPoseChannel*)*segcount);
tree->chain = MEM_callocN(sizeof(bPoseChannel *) * segcount, "SplineIK Chain");
memcpy(tree->chain, pchanChain, sizeof(bPoseChannel *) * segcount);
/* store reference to joint position array */
tree->points = jointPoints;
@ -1956,7 +1956,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
{
bSplineIKConstraint *ikData = tree->ikData;
float poseHead[3], poseTail[3], poseMat[4][4];
float splineVec[3], scaleFac, radius =1.0f;
float splineVec[3], scaleFac, radius = 1.0f;
/* firstly, calculate the bone matrix the standard way, since this is needed for roll control */
BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
@ -1970,14 +1970,14 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
float tailBlendFac = 1.0f;
/* determine if the bone should still be affected by SplineIK */
if (tree->points[index+1] >= 1.0f) {
if (tree->points[index + 1] >= 1.0f) {
/* spline doesn't affect the bone anymore, so done... */
pchan->flag |= POSE_DONE;
return;
}
else if ((tree->points[index] >= 1.0f) && (tree->points[index+1] < 1.0f)) {
else if ((tree->points[index] >= 1.0f) && (tree->points[index + 1] < 1.0f)) {
/* blending factor depends on the amount of the bone still left on the chain */
tailBlendFac = (1.0f - tree->points[index+1]) / (tree->points[index] - tree->points[index+1]);
tailBlendFac = (1.0f - tree->points[index + 1]) / (tree->points[index] - tree->points[index + 1]);
}
/* tail endpoint */
@ -1997,7 +1997,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
}
/* head endpoint */
if (where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad, NULL)) {
if (where_on_path(ikData->tar, tree->points[index + 1], vec, dir, NULL, &rad, NULL)) {
/* apply curve's object-mode transforms to the position
* unless the option to allow curve to be positioned elsewhere is activated (i.e. no root)
*/
@ -2009,7 +2009,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
copy_v3_v3(poseHead, vec);
/* set the new radius (it should be the average value) */
radius = (radius+rad) / 2;
radius = (radius + rad) / 2;
}
}
@ -2083,7 +2083,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
scale = len_v3(pchan->pose_mat[2]);
mul_v3_fl(poseMat[2], scale);
}
break;
break;
case CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC:
{
/* 'volume preservation' */
@ -2106,7 +2106,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
mul_v3_fl(poseMat[0], scale);
mul_v3_fl(poseMat[2], scale);
}
break;
break;
}
/* finally, multiply the x and z scaling by the radius of the curve too,
@ -2164,7 +2164,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_
* - the chain is traversed in the opposite order to storage order (i.e. parent to children)
* so that dependencies are correct
*/
for (i = tree->chainlen-1; i >= 0; i--) {
for (i = tree->chainlen - 1; i >= 0; i--) {
bPoseChannel *pchan = tree->chain[i];
splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime);
}
@ -2241,116 +2241,116 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
{
bActionModifier *amod;
bActionStrip *strip, *strip2;
float scene_cfra= (float)scene->r.cfra;
float scene_cfra = (float)scene->r.cfra;
int do_modif;
for (strip=armob->nlastrips.first; strip; strip=strip->next) {
do_modif=0;
for (strip = armob->nlastrips.first; strip; strip = strip->next) {
do_modif = 0;
if (scene_cfra>=strip->start && scene_cfra<=strip->end)
do_modif=1;
if (scene_cfra >= strip->start && scene_cfra <= strip->end)
do_modif = 1;
if ((scene_cfra > strip->end) && (strip->flag & ACTSTRIP_HOLDLASTFRAME)) {
do_modif=1;
do_modif = 1;
/* if there are any other strips active, ignore modifiers for this strip -
* 'hold' option should only hold action modifiers if there are
* no other active strips */
for (strip2=strip->next; strip2; strip2=strip2->next) {
for (strip2 = strip->next; strip2; strip2 = strip2->next) {
if (strip2 == strip) continue;
if (scene_cfra>=strip2->start && scene_cfra<=strip2->end) {
if (scene_cfra >= strip2->start && scene_cfra <= strip2->end) {
if (!(strip2->flag & ACTSTRIP_MUTE))
do_modif=0;
do_modif = 0;
}
}
/* if there are any later, activated, strips with 'hold' set, they take precedence,
* so ignore modifiers for this strip */
for (strip2=strip->next; strip2; strip2=strip2->next) {
for (strip2 = strip->next; strip2; strip2 = strip2->next) {
if (scene_cfra < strip2->start) continue;
if ((strip2->flag & ACTSTRIP_HOLDLASTFRAME) && !(strip2->flag & ACTSTRIP_MUTE)) {
do_modif=0;
do_modif = 0;
}
}
}
if (do_modif) {
/* temporal solution to prevent 2 strips accumulating */
if (scene_cfra==strip->end && strip->next && strip->next->start==scene_cfra)
if (scene_cfra == strip->end && strip->next && strip->next->start == scene_cfra)
continue;
for (amod= strip->modifiers.first; amod; amod= amod->next) {
for (amod = strip->modifiers.first; amod; amod = amod->next) {
switch (amod->type) {
case ACTSTRIP_MOD_DEFORM:
{
/* validate first */
if (amod->ob && amod->ob->type==OB_CURVE && amod->channel[0]) {
case ACTSTRIP_MOD_DEFORM:
{
/* validate first */
if (amod->ob && amod->ob->type == OB_CURVE && amod->channel[0]) {
if ( strcmp(pchan->name, amod->channel)==0 ) {
float mat4[4][4], mat3[3][3];
if (strcmp(pchan->name, amod->channel) == 0) {
float mat4[4][4], mat3[3][3];
curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
copy_m4_m4(mat4, pchan->pose_mat);
mul_m4_m3m4(pchan->pose_mat, mat3, mat4);
curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
copy_m4_m4(mat4, pchan->pose_mat);
mul_m4_m3m4(pchan->pose_mat, mat3, mat4);
}
}
}
}
break;
case ACTSTRIP_MOD_NOISE:
{
if ( strcmp(pchan->name, amod->channel)==0 ) {
float nor[3], loc[3], ofs;
float eul[3], size[3], eulo[3], sizeo[3];
case ACTSTRIP_MOD_NOISE:
{
if (strcmp(pchan->name, amod->channel) == 0) {
float nor[3], loc[3], ofs;
float eul[3], size[3], eulo[3], sizeo[3];
/* calculate turbulance */
ofs = amod->turbul / 200.0f;
/* calculate turbulance */
ofs = amod->turbul / 200.0f;
/* make a copy of starting conditions */
copy_v3_v3(loc, pchan->pose_mat[3]);
mat4_to_eul(eul, pchan->pose_mat);
mat4_to_size(size, pchan->pose_mat);
copy_v3_v3(eulo, eul);
copy_v3_v3(sizeo, size);
/* make a copy of starting conditions */
copy_v3_v3(loc, pchan->pose_mat[3]);
mat4_to_eul(eul, pchan->pose_mat);
mat4_to_size(size, pchan->pose_mat);
copy_v3_v3(eulo, eul);
copy_v3_v3(sizeo, size);
/* apply noise to each set of channels */
if (amod->channels & 4) {
/* for scaling */
nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs;
add_v3_v3(size, nor);
/* apply noise to each set of channels */
if (amod->channels & 4) {
/* for scaling */
nor[0] = BLI_gNoise(amod->noisesize, size[0] + ofs, size[1], size[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1] + ofs, size[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2] + ofs, 0, 0) - ofs;
add_v3_v3(size, nor);
if (sizeo[0] != 0)
mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]);
if (sizeo[1] != 0)
mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]);
if (sizeo[2] != 0)
mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]);
}
if (amod->channels & 2) {
/* for rotation */
nor[0] = BLI_gNoise(amod->noisesize, eul[0]+ofs, eul[1], eul[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, eul[0], eul[1]+ofs, eul[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs;
if (sizeo[0] != 0)
mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]);
if (sizeo[1] != 0)
mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]);
if (sizeo[2] != 0)
mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]);
}
if (amod->channels & 2) {
/* for rotation */
nor[0] = BLI_gNoise(amod->noisesize, eul[0] + ofs, eul[1], eul[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, eul[0], eul[1] + ofs, eul[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2] + ofs, 0, 0) - ofs;
compatible_eul(nor, eulo);
add_v3_v3(eul, nor);
compatible_eul(eul, eulo);
compatible_eul(nor, eulo);
add_v3_v3(eul, nor);
compatible_eul(eul, eulo);
loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size);
}
if (amod->channels & 1) {
/* for location */
nor[0] = BLI_gNoise(amod->noisesize, loc[0]+ofs, loc[1], loc[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1]+ofs, loc[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2]+ofs, 0, 0) - ofs;
loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size);
}
if (amod->channels & 1) {
/* for location */
nor[0] = BLI_gNoise(amod->noisesize, loc[0] + ofs, loc[1], loc[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1] + ofs, loc[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2] + ofs, 0, 0) - ofs;
add_v3_v3v3(pchan->pose_mat[3], loc, nor);
add_v3_v3v3(pchan->pose_mat[3], loc, nor);
}
}
}
}
break;
}
}
@ -2394,7 +2394,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
}
if (do_extra) {
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
/* do NLA strip modifiers - i.e. curve follow */
do_strip_modifiers(scene, ob, bone, pchan);
#endif
@ -2413,7 +2413,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
cob = constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
/* Solve PoseChannel's Constraints */
solve_constraints(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
solve_constraints(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
/* cleanup after Constraint Solving
* - applies matrix back to pchan, and frees temporary struct used
@ -2470,7 +2470,7 @@ void BKE_pose_where_is(Scene *scene, Object *ob)
/* 1. clear flags */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
pchan->flag &= ~(POSE_DONE|POSE_CHAIN|POSE_IKTREE|POSE_IKSPLINE);
pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE);
}
/* 2a. construct the IK tree (standard IK) */

File diff suppressed because it is too large Load Diff

View File

@ -54,15 +54,15 @@ void *BKE_camera_add(const char *name)
{
Camera *cam;
cam= BKE_libblock_alloc(&G.main->camera, ID_CA, name);
cam = BKE_libblock_alloc(&G.main->camera, ID_CA, name);
cam->lens= 35.0f;
cam->sensor_x= 32.0f;
cam->sensor_y= 18.0f;
cam->clipsta= 0.1f;
cam->clipend= 100.0f;
cam->drawsize= 0.5f;
cam->ortho_scale= 6.0;
cam->lens = 35.0f;
cam->sensor_x = 32.0f;
cam->sensor_y = 18.0f;
cam->clipsta = 0.1f;
cam->clipend = 100.0f;
cam->drawsize = 0.5f;
cam->ortho_scale = 6.0;
cam->flag |= CAM_SHOWPASSEPARTOUT;
cam->passepartalpha = 0.5f;
@ -73,7 +73,7 @@ Camera *BKE_camera_copy(Camera *cam)
{
Camera *camn;
camn= BKE_libblock_copy(&cam->id);
camn = BKE_libblock_copy(&cam->id);
id_lib_extern((ID *)camn->dof_ob);
@ -82,25 +82,25 @@ Camera *BKE_camera_copy(Camera *cam)
void BKE_camera_make_local(Camera *cam)
{
Main *bmain= G.main;
Main *bmain = G.main;
Object *ob;
int is_local= FALSE, is_lib= FALSE;
int is_local = FALSE, is_lib = FALSE;
/* - only lib users: do nothing
* - only local users: set flag
* - mixed: make copy
*/
if (cam->id.lib==NULL) return;
if (cam->id.us==1) {
if (cam->id.lib == NULL) return;
if (cam->id.us == 1) {
id_clear_lib_data(bmain, &cam->id);
return;
}
for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
if (ob->data==cam) {
if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
if (ob->data == cam) {
if (ob->id.lib) is_lib = TRUE;
else is_local = TRUE;
}
}
@ -108,17 +108,17 @@ void BKE_camera_make_local(Camera *cam)
id_clear_lib_data(bmain, &cam->id);
}
else if (is_local && is_lib) {
Camera *cam_new= BKE_camera_copy(cam);
Camera *cam_new = BKE_camera_copy(cam);
cam_new->id.us= 0;
cam_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, cam->id.lib, &cam_new->id);
for (ob= bmain->object.first; ob; ob= ob->id.next) {
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->data == cam) {
if (ob->id.lib==NULL) {
ob->data= cam_new;
if (ob->id.lib == NULL) {
ob->data = cam_new;
cam_new->id.us++;
cam->id.us--;
}
@ -136,10 +136,10 @@ void BKE_camera_free(Camera *ca)
void BKE_camera_object_mode(RenderData *rd, Object *cam_ob)
{
rd->mode &= ~(R_ORTHO|R_PANORAMA);
rd->mode &= ~(R_ORTHO | R_PANORAMA);
if (cam_ob && cam_ob->type==OB_CAMERA) {
Camera *cam= cam_ob->data;
if (cam_ob && cam_ob->type == OB_CAMERA) {
Camera *cam = cam_ob->data;
if (cam->type == CAM_ORTHO) rd->mode |= R_ORTHO;
if (cam->type == CAM_PANO) rd->mode |= R_PANORAMA;
}
@ -193,11 +193,11 @@ void BKE_camera_params_init(CameraParams *params)
memset(params, 0, sizeof(CameraParams));
/* defaults */
params->sensor_x= DEFAULT_SENSOR_WIDTH;
params->sensor_y= DEFAULT_SENSOR_HEIGHT;
params->sensor_fit= CAMERA_SENSOR_FIT_AUTO;
params->sensor_x = DEFAULT_SENSOR_WIDTH;
params->sensor_y = DEFAULT_SENSOR_HEIGHT;
params->sensor_fit = CAMERA_SENSOR_FIT_AUTO;
params->zoom= 1.0f;
params->zoom = 1.0f;
}
void BKE_camera_params_from_object(CameraParams *params, Object *ob)
@ -205,73 +205,73 @@ void BKE_camera_params_from_object(CameraParams *params, Object *ob)
if (!ob)
return;
if (ob->type==OB_CAMERA) {
if (ob->type == OB_CAMERA) {
/* camera object */
Camera *cam= ob->data;
Camera *cam = ob->data;
if (cam->type == CAM_ORTHO)
params->is_ortho= TRUE;
params->lens= cam->lens;
params->ortho_scale= cam->ortho_scale;
params->is_ortho = TRUE;
params->lens = cam->lens;
params->ortho_scale = cam->ortho_scale;
params->shiftx= cam->shiftx;
params->shifty= cam->shifty;
params->shiftx = cam->shiftx;
params->shifty = cam->shifty;
params->sensor_x= cam->sensor_x;
params->sensor_y= cam->sensor_y;
params->sensor_fit= cam->sensor_fit;
params->sensor_x = cam->sensor_x;
params->sensor_y = cam->sensor_y;
params->sensor_fit = cam->sensor_fit;
params->clipsta= cam->clipsta;
params->clipend= cam->clipend;
params->clipsta = cam->clipsta;
params->clipend = cam->clipend;
}
else if (ob->type==OB_LAMP) {
else if (ob->type == OB_LAMP) {
/* lamp object */
Lamp *la= ob->data;
float fac= cosf((float)M_PI*la->spotsize/360.0f);
float phi= acos(fac);
Lamp *la = ob->data;
float fac = cosf((float)M_PI * la->spotsize / 360.0f);
float phi = acos(fac);
params->lens= 16.0f*fac/sinf(phi);
if (params->lens==0.0f)
params->lens= 35.0f;
params->lens = 16.0f * fac / sinf(phi);
if (params->lens == 0.0f)
params->lens = 35.0f;
params->clipsta= la->clipsta;
params->clipend= la->clipend;
params->clipsta = la->clipsta;
params->clipend = la->clipend;
}
}
void BKE_camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *rv3d)
{
/* common */
params->lens= v3d->lens;
params->clipsta= v3d->near;
params->clipend= v3d->far;
params->lens = v3d->lens;
params->clipsta = v3d->near;
params->clipend = v3d->far;
if (rv3d->persp==RV3D_CAMOB) {
if (rv3d->persp == RV3D_CAMOB) {
/* camera view */
BKE_camera_params_from_object(params, v3d->camera);
params->zoom= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom);
params->zoom = BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom);
params->offsetx= 2.0f*rv3d->camdx*params->zoom;
params->offsety= 2.0f*rv3d->camdy*params->zoom;
params->offsetx = 2.0f * rv3d->camdx * params->zoom;
params->offsety = 2.0f * rv3d->camdy * params->zoom;
params->shiftx *= params->zoom;
params->shifty *= params->zoom;
params->zoom= 1.0f/params->zoom;
params->zoom = 1.0f / params->zoom;
}
else if (rv3d->persp==RV3D_ORTHO) {
else if (rv3d->persp == RV3D_ORTHO) {
/* orthographic view */
params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality
params->clipsta= - params->clipend;
params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality
params->clipsta = -params->clipend;
params->is_ortho= TRUE;
params->is_ortho = TRUE;
params->ortho_scale = rv3d->dist;
params->zoom= 2.0f;
params->zoom = 2.0f;
}
else {
/* perspective view */
params->zoom= 2.0f;
params->zoom = 2.0f;
}
}
@ -282,28 +282,28 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win
int sensor_fit;
/* fields rendering */
params->ycor= yasp/xasp;
params->ycor = yasp / xasp;
if (params->use_fields)
params->ycor *= 2.0f;
if (params->is_ortho) {
/* orthographic camera */
/* scale == 1.0 means exact 1 to 1 mapping */
pixsize= params->ortho_scale;
pixsize = params->ortho_scale;
}
else {
/* perspective camera */
sensor_size= BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y);
pixsize= (sensor_size * params->clipsta)/params->lens;
sensor_size = BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y);
pixsize = (sensor_size * params->clipsta) / params->lens;
}
/* determine sensor fit */
sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp*winx, yasp*winy);
sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp * winx, yasp * winy);
if (sensor_fit==CAMERA_SENSOR_FIT_HOR)
viewfac= winx;
if (sensor_fit == CAMERA_SENSOR_FIT_HOR)
viewfac = winx;
else
viewfac= params->ycor * winy;
viewfac = params->ycor * winy;
pixsize /= viewfac;
@ -312,14 +312,14 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win
/* compute view plane:
* fully centered, zbuffer fills in jittered between -.5 and +.5 */
viewplane.xmin = -0.5f*(float)winx;
viewplane.ymin = -0.5f*params->ycor*(float)winy;
viewplane.xmax = 0.5f*(float)winx;
viewplane.ymax = 0.5f*params->ycor*(float)winy;
viewplane.xmin = -0.5f * (float)winx;
viewplane.ymin = -0.5f * params->ycor * (float)winy;
viewplane.xmax = 0.5f * (float)winx;
viewplane.ymax = 0.5f * params->ycor * (float)winy;
/* lens shift and offset */
dx= params->shiftx*viewfac + winx*params->offsetx;
dy= params->shifty*viewfac + winy*params->offsety;
dx = params->shiftx * viewfac + winx * params->offsetx;
dy = params->shifty * viewfac + winy * params->offsety;
viewplane.xmin += dx;
viewplane.ymin += dy;
@ -329,12 +329,12 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win
/* fields offset */
if (params->field_second) {
if (params->field_odd) {
viewplane.ymin-= 0.5f * params->ycor;
viewplane.ymax-= 0.5f * params->ycor;
viewplane.ymin -= 0.5f * params->ycor;
viewplane.ymax -= 0.5f * params->ycor;
}
else {
viewplane.ymin+= 0.5f * params->ycor;
viewplane.ymax+= 0.5f * params->ycor;
viewplane.ymin += 0.5f * params->ycor;
viewplane.ymax += 0.5f * params->ycor;
}
}
@ -345,9 +345,9 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win
viewplane.ymin *= pixsize;
viewplane.ymax *= pixsize;
params->viewdx= pixsize;
params->viewdy= params->ycor * pixsize;
params->viewplane= viewplane;
params->viewdx = pixsize;
params->viewdy = params->ycor * pixsize;
params->viewplane = viewplane;
}
/* viewplane is assumed to be already computed */
@ -374,61 +374,61 @@ void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, cons
/* aspect correcton */
if (scene) {
float aspx= (float) scene->r.xsch*scene->r.xasp;
float aspy= (float) scene->r.ysch*scene->r.yasp;
int sensor_fit= BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy);
float aspx = (float) scene->r.xsch * scene->r.xasp;
float aspy = (float) scene->r.ysch * scene->r.yasp;
int sensor_fit = BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy);
if (sensor_fit==CAMERA_SENSOR_FIT_HOR) {
r_asp[0]= 1.0;
r_asp[1]= aspy / aspx;
if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
r_asp[0] = 1.0;
r_asp[1] = aspy / aspx;
}
else {
r_asp[0]= aspx / aspy;
r_asp[1]= 1.0;
r_asp[0] = aspx / aspy;
r_asp[1] = 1.0;
}
}
else {
r_asp[0]= 1.0f;
r_asp[1]= 1.0f;
r_asp[0] = 1.0f;
r_asp[1] = 1.0f;
}
if (camera->type==CAM_ORTHO) {
facx= 0.5f * camera->ortho_scale * r_asp[0] * scale[0];
facy= 0.5f * camera->ortho_scale * r_asp[1] * scale[1];
r_shift[0]= camera->shiftx * camera->ortho_scale * scale[0];
r_shift[1]= camera->shifty * camera->ortho_scale * scale[1];
depth= do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : - drawsize * camera->ortho_scale * scale[2];
if (camera->type == CAM_ORTHO) {
facx = 0.5f * camera->ortho_scale * r_asp[0] * scale[0];
facy = 0.5f * camera->ortho_scale * r_asp[1] * scale[1];
r_shift[0] = camera->shiftx * camera->ortho_scale * scale[0];
r_shift[1] = camera->shifty * camera->ortho_scale * scale[1];
depth = do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : -drawsize * camera->ortho_scale * scale[2];
*r_drawsize= 0.5f * camera->ortho_scale;
*r_drawsize = 0.5f * camera->ortho_scale;
}
else {
/* that way it's always visible - clipsta+0.1 */
float fac;
float half_sensor= 0.5f*((camera->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x));
float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x));
*r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
*r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
if (do_clip) {
/* fixed depth, variable size (avoids exceeding clipping range) */
depth = -(camera->clipsta + 0.1f);
fac = depth / (camera->lens/(-half_sensor) * scale[2]);
fac = depth / (camera->lens / (-half_sensor) * scale[2]);
}
else {
/* fixed size, variable depth (stays a reasonable size in the 3D view) */
depth= *r_drawsize * camera->lens/(-half_sensor) * scale[2];
fac= *r_drawsize;
depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
fac = *r_drawsize;
}
facx= fac * r_asp[0] * scale[0];
facy= fac * r_asp[1] * scale[1];
r_shift[0]= camera->shiftx*fac*2 * scale[0];
r_shift[1]= camera->shifty*fac*2 * scale[1];
facx = fac * r_asp[0] * scale[0];
facy = fac * r_asp[1] * scale[1];
r_shift[0] = camera->shiftx * fac * 2 * scale[0];
r_shift[1] = camera->shifty * fac * 2 * scale[1];
}
r_vec[0][0]= r_shift[0] + facx; r_vec[0][1]= r_shift[1] + facy; r_vec[0][2]= depth;
r_vec[1][0]= r_shift[0] + facx; r_vec[1][1]= r_shift[1] - facy; r_vec[1][2]= depth;
r_vec[2][0]= r_shift[0] - facx; r_vec[2][1]= r_shift[1] - facy; r_vec[2][2]= depth;
r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth;
r_vec[0][0] = r_shift[0] + facx; r_vec[0][1] = r_shift[1] + facy; r_vec[0][2] = depth;
r_vec[1][0] = r_shift[0] + facx; r_vec[1][1] = r_shift[1] - facy; r_vec[1][2] = depth;
r_vec[2][0] = r_shift[0] - facx; r_vec[2][1] = r_shift[1] - facy; r_vec[2][2] = depth;
r_vec[3][0] = r_shift[0] - facx; r_vec[3][1] = r_shift[1] + facy; r_vec[3][2] = depth;
}
void BKE_camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3])
@ -436,10 +436,10 @@ void BKE_camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3])
float dummy_asp[2];
float dummy_shift[2];
float dummy_drawsize;
const float dummy_scale[3]= {1.0f, 1.0f, 1.0f};
const float dummy_scale[3] = {1.0f, 1.0f, 1.0f};
BKE_camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale,
dummy_asp, dummy_shift, &dummy_drawsize, r_vec);
dummy_asp, dummy_shift, &dummy_drawsize, r_vec);
}
@ -452,13 +452,13 @@ typedef struct CameraViewFrameData {
static void BKE_camera_to_frame_view_cb(const float co[3], void *user_data)
{
CameraViewFrameData *data= (CameraViewFrameData *)user_data;
CameraViewFrameData *data = (CameraViewFrameData *)user_data;
unsigned int i;
for (i= 0; i < 4; i++) {
float nd= dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]);
for (i = 0; i < 4; i++) {
float nd = dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]);
if (nd < data->dist_vals[i]) {
data->dist_vals[i]= nd;
data->dist_vals[i] = nd;
}
}
@ -472,7 +472,7 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object
float shift[2];
float plane_tx[4][3];
float rot_obmat[3][3];
const float zero[3]= {0, 0, 0};
const float zero[3] = {0, 0, 0};
CameraViewFrameData data_cb;
unsigned int i;
@ -482,36 +482,36 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object
copy_m3_m4(rot_obmat, camera_ob->obmat);
normalize_m3(rot_obmat);
for (i= 0; i < 4; i++) {
for (i = 0; i < 4; i++) {
/* normalize so Z is always 1.0f*/
mul_v3_fl(data_cb.frame_tx[i], 1.0f/data_cb.frame_tx[i][2]);
mul_v3_fl(data_cb.frame_tx[i], 1.0f / data_cb.frame_tx[i][2]);
}
/* get the shift back out of the frame */
shift[0]= (data_cb.frame_tx[0][0] +
data_cb.frame_tx[1][0] +
data_cb.frame_tx[2][0] +
data_cb.frame_tx[3][0]) / 4.0f;
shift[1]= (data_cb.frame_tx[0][1] +
data_cb.frame_tx[1][1] +
data_cb.frame_tx[2][1] +
data_cb.frame_tx[3][1]) / 4.0f;
shift[0] = (data_cb.frame_tx[0][0] +
data_cb.frame_tx[1][0] +
data_cb.frame_tx[2][0] +
data_cb.frame_tx[3][0]) / 4.0f;
shift[1] = (data_cb.frame_tx[0][1] +
data_cb.frame_tx[1][1] +
data_cb.frame_tx[2][1] +
data_cb.frame_tx[3][1]) / 4.0f;
for (i= 0; i < 4; i++) {
for (i = 0; i < 4; i++) {
mul_m3_v3(rot_obmat, data_cb.frame_tx[i]);
}
for (i= 0; i < 4; i++) {
for (i = 0; i < 4; i++) {
normal_tri_v3(data_cb.normal_tx[i],
zero, data_cb.frame_tx[i], data_cb.frame_tx[(i + 1) % 4]);
}
/* initialize callback data */
data_cb.dist_vals[0]=
data_cb.dist_vals[1]=
data_cb.dist_vals[2]=
data_cb.dist_vals[3]= FLT_MAX;
data_cb.tot= 0;
data_cb.dist_vals[0] =
data_cb.dist_vals[1] =
data_cb.dist_vals[2] =
data_cb.dist_vals[3] = FLT_MAX;
data_cb.tot = 0;
/* run callback on all visible points */
BKE_scene_foreach_display_point(scene, v3d, BA_SELECT,
BKE_camera_to_frame_view_cb, &data_cb);
@ -526,7 +526,7 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object
float plane_isect_pt_1[3], plane_isect_pt_2[3];
/* apply the dist-from-plane's to the transformed plane points */
for (i= 0; i < 4; i++) {
for (i = 0; i < 4; i++) {
mul_v3_v3fl(plane_tx[i], data_cb.normal_tx[i], data_cb.dist_vals[i]);
}
@ -547,14 +547,14 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object
return FALSE;
}
else {
float cam_plane_no[3]= {0.0f, 0.0f, -1.0f};
float cam_plane_no[3] = {0.0f, 0.0f, -1.0f};
float plane_isect_delta[3];
float plane_isect_delta_len;
mul_m3_v3(rot_obmat, cam_plane_no);
sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1);
plane_isect_delta_len= len_v3(plane_isect_delta);
plane_isect_delta_len = len_v3(plane_isect_delta);
if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) {
copy_v3_v3(r_co, plane_isect_pt_1);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -62,8 +62,8 @@ void free_gpencil_strokes(bGPDframe *gpf)
if (gpf == NULL) return;
/* free strokes */
for (gps= gpf->strokes.first; gps; gps= gpsn) {
gpsn= gps->next;
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* free stroke memory arrays, then stroke itself */
if (gps->points) MEM_freeN(gps->points);
@ -80,8 +80,8 @@ void free_gpencil_frames(bGPDlayer *gpl)
if (gpl == NULL) return;
/* free frames */
for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
gpfn= gpf->next;
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
gpfn = gpf->next;
/* free strokes and their associated memory */
free_gpencil_strokes(gpf);
@ -98,8 +98,8 @@ void free_gpencil_layers(ListBase *list)
if (list == NULL) return;
/* delete layers*/
for (gpl= list->first; gpl; gpl= gpln) {
gpln= gpl->next;
for (gpl = list->first; gpl; gpl = gpln) {
gpln = gpl->next;
/* free layers and their data */
free_gpencil_frames(gpl);
@ -117,32 +117,32 @@ void BKE_gpencil_free(bGPdata *gpd)
/* -------- Container Creation ---------- */
/* add a new gp-frame to the given layer */
bGPDframe *gpencil_frame_addnew (bGPDlayer *gpl, int cframe)
bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
{
bGPDframe *gpf, *gf;
short state=0;
short state = 0;
/* error checking */
if ((gpl == NULL) || (cframe <= 0))
return NULL;
/* allocate memory for this frame */
gpf= MEM_callocN(sizeof(bGPDframe), "bGPDframe");
gpf->framenum= cframe;
gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe");
gpf->framenum = cframe;
/* find appropriate place to add frame */
if (gpl->frames.first) {
for (gf= gpl->frames.first; gf; gf= gf->next) {
for (gf = gpl->frames.first; gf; gf = gf->next) {
/* check if frame matches one that is supposed to be added */
if (gf->framenum == cframe) {
state= -1;
state = -1;
break;
}
/* if current frame has already exceeded the frame to add, add before */
if (gf->framenum > cframe) {
BLI_insertlinkbefore(&gpl->frames, gf, gpf);
state= 1;
state = 1;
break;
}
}
@ -163,7 +163,7 @@ bGPDframe *gpencil_frame_addnew (bGPDlayer *gpl, int cframe)
}
/* add a new gp-layer and make it the active layer */
bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
bGPDlayer *gpencil_layer_addnew(bGPdata *gpd)
{
bGPDlayer *gpl;
@ -172,13 +172,13 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
return NULL;
/* allocate memory for frame and add to end of list */
gpl= MEM_callocN(sizeof(bGPDlayer), "bGPDlayer");
gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer");
/* add to datablock */
BLI_addtail(&gpd->layers, gpl);
/* set basic settings */
gpl->color[3]= 0.9f;
gpl->color[3] = 0.9f;
gpl->thickness = 3;
/* auto-name */
@ -193,15 +193,15 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
}
/* add a new gp-datablock */
bGPdata *gpencil_data_addnew (const char name[])
bGPdata *gpencil_data_addnew(const char name[])
{
bGPdata *gpd;
/* allocate memory for a new block */
gpd= BKE_libblock_alloc(&G.main->gpencil, ID_GD, name);
gpd = BKE_libblock_alloc(&G.main->gpencil, ID_GD, name);
/* initial settings */
gpd->flag = (GP_DATA_DISPINFO|GP_DATA_EXPAND);
gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND);
/* for now, stick to view is also enabled by default
* since this is more useful...
@ -214,7 +214,7 @@ bGPdata *gpencil_data_addnew (const char name[])
/* -------- Data Duplication ---------- */
/* make a copy of a given gpencil frame */
bGPDframe *gpencil_frame_duplicate (bGPDframe *src)
bGPDframe *gpencil_frame_duplicate(bGPDframe *src)
{
bGPDstroke *gps, *gpsd;
bGPDframe *dst;
@ -224,15 +224,15 @@ bGPDframe *gpencil_frame_duplicate (bGPDframe *src)
return NULL;
/* make a copy of the source frame */
dst= MEM_dupallocN(src);
dst->prev= dst->next= NULL;
dst = MEM_dupallocN(src);
dst->prev = dst->next = NULL;
/* copy strokes */
dst->strokes.first = dst->strokes.last= NULL;
for (gps= src->strokes.first; gps; gps= gps->next) {
dst->strokes.first = dst->strokes.last = NULL;
for (gps = src->strokes.first; gps; gps = gps->next) {
/* make copy of source stroke, then adjust pointer to points too */
gpsd= MEM_dupallocN(gps);
gpsd->points= MEM_dupallocN(gps->points);
gpsd = MEM_dupallocN(gps);
gpsd->points = MEM_dupallocN(gps->points);
BLI_addtail(&dst->strokes, gpsd);
}
@ -242,7 +242,7 @@ bGPDframe *gpencil_frame_duplicate (bGPDframe *src)
}
/* make a copy of a given gpencil layer */
bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src)
bGPDlayer *gpencil_layer_duplicate(bGPDlayer *src)
{
bGPDframe *gpf, *gpfd;
bGPDlayer *dst;
@ -252,19 +252,19 @@ bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src)
return NULL;
/* make a copy of source layer */
dst= MEM_dupallocN(src);
dst->prev= dst->next= NULL;
dst = MEM_dupallocN(src);
dst->prev = dst->next = NULL;
/* copy frames */
dst->frames.first= dst->frames.last= NULL;
for (gpf= src->frames.first; gpf; gpf= gpf->next) {
dst->frames.first = dst->frames.last = NULL;
for (gpf = src->frames.first; gpf; gpf = gpf->next) {
/* make a copy of source frame */
gpfd= gpencil_frame_duplicate(gpf);
gpfd = gpencil_frame_duplicate(gpf);
BLI_addtail(&dst->frames, gpfd);
/* if source frame was the current layer's 'active' frame, reassign that too */
if (gpf == dst->actframe)
dst->actframe= gpfd;
dst->actframe = gpfd;
}
/* return new layer */
@ -272,7 +272,7 @@ bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src)
}
/* make a copy of a given gpencil datablock */
bGPdata *gpencil_data_duplicate (bGPdata *src)
bGPdata *gpencil_data_duplicate(bGPdata *src)
{
bGPDlayer *gpl, *gpld;
bGPdata *dst;
@ -282,13 +282,13 @@ bGPdata *gpencil_data_duplicate (bGPdata *src)
return NULL;
/* make a copy of the base-data */
dst= MEM_dupallocN(src);
dst = MEM_dupallocN(src);
/* copy layers */
dst->layers.first= dst->layers.last= NULL;
for (gpl= src->layers.first; gpl; gpl= gpl->next) {
dst->layers.first = dst->layers.last = NULL;
for (gpl = src->layers.first; gpl; gpl = gpl->next) {
/* make a copy of source layer and its data */
gpld= gpencil_layer_duplicate(gpl);
gpld = gpencil_layer_duplicate(gpl);
BLI_addtail(&dst->layers, gpld);
}
@ -301,7 +301,7 @@ bGPdata *gpencil_data_duplicate (bGPdata *src)
/* delete the last stroke of the given frame */
void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
{
bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL;
bGPDstroke *gps = (gpf) ? gpf->strokes.last : NULL;
int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */
/* error checking */
@ -325,7 +325,7 @@ void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
* - this sets the layer's actframe var (if allowed to)
* - extension beyond range (if first gp-frame is after all frame in interest and cannot add)
*/
bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew)
bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew)
{
bGPDframe *gpf = NULL;
short found = 0;
@ -336,12 +336,12 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew)
/* check if there is already an active frame */
if (gpl->actframe) {
gpf= gpl->actframe;
gpf = gpl->actframe;
/* do not allow any changes to layer's active frame if layer is locked from changes
* or if the layer has been set to stay on the current frame
*/
if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_FRAMELOCK))
if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_FRAMELOCK))
return gpf;
/* do not allow any changes to actframe if frame has painting tag attached to it */
if (gpf->flag & GP_FRAME_PAINT)
@ -349,13 +349,13 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew)
/* try to find matching frame */
if (gpf->framenum < cframe) {
for (; gpf; gpf= gpf->next) {
for (; gpf; gpf = gpf->next) {
if (gpf->framenum == cframe) {
found= 1;
found = 1;
break;
}
else if ((gpf->next) && (gpf->next->framenum > cframe)) {
found= 1;
found = 1;
break;
}
}
@ -363,19 +363,19 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew)
/* set the appropriate frame */
if (addnew) {
if ((found) && (gpf->framenum == cframe))
gpl->actframe= gpf;
gpl->actframe = gpf;
else
gpl->actframe= gpencil_frame_addnew(gpl, cframe);
gpl->actframe = gpencil_frame_addnew(gpl, cframe);
}
else if (found)
gpl->actframe= gpf;
gpl->actframe = gpf;
else
gpl->actframe= gpl->frames.last;
gpl->actframe = gpl->frames.last;
}
else {
for (; gpf; gpf= gpf->prev) {
for (; gpf; gpf = gpf->prev) {
if (gpf->framenum <= cframe) {
found= 1;
found = 1;
break;
}
}
@ -383,35 +383,35 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew)
/* set the appropriate frame */
if (addnew) {
if ((found) && (gpf->framenum == cframe))
gpl->actframe= gpf;
gpl->actframe = gpf;
else
gpl->actframe= gpencil_frame_addnew(gpl, cframe);
gpl->actframe = gpencil_frame_addnew(gpl, cframe);
}
else if (found)
gpl->actframe= gpf;
gpl->actframe = gpf;
else
gpl->actframe= gpl->frames.first;
gpl->actframe = gpl->frames.first;
}
}
else if (gpl->frames.first) {
/* check which of the ends to start checking from */
const int first= ((bGPDframe *)(gpl->frames.first))->framenum;
const int last= ((bGPDframe *)(gpl->frames.last))->framenum;
const int first = ((bGPDframe *)(gpl->frames.first))->framenum;
const int last = ((bGPDframe *)(gpl->frames.last))->framenum;
if (abs(cframe-first) > abs(cframe-last)) {
if (abs(cframe - first) > abs(cframe - last)) {
/* find gp-frame which is less than or equal to cframe */
for (gpf= gpl->frames.last; gpf; gpf= gpf->prev) {
for (gpf = gpl->frames.last; gpf; gpf = gpf->prev) {
if (gpf->framenum <= cframe) {
found= 1;
found = 1;
break;
}
}
}
else {
/* find gp-frame which is less than or equal to cframe */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->framenum <= cframe) {
found= 1;
found = 1;
break;
}
}
@ -420,12 +420,12 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew)
/* set the appropriate frame */
if (addnew) {
if ((found) && (gpf->framenum == cframe))
gpl->actframe= gpf;
gpl->actframe = gpf;
else
gpl->actframe= gpencil_frame_addnew(gpl, cframe);
gpl->actframe = gpencil_frame_addnew(gpl, cframe);
}
else if (found)
gpl->actframe= gpf;
gpl->actframe = gpf;
else {
/* unresolved errogenous situation! */
printf("Error: cannot find appropriate gp-frame\n");
@ -435,7 +435,7 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew)
else {
/* currently no frames (add if allowed to) */
if (addnew)
gpl->actframe= gpencil_frame_addnew(gpl, cframe);
gpl->actframe = gpencil_frame_addnew(gpl, cframe);
else {
/* don't do anything... this may be when no frames yet! */
/* gpl->actframe should still be NULL */
@ -460,7 +460,7 @@ void gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
}
/* get the active gp-layer for editing */
bGPDlayer *gpencil_layer_getactive (bGPdata *gpd)
bGPDlayer *gpencil_layer_getactive(bGPdata *gpd)
{
bGPDlayer *gpl;
@ -469,7 +469,7 @@ bGPDlayer *gpencil_layer_getactive (bGPdata *gpd)
return NULL;
/* loop over layers until found (assume only one active) */
for (gpl=gpd->layers.first; gpl; gpl=gpl->next) {
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpl->flag & GP_LAYER_ACTIVE)
return gpl;
}
@ -488,7 +488,7 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
return;
/* loop over layers deactivating all */
for (gpl=gpd->layers.first; gpl; gpl=gpl->next)
for (gpl = gpd->layers.first; gpl; gpl = gpl->next)
gpl->flag &= ~GP_LAYER_ACTIVE;
/* set as active one */
@ -498,7 +498,7 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
/* delete the active gp-layer */
void gpencil_layer_delactive(bGPdata *gpd)
{
bGPDlayer *gpl= gpencil_layer_getactive(gpd);
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
/* error checking */
if (ELEM(NULL, gpd, gpl))

View File

@ -66,7 +66,7 @@ void BKE_group_free(Group *group)
GroupObject *go;
while (group->gobject.first) {
go= group->gobject.first;
go = group->gobject.first;
BLI_remlink(&group->gobject, go);
free_group_object(go);
}
@ -74,67 +74,67 @@ void BKE_group_free(Group *group)
void BKE_group_unlink(Group *group)
{
Main *bmain= G.main;
Main *bmain = G.main;
Material *ma;
Object *ob;
Scene *sce;
SceneRenderLayer *srl;
ParticleSystem *psys;
for (ma= bmain->mat.first; ma; ma= ma->id.next) {
if (ma->group==group)
ma->group= NULL;
for (ma = bmain->mat.first; ma; ma = ma->id.next) {
if (ma->group == group)
ma->group = NULL;
}
for (ma= bmain->mat.first; ma; ma= ma->id.next) {
if (ma->group==group)
ma->group= NULL;
for (ma = bmain->mat.first; ma; ma = ma->id.next) {
if (ma->group == group)
ma->group = NULL;
}
for (sce= bmain->scene.first; sce; sce= sce->id.next) {
Base *base= sce->base.first;
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
Base *base = sce->base.first;
/* ensure objects are not in this group */
for (; base; base= base->next) {
if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL)==NULL) {
for (; base; base = base->next) {
if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL) == NULL) {
base->object->flag &= ~OB_FROMGROUP;
base->flag &= ~OB_FROMGROUP;
}
}
for (srl= sce->r.layers.first; srl; srl= srl->next) {
if (srl->light_override==group)
srl->light_override= NULL;
for (srl = sce->r.layers.first; srl; srl = srl->next) {
if (srl->light_override == group)
srl->light_override = NULL;
}
}
for (ob= bmain->object.first; ob; ob= ob->id.next) {
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->dup_group==group) {
ob->dup_group= NULL;
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
if (ob->dup_group == group) {
ob->dup_group = NULL;
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
{
bActionStrip *strip;
/* duplicator strips use a group object, we remove it */
for (strip= ob->nlastrips.first; strip; strip= strip->next) {
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
if (strip->object)
strip->object= NULL;
strip->object = NULL;
}
}
#endif
}
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
if (psys->part->dup_group==group)
psys->part->dup_group= NULL;
#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */
if (psys->part->eff_group==group)
psys->part->eff_group= NULL;
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
if (psys->part->dup_group == group)
psys->part->dup_group = NULL;
#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */
if (psys->part->eff_group == group)
psys->part->eff_group = NULL;
#endif
}
}
/* group stays in library, but no members */
BKE_group_free(group);
group->id.us= 0;
group->id.us = 0;
}
Group *add_group(const char *name)
@ -142,7 +142,7 @@ Group *add_group(const char *name)
Group *group;
group = BKE_libblock_alloc(&G.main->group, ID_GR, name);
group->layer= (1<<20)-1;
group->layer = (1 << 20) - 1;
return group;
}
@ -150,7 +150,7 @@ Group *BKE_group_copy(Group *group)
{
Group *groupn;
groupn= MEM_dupallocN(group);
groupn = MEM_dupallocN(group);
BLI_duplicatelist(&groupn->gobject, &group->gobject);
return groupn;
@ -161,17 +161,17 @@ static int add_to_group_internal(Group *group, Object *ob)
{
GroupObject *go;
if (group==NULL || ob==NULL) return 0;
if (group == NULL || ob == NULL) return 0;
/* check if the object has been added already */
for (go= group->gobject.first; go; go= go->next) {
if (go->ob==ob) return 0;
for (go = group->gobject.first; go; go = go->next) {
if (go->ob == ob) return 0;
}
go= MEM_callocN(sizeof(GroupObject), "groupobject");
go = MEM_callocN(sizeof(GroupObject), "groupobject");
BLI_addtail(&group->gobject, go);
go->ob= ob;
go->ob = ob;
return 1;
}
@ -179,10 +179,10 @@ static int add_to_group_internal(Group *group, Object *ob)
int add_to_group(Group *group, Object *object, Scene *scene, Base *base)
{
if (add_to_group_internal(group, object)) {
if ((object->flag & OB_FROMGROUP)==0) {
if ((object->flag & OB_FROMGROUP) == 0) {
if (scene && base==NULL)
base= BKE_scene_base_find(scene, object);
if (scene && base == NULL)
base = BKE_scene_base_find(scene, object);
object->flag |= OB_FROMGROUP;
@ -201,18 +201,18 @@ static int rem_from_group_internal(Group *group, Object *ob)
{
GroupObject *go, *gon;
int removed = 0;
if (group==NULL) return 0;
if (group == NULL) return 0;
go= group->gobject.first;
go = group->gobject.first;
while (go) {
gon= go->next;
if (go->ob==ob) {
gon = go->next;
if (go->ob == ob) {
BLI_remlink(&group->gobject, go);
free_group_object(go);
removed = 1;
/* should break here since an object being in a group twice cant happen? */
}
go= gon;
go = gon;
}
return removed;
}
@ -222,8 +222,8 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base)
if (rem_from_group_internal(group, object)) {
/* object can be NULL */
if (object && find_group(object, NULL) == NULL) {
if (scene && base==NULL)
base= BKE_scene_base_find(scene, object);
if (scene && base == NULL)
base = BKE_scene_base_find(scene, object);
object->flag &= ~OB_FROMGROUP;
@ -241,10 +241,10 @@ int object_in_group(Object *ob, Group *group)
{
GroupObject *go;
if (group==NULL || ob==NULL) return 0;
if (group == NULL || ob == NULL) return 0;
for (go= group->gobject.first; go; go= go->next) {
if (go->ob==ob)
for (go = group->gobject.first; go; go = go->next) {
if (go->ob == ob)
return 1;
}
return 0;
@ -253,14 +253,14 @@ int object_in_group(Object *ob, Group *group)
Group *find_group(Object *ob, Group *group)
{
if (group)
group= group->id.next;
group = group->id.next;
else
group= G.main->group.first;
group = G.main->group.first;
while (group) {
if (object_in_group(ob, group))
return group;
group= group->id.next;
group = group->id.next;
}
return NULL;
}
@ -269,11 +269,11 @@ void group_tag_recalc(Group *group)
{
GroupObject *go;
if (group==NULL) return;
if (group == NULL) return;
for (go= group->gobject.first; go; go= go->next) {
for (go = group->gobject.first; go; go = go->next) {
if (go->ob)
go->ob->recalc= go->recalc;
go->ob->recalc = go->recalc;
}
}
@ -286,7 +286,7 @@ int group_is_animated(Object *UNUSED(parent), Group *group)
return 1;
#endif
for (go= group->gobject.first; go; go= go->next)
for (go = group->gobject.first; go; go = go->next)
if (go->ob && go->ob->proxy)
return 1;
@ -298,38 +298,38 @@ int group_is_animated(Object *UNUSED(parent), Group *group)
/* keep checking nla.c though, in case internal structure of strip changes */
static void group_replaces_nla(Object *parent, Object *target, char mode)
{
static ListBase nlastrips={NULL, NULL};
static bAction *action= NULL;
static int done= 0;
static ListBase nlastrips = {NULL, NULL};
static bAction *action = NULL;
static int done = 0;
bActionStrip *strip, *nstrip;
if (mode=='s') {
if (mode == 's') {
for (strip= parent->nlastrips.first; strip; strip= strip->next) {
if (strip->object==target) {
if (done==0) {
for (strip = parent->nlastrips.first; strip; strip = strip->next) {
if (strip->object == target) {
if (done == 0) {
/* clear nla & action from object */
nlastrips= target->nlastrips;
target->nlastrips.first= target->nlastrips.last= NULL;
action= target->action;
target->action= NULL;
nlastrips = target->nlastrips;
target->nlastrips.first = target->nlastrips.last = NULL;
action = target->action;
target->action = NULL;
target->nlaflag |= OB_NLA_OVERRIDE;
done= 1;
done = 1;
}
nstrip= MEM_dupallocN(strip);
nstrip = MEM_dupallocN(strip);
BLI_addtail(&target->nlastrips, nstrip);
}
}
}
else if (mode=='e') {
else if (mode == 'e') {
if (done) {
BLI_freelistN(&target->nlastrips);
target->nlastrips= nlastrips;
target->action= action;
target->nlastrips = nlastrips;
target->action = action;
nlastrips.first= nlastrips.last= NULL; /* not needed, but yah... :) */
action= NULL;
done= 0;
nlastrips.first = nlastrips.last = NULL; /* not needed, but yah... :) */
action = NULL;
done = 0;
}
}
}
@ -353,30 +353,30 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group
int cfrao;
/* switch to local time */
cfrao= scene->r.cfra;
cfrao = scene->r.cfra;
/* we need a DAG per group... */
for (go= group->gobject.first; go; go= go->next) {
for (go = group->gobject.first; go; go = go->next) {
if (go->ob && go->recalc) {
go->ob->recalc= go->recalc;
go->ob->recalc = go->recalc;
group_replaces_nla(parent, go->ob, 's');
BKE_object_handle_update(scene, go->ob);
group_replaces_nla(parent, go->ob, 'e');
/* leave recalc tags in case group members are in normal scene */
go->ob->recalc= go->recalc;
go->ob->recalc = go->recalc;
}
}
/* restore */
scene->r.cfra= cfrao;
scene->r.cfra = cfrao;
}
else
#endif
{
/* only do existing tags, as set by regular depsgraph */
for (go= group->gobject.first; go; go= go->next) {
for (go = group->gobject.first; go; go = go->next) {
if (go->ob) {
if (go->ob->recalc) {
BKE_object_handle_update(scene, go->ob);
@ -391,17 +391,17 @@ Object *group_get_member_with_action(Group *group, bAction *act)
{
GroupObject *go;
if (group==NULL || act==NULL) return NULL;
if (group == NULL || act == NULL) return NULL;
for (go= group->gobject.first; go; go= go->next) {
for (go = group->gobject.first; go; go = go->next) {
if (go->ob) {
if (go->ob->action==act)
if (go->ob->action == act)
return go->ob;
if (go->ob->nlastrips.first) {
bActionStrip *strip;
for (strip= go->ob->nlastrips.first; strip; strip= strip->next) {
if (strip->act==act)
for (strip = go->ob->nlastrips.first; strip; strip = strip->next) {
if (strip->act == act)
return go->ob;
}
}
@ -418,21 +418,21 @@ void group_relink_nla_objects(Object *ob)
GroupObject *go;
bActionStrip *strip;
if (ob==NULL || ob->dup_group==NULL) return;
group= ob->dup_group;
if (ob == NULL || ob->dup_group == NULL) return;
group = ob->dup_group;
for (strip= ob->nlastrips.first; strip; strip= strip->next) {
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
if (strip->object) {
for (go= group->gobject.first; go; go= go->next) {
for (go = group->gobject.first; go; go = go->next) {
if (go->ob) {
if (strcmp(go->ob->id.name, strip->object->id.name)==0)
if (strcmp(go->ob->id.name, strip->object->id.name) == 0)
break;
}
}
if (go)
strip->object= go->ob;
strip->object = go->ob;
else
strip->object= NULL;
strip->object = NULL;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -55,30 +55,30 @@ void *BKE_lamp_add(const char *name)
{
Lamp *la;
la= BKE_libblock_alloc(&G.main->lamp, ID_LA, name);
la = BKE_libblock_alloc(&G.main->lamp, ID_LA, name);
la->r= la->g= la->b= la->k= 1.0f;
la->haint= la->energy= 1.0f;
la->dist= 25.0f;
la->spotsize= 45.0f;
la->spotblend= 0.15f;
la->att2= 1.0f;
la->mode= LA_SHAD_BUF;
la->bufsize= 512;
la->clipsta= 0.5f;
la->clipend= 40.0f;
la->shadspotsize= 45.0f;
la->samp= 3;
la->bias= 1.0f;
la->soft= 3.0f;
la->compressthresh= 0.05f;
la->ray_samp= la->ray_sampy= la->ray_sampz= 1;
la->area_size=la->area_sizey=la->area_sizez= 1.0f;
la->buffers= 1;
la->buftype= LA_SHADBUF_HALFWAY;
la->r = la->g = la->b = la->k = 1.0f;
la->haint = la->energy = 1.0f;
la->dist = 25.0f;
la->spotsize = 45.0f;
la->spotblend = 0.15f;
la->att2 = 1.0f;
la->mode = LA_SHAD_BUF;
la->bufsize = 512;
la->clipsta = 0.5f;
la->clipend = 40.0f;
la->shadspotsize = 45.0f;
la->samp = 3;
la->bias = 1.0f;
la->soft = 3.0f;
la->compressthresh = 0.05f;
la->ray_samp = la->ray_sampy = la->ray_sampz = 1;
la->area_size = la->area_sizey = la->area_sizez = 1.0f;
la->buffers = 1;
la->buftype = LA_SHADBUF_HALFWAY;
la->ray_samp_method = LA_SAMP_HALTON;
la->adapt_thresh = 0.001f;
la->preview=NULL;
la->preview = NULL;
la->falloff_type = LA_FALLOFF_INVSQUARE;
la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
la->sun_effect_type = 0;
@ -92,11 +92,11 @@ void *BKE_lamp_add(const char *name)
la->atm_extinction_factor = 1.0f;
la->atm_distance_factor = 1.0f;
la->sun_intensity = 1.0f;
la->skyblendtype= MA_RAMP_ADD;
la->skyblendfac= 1.0f;
la->sky_colorspace= BLI_XYZ_CIE;
la->sky_exposure= 1.0f;
la->shadow_frustum_size= 10.0f;
la->skyblendtype = MA_RAMP_ADD;
la->skyblendfac = 1.0f;
la->sky_colorspace = BLI_XYZ_CIE;
la->sky_exposure = 1.0f;
la->shadow_frustum_size = 10.0f;
curvemapping_initialize(la->curfalloff);
return la;
@ -107,11 +107,11 @@ Lamp *BKE_lamp_copy(Lamp *la)
Lamp *lan;
int a;
lan= BKE_libblock_copy(&la->id);
lan = BKE_libblock_copy(&la->id);
for (a=0; a<MAX_MTEX; a++) {
for (a = 0; a < MAX_MTEX; a++) {
if (lan->mtex[a]) {
lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex");
lan->mtex[a] = MEM_mallocN(sizeof(MTex), "copylamptex");
memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
id_us_plus((ID *)lan->mtex[a]->tex);
}
@ -120,7 +120,7 @@ Lamp *BKE_lamp_copy(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
if (la->nodetree)
lan->nodetree= ntreeCopyTree(la->nodetree);
lan->nodetree = ntreeCopyTree(la->nodetree);
if (la->preview)
lan->preview = BKE_previewimg_copy(la->preview);
@ -133,12 +133,12 @@ Lamp *localize_lamp(Lamp *la)
Lamp *lan;
int a;
lan= BKE_libblock_copy(&la->id);
lan = BKE_libblock_copy(&la->id);
BLI_remlink(&G.main->lamp, lan);
for (a=0; a<MAX_MTEX; a++) {
for (a = 0; a < MAX_MTEX; a++) {
if (lan->mtex[a]) {
lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
lan->mtex[a] = MEM_mallocN(sizeof(MTex), "localize_lamp");
memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
/* free lamp decrements */
id_us_plus((ID *)lan->mtex[a]->tex);
@ -148,60 +148,60 @@ Lamp *localize_lamp(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
if (la->nodetree)
lan->nodetree= ntreeLocalize(la->nodetree);
lan->nodetree = ntreeLocalize(la->nodetree);
lan->preview= NULL;
lan->preview = NULL;
return lan;
}
void BKE_lamp_make_local(Lamp *la)
{
Main *bmain= G.main;
Main *bmain = G.main;
Object *ob;
int is_local= FALSE, is_lib= FALSE;
int is_local = FALSE, is_lib = FALSE;
/* - only lib users: do nothing
* - only local users: set flag
* - mixed: make copy
*/
if (la->id.lib==NULL) return;
if (la->id.us==1) {
if (la->id.lib == NULL) return;
if (la->id.us == 1) {
id_clear_lib_data(bmain, &la->id);
return;
}
ob= bmain->object.first;
ob = bmain->object.first;
while (ob) {
if (ob->data==la) {
if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
if (ob->data == la) {
if (ob->id.lib) is_lib = TRUE;
else is_local = TRUE;
}
ob= ob->id.next;
ob = ob->id.next;
}
if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &la->id);
}
else if (is_local && is_lib) {
Lamp *la_new= BKE_lamp_copy(la);
la_new->id.us= 0;
Lamp *la_new = BKE_lamp_copy(la);
la_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, la->id.lib, &la_new->id);
ob= bmain->object.first;
ob = bmain->object.first;
while (ob) {
if (ob->data==la) {
if (ob->data == la) {
if (ob->id.lib==NULL) {
ob->data= la_new;
if (ob->id.lib == NULL) {
ob->data = la_new;
la_new->id.us++;
la->id.us--;
}
}
ob= ob->id.next;
ob = ob->id.next;
}
}
}
@ -211,8 +211,8 @@ void BKE_lamp_free(Lamp *la)
MTex *mtex;
int a;
for (a=0; a<MAX_MTEX; a++) {
mtex= la->mtex[a];
for (a = 0; a < MAX_MTEX; a++) {
mtex = la->mtex[a];
if (mtex && mtex->tex) mtex->tex->id.us--;
if (mtex) MEM_freeN(mtex);
}

View File

@ -69,17 +69,17 @@
void calc_lat_fudu(int flag, int res, float *fu, float *du)
{
if (res==1) {
*fu= 0.0;
*du= 0.0;
if (res == 1) {
*fu = 0.0;
*du = 0.0;
}
else if (flag & LT_GRID) {
*fu= -0.5f*(res-1);
*du= 1.0f;
*fu = -0.5f * (res - 1);
*du = 1.0f;
}
else {
*fu= -1.0f;
*du= 2.0f/(res-1);
*fu = -1.0f;
*du = 2.0f / (res - 1);
}
}
@ -87,53 +87,53 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
{
BPoint *bp;
int i, u, v, w;
float fu, fv, fw, uc, vc, wc, du=0.0, dv=0.0, dw=0.0;
float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
float *co, (*vertexCos)[3] = NULL;
/* vertex weight groups are just freed all for now */
if (lt->dvert) {
free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
lt->dvert= NULL;
free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
lt->dvert = NULL;
}
while (uNew*vNew*wNew > 32000) {
if ( uNew>=vNew && uNew>=wNew) uNew--;
else if ( vNew>=uNew && vNew>=wNew) vNew--;
while (uNew * vNew * wNew > 32000) {
if (uNew >= vNew && uNew >= wNew) uNew--;
else if (vNew >= uNew && vNew >= wNew) vNew--;
else wNew--;
}
vertexCos = MEM_mallocN(sizeof(*vertexCos)*uNew*vNew*wNew, "tmp_vcos");
vertexCos = MEM_mallocN(sizeof(*vertexCos) * uNew * vNew * wNew, "tmp_vcos");
calc_lat_fudu(lt->flag, uNew, &fu, &du);
calc_lat_fudu(lt->flag, vNew, &fv, &dv);
calc_lat_fudu(lt->flag, wNew, &fw, &dw);
/* If old size is different then resolution changed in interface,
* try to do clever reinit of points. Pretty simply idea, we just
* deform new verts by old lattice, but scaling them to match old
* size first.
*/
/* If old size is different then resolution changed in interface,
* try to do clever reinit of points. Pretty simply idea, we just
* deform new verts by old lattice, but scaling them to match old
* size first.
*/
if (ltOb) {
if (uNew!=1 && lt->pntsu!=1) {
if (uNew != 1 && lt->pntsu != 1) {
fu = lt->fu;
du = (lt->pntsu-1)*lt->du/(uNew-1);
du = (lt->pntsu - 1) * lt->du / (uNew - 1);
}
if (vNew!=1 && lt->pntsv!=1) {
if (vNew != 1 && lt->pntsv != 1) {
fv = lt->fv;
dv = (lt->pntsv-1)*lt->dv/(vNew-1);
dv = (lt->pntsv - 1) * lt->dv / (vNew - 1);
}
if (wNew!=1 && lt->pntsw!=1) {
if (wNew != 1 && lt->pntsw != 1) {
fw = lt->fw;
dw = (lt->pntsw-1)*lt->dw/(wNew-1);
dw = (lt->pntsw - 1) * lt->dw / (wNew - 1);
}
}
co = vertexCos[0];
for (w=0, wc=fw; w<wNew; w++, wc+=dw) {
for (v=0, vc=fv; v<vNew; v++, vc+=dv) {
for (u=0, uc=fu; u<uNew; u++, co+=3, uc+=du) {
for (w = 0, wc = fw; w < wNew; w++, wc += dw) {
for (v = 0, vc = fv; v < vNew; v++, vc += dv) {
for (u = 0, uc = fu; u < uNew; u++, co += 3, uc += du) {
co[0] = uc;
co[1] = vc;
co[2] = wc;
@ -145,15 +145,15 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
float mat[4][4];
int typeu = lt->typeu, typev = lt->typev, typew = lt->typew;
/* works best if we force to linear type (endpoints match) */
/* works best if we force to linear type (endpoints match) */
lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
/* prevent using deformed locations */
/* prevent using deformed locations */
freedisplist(&ltOb->disp);
copy_m4_m4(mat, ltOb->obmat);
unit_m4(ltOb->obmat);
lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL, 1.0f);
lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew * vNew * wNew, NULL, 1.0f);
copy_m4_m4(ltOb->obmat, mat);
lt->typeu = typeu;
@ -173,11 +173,11 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
lt->pntsw = wNew;
MEM_freeN(lt->def);
lt->def= MEM_callocN(lt->pntsu*lt->pntsv*lt->pntsw*sizeof(BPoint), "lattice bp");
lt->def = MEM_callocN(lt->pntsu * lt->pntsv * lt->pntsw * sizeof(BPoint), "lattice bp");
bp= lt->def;
bp = lt->def;
for (i=0; i<lt->pntsu*lt->pntsv*lt->pntsw; i++, bp++) {
for (i = 0; i < lt->pntsu * lt->pntsv * lt->pntsw; i++, bp++) {
copy_v3_v3(bp->vec, vertexCos[i]);
}
@ -188,14 +188,14 @@ Lattice *BKE_lattice_add(const char *name)
{
Lattice *lt;
lt= BKE_libblock_alloc(&G.main->latt, ID_LT, name);
lt = BKE_libblock_alloc(&G.main->latt, ID_LT, name);
lt->flag= LT_GRID;
lt->flag = LT_GRID;
lt->typeu= lt->typev= lt->typew= KEY_BSPLINE;
lt->typeu = lt->typev = lt->typew = KEY_BSPLINE;
lt->def= MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
return lt;
}
@ -204,19 +204,19 @@ Lattice *BKE_lattice_copy(Lattice *lt)
{
Lattice *ltn;
ltn= BKE_libblock_copy(&lt->id);
ltn->def= MEM_dupallocN(lt->def);
ltn = BKE_libblock_copy(&lt->id);
ltn->def = MEM_dupallocN(lt->def);
ltn->key= BKE_key_copy(ltn->key);
if (ltn->key) ltn->key->from= (ID *)ltn;
ltn->key = BKE_key_copy(ltn->key);
if (ltn->key) ltn->key->from = (ID *)ltn;
if (lt->dvert) {
int tot= lt->pntsu*lt->pntsv*lt->pntsw;
ltn->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
int tot = lt->pntsu * lt->pntsv * lt->pntsw;
ltn->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert");
copy_dverts(ltn->dvert, lt->dvert, tot);
}
ltn->editlatt= NULL;
ltn->editlatt = NULL;
return ltn;
}
@ -224,12 +224,12 @@ Lattice *BKE_lattice_copy(Lattice *lt)
void BKE_lattice_free(Lattice *lt)
{
if (lt->def) MEM_freeN(lt->def);
if (lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
if (lt->dvert) free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
if (lt->editlatt) {
Lattice *editlt= lt->editlatt->latt;
Lattice *editlt = lt->editlatt->latt;
if (editlt->def) MEM_freeN(editlt->def);
if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
MEM_freeN(editlt);
MEM_freeN(lt->editlatt);
@ -238,49 +238,49 @@ void BKE_lattice_free(Lattice *lt)
/* free animation data */
if (lt->adt) {
BKE_free_animdata(&lt->id);
lt->adt= NULL;
lt->adt = NULL;
}
}
void BKE_lattice_make_local(Lattice *lt)
{
Main *bmain= G.main;
Main *bmain = G.main;
Object *ob;
int is_local= FALSE, is_lib= FALSE;
int is_local = FALSE, is_lib = FALSE;
/* - only lib users: do nothing
* - only local users: set flag
* - mixed: make copy
*/
if (lt->id.lib==NULL) return;
if (lt->id.us==1) {
if (lt->id.lib == NULL) return;
if (lt->id.us == 1) {
id_clear_lib_data(bmain, &lt->id);
return;
}
for (ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) {
if (ob->data==lt) {
if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
for (ob = bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob = ob->id.next) {
if (ob->data == lt) {
if (ob->id.lib) is_lib = TRUE;
else is_local = TRUE;
}
}
if (is_local && is_lib==FALSE) {
if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &lt->id);
}
else if (is_local && is_lib) {
Lattice *lt_new= BKE_lattice_copy(lt);
lt_new->id.us= 0;
Lattice *lt_new = BKE_lattice_copy(lt);
lt_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, lt->id.lib, &lt_new->id);
for (ob= bmain->object.first; ob; ob= ob->id.next) {
if (ob->data==lt) {
if (ob->id.lib==NULL) {
ob->data= lt_new;
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->data == lt) {
if (ob->id.lib == NULL) {
ob->data = lt_new;
lt_new->id.us++;
lt->id.us--;
}
@ -291,22 +291,22 @@ void BKE_lattice_make_local(Lattice *lt)
void init_latt_deform(Object *oblatt, Object *ob)
{
/* we make an array with all differences */
Lattice *lt= oblatt->data;
/* we make an array with all differences */
Lattice *lt = oblatt->data;
BPoint *bp;
DispList *dl = find_displist(&oblatt->disp, DL_VERTS);
float *co = dl?dl->verts:NULL;
float *co = dl ? dl->verts : NULL;
float *fp, imat[4][4];
float fu, fv, fw;
int u, v, w;
if (lt->editlatt) lt= lt->editlatt->latt;
if (lt->editlatt) lt = lt->editlatt->latt;
bp = lt->def;
fp= lt->latticedata= MEM_mallocN(sizeof(float)*3*lt->pntsu*lt->pntsv*lt->pntsw, "latticedata");
fp = lt->latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw, "latticedata");
/* for example with a particle system: ob==0 */
if (ob==NULL) {
/* for example with a particle system: ob==0 */
if (ob == NULL) {
/* in deformspace, calc matrix */
invert_m4_m4(lt->latmat, oblatt->obmat);
@ -322,9 +322,9 @@ void init_latt_deform(Object *oblatt, Object *ob)
invert_m4_m4(imat, lt->latmat);
}
for (w=0, fw=lt->fw; w<lt->pntsw; w++, fw+=lt->dw) {
for (v=0, fv=lt->fv; v<lt->pntsv; v++, fv+=lt->dv) {
for (u=0, fu=lt->fu; u<lt->pntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) {
for (w = 0, fw = lt->fw; w < lt->pntsw; w++, fw += lt->dw) {
for (v = 0, fv = lt->fv; v < lt->pntsv; v++, fv += lt->dv) {
for (u = 0, fu = lt->fu; u < lt->pntsu; u++, bp++, co += 3, fp += 3, fu += lt->du) {
if (dl) {
fp[0] = co[0] - fu;
fp[1] = co[1] - fv;
@ -344,23 +344,23 @@ void init_latt_deform(Object *oblatt, Object *ob)
void calc_latt_deform(Object *ob, float co[3], float weight)
{
Lattice *lt= ob->data;
Lattice *lt = ob->data;
float u, v, w, tu[4], tv[4], tw[4];
float vec[3];
int idx_w, idx_v, idx_u;
int ui, vi, wi, uu, vv, ww;
/* vgroup influence */
int defgroup_nr= -1;
float co_prev[3], weight_blend= 0.0f;
MDeformVert *dvert= BKE_lattice_deform_verts_get(ob);
int defgroup_nr = -1;
float co_prev[3], weight_blend = 0.0f;
MDeformVert *dvert = BKE_lattice_deform_verts_get(ob);
if (lt->editlatt) lt= lt->editlatt->latt;
if (lt->latticedata==NULL) return;
if (lt->editlatt) lt = lt->editlatt->latt;
if (lt->latticedata == NULL) return;
if (lt->vgroup[0] && dvert) {
defgroup_nr= defgroup_name_index(ob, lt->vgroup);
defgroup_nr = defgroup_name_index(ob, lt->vgroup);
copy_v3_v3(co_prev, co);
}
@ -369,68 +369,68 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
/* u v w coords */
if (lt->pntsu>1) {
u= (vec[0]-lt->fu)/lt->du;
ui= (int)floor(u);
if (lt->pntsu > 1) {
u = (vec[0] - lt->fu) / lt->du;
ui = (int)floor(u);
u -= ui;
key_curve_position_weights(u, tu, lt->typeu);
}
else {
tu[0]= tu[2]= tu[3]= 0.0; tu[1]= 1.0;
ui= 0;
tu[0] = tu[2] = tu[3] = 0.0; tu[1] = 1.0;
ui = 0;
}
if (lt->pntsv>1) {
v= (vec[1]-lt->fv)/lt->dv;
vi= (int)floor(v);
if (lt->pntsv > 1) {
v = (vec[1] - lt->fv) / lt->dv;
vi = (int)floor(v);
v -= vi;
key_curve_position_weights(v, tv, lt->typev);
}
else {
tv[0]= tv[2]= tv[3]= 0.0; tv[1]= 1.0;
vi= 0;
tv[0] = tv[2] = tv[3] = 0.0; tv[1] = 1.0;
vi = 0;
}
if (lt->pntsw>1) {
w= (vec[2]-lt->fw)/lt->dw;
wi= (int)floor(w);
if (lt->pntsw > 1) {
w = (vec[2] - lt->fw) / lt->dw;
wi = (int)floor(w);
w -= wi;
key_curve_position_weights(w, tw, lt->typew);
}
else {
tw[0]= tw[2]= tw[3]= 0.0; tw[1]= 1.0;
wi= 0;
tw[0] = tw[2] = tw[3] = 0.0; tw[1] = 1.0;
wi = 0;
}
for (ww= wi-1; ww<=wi+2; ww++) {
w= tw[ww-wi+1];
for (ww = wi - 1; ww <= wi + 2; ww++) {
w = tw[ww - wi + 1];
if (w != 0.0f) {
if (ww>0) {
if (ww<lt->pntsw) idx_w= ww*lt->pntsu*lt->pntsv;
else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv;
if (ww > 0) {
if (ww < lt->pntsw) idx_w = ww * lt->pntsu * lt->pntsv;
else idx_w = (lt->pntsw - 1) * lt->pntsu * lt->pntsv;
}
else idx_w= 0;
else idx_w = 0;
for (vv= vi-1; vv<=vi+2; vv++) {
v= w*tv[vv-vi+1];
for (vv = vi - 1; vv <= vi + 2; vv++) {
v = w * tv[vv - vi + 1];
if (v != 0.0f) {
if (vv>0) {
if (vv<lt->pntsv) idx_v= idx_w + vv*lt->pntsu;
else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu;
if (vv > 0) {
if (vv < lt->pntsv) idx_v = idx_w + vv * lt->pntsu;
else idx_v = idx_w + (lt->pntsv - 1) * lt->pntsu;
}
else idx_v= idx_w;
else idx_v = idx_w;
for (uu= ui-1; uu<=ui+2; uu++) {
u= weight*v*tu[uu-ui+1];
for (uu = ui - 1; uu <= ui + 2; uu++) {
u = weight * v * tu[uu - ui + 1];
if (u != 0.0f) {
if (uu>0) {
if (uu<lt->pntsu) idx_u= idx_v + uu;
else idx_u= idx_v + (lt->pntsu-1);
if (uu > 0) {
if (uu < lt->pntsu) idx_u = idx_v + uu;
else idx_u = idx_v + (lt->pntsu - 1);
}
else idx_u= idx_v;
else idx_u = idx_v;
madd_v3_v3fl(co, &lt->latticedata[idx_u * 3], u);
@ -450,18 +450,18 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
void end_latt_deform(Object *ob)
{
Lattice *lt= ob->data;
Lattice *lt = ob->data;
if (lt->editlatt) lt= lt->editlatt->latt;
if (lt->editlatt) lt = lt->editlatt->latt;
if (lt->latticedata)
MEM_freeN(lt->latticedata);
lt->latticedata= NULL;
lt->latticedata = NULL;
}
/* calculations is in local space of deformed object
* so we store in latmat transform from path coord inside object
*/
/* calculations is in local space of deformed object
* so we store in latmat transform from path coord inside object
*/
typedef struct {
float dmin[3], dmax[3];
float curvespace[4][4], objectspace[4][4], objectspace3[3][3];
@ -474,7 +474,7 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd)
mult_m4_m4m4(cd->objectspace, ob->imat, par->obmat);
invert_m4_m4(cd->curvespace, cd->objectspace);
copy_m3_m4(cd->objectspace3, cd->objectspace);
cd->no_rot_axis= 0;
cd->no_rot_axis = 0;
}
/* this makes sure we can extend for non-cyclic.
@ -483,41 +483,41 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd)
*/
static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir[3], float quat[4], float *radius)
{
Curve *cu= ob->data;
Curve *cu = ob->data;
BevList *bl;
float ctime1;
int cycl=0;
int cycl = 0;
/* test for cyclic */
bl= cu->bev.first;
bl = cu->bev.first;
if (!bl->nr) return 0;
if (bl && bl->poly> -1) cycl= 1;
if (bl && bl->poly > -1) cycl = 1;
if (cycl==0) {
ctime1= CLAMPIS(ctime, 0.0f, 1.0f);
if (cycl == 0) {
ctime1 = CLAMPIS(ctime, 0.0f, 1.0f);
}
else ctime1= ctime;
else ctime1 = ctime;
/* vec needs 4 items */
if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {
if (cycl==0) {
Path *path= cu->path;
if (cycl == 0) {
Path *path = cu->path;
float dvec[3];
if (ctime < 0.0f) {
sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
mul_v3_fl(dvec, ctime*(float)path->len);
mul_v3_fl(dvec, ctime * (float)path->len);
add_v3_v3(vec, dvec);
if (quat) copy_qt_qt(quat, path->data[0].quat);
if (radius) *radius= path->data[0].radius;
if (radius) *radius = path->data[0].radius;
}
else if (ctime > 1.0f) {
sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
mul_v3_fl(dvec, (ctime-1.0f)*(float)path->len);
sub_v3_v3v3(dvec, path->data[path->len - 1].vec, path->data[path->len - 2].vec);
mul_v3_fl(dvec, (ctime - 1.0f) * (float)path->len);
add_v3_v3(vec, dvec);
if (quat) copy_qt_qt(quat, path->data[path->len-1].quat);
if (radius) *radius= path->data[path->len-1].radius;
if (quat) copy_qt_qt(quat, path->data[path->len - 1].quat);
if (radius) *radius = path->data[path->len - 1].radius;
/* weight - not used but could be added */
}
}
@ -534,43 +534,43 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir
static int calc_curve_deform(Scene *scene, Object *par, float co[3],
const short axis, CurveDeform *cd, float quat_r[4])
{
Curve *cu= par->data;
Curve *cu = par->data;
float fac, loc[4], dir[3], new_quat[4], radius;
short index;
const int is_neg_axis = (axis > 2);
/* to be sure, mostly after file load */
if (cu->path==NULL) {
if (cu->path == NULL) {
makeDispListCurveTypes(scene, par, 0);
if (cu->path==NULL) return 0; // happens on append...
if (cu->path == NULL) return 0; // happens on append...
}
/* options */
if (is_neg_axis) {
index = axis - 3;
if (cu->flag & CU_STRETCH)
fac= (-co[index]-cd->dmax[index])/(cd->dmax[index] - cd->dmin[index]);
fac = (-co[index] - cd->dmax[index]) / (cd->dmax[index] - cd->dmin[index]);
else
fac= - (co[index]-cd->dmax[index])/(cu->path->totdist);
fac = -(co[index] - cd->dmax[index]) / (cu->path->totdist);
}
else {
index = axis;
if (cu->flag & CU_STRETCH)
fac= (co[index]-cd->dmin[index])/(cd->dmax[index] - cd->dmin[index]);
fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]);
else
fac= + (co[index]-cd->dmin[index])/(cu->path->totdist);
fac = +(co[index] - cd->dmin[index]) / (cu->path->totdist);
}
if ( where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
if (where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
float quat[4], cent[3];
if (cd->no_rot_axis) { /* set by caller */
if (cd->no_rot_axis) { /* set by caller */
/* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than
* changing the axis before calculating the tilt but serves much the same purpose */
float dir_flat[3]={0, 0, 0}, q[4];
float dir_flat[3] = {0, 0, 0}, q[4];
copy_v3_v3(dir_flat, dir);
dir_flat[cd->no_rot_axis-1]= 0.0f;
dir_flat[cd->no_rot_axis - 1] = 0.0f;
normalize_v3(dir);
normalize_v3(dir_flat);
@ -598,9 +598,9 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
/* zero the axis which is not used,
* the big block of text above now applies to these 3 lines */
quat_apply_track(quat, axis, (axis == 0 || axis == 2) ? 1:0); /* up flag is a dummy, set so no rotation is done */
quat_apply_track(quat, axis, (axis == 0 || axis == 2) ? 1 : 0); /* up flag is a dummy, set so no rotation is done */
vec_apply_track(cent, axis);
cent[index]= 0.0f;
cent[index] = 0.0f;
/* scale if enabled */
@ -637,26 +637,26 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
cu = cuOb->data;
flag = cu->flag;
cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist
cu->flag |= (CU_PATH | CU_FOLLOW); // needed for path & bevlist
init_curve_deform(cuOb, target, &cd);
/* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */
if (is_neg_axis == FALSE) {
cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f;
cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f;
cd.dmin[0] = cd.dmin[1] = cd.dmin[2] = 0.0f;
cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 1.0f;
}
else {
/* negative, these bounds give a good rest position */
cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= -1.0f;
cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 0.0f;
cd.dmin[0] = cd.dmin[1] = cd.dmin[2] = -1.0f;
cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 0.0f;
}
/* check whether to use vertex groups (only possible if target is a Mesh)
* we want either a Mesh with no derived data, or derived data with
* deformverts
*/
if (target && target->type==OB_MESH) {
if (target && target->type == OB_MESH) {
/* if there's derived data without deformverts, don't use vgroups */
if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
use_vgroups = 0;
@ -668,8 +668,8 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
}
if (vgroup && vgroup[0] && use_vgroups) {
Mesh *me= target->data;
int index= defgroup_name_index(target, vgroup);
Mesh *me = target->data;
int index = defgroup_name_index(target, vgroup);
if (index != -1 && (me->dvert || dm)) {
MDeformVert *dvert = me->dvert;
@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
dvert = me->dvert;
for (a = 0; a < numVerts; a++, dvert++) {
if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
weight= defvert_find_weight(dvert, index);
weight = defvert_find_weight(dvert, index);
if (weight > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
@ -709,7 +709,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
for (a = 0; a < numVerts; a++, dvert++) {
if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
weight= defvert_find_weight(dvert, index);
weight = defvert_find_weight(dvert, index);
if (weight > 0.0f) {
/* already in 'cd.curvespace', prev for loop */
@ -764,7 +764,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
}
init_curve_deform(cuOb, target, &cd);
cd.no_rot_axis= no_rot_axis; /* option to only rotate for XY, for example */
cd.no_rot_axis = no_rot_axis; /* option to only rotate for XY, for example */
copy_v3_v3(cd.dmin, orco);
copy_v3_v3(cd.dmax, orco);
@ -799,7 +799,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
* we want either a Mesh with no derived data, or derived data with
* deformverts
*/
if (target && target->type==OB_MESH) {
if (target && target->type == OB_MESH) {
/* if there's derived data without deformverts, don't use vgroups */
if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
use_vgroups = 0;
@ -821,7 +821,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
for (a = 0; a < numVerts; a++, dvert++) {
if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
weight= defvert_find_weight(dvert, index);
weight = defvert_find_weight(dvert, index);
if (weight > 0.0f)
calc_latt_deform(laOb, vertexCos[a], weight * fac);
@ -838,12 +838,12 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
int object_deform_mball(Object *ob, ListBase *dispbase)
{
if (ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) {
if (ob->parent && ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) {
DispList *dl;
for (dl=dispbase->first; dl; dl=dl->next) {
for (dl = dispbase->first; dl; dl = dl->next) {
lattice_deform_verts(ob->parent, ob, NULL,
(float(*)[3]) dl->verts, dl->nr, NULL, 1.0f);
(float(*)[3])dl->verts, dl->nr, NULL, 1.0f);
}
return 1;
@ -862,52 +862,52 @@ void outside_lattice(Lattice *lt)
{
BPoint *bp, *bp1, *bp2;
int u, v, w;
float fac1, du=0.0, dv=0.0, dw=0.0;
float fac1, du = 0.0, dv = 0.0, dw = 0.0;
if (lt->flag & LT_OUTSIDE) {
bp= lt->def;
bp = lt->def;
if (lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
if (lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
if (lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
if (lt->pntsu > 1) du = 1.0f / ((float)lt->pntsu - 1);
if (lt->pntsv > 1) dv = 1.0f / ((float)lt->pntsv - 1);
if (lt->pntsw > 1) dw = 1.0f / ((float)lt->pntsw - 1);
for (w=0; w<lt->pntsw; w++) {
for (w = 0; w < lt->pntsw; w++) {
for (v=0; v<lt->pntsv; v++) {
for (v = 0; v < lt->pntsv; v++) {
for (u=0; u<lt->pntsu; u++, bp++) {
if (u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
for (u = 0; u < lt->pntsu; u++, bp++) {
if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 || w == lt->pntsw - 1) ;
else {
bp->hide= 1;
bp->hide = 1;
bp->f1 &= ~SELECT;
/* u extrema */
bp1= latt_bp(lt, 0, v, w);
bp2= latt_bp(lt, lt->pntsu-1, v, w);
bp1 = latt_bp(lt, 0, v, w);
bp2 = latt_bp(lt, lt->pntsu - 1, v, w);
fac1= du*u;
bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
fac1 = du * u;
bp->vec[0] = (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
bp->vec[1] = (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
bp->vec[2] = (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
/* v extrema */
bp1= latt_bp(lt, u, 0, w);
bp2= latt_bp(lt, u, lt->pntsv-1, w);
bp1 = latt_bp(lt, u, 0, w);
bp2 = latt_bp(lt, u, lt->pntsv - 1, w);
fac1= dv*v;
bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
fac1 = dv * v;
bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
/* w extrema */
bp1= latt_bp(lt, u, v, 0);
bp2= latt_bp(lt, u, v, lt->pntsw-1);
bp1 = latt_bp(lt, u, v, 0);
bp2 = latt_bp(lt, u, v, lt->pntsw - 1);
fac1= dw*w;
bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
fac1 = dw * w;
bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
mul_v3_fl(bp->vec, 0.3333333f);
@ -919,12 +919,12 @@ void outside_lattice(Lattice *lt)
}
}
else {
bp= lt->def;
bp = lt->def;
for (w=0; w<lt->pntsw; w++)
for (v=0; v<lt->pntsv; v++)
for (u=0; u<lt->pntsu; u++, bp++)
bp->hide= 0;
for (w = 0; w < lt->pntsw; w++)
for (v = 0; v < lt->pntsv; v++)
for (u = 0; u < lt->pntsu; u++, bp++)
bp->hide = 0;
}
}
@ -934,12 +934,12 @@ float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[3]
int i, numVerts;
float (*vertexCos)[3];
if (lt->editlatt) lt= lt->editlatt->latt;
numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw;
if (lt->editlatt) lt = lt->editlatt->latt;
numVerts = *numVerts_r = lt->pntsu * lt->pntsv * lt->pntsw;
vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts, "lt_vcos");
vertexCos = MEM_mallocN(sizeof(*vertexCos) * numVerts, "lt_vcos");
for (i=0; i<numVerts; i++) {
for (i = 0; i < numVerts; i++) {
copy_v3_v3(vertexCos[i], lt->def[i].vec);
}
@ -949,31 +949,31 @@ float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[3]
void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3])
{
Lattice *lt = ob->data;
int i, numVerts = lt->pntsu*lt->pntsv*lt->pntsw;
int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
for (i=0; i<numVerts; i++) {
for (i = 0; i < numVerts; i++) {
copy_v3_v3(lt->def[i].vec, vertexCos[i]);
}
}
void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
{
Lattice *lt= ob->data;
Lattice *lt = ob->data;
ModifierData *md = modifiers_getVirtualModifierList(ob);
float (*vertexCos)[3] = NULL;
int numVerts, editmode = (lt->editlatt!=NULL);
int numVerts, editmode = (lt->editlatt != NULL);
freedisplist(&ob->disp);
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&eModifierMode_Realtime)) continue;
if (editmode && !(md->mode&eModifierMode_Editmode)) continue;
if (!(md->mode & eModifierMode_Realtime)) continue;
if (editmode && !(md->mode & eModifierMode_Editmode)) continue;
if (mti->isDisabled && mti->isDisabled(md, 0)) continue;
if (mti->type!=eModifierTypeType_OnlyDeform) continue;
if (mti->type != eModifierTypeType_OnlyDeform) continue;
if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts);
mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0);
@ -987,16 +987,16 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
dl->type = DL_VERTS;
dl->parts = 1;
dl->nr = numVerts;
dl->verts = (float*) vertexCos;
dl->verts = (float *) vertexCos;
BLI_addtail(&ob->disp, dl);
}
}
struct MDeformVert* BKE_lattice_deform_verts_get(struct Object *oblatt)
struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *oblatt)
{
Lattice *lt = (Lattice*)oblatt->data;
Lattice *lt = (Lattice *)oblatt->data;
BLI_assert(oblatt->type == OB_LATTICE);
if (lt->editlatt) lt= lt->editlatt->latt;
if (lt->editlatt) lt = lt->editlatt->latt;
return lt->dvert;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@
#include "BKE_main.h"
#include "BKE_utildefines.h"
#include "BKE_movieclip.h"
#include "BKE_image.h" /* openanim */
#include "BKE_image.h" /* openanim */
#include "BKE_tracking.h"
#include "IMB_imbuf_types.h"
@ -205,7 +205,7 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user,
else
get_sequence_fname(clip, framenr, name);
loadflag = IB_rect|IB_multilayer;
loadflag = IB_rect | IB_multilayer;
/* read ibuf */
ibuf = IMB_loadiffname(name, loadflag);
@ -250,7 +250,7 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
dur = IMB_anim_get_duration(clip->anim, tc);
fra = framenr - 1;
if (fra<0)
if (fra < 0)
fra = 0;
if (fra > (dur - 1))
@ -283,7 +283,7 @@ static void movieclip_calc_length(MovieClip *clip)
clip->len = framenr + 1;
}
else {
for (;;) {
for (;; ) {
get_sequence_fname(clip, framenr, name);
if (!BLI_exists(name)) {
@ -338,7 +338,7 @@ typedef struct MovieClipImBufCacheKey {
static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags)
{
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)userkey;
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)userkey;
*framenr = key->framenr;
*proxy = key->proxy;
@ -347,7 +347,7 @@ static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *ren
static unsigned int moviecache_hashhash(const void *keyv)
{
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)keyv;
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)keyv;
int rval = key->framenr;
return rval;
@ -355,8 +355,8 @@ static unsigned int moviecache_hashhash(const void *keyv)
static int moviecache_hashcmp(const void *av, const void *bv)
{
const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey*)av;
const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey*)bv;
const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey *)av;
const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey *)bv;
if (a->framenr < b->framenr)
return -1;
@ -406,7 +406,7 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i
clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash,
moviecache_hashcmp, moviecache_keydata);
moviecache_hashcmp, moviecache_keydata);
}
key.framenr = user->framenr;
@ -529,8 +529,8 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in
break;
case MCLIP_PROXY_RENDER_SIZE_75:
*width = ((float)*width)*4.0f/3.0f;
*height = ((float)*height)*4.0f/3.0f;
*width = ((float)*width) * 4.0f / 3.0f;
*height = ((float)*height) * 4.0f / 3.0f;
break;
}
}
@ -669,8 +669,8 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
if (postprocess_flag) {
int disable_red = postprocess_flag & MOVIECLIP_DISABLE_RED,
disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN,
disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE,
grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE;
disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE,
grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE;
if (!postproc_ibuf)
postproc_ibuf = IMB_dupImBuf(ibuf);
@ -801,8 +801,8 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
/* check for stabilization parameters */
if (tscale != cache->stabilized.scale ||
tangle != cache->stabilized.angle ||
!equals_v2v2(tloc, cache->stabilized.loc))
tangle != cache->stabilized.angle ||
!equals_v2v2(tloc, cache->stabilized.loc))
{
return NULL;
}
@ -1049,17 +1049,17 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
BKE_movieclip_get_size(clip, user, &width, &height);
undist_marker.pos[0] *= width;
undist_marker.pos[1] *= height*aspy;
undist_marker.pos[1] *= height * aspy;
BKE_tracking_invert_intrinsics(&clip->tracking, undist_marker.pos, undist_marker.pos);
undist_marker.pos[0] /= width;
undist_marker.pos[1] /= height*aspy;
undist_marker.pos[1] /= height * aspy;
}
/* NOTE: margin should be kept in sync with value from ui_draw_but_TRACKPREVIEW */
tmpibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 3 /* margin */,
1 /* anchor */, scopes->track_pos, NULL);
1 /* anchor */, scopes->track_pos, NULL);
if (tmpibuf->rect_float)
IMB_rect_from_float(tmpibuf);
@ -1073,11 +1073,11 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
IMB_freeImBuf(ibuf);
}
if ((track->flag & TRACK_LOCKED)==0) {
if ((track->flag & TRACK_LOCKED) == 0) {
scopes->marker = marker;
scopes->track = track;
scopes->slide_scale[0] = track->pat_max[0]-track->pat_min[0];
scopes->slide_scale[1] = track->pat_max[1]-track->pat_min[1];
scopes->slide_scale[0] = track->pat_max[0] - track->pat_min[0];
scopes->slide_scale[1] = track->pat_max[1] - track->pat_min[1];
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -118,20 +118,20 @@ Scene *BKE_scene_copy(Scene *sce, int type)
if (type == SCE_COPY_EMPTY) {
ListBase lb;
scen= BKE_scene_add(sce->id.name+2);
scen = BKE_scene_add(sce->id.name + 2);
lb= scen->r.layers;
scen->r= sce->r;
scen->r.layers= lb;
scen->unit= sce->unit;
scen->physics_settings= sce->physics_settings;
scen->gm= sce->gm;
scen->audio= sce->audio;
lb = scen->r.layers;
scen->r = sce->r;
scen->r.layers = lb;
scen->unit = sce->unit;
scen->physics_settings = sce->physics_settings;
scen->gm = sce->gm;
scen->audio = sce->audio;
MEM_freeN(scen->toolsettings);
}
else {
scen= BKE_libblock_copy(&sce->id);
scen = BKE_libblock_copy(&sce->id);
BLI_duplicatelist(&(scen->base), &(sce->base));
clear_id_newpoins();
@ -140,11 +140,11 @@ Scene *BKE_scene_copy(Scene *sce, int type)
id_us_plus((ID *)scen->set);
id_us_plus((ID *)scen->gm.dome.warptext);
scen->ed= NULL;
scen->theDag= NULL;
scen->obedit= NULL;
scen->stats= NULL;
scen->fps_info= NULL;
scen->ed = NULL;
scen->theDag = NULL;
scen->obedit = NULL;
scen->stats = NULL;
scen->fps_info = NULL;
BLI_duplicatelist(&(scen->markers), &(sce->markers));
BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces));
@ -152,48 +152,48 @@ Scene *BKE_scene_copy(Scene *sce, int type)
BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
if (sce->nodetree) {
scen->nodetree= ntreeCopyTree(sce->nodetree); /* copies actions */
scen->nodetree = ntreeCopyTree(sce->nodetree); /* copies actions */
ntreeSwitchID(scen->nodetree, &sce->id, &scen->id);
}
obase= sce->base.first;
base= scen->base.first;
obase = sce->base.first;
base = scen->base.first;
while (base) {
id_us_plus(&base->object->id);
if (obase==sce->basact) scen->basact= base;
if (obase == sce->basact) scen->basact = base;
obase= obase->next;
base= base->next;
obase = obase->next;
base = base->next;
}
}
/* tool settings */
scen->toolsettings= MEM_dupallocN(sce->toolsettings);
scen->toolsettings = MEM_dupallocN(sce->toolsettings);
ts= scen->toolsettings;
ts = scen->toolsettings;
if (ts) {
if (ts->vpaint) {
ts->vpaint= MEM_dupallocN(ts->vpaint);
ts->vpaint->paintcursor= NULL;
ts->vpaint->vpaint_prev= NULL;
ts->vpaint->wpaint_prev= NULL;
ts->vpaint = MEM_dupallocN(ts->vpaint);
ts->vpaint->paintcursor = NULL;
ts->vpaint->vpaint_prev = NULL;
ts->vpaint->wpaint_prev = NULL;
copy_paint(&ts->vpaint->paint, &ts->vpaint->paint);
}
if (ts->wpaint) {
ts->wpaint= MEM_dupallocN(ts->wpaint);
ts->wpaint->paintcursor= NULL;
ts->wpaint->vpaint_prev= NULL;
ts->wpaint->wpaint_prev= NULL;
ts->wpaint = MEM_dupallocN(ts->wpaint);
ts->wpaint->paintcursor = NULL;
ts->wpaint->vpaint_prev = NULL;
ts->wpaint->wpaint_prev = NULL;
copy_paint(&ts->wpaint->paint, &ts->wpaint->paint);
}
if (ts->sculpt) {
ts->sculpt= MEM_dupallocN(ts->sculpt);
ts->sculpt = MEM_dupallocN(ts->sculpt);
copy_paint(&ts->sculpt->paint, &ts->sculpt->paint);
}
copy_paint(&ts->imapaint.paint, &ts->imapaint.paint);
ts->imapaint.paintcursor= NULL;
ts->particle.paintcursor= NULL;
ts->imapaint.paintcursor = NULL;
ts->particle.paintcursor = NULL;
}
/* make a private copy of the avicodecdata */
@ -210,7 +210,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
}
if (sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */
scen->r.ffcodecdata.properties= IDP_CopyProperty(sce->r.ffcodecdata.properties);
scen->r.ffcodecdata.properties = IDP_CopyProperty(sce->r.ffcodecdata.properties);
}
/* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations
@ -229,13 +229,13 @@ Scene *BKE_scene_copy(Scene *sce, int type)
BKE_copy_animdata_id_action((ID *)scen);
if (scen->world) {
id_us_plus((ID *)scen->world);
scen->world= BKE_world_copy(scen->world);
scen->world = BKE_world_copy(scen->world);
BKE_copy_animdata_id_action((ID *)scen->world);
}
if (sce->ed) {
scen->ed= MEM_callocN(sizeof(Editing), "addseq");
scen->ed->seqbasep= &scen->ed->seqbase;
scen->ed = MEM_callocN(sizeof(Editing), "addseq");
scen->ed->seqbasep = &scen->ed->seqbase;
seqbase_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL);
}
}
@ -248,10 +248,10 @@ void BKE_scene_free(Scene *sce)
{
Base *base;
base= sce->base.first;
base = sce->base.first;
while (base) {
base->object->id.us--;
base= base->next;
base = base->next;
}
/* do not free objects! */
@ -262,7 +262,7 @@ void BKE_scene_free(Scene *sce)
// its probably safe not to do this, some save and reload will free this.
sce->gpd->id.us--;
#endif
sce->gpd= NULL;
sce->gpd = NULL;
}
BLI_freelistN(&sce->base);
@ -334,74 +334,74 @@ void BKE_scene_free(Scene *sce)
Scene *BKE_scene_add(const char *name)
{
Main *bmain= G.main;
Main *bmain = G.main;
Scene *sce;
ParticleEditSettings *pset;
int a;
sce= BKE_libblock_alloc(&bmain->scene, ID_SCE, name);
sce->lay= sce->layact= 1;
sce = BKE_libblock_alloc(&bmain->scene, ID_SCE, name);
sce->lay = sce->layact = 1;
sce->r.mode= R_GAMMA|R_OSA|R_SHADOW|R_SSS|R_ENVMAP|R_RAYTRACE;
sce->r.cfra= 1;
sce->r.sfra= 1;
sce->r.efra= 250;
sce->r.frame_step= 1;
sce->r.xsch= 1920;
sce->r.ysch= 1080;
sce->r.xasp= 1;
sce->r.yasp= 1;
sce->r.xparts= 8;
sce->r.yparts= 8;
sce->r.mblur_samples= 1;
sce->r.filtertype= R_FILTER_MITCH;
sce->r.size= 50;
sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE;
sce->r.cfra = 1;
sce->r.sfra = 1;
sce->r.efra = 250;
sce->r.frame_step = 1;
sce->r.xsch = 1920;
sce->r.ysch = 1080;
sce->r.xasp = 1;
sce->r.yasp = 1;
sce->r.xparts = 8;
sce->r.yparts = 8;
sce->r.mblur_samples = 1;
sce->r.filtertype = R_FILTER_MITCH;
sce->r.size = 50;
sce->r.im_format.planes= R_IMF_PLANES_RGB;
sce->r.im_format.imtype= R_IMF_IMTYPE_PNG;
sce->r.im_format.quality= 90;
sce->r.im_format.planes = R_IMF_PLANES_RGB;
sce->r.im_format.imtype = R_IMF_IMTYPE_PNG;
sce->r.im_format.quality = 90;
sce->r.displaymode= R_OUTPUT_AREA;
sce->r.framapto= 100;
sce->r.images= 100;
sce->r.framelen= 1.0;
sce->r.blurfac= 0.5;
sce->r.frs_sec= 24;
sce->r.frs_sec_base= 1;
sce->r.edgeint= 10;
sce->r.displaymode = R_OUTPUT_AREA;
sce->r.framapto = 100;
sce->r.images = 100;
sce->r.framelen = 1.0;
sce->r.blurfac = 0.5;
sce->r.frs_sec = 24;
sce->r.frs_sec_base = 1;
sce->r.edgeint = 10;
sce->r.ocres = 128;
sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT;
sce->r.gauss= 1.0;
sce->r.gauss = 1.0;
/* deprecated but keep for upwards compat */
sce->r.postgamma= 1.0;
sce->r.posthue= 0.0;
sce->r.postsat= 1.0;
sce->r.bake_mode= 1; /* prevent to include render stuff here */
sce->r.bake_filter= 2;
sce->r.bake_osa= 5;
sce->r.bake_flag= R_BAKE_CLEAR;
sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT;
sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION;
sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_FILENAME|R_STAMP_RENDERTIME;
sce->r.stamp_font_id= 12;
sce->r.fg_stamp[0]= sce->r.fg_stamp[1]= sce->r.fg_stamp[2]= 0.8f;
sce->r.fg_stamp[3]= 1.0f;
sce->r.bg_stamp[0]= sce->r.bg_stamp[1]= sce->r.bg_stamp[2]= 0.0f;
sce->r.bg_stamp[3]= 0.25f;
sce->r.postgamma = 1.0;
sce->r.posthue = 0.0;
sce->r.postsat = 1.0;
sce->r.bake_mode = 1; /* prevent to include render stuff here */
sce->r.bake_filter = 2;
sce->r.bake_osa = 5;
sce->r.bake_flag = R_BAKE_CLEAR;
sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT;
sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION;
sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME;
sce->r.stamp_font_id = 12;
sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
sce->r.fg_stamp[3] = 1.0f;
sce->r.bg_stamp[0] = sce->r.bg_stamp[1] = sce->r.bg_stamp[2] = 0.0f;
sce->r.bg_stamp[3] = 0.25f;
sce->r.raytrace_options = R_RAYTRACE_USE_INSTANCES;
sce->r.seq_prev_type= OB_SOLID;
sce->r.seq_rend_type= OB_SOLID;
sce->r.seq_flag= R_SEQ_GL_PREV;
sce->r.seq_prev_type = OB_SOLID;
sce->r.seq_rend_type = OB_SOLID;
sce->r.seq_flag = R_SEQ_GL_PREV;
sce->r.threads= 1;
sce->r.threads = 1;
sce->r.simplify_subsurf= 6;
sce->r.simplify_particles= 1.0f;
sce->r.simplify_shadowsamples= 16;
sce->r.simplify_aosss= 1.0f;
sce->r.simplify_subsurf = 6;
sce->r.simplify_particles = 1.0f;
sce->r.simplify_shadowsamples = 16;
sce->r.simplify_aosss = 1.0f;
sce->r.border.xmin = 0.0f;
sce->r.border.ymin = 0.0f;
@ -409,7 +409,7 @@ Scene *BKE_scene_add(const char *name)
sce->r.border.ymax = 1.0f;
sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct");
sce->toolsettings->cornertype=1;
sce->toolsettings->cornertype = 1;
sce->toolsettings->degr = 90;
sce->toolsettings->step = 9;
sce->toolsettings->turn = 1;
@ -423,25 +423,25 @@ Scene *BKE_scene_add(const char *name)
sce->toolsettings->uvcalc_mapdir = 1;
sce->toolsettings->uvcalc_mapalign = 1;
sce->toolsettings->unwrapper = 1;
sce->toolsettings->select_thresh= 0.01f;
sce->toolsettings->select_thresh = 0.01f;
sce->toolsettings->jointrilimit = 0.8f;
sce->toolsettings->selectmode= SCE_SELECT_VERTEX;
sce->toolsettings->uv_selectmode= UV_SELECT_VERTEX;
sce->toolsettings->normalsize= 0.1;
sce->toolsettings->autokey_mode= U.autokey_mode;
sce->toolsettings->selectmode = SCE_SELECT_VERTEX;
sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX;
sce->toolsettings->normalsize = 0.1;
sce->toolsettings->autokey_mode = U.autokey_mode;
sce->toolsettings->skgen_resolution = 100;
sce->toolsettings->skgen_threshold_internal = 0.01f;
sce->toolsettings->skgen_threshold_external = 0.01f;
sce->toolsettings->skgen_angle_limit = 45.0f;
sce->toolsettings->skgen_length_ratio = 1.3f;
sce->toolsettings->skgen_length_limit = 1.5f;
sce->toolsettings->skgen_correlation_limit = 0.98f;
sce->toolsettings->skgen_symmetry_limit = 0.1f;
sce->toolsettings->skgen_threshold_internal = 0.01f;
sce->toolsettings->skgen_threshold_external = 0.01f;
sce->toolsettings->skgen_angle_limit = 45.0f;
sce->toolsettings->skgen_length_ratio = 1.3f;
sce->toolsettings->skgen_length_limit = 1.5f;
sce->toolsettings->skgen_correlation_limit = 0.98f;
sce->toolsettings->skgen_symmetry_limit = 0.1f;
sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
sce->toolsettings->skgen_postpro_passes = 1;
sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_HARMONIC|SKGEN_SUB_CORRELATION|SKGEN_STICK_TO_EMBEDDING;
sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL | SKGEN_FILTER_EXTERNAL | SKGEN_FILTER_SMART | SKGEN_HARMONIC | SKGEN_SUB_CORRELATION | SKGEN_STICK_TO_EMBEDDING;
sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
@ -455,22 +455,22 @@ Scene *BKE_scene_add(const char *name)
sce->unit.scale_length = 1.0f;
pset= &sce->toolsettings->particle;
pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER|PE_AUTO_VELOCITY;
pset->emitterdist= 0.25f;
pset->totrekey= 5;
pset->totaddkey= 5;
pset->brushtype= PE_BRUSH_NONE;
pset->draw_step= 2;
pset->fade_frames= 2;
pset->selectmode= SCE_SELECT_PATH;
for (a=0; a<PE_TOT_BRUSH; a++) {
pset->brush[a].strength= 0.5;
pset->brush[a].size= 50;
pset->brush[a].step= 10;
pset->brush[a].count= 10;
pset = &sce->toolsettings->particle;
pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER | PE_AUTO_VELOCITY;
pset->emitterdist = 0.25f;
pset->totrekey = 5;
pset->totaddkey = 5;
pset->brushtype = PE_BRUSH_NONE;
pset->draw_step = 2;
pset->fade_frames = 2;
pset->selectmode = SCE_SELECT_PATH;
for (a = 0; a < PE_TOT_BRUSH; a++) {
pset->brush[a].strength = 0.5;
pset->brush[a].size = 50;
pset->brush[a].step = 10;
pset->brush[a].count = 10;
}
pset->brush[PE_BRUSH_CUT].strength= 100;
pset->brush[PE_BRUSH_CUT].strength = 100;
sce->r.ffcodecdata.audio_mixrate = 44100;
sce->r.ffcodecdata.audio_volume = 1.0f;
@ -487,7 +487,7 @@ Scene *BKE_scene_add(const char *name)
BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic));
BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
sce->r.osa= 8;
sce->r.osa = 8;
/* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
BKE_scene_add_render_layer(sce, NULL);
@ -503,13 +503,13 @@ Scene *BKE_scene_add(const char *name)
sce->gm.dome.resbuf = 1.0f;
sce->gm.dome.tilt = 0;
sce->gm.xplay= 640;
sce->gm.yplay= 480;
sce->gm.freqplay= 60;
sce->gm.depth= 32;
sce->gm.xplay = 640;
sce->gm.yplay = 480;
sce->gm.freqplay = 60;
sce->gm.depth = 32;
sce->gm.gravity= 9.8f;
sce->gm.physicsEngine= WOPHY_BULLET;
sce->gm.gravity = 9.8f;
sce->gm.physicsEngine = WOPHY_BULLET;
sce->gm.mode = 32; //XXX ugly harcoding, still not sure we should drop mode. 32 == 1 << 5 == use_occlusion_culling
sce->gm.occlusionRes = 128;
sce->gm.ticrate = 60;
@ -520,12 +520,12 @@ Scene *BKE_scene_add(const char *name)
sce->gm.flag = GAME_DISPLAY_LISTS;
sce->gm.matmode = GAME_MAT_MULTITEX;
sce->gm.obstacleSimulation= OBSTSIMULATION_NONE;
sce->gm.obstacleSimulation = OBSTSIMULATION_NONE;
sce->gm.levelHeight = 2.f;
sce->gm.recastData.cellsize = 0.3f;
sce->gm.recastData.cellheight = 0.2f;
sce->gm.recastData.agentmaxslope = M_PI/2;
sce->gm.recastData.agentmaxslope = M_PI / 2;
sce->gm.recastData.agentmaxclimb = 0.9f;
sce->gm.recastData.agentheight = 2.0f;
sce->gm.recastData.agentradius = 0.6f;
@ -548,10 +548,10 @@ Base *BKE_scene_base_find(Scene *scene, Object *ob)
{
Base *base;
base= scene->base.first;
base = scene->base.first;
while (base) {
if (base->object == ob) return base;
base= base->next;
base = base->next;
}
return NULL;
}
@ -570,18 +570,18 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
/* can happen when switching modes in other scenes */
if (scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT))
scene->obedit= NULL;
scene->obedit = NULL;
/* deselect objects (for dataselect) */
for (ob= bmain->object.first; ob; ob= ob->id.next)
ob->flag &= ~(SELECT|OB_FROMGROUP);
for (ob = bmain->object.first; ob; ob = ob->id.next)
ob->flag &= ~(SELECT | OB_FROMGROUP);
/* group flags again */
for (group= bmain->group.first; group; group= group->id.next) {
go= group->gobject.first;
for (group = bmain->group.first; group; group = group->id.next) {
go = group->gobject.first;
while (go) {
if (go->ob) go->ob->flag |= OB_FROMGROUP;
go= go->next;
go = go->next;
}
}
@ -589,25 +589,25 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
DAG_scene_sort(bmain, scene);
/* ensure dags are built for sets */
for (sce= scene->set; sce; sce= sce->set)
if (sce->theDag==NULL)
for (sce = scene->set; sce; sce = sce->set)
if (sce->theDag == NULL)
DAG_scene_sort(bmain, sce);
/* copy layers and flags from bases to objects */
for (base= scene->base.first; base; base= base->next) {
ob= base->object;
ob->lay= base->lay;
for (base = scene->base.first; base; base = base->next) {
ob = base->object;
ob->lay = base->lay;
/* group patch... */
base->flag &= ~(OB_FROMGROUP);
flag= ob->flag & (OB_FROMGROUP);
flag = ob->flag & (OB_FROMGROUP);
base->flag |= flag;
/* not too nice... for recovering objects with lost data */
//if (ob->pose==NULL) base->flag &= ~OB_POSEMODE;
ob->flag= base->flag;
ob->flag = base->flag;
ob->ctime= -1234567.0; /* force ipo to be calculated later */
ob->ctime = -1234567.0; /* force ipo to be calculated later */
}
/* no full animation update, this to enable render code to work (render code calls own animation updates) */
}
@ -632,9 +632,9 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
bScreen *sc;
/* check all sets */
for (sce1= bmain->scene.first; sce1; sce1= sce1->id.next)
for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next)
if (sce1->set == sce)
sce1->set= NULL;
sce1->set = NULL;
/* check all sequences */
clear_scene_in_allseqs(bmain, sce);
@ -643,9 +643,9 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
clear_scene_in_nodes(bmain, sce);
/* al screens */
for (sc= bmain->screen.first; sc; sc= sc->id.next)
for (sc = bmain->screen.first; sc; sc = sc->id.next)
if (sc->scene == sce)
sc->scene= newsce;
sc->scene = newsce;
BKE_libblock_free(&bmain->scene, sce);
}
@ -655,15 +655,15 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
*/
int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
{
static ListBase *duplilist= NULL;
static ListBase *duplilist = NULL;
static DupliObject *dupob;
static int fase= F_START, in_next_object= 0;
int run_again=1;
static int fase = F_START, in_next_object = 0;
int run_again = 1;
/* init */
if (val==0) {
fase= F_START;
dupob= NULL;
if (val == 0) {
fase = F_START;
dupob = NULL;
/* XXX particle systems with metas+dupligroups call this recursively */
/* see bug #18725 */
@ -674,44 +674,44 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
}
}
else {
in_next_object= 1;
in_next_object = 1;
/* run_again is set when a duplilist has been ended */
while (run_again) {
run_again= 0;
run_again = 0;
/* the first base */
if (fase==F_START) {
*base= (*scene)->base.first;
if (fase == F_START) {
*base = (*scene)->base.first;
if (*base) {
*ob= (*base)->object;
fase= F_SCENE;
*ob = (*base)->object;
fase = F_SCENE;
}
else {
/* exception: empty scene */
while ((*scene)->set) {
(*scene)= (*scene)->set;
(*scene) = (*scene)->set;
if ((*scene)->base.first) {
*base= (*scene)->base.first;
*ob= (*base)->object;
fase= F_SCENE;
*base = (*scene)->base.first;
*ob = (*base)->object;
fase = F_SCENE;
break;
}
}
}
}
else {
if (*base && fase!=F_DUPLI) {
*base= (*base)->next;
if (*base) *ob= (*base)->object;
if (*base && fase != F_DUPLI) {
*base = (*base)->next;
if (*base) *ob = (*base)->object;
else {
if (fase==F_SCENE) {
if (fase == F_SCENE) {
/* (*scene) is finished, now do the set */
while ((*scene)->set) {
(*scene)= (*scene)->set;
(*scene) = (*scene)->set;
if ((*scene)->base.first) {
*base= (*scene)->base.first;
*ob= (*base)->object;
*base = (*scene)->base.first;
*ob = (*base)->object;
break;
}
}
@ -720,17 +720,17 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
}
}
if (*base == NULL) fase= F_START;
if (*base == NULL) fase = F_START;
else {
if (fase!=F_DUPLI) {
if (fase != F_DUPLI) {
if ( (*base)->object->transflag & OB_DUPLI) {
/* groups cannot be duplicated for mballs yet,
* this enters eternal loop because of
* makeDispListMBall getting called inside of group_duplilist */
if ((*base)->object->dup_group == NULL) {
duplilist= object_duplilist((*scene), (*base)->object);
duplilist = object_duplilist((*scene), (*base)->object);
dupob= duplilist->first;
dupob = duplilist->first;
if (!dupob)
free_object_duplilist(duplilist);
@ -743,22 +743,22 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
copy_m4_m4(dupob->ob->obmat, dupob->mat);
(*base)->flag |= OB_FROMDUPLI;
*ob= dupob->ob;
fase= F_DUPLI;
*ob = dupob->ob;
fase = F_DUPLI;
dupob= dupob->next;
dupob = dupob->next;
}
else if (fase==F_DUPLI) {
fase= F_SCENE;
else if (fase == F_DUPLI) {
fase = F_SCENE;
(*base)->flag &= ~OB_FROMDUPLI;
for (dupob= duplilist->first; dupob; dupob= dupob->next) {
for (dupob = duplilist->first; dupob; dupob = dupob->next) {
copy_m4_m4(dupob->ob->obmat, dupob->omat);
}
free_object_duplilist(duplilist);
duplilist= NULL;
run_again= 1;
duplilist = NULL;
run_again = 1;
}
}
}
@ -766,12 +766,12 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
#if 0
if (ob && *ob) {
printf("Scene: '%s', '%s'\n", (*scene)->id.name+2, (*ob)->id.name+2);
printf("Scene: '%s', '%s'\n", (*scene)->id.name + 2, (*ob)->id.name + 2);
}
#endif
/* reset recursion test */
in_next_object= 0;
in_next_object = 0;
return fase;
}
@ -780,8 +780,8 @@ Object *BKE_scene_camera_find(Scene *sc)
{
Base *base;
for (base= sc->base.first; base; base= base->next)
if (base->object->type==OB_CAMERA)
for (base = sc->base.first; base; base = base->next)
if (base->object->type == OB_CAMERA)
return base->object;
return NULL;
@ -793,12 +793,12 @@ Object *BKE_scene_camera_switch_find(Scene *scene)
TimeMarker *m;
int cfra = scene->r.cfra;
int frame = -(MAXFRAME + 1);
Object *camera= NULL;
Object *camera = NULL;
for (m= scene->markers.first; m; m= m->next) {
if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER)==0 && (m->frame <= cfra) && (m->frame > frame)) {
camera= m->camera;
frame= m->frame;
for (m = scene->markers.first; m; m = m->next) {
if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0 && (m->frame <= cfra) && (m->frame > frame)) {
camera = m->camera;
frame = m->frame;
if (frame == cfra)
break;
@ -812,9 +812,9 @@ Object *BKE_scene_camera_switch_find(Scene *scene)
int BKE_scene_camera_switch_update(Scene *scene)
{
#ifdef DURIAN_CAMERA_SWITCH
Object *camera= BKE_scene_camera_switch_find(scene);
Object *camera = BKE_scene_camera_switch_find(scene);
if (camera) {
scene->camera= camera;
scene->camera = camera;
return 1;
}
#else
@ -825,18 +825,18 @@ int BKE_scene_camera_switch_update(Scene *scene)
char *BKE_scene_find_marker_name(Scene *scene, int frame)
{
ListBase *markers= &scene->markers;
ListBase *markers = &scene->markers;
TimeMarker *m1, *m2;
/* search through markers for match */
for (m1=markers->first, m2=markers->last; m1 && m2; m1=m1->next, m2=m2->prev) {
if (m1->frame==frame)
for (m1 = markers->first, m2 = markers->last; m1 && m2; m1 = m1->next, m2 = m2->prev) {
if (m1->frame == frame)
return m1->name;
if (m1 == m2)
break;
if (m2->frame==frame)
if (m2->frame == frame)
return m2->name;
}
@ -848,13 +848,13 @@ char *BKE_scene_find_marker_name(Scene *scene, int frame)
char *BKE_scene_find_last_marker_name(Scene *scene, int frame)
{
TimeMarker *marker, *best_marker = NULL;
int best_frame = -MAXFRAME*2;
for (marker= scene->markers.first; marker; marker= marker->next) {
if (marker->frame==frame) {
int best_frame = -MAXFRAME * 2;
for (marker = scene->markers.first; marker; marker = marker->next) {
if (marker->frame == frame) {
return marker->name;
}
if ( marker->frame > best_frame && marker->frame < frame) {
if (marker->frame > best_frame && marker->frame < frame) {
best_marker = marker;
best_frame = marker->frame;
}
@ -866,12 +866,12 @@ char *BKE_scene_find_last_marker_name(Scene *scene, int frame)
Base *BKE_scene_base_add(Scene *sce, Object *ob)
{
Base *b= MEM_callocN(sizeof(*b), "BKE_scene_base_add");
Base *b = MEM_callocN(sizeof(*b), "BKE_scene_base_add");
BLI_addhead(&sce->base, b);
b->object= ob;
b->flag= ob->flag;
b->lay= ob->lay;
b->object = ob;
b->flag = ob->flag;
b->lay = ob->lay;
return b;
}
@ -880,18 +880,18 @@ void BKE_scene_base_deselect_all(Scene *sce)
{
Base *b;
for (b= sce->base.first; b; b= b->next) {
b->flag&= ~SELECT;
b->object->flag= b->flag;
for (b = sce->base.first; b; b = b->next) {
b->flag &= ~SELECT;
b->object->flag = b->flag;
}
}
void BKE_scene_base_select(Scene *sce, Base *selbase)
{
selbase->flag |= SELECT;
selbase->object->flag= selbase->flag;
selbase->object->flag = selbase->flag;
sce->basact= selbase;
sce->basact = selbase;
}
/* checks for cycle, returns 1 if it's all OK */
@ -900,17 +900,17 @@ int BKE_scene_validate_setscene(Main *bmain, Scene *sce)
Scene *scene;
int a, totscene;
if (sce->set==NULL) return 1;
if (sce->set == NULL) return 1;
totscene= 0;
for (scene= bmain->scene.first; scene; scene= scene->id.next)
totscene = 0;
for (scene = bmain->scene.first; scene; scene = scene->id.next)
totscene++;
for (a=0, scene=sce; scene->set; scene=scene->set, a++) {
for (a = 0, scene = sce; scene->set; scene = scene->set, a++) {
/* more iterations than scenes means we have a cycle */
if (a > totscene) {
/* the tested scene gets zero'ed, that's typically current scene */
sce->set= NULL;
sce->set = NULL;
return 0;
}
}
@ -937,7 +937,7 @@ float BKE_scene_frame_get_from_ctime(Scene *scene, const float frame)
}
/* drivers support/hacks
* - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render
* - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render
* - these are always run since the depsgraph can't handle non-object data
* - these happen after objects are all done so that we can read in their final transform values,
* though this means that objects can't refer to scene info for guidance...
@ -955,7 +955,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
// TODO: what about world textures? but then those have nodes too...
if (scene->world) {
ID *wid = (ID *)scene->world;
AnimData *adt= BKE_animdata_from_id(wid);
AnimData *adt = BKE_animdata_from_id(wid);
if (adt && adt->drivers.first)
BKE_animsys_evaluate_animdata(scene, wid, adt, ctime, ADT_RECALC_DRIVERS);
@ -964,7 +964,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
/* nodes */
if (scene->nodetree) {
ID *nid = (ID *)scene->nodetree;
AnimData *adt= BKE_animdata_from_id(nid);
AnimData *adt = BKE_animdata_from_id(nid);
if (adt && adt->drivers.first)
BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, ADT_RECALC_DRIVERS);
@ -976,7 +976,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen
Base *base;
scene->customdata_mask= scene_parent->customdata_mask;
scene->customdata_mask = scene_parent->customdata_mask;
/* sets first, we allow per definition current scene to have
* dependencies on sets, but not the other way around. */
@ -984,8 +984,8 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen
scene_update_tagged_recursive(bmain, scene->set, scene_parent);
/* scene objects */
for (base= scene->base.first; base; base= base->next) {
Object *ob= base->object;
for (base = scene->base.first; base; base = base->next) {
Object *ob = base->object;
BKE_object_handle_update(scene_parent, ob);
@ -993,7 +993,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen
group_handle_recalc_and_update(scene_parent, ob, ob->dup_group);
/* always update layer, so that animating layers works */
base->lay= ob->lay;
base->lay = ob->lay;
}
/* scene drivers... */
@ -1012,7 +1012,7 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene)
/* flush recalc flags to dependencies */
DAG_ids_flush_tagged(bmain);
scene->physics_settings.quick_cache_step= 0;
scene->physics_settings.quick_cache_step = 0;
/* update all objects: drivers, matrices, displists, etc. flags set
* by depgraph or manual, no layer check here, gets correct flushed
@ -1023,7 +1023,7 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene)
/* extra call here to recalc scene animation (for sequencer) */
{
AnimData *adt= BKE_animdata_from_id(&scene->id);
AnimData *adt = BKE_animdata_from_id(&scene->id);
float ctime = BKE_scene_frame_get(scene);
if (adt && (adt->recalc & ADT_RECALC_ANIM))
@ -1057,8 +1057,8 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
/* clear animation overrides */
// XXX TODO...
for (sce_iter= sce; sce_iter; sce_iter= sce_iter->set) {
if (sce_iter->theDag==NULL)
for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) {
if (sce_iter->theDag == NULL)
DAG_scene_sort(bmain, sce_iter);
}
@ -1099,24 +1099,24 @@ SceneRenderLayer *BKE_scene_add_render_layer(Scene *sce, const char *name)
SceneRenderLayer *srl;
if (!name)
name= "RenderLayer";
name = "RenderLayer";
srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer");
srl = MEM_callocN(sizeof(SceneRenderLayer), "new render layer");
BLI_strncpy(srl->name, name, sizeof(srl->name));
BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), sizeof(srl->name));
BLI_addtail(&sce->r.layers, srl);
/* note, this is also in render, pipeline.c, to make layer when scenedata doesnt have it */
srl->lay= (1<<20) -1;
srl->layflag= 0x7FFF; /* solid ztra halo edge strand */
srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z;
srl->lay = (1 << 20) - 1;
srl->layflag = 0x7FFF; /* solid ztra halo edge strand */
srl->passflag = SCE_PASS_COMBINED | SCE_PASS_Z;
return srl;
}
int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl)
{
const int act= BLI_findindex(&scene->r.layers, srl);
const int act = BLI_findindex(&scene->r.layers, srl);
Scene *sce;
if (act == -1) {
@ -1132,16 +1132,16 @@ int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *s
BLI_remlink(&scene->r.layers, srl);
MEM_freeN(srl);
scene->r.actlay= 0;
scene->r.actlay = 0;
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
for (node = sce->nodetree->nodes.first; node; node = node->next) {
if (node->type==CMP_NODE_R_LAYERS && (Scene*)node->id==scene) {
if (node->custom1==act)
node->custom1= 0;
else if (node->custom1>act)
if (node->type == CMP_NODE_R_LAYERS && (Scene *)node->id == scene) {
if (node->custom1 == act)
node->custom1 = 0;
else if (node->custom1 > act)
node->custom1--;
}
}
@ -1164,7 +1164,7 @@ int get_render_subsurf_level(RenderData *r, int lvl)
int get_render_child_particle_number(RenderData *r, int num)
{
if (r->mode & R_SIMPLIFY)
return (int)(r->simplify_particles*num);
return (int)(r->simplify_particles * num);
else
return num;
}
@ -1180,7 +1180,7 @@ int get_render_shadow_samples(RenderData *r, int samples)
float get_render_aosss_error(RenderData *r, float error)
{
if (r->mode & R_SIMPLIFY)
return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error;
return ((1.0f - r->simplify_aosss) * 10.0f + 1.0f) * error;
else
return error;
}
@ -1192,14 +1192,14 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base)
/* common case, step to the next */
return base->next;
}
else if (base==NULL && (*sce_iter)->base.first) {
else if (base == NULL && (*sce_iter)->base.first) {
/* first time looping, return the scenes first base */
return (Base *)(*sce_iter)->base.first;
}
else {
/* reached the end, get the next base in the set */
while ((*sce_iter= (*sce_iter)->set)) {
base= (Base *)(*sce_iter)->base.first;
while ((*sce_iter = (*sce_iter)->set)) {
base = (Base *)(*sce_iter)->base.first;
if (base) {
return base;
}
@ -1211,26 +1211,26 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base)
int BKE_scene_use_new_shading_nodes(Scene *scene)
{
RenderEngineType *type= RE_engines_find(scene->r.engine);
RenderEngineType *type = RE_engines_find(scene->r.engine);
return (type && type->flag & RE_USE_SHADING_NODES);
}
void BKE_scene_base_flag_to_objects(struct Scene *scene)
{
Base *base= scene->base.first;
Base *base = scene->base.first;
while (base) {
base->object->flag= base->flag;
base= base->next;
base->object->flag = base->flag;
base = base->next;
}
}
void BKE_scene_base_flag_from_objects(struct Scene *scene)
{
Base *base= scene->base.first;
Base *base = scene->base.first;
while (base) {
base->flag= base->object->flag;
base= base->next;
base->flag = base->object->flag;
base = base->next;
}
}

View File

@ -51,7 +51,7 @@
/* ************ Spacetype/regiontype handling ************** */
/* keep global; this has to be accessible outside of windowmanager */
static ListBase spacetypes= {NULL, NULL};
static ListBase spacetypes = {NULL, NULL};
/* not SpaceType itself */
static void spacetype_free(SpaceType *st)
@ -60,14 +60,14 @@ static void spacetype_free(SpaceType *st)
PanelType *pt;
HeaderType *ht;
for (art= st->regiontypes.first; art; art= art->next) {
for (art = st->regiontypes.first; art; art = art->next) {
BLI_freelistN(&art->drawcalls);
for (pt= art->paneltypes.first; pt; pt= pt->next)
for (pt = art->paneltypes.first; pt; pt = pt->next)
if (pt->ext.free)
pt->ext.free(pt->ext.data);
for (ht= art->headertypes.first; ht; ht= ht->next)
for (ht = art->headertypes.first; ht; ht = ht->next)
if (ht->ext.free)
ht->ext.free(ht->ext.data);
@ -84,7 +84,7 @@ void BKE_spacetypes_free(void)
{
SpaceType *st;
for (st= spacetypes.first; st; st= st->next) {
for (st = spacetypes.first; st; st = st->next) {
spacetype_free(st);
}
@ -95,8 +95,8 @@ SpaceType *BKE_spacetype_from_id(int spaceid)
{
SpaceType *st;
for (st= spacetypes.first; st; st= st->next) {
if (st->spaceid==spaceid)
for (st = spacetypes.first; st; st = st->next) {
if (st->spaceid == spaceid)
return st;
}
return NULL;
@ -106,8 +106,8 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
{
ARegionType *art;
for (art= st->regiontypes.first; art; art= art->next)
if (art->regionid==regionid)
for (art = st->regiontypes.first; art; art = art->next)
if (art->regionid == regionid)
return art;
printf("Error, region type missing in - name:\"%s\", id:%d\n", st->name, st->spaceid);
@ -125,7 +125,7 @@ void BKE_spacetype_register(SpaceType *st)
SpaceType *stype;
/* sanity check */
stype= BKE_spacetype_from_id(st->spaceid);
stype = BKE_spacetype_from_id(st->spaceid);
if (stype) {
printf("error: redefinition of spacetype %s\n", stype->name);
spacetype_free(stype);
@ -142,11 +142,11 @@ void BKE_spacedata_freelist(ListBase *lb)
SpaceLink *sl;
ARegion *ar;
for (sl= lb->first; sl; sl= sl->next) {
SpaceType *st= BKE_spacetype_from_id(sl->spacetype);
for (sl = lb->first; sl; sl = sl->next) {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
/* free regions for pushed spaces */
for (ar=sl->regionbase.first; ar; ar=ar->next)
for (ar = sl->regionbase.first; ar; ar = ar->next)
BKE_area_region_free(st, ar);
BLI_freelistN(&sl->regionbase);
@ -160,41 +160,41 @@ void BKE_spacedata_freelist(ListBase *lb)
ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
{
ARegion *newar= MEM_dupallocN(ar);
ARegion *newar = MEM_dupallocN(ar);
Panel *pa, *newpa, *patab;
newar->prev= newar->next= NULL;
newar->handlers.first= newar->handlers.last= NULL;
newar->uiblocks.first= newar->uiblocks.last= NULL;
newar->swinid= 0;
newar->prev = newar->next = NULL;
newar->handlers.first = newar->handlers.last = NULL;
newar->uiblocks.first = newar->uiblocks.last = NULL;
newar->swinid = 0;
/* use optional regiondata callback */
if (ar->regiondata) {
ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype);
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
if (art && art->duplicate)
newar->regiondata= art->duplicate(ar->regiondata);
newar->regiondata = art->duplicate(ar->regiondata);
else
newar->regiondata= MEM_dupallocN(ar->regiondata);
newar->regiondata = MEM_dupallocN(ar->regiondata);
}
if (ar->v2d.tab_offset)
newar->v2d.tab_offset= MEM_dupallocN(ar->v2d.tab_offset);
newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset);
newar->panels.first= newar->panels.last= NULL;
newar->panels.first = newar->panels.last = NULL;
BLI_duplicatelist(&newar->panels, &ar->panels);
/* copy panel pointers */
for (newpa= newar->panels.first; newpa; newpa= newpa->next) {
patab= newar->panels.first;
pa= ar->panels.first;
for (newpa = newar->panels.first; newpa; newpa = newpa->next) {
patab = newar->panels.first;
pa = ar->panels.first;
while (patab) {
if (newpa->paneltab == pa) {
newpa->paneltab = patab;
break;
}
patab= patab->next;
pa= pa->next;
patab = patab->next;
pa = pa->next;
}
}
@ -208,10 +208,10 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
ARegion *ar;
/* to be sure */
lb1->first= lb1->last= NULL;
lb1->first = lb1->last = NULL;
for (ar= lb2->first; ar; ar= ar->next) {
ARegion *arnew= BKE_area_region_copy(st, ar);
for (ar = lb2->first; ar; ar = ar->next) {
ARegion *arnew = BKE_area_region_copy(st, ar);
BLI_addtail(lb1, arnew);
}
}
@ -222,13 +222,13 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
{
SpaceLink *sl;
lb1->first= lb1->last= NULL; /* to be sure */
lb1->first = lb1->last = NULL; /* to be sure */
for (sl= lb2->first; sl; sl= sl->next) {
SpaceType *st= BKE_spacetype_from_id(sl->spacetype);
for (sl = lb2->first; sl; sl = sl->next) {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
if (st && st->duplicate) {
SpaceLink *slnew= st->duplicate(sl);
SpaceLink *slnew = st->duplicate(sl);
BLI_addtail(lb1, slnew);
@ -244,14 +244,14 @@ void BKE_spacedata_draw_locks(int set)
{
SpaceType *st;
for (st= spacetypes.first; st; st= st->next) {
for (st = spacetypes.first; st; st = st->next) {
ARegionType *art;
for (art= st->regiontypes.first; art; art= art->next) {
for (art = st->regiontypes.first; art; art = art->next) {
if (set)
art->do_lock= art->lock;
art->do_lock = art->lock;
else
art->do_lock= 0;
art->do_lock = 0;
}
}
}
@ -261,7 +261,7 @@ void BKE_spacedata_draw_locks(int set)
void BKE_area_region_free(SpaceType *st, ARegion *ar)
{
if (st) {
ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype);
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
if (art && art->free)
art->free(ar);
@ -274,7 +274,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
if (ar->v2d.tab_offset) {
MEM_freeN(ar->v2d.tab_offset);
ar->v2d.tab_offset= NULL;
ar->v2d.tab_offset = NULL;
}
BLI_freelistN(&ar->panels);
@ -283,10 +283,10 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
/* not area itself */
void BKE_screen_area_free(ScrArea *sa)
{
SpaceType *st= BKE_spacetype_from_id(sa->spacetype);
SpaceType *st = BKE_spacetype_from_id(sa->spacetype);
ARegion *ar;
for (ar=sa->regionbase.first; ar; ar=ar->next)
for (ar = sa->regionbase.first; ar; ar = ar->next)
BKE_area_region_free(st, ar);
BLI_freelistN(&sa->regionbase);
@ -302,13 +302,13 @@ void BKE_screen_free(bScreen *sc)
ScrArea *sa, *san;
ARegion *ar;
for (ar=sc->regionbase.first; ar; ar=ar->next)
for (ar = sc->regionbase.first; ar; ar = ar->next)
BKE_area_region_free(NULL, ar);
BLI_freelistN(&sc->regionbase);
for (sa= sc->areabase.first; sa; sa= san) {
san= sa->next;
for (sa = sc->areabase.first; sa; sa = san) {
san = sa->next;
BKE_screen_area_free(sa);
}
@ -321,12 +321,12 @@ void BKE_screen_free(bScreen *sc)
unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene)
{
ScrArea *sa;
unsigned int layer= 0;
unsigned int layer = 0;
if (screen) {
/* get all used view3d layers */
for (sa= screen->areabase.first; sa; sa= sa->next)
if (sa->spacetype==SPACE_VIEW3D)
for (sa = screen->areabase.first; sa; sa = sa->next)
if (sa->spacetype == SPACE_VIEW3D)
layer |= ((View3D *)sa->spacedata.first)->lay;
}
@ -344,7 +344,7 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
if (sa) {
ARegion *ar;
for (ar=sa->regionbase.first; ar; ar= ar->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == type)
return ar;
}
@ -357,16 +357,16 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
* -1 for any type */
struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min)
{
ScrArea *sa, *big= NULL;
int size, maxsize= 0;
ScrArea *sa, *big = NULL;
int size, maxsize = 0;
for (sa= sc->areabase.first; sa; sa= sa->next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
if ((spacetype == -1) || sa->spacetype == spacetype) {
if (min <= sa->winx && min <= sa->winy) {
size= sa->winx*sa->winy;
size = sa->winx * sa->winy;
if (size > maxsize) {
maxsize= size;
big= sa;
maxsize = size;
big = sa;
}
}
}
@ -379,26 +379,26 @@ void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene)
{
int bit;
if (v3d->scenelock && v3d->localvd==NULL) {
v3d->lay= scene->lay;
v3d->camera= scene->camera;
if (v3d->scenelock && v3d->localvd == NULL) {
v3d->lay = scene->lay;
v3d->camera = scene->camera;
if (v3d->camera==NULL) {
if (v3d->camera == NULL) {
ARegion *ar;
for (ar=v3d->regionbase.first; ar; ar= ar->next) {
for (ar = v3d->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d= ar->regiondata;
if (rv3d->persp==RV3D_CAMOB)
rv3d->persp= RV3D_PERSP;
RegionView3D *rv3d = ar->regiondata;
if (rv3d->persp == RV3D_CAMOB)
rv3d->persp = RV3D_PERSP;
}
}
}
if ((v3d->lay & v3d->layact) == 0) {
for (bit= 0; bit<32; bit++) {
if (v3d->lay & (1<<bit)) {
v3d->layact= 1<<bit;
for (bit = 0; bit < 32; bit++) {
if (v3d->lay & (1 << bit)) {
v3d->layact = 1 << bit;
break;
}
}
@ -410,11 +410,11 @@ void BKE_screen_view3d_scene_sync(bScreen *sc)
{
/* are there cameras in the views that are not in the scene? */
ScrArea *sa;
for (sa= sc->areabase.first; sa; sa= sa->next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl= sa->spacedata.first; sl; sl= sl->next) {
if (sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D*) sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *) sl;
BKE_screen_view3d_sync(v3d, sc->scene);
}
}
@ -428,14 +428,14 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
SpaceLink *sl;
/* from scene copy to the other views */
for (sc=screen_lb->first; sc; sc=sc->id.next) {
if (sc->scene!=scene)
for (sc = screen_lb->first; sc; sc = sc->id.next) {
if (sc->scene != scene)
continue;
for (sa=sc->areabase.first; sa; sa=sa->next)
for (sl=sa->spacedata.first; sl; sl=sl->next)
if (sl->spacetype==SPACE_VIEW3D)
BKE_screen_view3d_sync((View3D*)sl, scene);
for (sa = sc->areabase.first; sa; sa = sa->next)
for (sl = sa->spacedata.first; sl; sl = sl->next)
if (sl->spacetype == SPACE_VIEW3D)
BKE_screen_view3d_sync((View3D *)sl, scene);
}
}
@ -449,7 +449,7 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
*/
float BKE_screen_view3d_zoom_to_fac(float camzoom)
{
return powf(((float)M_SQRT2 + camzoom/50.0f), 2.0f) / 4.0f;
return powf(((float)M_SQRT2 + camzoom / 50.0f), 2.0f) / 4.0f;
}
float BKE_screen_view3d_zoom_from_fac(float zoomfac)

View File

@ -63,16 +63,16 @@
// evil quiet NaN definition
static const int NAN_INT = 0x7FC00000;
#define NAN_FLT *((float*)(&NAN_INT))
#define NAN_FLT *((float *)(&NAN_INT))
#ifdef WITH_AUDASPACE
// evil global ;-)
static int sound_cfra;
#endif
struct bSound* sound_new_file(struct Main *bmain, const char *filename)
struct bSound *sound_new_file(struct Main *bmain, const char *filename)
{
bSound* sound = NULL;
bSound *sound = NULL;
char str[FILE_MAX];
char *path;
@ -86,10 +86,10 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
BLI_path_abs(str, path);
len = strlen(filename);
while (len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
while (len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\')
len--;
sound = BKE_libblock_alloc(&bmain->sound, ID_SO, filename+len);
sound = BKE_libblock_alloc(&bmain->sound, ID_SO, filename + len);
BLI_strncpy(sound->name, filename, FILE_MAX);
// XXX unused currently sound->type = SOUND_TYPE_FILE;
@ -103,7 +103,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
return sound;
}
void BKE_sound_free(struct bSound* sound)
void BKE_sound_free(struct bSound *sound)
{
if (sound->packedfile) {
freePackedFile(sound->packedfile);
@ -131,10 +131,10 @@ void BKE_sound_free(struct bSound* sound)
static int force_device = -1;
#ifdef WITH_JACK
static void sound_sync_callback(void* data, int mode, float time)
static void sound_sync_callback(void *data, int mode, float time)
{
struct Main* bmain = (struct Main*)data;
struct Scene* scene;
struct Main *bmain = (struct Main *)data;
struct Scene *scene;
scene = bmain->scene.first;
while (scene) {
@ -223,11 +223,11 @@ void sound_exit(void)
// XXX unused currently
#if 0
struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source)
struct bSound *sound_new_buffer(struct Main *bmain, struct bSound *source)
{
bSound* sound = NULL;
bSound *sound = NULL;
char name[MAX_ID_NAME+5];
char name[MAX_ID_NAME + 5];
strcpy(name, "buf_");
strcpy(name + 4, source->id.name);
@ -247,11 +247,11 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source)
return sound;
}
struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end)
struct bSound *sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end)
{
bSound* sound = NULL;
bSound *sound = NULL;
char name[MAX_ID_NAME+5];
char name[MAX_ID_NAME + 5];
strcpy(name, "lim_");
strcpy(name + 4, source->id.name);
@ -274,7 +274,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa
}
#endif
void sound_delete(struct Main *bmain, struct bSound* sound)
void sound_delete(struct Main *bmain, struct bSound *sound)
{
if (sound) {
BKE_sound_free(sound);
@ -283,7 +283,7 @@ void sound_delete(struct Main *bmain, struct bSound* sound)
}
}
void sound_cache(struct bSound* sound)
void sound_cache(struct bSound *sound)
{
sound->flags |= SOUND_FLAGS_CACHING;
if (sound->cache)
@ -296,13 +296,13 @@ void sound_cache(struct bSound* sound)
sound->playback_handle = sound->handle;
}
void sound_cache_notifying(struct Main* main, struct bSound* sound)
void sound_cache_notifying(struct Main *main, struct bSound *sound)
{
sound_cache(sound);
sound_update_sequencer(main, sound);
}
void sound_delete_cache(struct bSound* sound)
void sound_delete_cache(struct bSound *sound)
{
sound->flags &= ~SOUND_FLAGS_CACHING;
if (sound->cache) {
@ -312,7 +312,7 @@ void sound_delete_cache(struct bSound* sound)
}
}
void sound_load(struct Main *bmain, struct bSound* sound)
void sound_load(struct Main *bmain, struct bSound *sound)
{
if (sound) {
if (sound->cache) {
@ -332,13 +332,13 @@ void sound_load(struct Main *bmain, struct bSound* sound)
#if 0
switch (sound->type)
{
case SOUND_TYPE_FILE:
case SOUND_TYPE_FILE:
#endif
{
char fullpath[FILE_MAX];
/* load sound */
PackedFile* pf = sound->packedfile;
PackedFile *pf = sound->packedfile;
/* don't modify soundact->sound->name, only change a copy */
BLI_strncpy(fullpath, sound->name, sizeof(fullpath));
@ -346,7 +346,7 @@ void sound_load(struct Main *bmain, struct bSound* sound)
/* but we need a packed file then */
if (pf)
sound->handle = AUD_loadBuffer((unsigned char*) pf->data, pf->size);
sound->handle = AUD_loadBuffer((unsigned char *) pf->data, pf->size);
/* or else load it from disk */
else
sound->handle = AUD_load(fullpath);
@ -366,7 +366,7 @@ void sound_load(struct Main *bmain, struct bSound* sound)
}
#endif
if (sound->flags & SOUND_FLAGS_MONO) {
void* handle = AUD_monoSound(sound->handle);
void *handle = AUD_monoSound(sound->handle);
AUD_unload(sound->handle);
sound->handle = handle;
}
@ -384,7 +384,7 @@ void sound_load(struct Main *bmain, struct bSound* sound)
}
}
AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
AUD_Device *sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
{
return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS);
}
@ -393,7 +393,7 @@ void sound_create_scene(struct Scene *scene)
{
scene->sound_scene = AUD_createSequencer(FPS, scene->audio.flag & AUDIO_MUTE);
AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound,
scene->audio.doppler_factor, scene->audio.distance_model);
scene->audio.doppler_factor, scene->audio.distance_model);
scene->sound_scene_handle = NULL;
scene->sound_scrub_handle = NULL;
scene->speaker_handles = NULL;
@ -426,26 +426,26 @@ void sound_update_fps(struct Scene *scene)
void sound_update_scene_listener(struct Scene *scene)
{
AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound,
scene->audio.doppler_factor, scene->audio.distance_model);
scene->audio.doppler_factor, scene->audio.distance_model);
}
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
{
if (scene != sequence->scene)
return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS);
return NULL;
}
void* sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence)
void *sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
{
return sound_scene_add_scene_sound(scene, sequence,
sequence->startdisp, sequence->enddisp,
sequence->startofs + sequence->anim_startofs);
}
void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
void *sound_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
{
void* handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
void *handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0);
AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0);
AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0);
@ -453,29 +453,29 @@ void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int
return handle;
}
void* sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence)
void *sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
{
return sound_add_scene_sound(scene, sequence,
sequence->startdisp, sequence->enddisp,
sequence->startofs + sequence->anim_startofs);
}
void sound_remove_scene_sound(struct Scene *scene, void* handle)
void sound_remove_scene_sound(struct Scene *scene, void *handle)
{
AUD_removeSequence(scene->sound_scene, handle);
}
void sound_mute_scene_sound(void* handle, char mute)
void sound_mute_scene_sound(void *handle, char mute)
{
AUD_muteSequence(handle, mute);
}
void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip)
void sound_move_scene_sound(struct Scene *scene, void *handle, int startframe, int endframe, int frameskip)
{
AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS);
}
void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence)
void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
{
if (sequence->scene_sound) {
sound_move_scene_sound(scene, sequence->scene_sound,
@ -484,7 +484,7 @@ void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence* seque
}
}
void sound_update_scene_sound(void* handle, struct bSound* sound)
void sound_update_scene_sound(void *handle, struct bSound *sound)
{
AUD_updateSequenceSound(handle, sound->playback_handle);
}
@ -499,24 +499,24 @@ void sound_set_scene_volume(struct Scene *scene, float volume)
AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume, (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0);
}
void sound_set_scene_sound_volume(void* handle, float volume, char animated)
void sound_set_scene_sound_volume(void *handle, float volume, char animated)
{
AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, sound_cfra, &volume, animated);
}
void sound_set_scene_sound_pitch(void* handle, float pitch, char animated)
void sound_set_scene_sound_pitch(void *handle, float pitch, char animated)
{
AUD_setSequenceAnimData(handle, AUD_AP_PITCH, sound_cfra, &pitch, animated);
}
void sound_set_scene_sound_pan(void* handle, float pan, char animated)
void sound_set_scene_sound_pan(void *handle, float pan, char animated)
{
AUD_setSequenceAnimData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated);
}
void sound_update_sequencer(struct Main* main, struct bSound* sound)
void sound_update_sequencer(struct Main *main, struct bSound *sound)
{
struct Scene* scene;
struct Scene *scene;
for (scene = main->scene.first; scene; scene = scene->id.next) {
seq_update_sound(scene, sound);
@ -592,7 +592,7 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
}
animation_playing = 0;
for (screen=bmain->screen.first; screen; screen=screen->id.next) {
for (screen = bmain->screen.first; screen; screen = screen->id.next) {
if (screen->animtimer) {
animation_playing = 1;
}
@ -645,24 +645,24 @@ int sound_scene_playing(struct Scene *scene)
return -1;
}
void sound_free_waveform(struct bSound* sound)
void sound_free_waveform(struct bSound *sound)
{
if (sound->waveform) {
MEM_freeN(((SoundWaveform*)sound->waveform)->data);
MEM_freeN(((SoundWaveform *)sound->waveform)->data);
MEM_freeN(sound->waveform);
}
sound->waveform = NULL;
}
void sound_read_waveform(struct bSound* sound)
void sound_read_waveform(struct bSound *sound)
{
AUD_SoundInfo info;
info = AUD_getInfo(sound->playback_handle);
if (info.length > 0) {
SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
SoundWaveform *waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples");
@ -673,17 +673,17 @@ void sound_read_waveform(struct bSound* sound)
}
}
void sound_update_scene(struct Scene* scene)
void sound_update_scene(struct Scene *scene)
{
Object* ob;
Base* base;
NlaTrack* track;
NlaStrip* strip;
Speaker* speaker;
Scene* sce_it;
Object *ob;
Base *base;
NlaTrack *track;
NlaStrip *strip;
Speaker *speaker;
Scene *sce_it;
void* new_set = AUD_createSet();
void* handle;
void *new_set = AUD_createSet();
void *handle;
float quat[4];
for (SETLOOPER(scene, sce_it, base)) {
@ -693,7 +693,7 @@ void sound_update_scene(struct Scene* scene)
for (track = ob->adt->nla_tracks.first; track; track = track->next) {
for (strip = track->strips.first; strip; strip = strip->next) {
if (strip->type == NLASTRIP_TYPE_SOUND) {
speaker = (Speaker*)ob->data;
speaker = (Speaker *)ob->data;
if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
if (speaker->sound)
@ -713,10 +713,10 @@ void sound_update_scene(struct Scene* scene)
if (strip->speaker_handle) {
AUD_addSet(new_set, strip->speaker_handle);
AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
speaker->volume_min, speaker->distance_max,
speaker->distance_reference, speaker->attenuation,
speaker->cone_angle_outer, speaker->cone_angle_inner,
speaker->cone_volume_outer);
speaker->volume_min, speaker->distance_max,
speaker->distance_reference, speaker->attenuation,
speaker->cone_angle_outer, speaker->cone_angle_inner,
speaker->cone_volume_outer);
mat4_to_quat(quat, ob->obmat);
AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1);
@ -747,9 +747,9 @@ void sound_update_scene(struct Scene* scene)
scene->speaker_handles = new_set;
}
void* sound_get_factory(void* sound)
void *sound_get_factory(void *sound)
{
return ((struct bSound*) sound)->playback_handle;
return ((struct bSound *) sound)->playback_handle;
}
#else // WITH_AUDASPACE

View File

@ -47,7 +47,7 @@ void *BKE_speaker_add(const char *name)
{
Speaker *spk;
spk= BKE_libblock_alloc(&G.main->speaker, ID_SPK, name);
spk = BKE_libblock_alloc(&G.main->speaker, ID_SPK, name);
spk->attenuation = 1.0f;
spk->cone_angle_inner = 360.0f;
@ -69,7 +69,7 @@ Speaker *BKE_speaker_copy(Speaker *spk)
{
Speaker *spkn;
spkn= BKE_libblock_copy(&spk->id);
spkn = BKE_libblock_copy(&spk->id);
if (spkn->sound)
spkn->sound->id.us++;
@ -78,51 +78,51 @@ Speaker *BKE_speaker_copy(Speaker *spk)
void BKE_speaker_make_local(Speaker *spk)
{
Main *bmain= G.main;
Main *bmain = G.main;
Object *ob;
int is_local= FALSE, is_lib= FALSE;
int is_local = FALSE, is_lib = FALSE;
/* - only lib users: do nothing
* - only local users: set flag
* - mixed: make copy
*/
if (spk->id.lib==NULL) return;
if (spk->id.us==1) {
if (spk->id.lib == NULL) return;
if (spk->id.us == 1) {
id_clear_lib_data(bmain, &spk->id);
return;
}
ob= bmain->object.first;
ob = bmain->object.first;
while (ob) {
if (ob->data==spk) {
if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
if (ob->data == spk) {
if (ob->id.lib) is_lib = TRUE;
else is_local = TRUE;
}
ob= ob->id.next;
ob = ob->id.next;
}
if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &spk->id);
}
else if (is_local && is_lib) {
Speaker *spk_new= BKE_speaker_copy(spk);
spk_new->id.us= 0;
Speaker *spk_new = BKE_speaker_copy(spk);
spk_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, spk->id.lib, &spk_new->id);
ob= bmain->object.first;
ob = bmain->object.first;
while (ob) {
if (ob->data==spk) {
if (ob->data == spk) {
if (ob->id.lib==NULL) {
ob->data= spk_new;
if (ob->id.lib == NULL) {
ob->data = spk_new;
spk_new->id.us++;
spk->id.us--;
}
}
ob= ob->id.next;
ob = ob->id.next;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -56,8 +56,8 @@ void BKE_world_free(World *wrld)
MTex *mtex;
int a;
for (a=0; a<MAX_MTEX; a++) {
mtex= wrld->mtex[a];
for (a = 0; a < MAX_MTEX; a++) {
mtex = wrld->mtex[a];
if (mtex && mtex->tex) mtex->tex->id.us--;
if (mtex) MEM_freeN(mtex);
}
@ -71,40 +71,40 @@ void BKE_world_free(World *wrld)
MEM_freeN(wrld->nodetree);
}
BKE_icon_delete((struct ID*)wrld);
BKE_icon_delete((struct ID *)wrld);
wrld->id.icon_id = 0;
}
World *add_world(const char *name)
{
Main *bmain= G.main;
Main *bmain = G.main;
World *wrld;
wrld= BKE_libblock_alloc(&bmain->world, ID_WO, name);
wrld = BKE_libblock_alloc(&bmain->world, ID_WO, name);
wrld->horr= 0.05f;
wrld->horg= 0.05f;
wrld->horb= 0.05f;
wrld->zenr= 0.01f;
wrld->zeng= 0.01f;
wrld->zenb= 0.01f;
wrld->skytype= 0;
wrld->stardist= 15.0f;
wrld->starsize= 2.0f;
wrld->exp= 0.0f;
wrld->exposure=wrld->range= 1.0f;
wrld->horr = 0.05f;
wrld->horg = 0.05f;
wrld->horb = 0.05f;
wrld->zenr = 0.01f;
wrld->zeng = 0.01f;
wrld->zenb = 0.01f;
wrld->skytype = 0;
wrld->stardist = 15.0f;
wrld->starsize = 2.0f;
wrld->aodist= 10.0f;
wrld->aosamp= 5;
wrld->aoenergy= 1.0f;
wrld->ao_env_energy= 1.0f;
wrld->ao_indirect_energy= 1.0f;
wrld->ao_indirect_bounces= 1;
wrld->aobias= 0.05f;
wrld->exp = 0.0f;
wrld->exposure = wrld->range = 1.0f;
wrld->aodist = 10.0f;
wrld->aosamp = 5;
wrld->aoenergy = 1.0f;
wrld->ao_env_energy = 1.0f;
wrld->ao_indirect_energy = 1.0f;
wrld->ao_indirect_bounces = 1;
wrld->aobias = 0.05f;
wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
wrld->ao_approx_error= 0.25f;
wrld->ao_approx_error = 0.25f;
wrld->preview = NULL;
wrld->miststa = 5.0f;
@ -118,18 +118,18 @@ World *BKE_world_copy(World *wrld)
World *wrldn;
int a;
wrldn= BKE_libblock_copy(&wrld->id);
wrldn = BKE_libblock_copy(&wrld->id);
for (a=0; a<MAX_MTEX; a++) {
for (a = 0; a < MAX_MTEX; a++) {
if (wrld->mtex[a]) {
wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "BKE_world_copy");
wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), "BKE_world_copy");
memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
id_us_plus((ID *)wrldn->mtex[a]->tex);
}
}
if (wrld->nodetree)
wrldn->nodetree= ntreeCopyTree(wrld->nodetree);
wrldn->nodetree = ntreeCopyTree(wrld->nodetree);
if (wrld->preview)
wrldn->preview = BKE_previewimg_copy(wrld->preview);
@ -142,12 +142,12 @@ World *localize_world(World *wrld)
World *wrldn;
int a;
wrldn= BKE_libblock_copy(&wrld->id);
wrldn = BKE_libblock_copy(&wrld->id);
BLI_remlink(&G.main->world, wrldn);
for (a=0; a<MAX_MTEX; a++) {
for (a = 0; a < MAX_MTEX; a++) {
if (wrld->mtex[a]) {
wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_world");
wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), "localize_world");
memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
/* free world decrements */
id_us_plus((ID *)wrldn->mtex[a]->tex);
@ -155,51 +155,51 @@ World *localize_world(World *wrld)
}
if (wrld->nodetree)
wrldn->nodetree= ntreeLocalize(wrld->nodetree);
wrldn->nodetree = ntreeLocalize(wrld->nodetree);
wrldn->preview= NULL;
wrldn->preview = NULL;
return wrldn;
}
void BKE_world_make_local(World *wrld)
{
Main *bmain= G.main;
Main *bmain = G.main;
Scene *sce;
int is_local= FALSE, is_lib= FALSE;
int is_local = FALSE, is_lib = FALSE;
/* - only lib users: do nothing
* - only local users: set flag
* - mixed: make copy
*/
if (wrld->id.lib==NULL) return;
if (wrld->id.us==1) {
if (wrld->id.lib == NULL) return;
if (wrld->id.us == 1) {
id_clear_lib_data(bmain, &wrld->id);
return;
}
for (sce= bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce= sce->id.next) {
for (sce = bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce = sce->id.next) {
if (sce->world == wrld) {
if (sce->id.lib) is_lib= TRUE;
else is_local= TRUE;
if (sce->id.lib) is_lib = TRUE;
else is_local = TRUE;
}
}
if (is_local && is_lib==FALSE) {
if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &wrld->id);
}
else if (is_local && is_lib) {
World *wrld_new= BKE_world_copy(wrld);
wrld_new->id.us= 0;
World *wrld_new = BKE_world_copy(wrld);
wrld_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrld_new->id);
for (sce= bmain->scene.first; sce; sce= sce->id.next) {
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->world == wrld) {
if (sce->id.lib==NULL) {
sce->world= wrld_new;
if (sce->id.lib == NULL) {
sce->world = wrld_new;
wrld_new->id.us++;
wrld->id.us--;
}