Commit: 4da2c8498f0ec4f75ad705843986571d6c431d20
Author: Lukas Tönne
Date:   Sun Sep 14 13:23:14 2014 +0200
Branches: hair_immediate_fixes
https://developer.blender.org/rB4da2c8498f0ec4f75ad705843986571d6c431d20

Moved "set_positions" for cloth out of core implicit solver.

API for the solver now has functions for setting of vertex motion state
and the associated root transform data.

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

M       source/blender/physics/BPH_mass_spring.h
M       source/blender/physics/intern/BPH_mass_spring.cpp
M       source/blender/physics/intern/implicit.h
M       source/blender/physics/intern/implicit_blender.c

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

diff --git a/source/blender/physics/BPH_mass_spring.h 
b/source/blender/physics/BPH_mass_spring.h
index 8382d0b..14c03d8 100644
--- a/source/blender/physics/BPH_mass_spring.h
+++ b/source/blender/physics/BPH_mass_spring.h
@@ -28,7 +28,12 @@
 #ifndef __BPH_MASS_SPRING_H__
 #define __BPH_MASS_SPRING_H__
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct Implicit_Data;
+struct ClothModifierData;
 
 struct Implicit_Data *BPH_mass_spring_solver_create(int numverts, int 
numsprings);
 void BPH_mass_spring_solver_free(struct Implicit_Data *id);
@@ -36,8 +41,12 @@ void BPH_mass_spring_solver_free(struct Implicit_Data *id);
 int BPH_cloth_solver_init(struct Object *ob, struct ClothModifierData *clmd);
 void BPH_cloth_solver_free(struct ClothModifierData *clmd);
 int BPH_cloth_solve(struct Object *ob, float frame, struct ClothModifierData 
*clmd, struct ListBase *effectors);
-void BKE_cloth_solver_set_positions (struct ClothModifierData *clmd );
+void BKE_cloth_solver_set_positions(struct ClothModifierData *clmd);
 
 bool implicit_hair_volume_get_texture_data(struct Object *UNUSED(ob), struct 
ClothModifierData *clmd, struct ListBase *UNUSED(effectors), struct VoxelData 
*vd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp 
b/source/blender/physics/intern/BPH_mass_spring.cpp
index e69de29..4c8c5a3 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -0,0 +1,61 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/BPH_mass_spring.c
+ *  \ingroup bph
+ */
+
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+
+#include "BLI_math.h"
+#include "BLI_linklist.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_cloth.h"
+
+#include "BPH_mass_spring.h"
+#include "implicit.h"
+
+void BKE_cloth_solver_set_positions(ClothModifierData *clmd)
+{
+       Cloth *cloth = clmd->clothObject;
+       ClothVertex *verts = cloth->verts;
+       unsigned int numverts = cloth->numverts, i;
+       ClothHairRoot *cloth_roots = clmd->roots;
+       Implicit_Data *id = cloth->implicit;
+       const float ZERO[3] = {0.0f, 0.0f, 0.0f};
+       
+       for (i = 0; i < numverts; i++) {
+               ClothHairRoot *root = &cloth_roots[i];
+               
+               BPH_mass_spring_set_root_motion(id, i, root->loc, ZERO, 
root->rot, ZERO);
+               BPH_mass_spring_set_motion_state(id, i, verts[i].x, verts[i].v);
+       }
+}
diff --git a/source/blender/physics/intern/implicit.h 
b/source/blender/physics/intern/implicit.h
index edddd1b..66d91d7 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -36,6 +36,10 @@
 
 #include "BLI_utildefines.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 //#define IMPLICIT_SOLVER_EIGEN
 #define IMPLICIT_SOLVER_BLENDER
 
@@ -52,9 +56,18 @@
 
 //#define IMPLICIT_ENABLE_EIGEN_DEBUG
 
+struct Implicit_Data;
+
 BLI_INLINE void implicit_print_matrix_elem(float v)
 {
     printf("%-8.3f", v);
 }
 
+void BPH_mass_spring_set_root_motion(struct Implicit_Data *data, int index, 
const float loc[3], const float vel[3], float rot[3][3], const float angvel[3]);
+void BPH_mass_spring_set_motion_state(struct Implicit_Data *data, int index, 
const float x[3], const float v[3]);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/source/blender/physics/intern/implicit_blender.c 
b/source/blender/physics/intern/implicit_blender.c
index 9b78447..90286a2 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -2908,29 +2908,38 @@ int BPH_cloth_solve(Object *ob, float frame, 
ClothModifierData *clmd, ListBase *
        return 1;
 }
 
-void BKE_cloth_solver_set_positions(ClothModifierData *clmd)
+void BPH_mass_spring_set_root_motion(Implicit_Data *data, int index, const 
float loc[3], const float vel[3], float rot[3][3], const float angvel[3])
 {
-       Cloth *cloth = clmd->clothObject;
-       ClothVertex *verts = cloth->verts;
-       unsigned int numverts = cloth->numverts, i;
-       ClothHairRoot *cloth_roots = clmd->roots;
-       Implicit_Data *id = cloth->implicit;
+       RootTransform *root = &data->root[index];
        
-       for (i = 0; i < numverts; i++) {
 #ifdef CLOTH_ROOT_FRAME
-               copy_v3_v3(id->root[i].loc, cloth_roots[i].loc);
-               copy_m3_m3(id->root[i].rot, cloth_roots[i].rot);
+       copy_v3_v3(root->loc, loc);
+       copy_v3_v3(root->vel, vel);
+       copy_m3_m3(root->rot, rot);
+       copy_v3_v3(root->omega, angvel);
+       /* XXX root frame acceleration ignored for now */
+       zero_v3(root->acc);
+       zero_v3(root->domega_dt);
 #else
-               zero_v3(id->root[i].loc);
-               unit_m3(id->root[i].rot);
-               (void)cloth_roots;
+       zero_v3(root->loc);
+       zero_v3(root->vel);
+       unit_m3(root->rot);
+       zero_v3(root->omega);
+       zero_v3(root->acc);
+       zero_v3(root->domega_dt);
+       (void)loc;
+       (void)vel;
+       (void)rot;
+       (void)angvel;
 #endif
-               
-               loc_world_to_root(id->X[i], verts[i].x, &id->root[i]);
-               vel_world_to_root(id->V[i], id->X[i], verts[i].v, &id->root[i]);
-       }
-       if (G.debug_value > 0)
-               printf("implicit_set_positions\n");
+}
+
+void BPH_mass_spring_set_motion_state(Implicit_Data *data, int index, const 
float x[3], const float v[3])
+{
+       RootTransform *root = &data->root[index];
+       
+       loc_world_to_root(data->X[index], x, root);
+       vel_world_to_root(data->V[index], data->X[index], v, root);
 }
 
 #endif /* IMPLICIT_SOLVER_BLENDER */

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

Reply via email to