Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2012-09-26 18:53:41 +0400
committerAntony Riakiotakis <kalast@gmail.com>2012-09-26 18:53:41 +0400
commitc112e1b796d4f0f5d481da056c3298fdf05f671c (patch)
treee11513f65e1a7ec3f8f95cf3b33b58a601a86293 /source/blender/modifiers/intern
parent4e39a8f939fff178d320c88c290e927bddd98571 (diff)
parent433816ea9be382244ce2ca79686f242ef1d65c0b (diff)
merge with trunk -r50910
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c4
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c1
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c1
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c238
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c8
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c10
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c12
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c24
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c14
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c64
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c4
11 files changed, 187 insertions, 193 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index cdb200ff180..638e91e22f1 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -88,10 +88,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-#define EDGE_MARK 1
-
#ifdef USE_BM_BEVEL_OP_AS_MOD
+#define EDGE_MARK 1
+
/* BMESH_TODO
*
* this bevel calls the operator which is missing many of the options
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 1c98880c3db..9acac6d00cd 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -51,7 +51,6 @@
#include "BKE_fluidsim.h" /* ensure definitions here match */
#include "BKE_cdderivedmesh.h"
#include "BKE_mesh.h"
-#include "BKE_utildefines.h"
#include "BKE_global.h" /* G.main->name only */
#include "MOD_fluidsim_util.h"
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 21836453eed..3bf8b9ffacc 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -37,7 +37,6 @@
#include "BKE_global.h"
#include "BKE_modifier.h"
#include "BKE_ocean.h"
-#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index c034832bfb4..e64e80efde3 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -105,6 +105,41 @@ static void foreachObjectLink(ModifierData *md, Object *ob,
walk(userData, ob, &pimd->ob);
}
+static int particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *psys, int p)
+{
+ ParticleData *pa;
+
+ if (pimd->flag & eParticleInstanceFlag_Parents) {
+ if (p >= psys->totpart) {
+ if (psys->part->childtype == PART_CHILD_PARTICLES) {
+ pa = psys->particles + (psys->child + p - psys->totpart)->parent;
+ }
+ else {
+ pa = NULL;
+ }
+ }
+ else {
+ pa = psys->particles + p;
+ }
+ }
+ else {
+ if (psys->part->childtype == PART_CHILD_PARTICLES) {
+ pa = psys->particles + (psys->child + p)->parent;
+ }
+ else {
+ pa = NULL;
+ }
+ }
+
+ if (pa) {
+ if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) return 1;
+ if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) return 1;
+ if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) return 1;
+ }
+
+ return 0;
+}
+
static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
@@ -113,11 +148,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
ParticleSimulationData sim;
ParticleSystem *psys = NULL;
- ParticleData *pa = NULL, *pars = NULL;
+ ParticleData *pa = NULL;
MPoly *mpoly, *orig_mpoly;
MLoop *mloop, *orig_mloop;
MVert *mvert, *orig_mvert;
- int i, totvert, totpoly, totloop, maxvert, maxpoly, maxloop, totpart = 0, first_particle = 0;
+ int totvert, totpoly, totloop /* , totedge */;
+ int maxvert, maxpoly, maxloop, totpart = 0, first_particle = 0;
+ int k, p, p_skip;
short track = ob->trackflag % 3, trackneg, axis = pimd->axis;
float max_co = 0.0, min_co = 0.0, temp_co[3], cross[3];
float *size = NULL;
@@ -153,7 +190,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
sim.psmd = psys_get_modifier(pimd->ob, psys);
if (pimd->flag & eParticleInstanceFlag_UseSize) {
- int p;
float *si;
si = size = MEM_callocN(totpart * sizeof(float), "particle size array");
@@ -171,15 +207,24 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
}
- pars = psys->particles;
-
totvert = dm->getNumVerts(dm);
totpoly = dm->getNumPolys(dm);
totloop = dm->getNumLoops(dm);
+ /* totedge = dm->getNumEdges(dm); */ /* UNUSED */
- maxvert = totvert * totpart;
- maxpoly = totpoly * totpart;
- maxloop = totloop * totpart;
+ /* count particles */
+ maxvert = 0;
+ maxpoly = 0;
+ maxloop = 0;
+
+ for (p = 0; p < totpart; p++) {
+ if (particle_skip(pimd, psys, p))
+ continue;
+
+ maxvert += totvert;
+ maxpoly += totpoly;
+ maxloop += totloop;
+ }
psys->lattice = psys_get_lattice(&sim);
@@ -191,127 +236,110 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
max_co = max_r[track];
}
- result = CDDM_from_template(dm, maxvert, dm->getNumEdges(dm) * totpart, 0, maxloop, maxpoly);
+ result = CDDM_from_template(dm, maxvert, 0, 0, maxloop, maxpoly);
mvert = result->getVertArray(result);
orig_mvert = dm->getVertArray(dm);
- for (i = 0; i < maxvert; i++) {
- MVert *inMV;
- MVert *mv = mvert + i;
- ParticleKey state;
-
- inMV = orig_mvert + i % totvert;
- DM_copy_vert_data(dm, result, i % totvert, i, 1);
- *mv = *inMV;
-
- /*change orientation based on object trackflag*/
- copy_v3_v3(temp_co, mv->co);
- mv->co[axis] = temp_co[track];
- mv->co[(axis + 1) % 3] = temp_co[(track + 1) % 3];
- mv->co[(axis + 2) % 3] = temp_co[(track + 2) % 3];
-
- if ((psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) &&
- (pimd->flag & eParticleInstanceFlag_Path))
- {
- float ran = 0.0f;
- if (pimd->random_position != 0.0f) {
- BLI_srandom(psys->seed + (i / totvert) % totpart);
- ran = pimd->random_position * BLI_frand();
- }
-
- if (pimd->flag & eParticleInstanceFlag_KeepShape) {
- state.time = pimd->position * (1.0f - ran);
- }
- else {
- state.time = (mv->co[axis] - min_co) / (max_co - min_co) * pimd->position * (1.0f - ran);
-
- if (trackneg)
- state.time = 1.0f - state.time;
-
- mv->co[axis] = 0.0;
- }
-
- psys_get_particle_on_path(&sim, first_particle + i / totvert, &state, 1);
-
- normalize_v3(state.vel);
+ mpoly = result->getPolyArray(result);
+ orig_mpoly = dm->getPolyArray(dm);
+ mloop = result->getLoopArray(result);
+ orig_mloop = dm->getLoopArray(dm);
- /* TODO: incremental rotations somehow */
- if (state.vel[axis] < -0.9999f || state.vel[axis] > 0.9999f) {
- unit_qt(state.rot);
- }
- else {
- float temp[3] = {0.0f, 0.0f, 0.0f};
- temp[axis] = 1.0f;
+ for (p = 0, p_skip = 0; p < totpart; p++) {
+ /* skip particle? */
+ if (particle_skip(pimd, psys, p))
+ continue;
+
+ /* set vertices coordinates */
+ for (k = 0; k < totvert; k++) {
+ ParticleKey state;
+ MVert *inMV;
+ MVert *mv = mvert + p_skip * totvert + k;
+
+ inMV = orig_mvert + k;
+ DM_copy_vert_data(dm, result, k, p_skip * totvert + k, 1);
+ *mv = *inMV;
+
+ /*change orientation based on object trackflag*/
+ copy_v3_v3(temp_co, mv->co);
+ mv->co[axis] = temp_co[track];
+ mv->co[(axis + 1) % 3] = temp_co[(track + 1) % 3];
+ mv->co[(axis + 2) % 3] = temp_co[(track + 2) % 3];
+
+ /* get particle state */
+ if ((psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) &&
+ (pimd->flag & eParticleInstanceFlag_Path))
+ {
+ float ran = 0.0f;
+ if (pimd->random_position != 0.0f) {
+ BLI_srandom(psys->seed + p);
+ ran = pimd->random_position * BLI_frand();
+ }
- cross_v3_v3v3(cross, temp, state.vel);
+ if (pimd->flag & eParticleInstanceFlag_KeepShape) {
+ state.time = pimd->position * (1.0f - ran);
+ }
+ else {
+ state.time = (mv->co[axis] - min_co) / (max_co - min_co) * pimd->position * (1.0f - ran);
- /* state.vel[axis] is the only component surviving from a dot product with the axis */
- axis_angle_to_quat(state.rot, cross, saacos(state.vel[axis]));
- }
- }
- else {
- state.time = -1.0;
- psys_get_particle_state(&sim, first_particle + i / totvert, &state, 1);
- }
+ if (trackneg)
+ state.time = 1.0f - state.time;
- mul_qt_v3(state.rot, mv->co);
- if (pimd->flag & eParticleInstanceFlag_UseSize)
- mul_v3_fl(mv->co, size[i / totvert]);
- add_v3_v3(mv->co, state.co);
- }
+ mv->co[axis] = 0.0;
+ }
- mpoly = result->getPolyArray(result);
- orig_mpoly = dm->getPolyArray(dm);
- mloop = result->getLoopArray(result);
- orig_mloop = dm->getLoopArray(dm);
+ psys_get_particle_on_path(&sim, first_particle + p, &state, 1);
- for (i = 0; i < maxpoly; i++) {
- MPoly *inMP = orig_mpoly + i % totpoly;
- MPoly *mp = mpoly + i;
+ normalize_v3(state.vel);
- if (pimd->flag & eParticleInstanceFlag_Parents) {
- if (i / totpoly >= psys->totpart) {
- if (psys->part->childtype == PART_CHILD_PARTICLES) {
- pa = psys->particles + (psys->child + i / totpoly - psys->totpart)->parent;
+ /* TODO: incremental rotations somehow */
+ if (state.vel[axis] < -0.9999f || state.vel[axis] > 0.9999f) {
+ unit_qt(state.rot);
}
else {
- pa = NULL;
+ float temp[3] = {0.0f, 0.0f, 0.0f};
+ temp[axis] = 1.0f;
+
+ cross_v3_v3v3(cross, temp, state.vel);
+
+ /* state.vel[axis] is the only component surviving from a dot product with the axis */
+ axis_angle_to_quat(state.rot, cross, saacos(state.vel[axis]));
}
}
else {
- pa = pars + i / totpoly;
- }
- }
- else {
- if (psys->part->childtype == PART_CHILD_PARTICLES) {
- pa = psys->particles + (psys->child + i / totpoly)->parent;
- }
- else {
- pa = NULL;
+ state.time = -1.0;
+ psys_get_particle_state(&sim, first_particle + p, &state, 1);
}
- }
- if (pa) {
- if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) continue;
- if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) continue;
- if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) continue;
+ mul_qt_v3(state.rot, mv->co);
+ if (pimd->flag & eParticleInstanceFlag_UseSize)
+ mul_v3_fl(mv->co, size[p]);
+ add_v3_v3(mv->co, state.co);
}
- DM_copy_poly_data(dm, result, i % totpoly, i, 1);
- *mp = *inMP;
- mp->loopstart += (i / totpoly) * totloop;
+ /* create polys and loops */
+ for (k = 0; k < totpoly; k++) {
+ MPoly *inMP = orig_mpoly + k;
+ MPoly *mp = mpoly + p_skip * totpoly + k;
+
+ DM_copy_poly_data(dm, result, k, p_skip * totpoly + k, 1);
+ *mp = *inMP;
+ mp->loopstart += p_skip * totloop;
- {
- MLoop *inML = orig_mloop + inMP->loopstart;
- MLoop *ml = mloop + mp->loopstart;
- int j = mp->totloop;
+ {
+ MLoop *inML = orig_mloop + inMP->loopstart;
+ MLoop *ml = mloop + mp->loopstart;
+ int j = mp->totloop;
- DM_copy_loop_data(dm, result, inMP->loopstart, mp->loopstart, j);
- for (; j; j--, ml++, inML++) {
- ml->v = inML->v + ((i / totpoly) * totvert);
+ DM_copy_loop_data(dm, result, inMP->loopstart, mp->loopstart, j);
+ for (; j; j--, ml++, inML++) {
+ ml->v = inML->v + (p_skip * totvert);
+ }
}
}
+
+ p_skip++;
}
CDDM_calc_edges(result);
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 890e45f7e80..254c02b7672 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -188,11 +188,9 @@ static void deformVerts(ModifierData *md, Object *ob,
psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm);
}
- if (psys) {
- psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(md->scene, ob, psys);
- psmd->flag |= eParticleSystemFlag_psys_updated;
- }
+ psmd->flag &= ~eParticleSystemFlag_psys_updated;
+ particle_system_update(md->scene, ob, psys);
+ psmd->flag |= eParticleSystemFlag_psys_updated;
}
/* disabled particles in editmode for now, until support for proper derivedmesh
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index aed8a70a805..a94b4834d18 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -393,7 +393,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
mul_m4_v3(mtx_tx, vc->co);
/* length in 2d, don't sqrt because this is only for comparison */
- vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
+ vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
/* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
@@ -410,7 +410,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->v[0] = vc->v[1] = -1;
/* length in 2d, don't sqrt because this is only for comparison */
- vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
+ vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
/* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
@@ -430,7 +430,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->e[1] = med_new;
}
else {
- vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */
+ vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
}
vc = &vert_connect[med_new->v2];
@@ -445,7 +445,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->e[1] = med_new;
}
else {
- vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */
+ vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
}
}
@@ -857,7 +857,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
mp_new->loopstart = mpoly_index * 4;
mp_new->totloop = 4;
- mp_new->flag = ME_SMOOTH;
+ mp_new->flag = mpoly_flag;
origindex[mpoly_index] = ORIGINDEX_NONE;
mp_new++;
ml_new += 4;
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 3353382fa3d..8ef86362edd 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -54,7 +54,7 @@ static void deformVerts(ModifierData *md, Object *ob,
int numVerts,
ModifierApplyFlag UNUSED(flag))
{
- KeyBlock *kb = ob_get_keyblock(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float (*deformedVerts)[3];
if (kb && kb->totelem == numVerts) {
@@ -69,8 +69,8 @@ static void deformVerts(ModifierData *md, Object *ob,
static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float scale[3][3];
(void)vertexCos; /* unused */
@@ -94,7 +94,7 @@ static void deformVertsEM(ModifierData *md, Object *ob,
float (*vertexCos)[3],
int numVerts)
{
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
if (key && key->type == KEY_RELATIVE)
deformVerts(md, ob, derivedData, vertexCos, numVerts, 0);
@@ -107,8 +107,8 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob,
float (*defMats)[3][3],
int numVerts)
{
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float scale[3][3];
(void)vertexCos; /* unused */
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index bf5f6cd095e..44ebc76e4a1 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -72,7 +72,7 @@ static void simpleDeform_taper(const float factor, const float dcut[3], float r_
r_co[1] = y + y * scale;
r_co[2] = z;
- if (dcut) {
+ {
r_co[0] += dcut[0];
r_co[1] += dcut[1];
r_co[2] += dcut[2];
@@ -90,7 +90,7 @@ static void simpleDeform_stretch(const float factor, const float dcut[3], float
r_co[1] = y * scale;
r_co[2] = z * (1.0f + factor);
- if (dcut) {
+ {
r_co[0] += dcut[0];
r_co[1] += dcut[1];
r_co[2] += dcut[2];
@@ -110,7 +110,7 @@ static void simpleDeform_twist(const float factor, const float *dcut, float r_co
r_co[1] = x * sint + y * cost;
r_co[2] = z;
- if (dcut) {
+ {
r_co[0] += dcut[0];
r_co[1] += dcut[1];
r_co[2] += dcut[2];
@@ -132,7 +132,7 @@ static void simpleDeform_bend(const float factor, const float dcut[3], float r_c
r_co[2] = z;
}
- if (dcut) {
+ {
r_co[0] += cost * dcut[0];
r_co[1] += sint * dcut[0];
r_co[2] += dcut[2];
@@ -163,7 +163,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
smd->limit[0] = minf(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */
- //Calculate matrixs do convert between coordinate spaces
+ /* Calculate matrixs do convert between coordinate spaces */
if (smd->origin) {
transf = &tmp_transf;
@@ -176,10 +176,11 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
}
}
- //Setup vars
- limit_axis = (smd->mode == MOD_SIMPLEDEFORM_MODE_BEND) ? 0 : 2; //Bend limits on X.. all other modes limit on Z
+ /* Setup vars,
+ * Bend limits on X.. all other modes limit on Z */
+ limit_axis = (smd->mode == MOD_SIMPLEDEFORM_MODE_BEND) ? 0 : 2;
- //Update limits if needed
+ /* Update limits if needed */
{
float lower = FLT_MAX;
float upper = -FLT_MAX;
@@ -199,7 +200,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
smd_limit[1] = lower + (upper - lower) * smd->limit[1];
smd_limit[0] = lower + (upper - lower) * smd->limit[0];
- smd_factor = smd->factor / MAX2(FLT_EPSILON, smd_limit[1] - smd_limit[0]);
+ smd_factor = smd->factor / maxf(FLT_EPSILON, smd_limit[1] - smd_limit[0]);
}
modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup);
@@ -235,7 +236,9 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
simpleDeform_callback(smd_factor, dcut, co); /* apply deform */
interp_v3_v3v3(vertexCos[i], vertexCos[i], co, weight); /* Use vertex weight has coef of linear interpolation */
- if (transf) space_transform_invert(transf, vertexCos[i]);
+ if (transf) {
+ space_transform_invert(transf, vertexCos[i]);
+ }
}
}
}
@@ -249,6 +252,7 @@ static void initData(ModifierData *md)
SimpleDeformModifierData *smd = (SimpleDeformModifierData *) md;
smd->mode = MOD_SIMPLEDEFORM_MODE_TWIST;
+ smd->originOpts = MOD_SIMPLEDEFORM_ORIGIN_LOCAL;
smd->axis = 0;
smd->origin = NULL;
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index fc74b446762..1df7d535c35 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -107,7 +107,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
f_no = face_nors[i];
if (calc_face_nors)
- mesh_calc_poly_normal(mp, mloop + mp->loopstart, mvert, f_no);
+ BKE_mesh_calc_poly_normal(mp, mloop + mp->loopstart, mvert, f_no);
ml = mloop + mp->loopstart;
@@ -483,7 +483,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* --- not related to angle calc --- */
if (face_nors_calc)
- mesh_calc_poly_normal(mp, ml, mvert, face_nors[i]);
+ BKE_mesh_calc_poly_normal(mp, ml, mvert, face_nors[i]);
/* --- end non-angle-calc section --- */
sub_v3_v3v3(nor_prev, mvert[ml[i_this - 1].v].co, mvert[ml[i_this].v].co);
@@ -635,15 +635,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* notice we use 'mp->totloop' which is later overwritten,
* we could lookup the original face but theres no point since this is a copy
* and will have the same value, just take care when changing order of assignment */
- k1 = mpoly[fidx].loopstart + ((edge_order[eidx] + 1) % mp->totloop);
+ k1 = mpoly[fidx].loopstart + (((edge_order[eidx] - 1) + mp->totloop) % mp->totloop); /* prev loop */
k2 = mpoly[fidx].loopstart + (edge_order[eidx]);
mp->totloop = 4;
- CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 0, 1);
- CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 1, 1);
- CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 2, 1);
- CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 3, 1);
+ CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 0, 1);
+ CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 1, 1);
+ CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 2, 1);
+ CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 3, 1);
if (flip == FALSE) {
ml[j].v = ed->v1;
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index eb5a74f0dcc..88951919272 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -157,7 +157,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0);
Projector projectors[MOD_UVPROJECT_MAXPROJECTORS];
int num_projectors = 0;
- float aspect;
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
float aspx = umd->aspectx ? umd->aspectx : 1.0f;
float aspy = umd->aspecty ? umd->aspecty : 1.0f;
@@ -165,8 +164,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
float scay = umd->scaley ? umd->scaley : 1.0f;
int free_uci = 0;
- aspect = aspx / aspy;
-
for (i = 0; i < umd->num_projectors; ++i)
if (umd->projectors[i])
projectors[num_projectors++].ob = umd->projectors[i];
@@ -199,39 +196,23 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
free_uci = 1;
}
else {
- float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
- int sensor_fit = BKE_camera_sensor_fit(cam->sensor_fit, aspx, aspy);
- float scale = (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale;
- float xmax, xmin, ymax, ymin;
-
- if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
- xmax = 0.5f * scale;
- ymax = xmax / aspect;
- }
- else {
- ymax = 0.5f * scale;
- xmax = ymax * aspect;
- }
+ CameraParams params;
- xmin = -xmax;
- ymin = -ymax;
+ /* setup parameters */
+ BKE_camera_params_init(&params);
+ BKE_camera_params_from_object(&params, projectors[i].ob);
- /* scale the matrix */
- xmin *= scax;
- xmax *= scax;
- ymin *= scay;
- ymax *= scay;
+ /* compute matrix, viewplane, .. */
+ BKE_camera_params_compute_viewplane(&params, 1, 1, aspx, aspy);
- if (cam->type == CAM_PERSP) {
- float perspmat[4][4];
- perspective_m4(perspmat, xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
- mult_m4_m4m4(tmpmat, perspmat, projectors[i].projmat);
- }
- else { /* if (cam->type == CAM_ORTHO) */
- float orthomat[4][4];
- orthographic_m4(orthomat, xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
- mult_m4_m4m4(tmpmat, orthomat, projectors[i].projmat);
- }
+ /* scale the view-plane */
+ params.viewplane.xmin *= scax;
+ params.viewplane.xmax *= scax;
+ params.viewplane.ymin *= scay;
+ params.viewplane.ymax *= scay;
+
+ BKE_camera_params_compute_matrix(&params);
+ mult_m4_m4m4(tmpmat, params.winmat, projectors[i].projmat);
}
}
else {
@@ -241,22 +222,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
unit_m4(offsetmat);
mul_mat3_m4_fl(offsetmat, 0.5);
offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5;
-
- if (cam) {
- if (aspx == aspy) {
- offsetmat[3][0] -= cam->shiftx;
- offsetmat[3][1] -= cam->shifty;
- }
- else if (aspx < aspy) {
- offsetmat[3][0] -= (cam->shiftx * aspy / aspx);
- offsetmat[3][1] -= cam->shifty;
- }
- else {
- offsetmat[3][0] -= cam->shiftx;
- offsetmat[3][1] -= (cam->shifty * aspx / aspy);
- }
- }
-
+
mult_m4_m4m4(projectors[i].projmat, offsetmat, tmpmat);
/* calculate worldspace projector normal (for best projector test) */
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index d5deb50e1f9..25a2a61d8e3 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -185,7 +185,7 @@ static float get_ob2ob_distance(const Object *ob, const Object *obr)
/**
* Maps distances to weights, with an optional "smoothing" mapping.
*/
-void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode)
+static void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode)
{
const float range_inv = 1.0f / (max_d - min_d); /* invert since multiplication is faster */
unsigned int i = nidx;
@@ -474,7 +474,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
float *dists_e = use_trgt_edges ? MEM_mallocN(sizeof(float) * numIdx, "dists_e") : NULL;
float *dists_f = use_trgt_faces ? MEM_mallocN(sizeof(float) * numIdx, "dists_f") : NULL;
- space_transform_setup(&loc2trgt, ob, obr);
+ SPACE_TRANSFORM_SETUP(&loc2trgt, ob, obr);
get_vert2geom_distance(numIdx, v_cos, dists_v, dists_e, dists_f,
target_dm, &loc2trgt);
for (i = 0; i < numIdx; i++) {