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:
authorLukas Tönne <lukas.toenne@gmail.com>2022-06-29 22:50:35 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2022-06-29 22:50:35 +0300
commitfa2084ae58a77b1201289b6bedac427f73c762d1 (patch)
treefd99401eb8e742415f59332d115f0f34699f92b6 /source/blender/blenkernel/intern/DerivedMesh.cc
parent0ea282f7462070041b2599389ba61c7ef50426b5 (diff)
Geometry Nodes: Experimental rigid body integration.
This is an exploration of how geometry nodes might be coupled with rigid bodies and iterative simulations in general. It's a very rough-and-ready implementation, not meant as a final version, but rather to prove the possiblity and to find challenging areas where redesign is needed. The core additions are: - Geometry nodes to flag points and/or instances as rigid bodies. - Depsgraph integration to ensure the necessary order of operations between modifiers and rigid body pre/post simulation updates. - Simple cache feature to store arbitrary geometry and loop back into the next iteration.
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.cc')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index ffac89c15e6..368b72dbeb1 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -734,7 +734,8 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
/* return args */
Mesh **r_deform,
Mesh **r_final,
- GeometrySet **r_geometry_set)
+ GeometrySet **r_geometry_set,
+ bool *r_need_caching)
{
/* Input and final mesh. Final mesh is only created the moment the first
* constructive modifier is executed, or a deform modifier needs normals
@@ -875,6 +876,10 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
continue;
}
+ if (r_need_caching && (mti->flags & eModifierTypeFlag_NeedCaching)) {
+ *r_need_caching = true;
+ }
+
if (sculpt_mode && (!has_multires || multires_applied || sculpt_dyntopo)) {
bool unsupported = false;
@@ -1617,6 +1622,7 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
Mesh *mesh_eval = nullptr, *mesh_deform_eval = nullptr;
GeometrySet *geometry_set_eval = nullptr;
+ bool need_caching = false;
mesh_calc_modifiers(depsgraph,
scene,
ob,
@@ -1627,7 +1633,8 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
true,
&mesh_deform_eval,
&mesh_eval,
- &geometry_set_eval);
+ &geometry_set_eval,
+ &need_caching);
/* The modifier stack evaluation is storing result in mesh->runtime.mesh_eval, but this result
* is not guaranteed to be owned by object.
@@ -1647,6 +1654,7 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
ob->runtime.mesh_deform_eval = mesh_deform_eval;
ob->runtime.last_data_mask = *dataMask;
ob->runtime.last_need_mapping = need_mapping;
+ BKE_object_runtime_ensure_geometry_cache(ob, need_caching);
BKE_object_boundbox_calc_from_mesh(ob, mesh_eval);
@@ -1876,7 +1884,7 @@ Mesh *mesh_create_eval_final(Depsgraph *depsgraph,
{
Mesh *result;
mesh_calc_modifiers(
- depsgraph, scene, ob, true, false, dataMask, false, false, nullptr, &result, nullptr);
+ depsgraph, scene, ob, true, false, dataMask, false, false, nullptr, &result, nullptr, nullptr);
return result;
}
@@ -1887,7 +1895,7 @@ Mesh *mesh_create_eval_no_deform(Depsgraph *depsgraph,
{
Mesh *result;
mesh_calc_modifiers(
- depsgraph, scene, ob, false, false, dataMask, false, false, nullptr, &result, nullptr);
+ depsgraph, scene, ob, false, false, dataMask, false, false, nullptr, &result, nullptr, nullptr);
return result;
}
@@ -1898,7 +1906,7 @@ Mesh *mesh_create_eval_no_deform_render(Depsgraph *depsgraph,
{
Mesh *result;
mesh_calc_modifiers(
- depsgraph, scene, ob, false, false, dataMask, false, false, nullptr, &result, nullptr);
+ depsgraph, scene, ob, false, false, dataMask, false, false, nullptr, &result, nullptr, nullptr);
return result;
}