[Bf-blender-cvs] [2438ada3415] soc-2022-soft-bodies: Implemented XPBD with distance and volume constraints. Self collisions implemented is not working. Point cache and UI have been attatched.
Aarnav Dhanuka
noreply at git.blender.org
Wed Sep 14 16:19:02 CEST 2022
Commit: 2438ada34158a6a92ce43c88394737d07650e6b6
Author: Aarnav Dhanuka
Date: Wed Sep 14 19:47:13 2022 +0530
Branches: soc-2022-soft-bodies
https://developer.blender.org/rB2438ada34158a6a92ce43c88394737d07650e6b6
Implemented XPBD with distance and volume constraints. Self collisions implemented is not working. Point cache and UI have been attatched.
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/startup/bl_ui/properties_physics_softbody.py
M source/blender/blenkernel/BKE_softbody.h
M source/blender/blenkernel/CMakeLists.txt
M source/blender/blenkernel/intern/object.cc
M source/blender/blenkernel/intern/pointcache.c
D source/blender/blenkernel/intern/softbody.c
A source/blender/blenkernel/intern/softbody.cc
M source/blender/blenloader/intern/versioning_250.c
M source/blender/blenloader/intern/versioning_280.c
M source/blender/blenloader/intern/versioning_legacy.c
M source/blender/editors/object/object_modifier.cc
M source/blender/makesdna/DNA_object_force_types.h
M source/blender/makesrna/intern/rna_object_force.c
M source/blender/modifiers/intern/MOD_softbody.c
M source/blender/modifiers/intern/MOD_weld.cc
M source/blender/simulation/CMakeLists.txt
A source/blender/simulation/intern/xpbd.cc
A source/blender/simulation/intern/xpbd.h
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 915744ad8e2..c15c8b01dcf 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 915744ad8e255d1723d77671a6c6b074773c2199
+Subproject commit c15c8b01dcf6ddaa753d04efab8aed9b1c1603da
diff --git a/release/scripts/addons b/release/scripts/addons
index c51e0bb1793..849e7196eb4 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit c51e0bb1793c44c7a1b7435593dd5022cf7c8eec
+Subproject commit 849e7196eb4ee7bc5ca8a5644da49ffbd3ff3c97
diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py
index bde7778e54c..b9da85a20cf 100644
--- a/release/scripts/startup/bl_ui/properties_physics_softbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py
@@ -37,7 +37,8 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
md = context.soft_body
softbody = md.settings
- layout.prop(softbody, "collision_collection")
+ # layout.prop(softbody, "collision_collection")
+
class PHYSICS_PT_softbody_object(PhysicButtonsPanel, Panel):
@@ -80,10 +81,24 @@ class PHYSICS_PT_softbody_simulation(PhysicButtonsPanel, Panel):
md = context.soft_body
softbody = md.settings
+ ob = context.object
layout.enabled = softbody_panel_enabled(md)
+ flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
+
+ col = flow.column()
+ col.prop(softbody, "dt")
+
+ col = flow.column()
+ col.prop(softbody, "substep_count")
+
+ col = flow.column()
+ col.prop(softbody, "alpha_vol")
+
+ col = flow.column()
+ col.prop(softbody, "alpha_edge")
- layout.prop(softbody, "speed")
+ # layout.prop(softbody, "speed")
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
@@ -382,20 +397,20 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
classes = (
PHYSICS_PT_softbody,
- PHYSICS_PT_softbody_object,
+ # PHYSICS_PT_softbody_object,
PHYSICS_PT_softbody_simulation,
- PHYSICS_PT_softbody_cache,
- PHYSICS_PT_softbody_goal,
- PHYSICS_PT_softbody_goal_settings,
- PHYSICS_PT_softbody_goal_strengths,
- PHYSICS_PT_softbody_edge,
- PHYSICS_PT_softbody_edge_aerodynamics,
- PHYSICS_PT_softbody_edge_stiffness,
- PHYSICS_PT_softbody_collision,
- PHYSICS_PT_softbody_solver,
- PHYSICS_PT_softbody_solver_diagnostics,
- PHYSICS_PT_softbody_solver_helpers,
- PHYSICS_PT_softbody_field_weights,
+ # PHYSICS_PT_softbody_cache,
+ # PHYSICS_PT_softbody_goal,
+ # PHYSICS_PT_softbody_goal_settings,
+ # PHYSICS_PT_softbody_goal_strengths,
+ # PHYSICS_PT_softbody_edge,
+ # PHYSICS_PT_softbody_edge_aerodynamics,
+ # PHYSICS_PT_softbody_edge_stiffness,
+ # PHYSICS_PT_softbody_collision,
+ # PHYSICS_PT_softbody_solver,
+ # PHYSICS_PT_softbody_solver_diagnostics,
+ # PHYSICS_PT_softbody_solver_helpers,
+ # PHYSICS_PT_softbody_field_weights,
)
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index 09b18d3a731..31aa612c78d 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -15,71 +15,54 @@ struct Object;
struct Scene;
struct SoftBody;
-typedef struct BodyPoint {
- float origS[3], origE[3], origT[3], pos[3], vec[3], force[3];
- float goal;
- float prevpos[3], prevvec[3], prevdx[3], prevdv[3]; /* used for Heun integration */
- float impdv[3], impdx[3];
- int nofsprings;
- int *springs;
- float choke, choke2, frozen;
- float colball;
- short loc_flag; /* reserved by locale module specific states */
- // char octantflag;
- float mass;
- float springweight;
+// typedef struct BodyPoint {
+// float origS[3], origE[3], origT[3], pos[3], vec[3], force[3];
+// float goal;
+// float prevpos[3], prevvec[3], prevdx[3], prevdv[3]; /* used for Heun integration */
+// float impdv[3], impdx[3];
+// int nofsprings;
+// int *springs;
+// float choke, choke2, frozen;
+// float colball;
+// short loc_flag; /* reserved by locale module specific states */
+// // char octantflag;
+// float mass;
+// float springweight;
+// } BodyPoint;
+
+typedef struct BodyPoint{
+ float x[3], v[3], a[3];
+ float x_prev[3], v_prev[3], a_prev[3];
+ float x_ini[3], v_ini[3], a_ini[3];
+
+ float mass_inv; // 1/mass
} BodyPoint;
-/**
- * Allocates and initializes general main data.
- */
-extern struct SoftBody *sbNew(void);
+typedef struct BodyEdge{
+ int u, v;
+} BodyEdge;
-/**
- * Frees internal data and soft-body itself.
- */
-extern void sbFree(struct Object *ob);
+typedef struct BodyTet{
+ int verts[4];
+ float initial_volume;
+} BodyTet;
-/**
- * Frees simulation data to reset simulation.
- */
-extern void sbFreeSimulation(struct SoftBody *sb);
-
-/**
- * Do one simulation step, reading and writing vertex locs from given array.
- * */
-extern void sbObjectStep(struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct Object *ob,
- float cfra,
- float (*vertexCos)[3],
- int numVerts);
-
-/**
- * Makes totally fresh start situation, resets time.
- */
-extern void sbObjectToSoftbody(struct Object *ob);
+struct SoftBody *init_softbody(void);
+
+void free_softbody_intern(struct SoftBody *sb);
+
+void sbFree(struct Object *ob);
+
+float get_tet_volume(BodyPoint *bpoint, BodyTet *curr_tet);
+
+void mesh_to_softbody(struct Object *ob, float (*vertexCos)[3], int numVerts);
+
+void sb_store_last_frame(struct Depsgraph *depsgraph, struct Object *object, float framenr);
+
+void softbody_to_object(struct Object *ob, float (*vertexCos)[3], int numVerts);
+
+void sbObjectStep(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float cfra, float (*vertexCos)[3], int numVerts);
-/**
- * Soft-body global visible functions.
- * Links the soft-body module to a 'test for Interrupt' function, pass NULL to clear the callback.
- */
-extern void sbSetInterruptCallBack(int (*f)(void));
-
-/**
- * A precise position vector denoting the motion of the center of mass give a rotation/scale matrix
- * using averaging method, that's why estimate and not calculate see: this is kind of reverse
- * engineering: having to states of a point cloud and recover what happened our advantage here we
- * know the identity of the vertex there are others methods giving other results.
- *
- * \param ob: Any object that can do soft-body e.g. mesh, lattice, curve.
- * \param lloc: Output of the calculated location (or NULL).
- * \param lrot: Output of the calculated rotation (or NULL).
- * \param lscale: Output for the calculated scale (or NULL).
- *
- * For velocity & 2nd order stuff see: #vcloud_estimate_transform_v3.
- */
-extern void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3]);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 8dc6f711fae..eb009fd08c1 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -257,7 +257,7 @@ set(SRC
intern/shader_fx.c
intern/shrinkwrap.c
intern/simulation.cc
- intern/softbody.c
+ intern/softbody.cc
intern/sound.c
intern/speaker.c
intern/spline_base.cc
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc
index c8b87c27697..45aaf165ba3 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -444,14 +444,14 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
data, BKE_particlesystem_id_loop(psys, library_foreach_particlesystemsObjectLooper, data));
}
- if (object->soft) {
- BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->soft->collision_group, IDWALK_CB_NOP);
+ // if (object->soft) {
+ // BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->soft->collision_group, IDWALK_CB_NOP);
- if (object->soft->effector_weights) {
- BKE_LIB_FOREACHID_PROCESS_IDSUPER(
- data, object->soft->effector_weights->group, IDWALK_CB_NOP);
- }
- }
+ // if (object->soft->effector_weights) {
+ // BKE_LIB_FOREACHID_PROCESS_IDSUPER(
+ // data, object->soft->effector_weights->group, IDWALK_CB_NOP);
+ // }
+ // }
}
static void object_foreach_path_pointcache(ListBase *ptcache_list,
@@ -562,12 +562,12 @@ static void object_blend_write(BlendWriter *writer, ID *id, const void *id_addre
BLO_write_struct(writer, PartDeflect, ob->pd);
if (ob->soft) {
/* Set deprecated pointers to prevent crashes of older Blenders */
- ob->soft->pointcache = ob->soft->shared->pointcache;
- ob->soft->ptcaches = ob->soft->shared->ptcaches;
+ // ob->soft->pointcache = ob->soft->shared->pointcache;
+ // ob->soft->ptcaches = ob->soft->shared->ptcaches;
BLO_write_struct(writer, SoftBody, ob->soft);
BLO_write_struct(writer, SoftBody_Shared, ob->soft->shared);
BKE_ptcache_blend_write(writer, &(ob->soft->shared->ptcaches));
- BLO_write_struct(writer, EffectorWeights, ob->soft->effector_weights);
+ // BLO_write_struct(writer, EffectorWeights, ob->soft->effector_weights);
}
if (ob->rigidbody_object) {
@@ -715,21 +715,21 @@ static void object_blend_read_data(BlendDataReader *reader, ID *id)
SoftBody *sb = ob->soft;
sb->bpoint = nullptr; /* init pointers so it gets rebuilt nicely */
- sb->bspring = nullptr;
- sb->scratch = nullptr;
- /* although not used anymore */
- /* still have to be loaded to be compatible with old files */
- BLO_read_pointer_array(reader, (void **)&sb->keys);
- if (sb->keys) {
- for (int a = 0; a < sb->totkey; a++) {
- BLO_read_data_address(reader, &sb->keys[a]);
- }
- }
-
- BLO_read_data_address(reader, &sb->effector_weights);
- if (!sb->effector_weights) {
- sb->effector_weights = BKE_effector_add_weights(nul
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list