Commit: 95ccb70e1dc370c8d1f4a3e5e410b723297e7954
Author: Martin Felke
Date:   Mon Nov 17 02:35:53 2014 +0100
Branches: fracture_modifier
https://developer.blender.org/rB95ccb70e1dc370c8d1f4a3e5e410b723297e7954

fix for "fix normals", used incorrect float to short and back conversion and 
ignore global rotation of object in normals rotation now

===================================================================

M       source/blender/blenkernel/intern/rigidbody.c
M       source/blender/modifiers/intern/MOD_fracture.c

===================================================================

diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index 133480d..0718bb7 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -443,7 +443,7 @@ void BKE_rigidbody_update_cell(struct MeshIsland *mi, 
Object *ob, float loc[3],
                }
                
                vert = mi->vertices_cached[j];
-               if (vert == NULL) continue;
+               if (vert == NULL) break;
                if (vert->co == NULL) break;
                if (rmd->refresh == true) break;
 
@@ -451,13 +451,19 @@ void BKE_rigidbody_update_cell(struct MeshIsland *mi, 
Object *ob, float loc[3],
                startco[1] = mi->vertco[j * 3 + 1];
                startco[2] = mi->vertco[j * 3 + 2];
 
-               if (rmd->fix_normals) {
+               if (rmd->fix_normals)
+               {
+                       float irot[4], qrot[4];
                        startno[0] = mi->vertno[j * 3];
                        startno[1] = mi->vertno[j * 3 + 1];
                        startno[2] = mi->vertno[j * 3 + 2];
 
+                       /*ignore global quaternion rotation here */
                        normal_short_to_float_v3(fno, startno);
+                       mat4_to_quat(qrot, ob->obmat);
+                       invert_qt_qt(irot, qrot);
                        mul_qt_v3(rot, fno);
+                       mul_qt_v3(irot, fno);
                        normal_float_to_short_v3(vert->no, fno);
                }
 
diff --git a/source/blender/modifiers/intern/MOD_fracture.c 
b/source/blender/modifiers/intern/MOD_fracture.c
index f4b286b..2d94c18 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -1938,12 +1938,12 @@ static DerivedMesh *createCache(FractureModifierData 
*rmd, Object *ob, DerivedMe
                                }
 
                                if (mi->vertno != NULL && rmd->fix_normals) {
-                                       float no[3];
+                                       //float no[3];
                                        short sno[3];
-                                       no[0] = mi->vertno[i * 3];
-                                       no[1] = mi->vertno[i * 3 + 1];
-                                       no[2] = mi->vertno[i * 3 + 2];
-                                       normal_float_to_short_v3(sno, no);
+                                       sno[0] = mi->vertno[i * 3];
+                                       sno[1] = mi->vertno[i * 3 + 1];
+                                       sno[2] = mi->vertno[i * 3 + 2];
+                                       //normal_float_to_short_v3(sno, no);
                                        
copy_v3_v3_short(mi->vertices_cached[i]->no, sno);
                                }
                        }
@@ -1952,7 +1952,7 @@ static DerivedMesh *createCache(FractureModifierData 
*rmd, Object *ob, DerivedMe
                }
                else {  /* halving case... */
                        for (i = 0; i < mi->vertex_count; i++) {
-                               float no[3];
+                               //float no[3];
                                int index = mi->vertex_indices[i];
                                if (index >= 0 && index <= 
rmd->visible_mesh->totvert) {
                                        mi->vertices_cached[i] = verts + index;
@@ -1974,10 +1974,10 @@ static DerivedMesh *createCache(FractureModifierData 
*rmd, Object *ob, DerivedMe
 
                                if (mi->vertno != NULL && rmd->fix_normals) {
                                        short sno[3];
-                                       no[0] = mi->vertno[i * 3];
-                                       no[1] = mi->vertno[i * 3 + 1];
-                                       no[2] = mi->vertno[i * 3 + 2];
-                                       normal_float_to_short_v3(sno, no);
+                                       sno[0] = mi->vertno[i * 3];
+                                       sno[1] = mi->vertno[i * 3 + 1];
+                                       sno[2] = mi->vertno[i * 3 + 2];
+                                       //normal_float_to_short_v3(sno, no);
                                        
copy_v3_v3_short(mi->vertices_cached[i]->no, sno);
                                }
                        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to