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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2007-12-11 23:02:21 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2007-12-11 23:02:21 +0300
commit457057a9e817d5cb410b9464616b6e05cfb054ee (patch)
treee576a995c7df2979b9c369b07ce5fedbcea7564e /source/blender/blenkernel
parent160e6afdb8dc36b7d3a982a0411e633be165d2f4 (diff)
Fix for mirroring issues in particle mode, where the particles were
not mirrored exactly, though the problem is not completely solved. The way local frames are computed for particles is still not fully symmetric, which shows especially on long hairs... Also made the shift+o subsurf switch work recursively into dupli-groups, did only the first level before.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c2
-rw-r--r--source/blender/blenkernel/intern/mesh.c22
-rw-r--r--source/blender/blenkernel/intern/particle.c32
4 files changed, 38 insertions, 20 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 556ba19d7d7..be0a04ba563 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -63,7 +63,7 @@ void make_local_mesh(struct Mesh *me);
void boundbox_mesh(struct Mesh *me, float *loc, float *size);
void tex_space_mesh(struct Mesh *me);
float *get_mesh_orco_verts(struct Object *ob);
-void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert);
+void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert, int invert);
void test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr);
struct Mesh *get_mesh(struct Object *ob);
void set_mesh(struct Object *ob, struct Mesh *me);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 713f595d09d..4cc134476e4 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1861,7 +1861,7 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
else
orco= (float(*)[3])get_mesh_orco_verts(ob);
- transform_mesh_orco_verts(ob->data, orco, totvert);
+ transform_mesh_orco_verts(ob->data, orco, totvert, 0);
if((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) {
memcpy(layerorco, orco, sizeof(float)*totvert);
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index f57daae811f..79a8afedf3f 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -515,18 +515,28 @@ float *get_mesh_orco_verts(Object *ob)
return (float*)vcos;
}
-void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert)
+void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int invert)
{
float loc[3], size[3];
int a;
mesh_get_texspace(me->texcomesh?me->texcomesh:me, loc, NULL, size);
- for(a=0; a<totvert; a++) {
- float *co = orco[a];
- co[0] = (co[0]-loc[0])/size[0];
- co[1] = (co[1]-loc[1])/size[1];
- co[2] = (co[2]-loc[2])/size[2];
+ if(invert) {
+ for(a=0; a<totvert; a++) {
+ float *co = orco[a];
+ co[0] = co[0]*size[0] + loc[0];
+ co[1] = co[1]*size[1] + loc[1];
+ co[2] = co[2]*size[2] + loc[2];
+ }
+ }
+ else {
+ for(a=0; a<totvert; a++) {
+ float *co = orco[a];
+ co[0] = (co[0]-loc[0])/size[0];
+ co[1] = (co[1]-loc[1])/size[1];
+ co[2] = (co[2]-loc[2])/size[2];
+ }
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 639a9824600..154ca9a5716 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -76,6 +76,7 @@
#include "BKE_depsgraph.h"
#include "BKE_bad_level_calls.h"
#include "BKE_modifier.h"
+#include "BKE_mesh.h"
#include "blendef.h"
#include "RE_render_ext.h"
@@ -2240,9 +2241,9 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
Crossf(mat[0], mat[1], mat[2]);
}
-static void psys_face_mat(DerivedMesh *dm, ParticleData *pa, float mat[][4], int orco)
+static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float mat[][4], int orco)
{
- float v1[3], v2[3], v3[3];
+ float v[3][3];
MFace *mface;
OrigSpaceFace *osface;
float (*orcodata)[3];
@@ -2255,24 +2256,28 @@ static void psys_face_mat(DerivedMesh *dm, ParticleData *pa, float mat[][4], int
osface=dm->getFaceData(dm,i,CD_ORIGSPACE);
if(orco && (orcodata=dm->getVertDataArray(dm, CD_ORCO))) {
- VECCOPY(v1, orcodata[mface->v1]);
- VECCOPY(v2, orcodata[mface->v2]);
- VECCOPY(v3, orcodata[mface->v3]);
+ VECCOPY(v[0], orcodata[mface->v1]);
+ VECCOPY(v[1], orcodata[mface->v2]);
+ VECCOPY(v[2], orcodata[mface->v3]);
+
+ /* ugly hack to use non-transformed orcos, since only those
+ * give symmetric results for mirroring in particle mode */
+ transform_mesh_orco_verts(ob->data, v, 3, 1);
}
else {
- dm->getVertCo(dm,mface->v1,v1);
- dm->getVertCo(dm,mface->v2,v2);
- dm->getVertCo(dm,mface->v3,v3);
+ dm->getVertCo(dm,mface->v1,v[0]);
+ dm->getVertCo(dm,mface->v2,v[1]);
+ dm->getVertCo(dm,mface->v3,v[2]);
}
- triatomat(v1, v2, v3, (osface)? osface->uv: NULL, mat);
+ triatomat(v[0], v[1], v[2], (osface)? osface->uv: NULL, mat);
}
void psys_mat_hair_to_object(Object *ob, DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4])
{
float vec[3];
- psys_face_mat(dm, pa, hairmat, 0);
+ psys_face_mat(0, dm, pa, hairmat, 0);
psys_particle_on_dm(ob, dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0, 0);
VECCOPY(hairmat[3],vec);
}
@@ -2281,8 +2286,11 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData
{
float vec[3], orco[3];
- psys_face_mat(dm, pa, hairmat, 1);
+ psys_face_mat(ob, dm, pa, hairmat, 1);
psys_particle_on_dm(ob, dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco, 0);
+
+ /* see psys_face_mat for why this function is called */
+ transform_mesh_orco_verts(ob->data, orco, 1, 1);
VECCOPY(hairmat[3],orco);
}
@@ -2338,7 +2346,7 @@ void psys_vec_rot_to_face(DerivedMesh *dm, ParticleData *pa, float *vec)//to_geo
{
float mat[4][4];
- psys_face_mat(dm, pa, mat, 0);
+ psys_face_mat(0, dm, pa, mat, 0);
Mat4Transp(mat); /* cheap inverse for rotation matrix */
Mat4Mul3Vecfl(mat, vec);
}