[Bf-blender-cvs] [5f96f793430] particle-solver-dev: store some more information for collision objects
Jacques Lucke
noreply at git.blender.org
Tue Mar 10 11:26:31 CET 2020
Commit: 5f96f79343082e4012d88faaf6a840bd6a5310df
Author: Jacques Lucke
Date: Tue Mar 10 11:25:16 2020 +0100
Branches: particle-solver-dev
https://developer.blender.org/rB5f96f79343082e4012d88faaf6a840bd6a5310df
store some more information for collision objects
===================================================================
M release/scripts/startup/nodes/bparticle_nodes/collision_object.py
M source/blender/simulations/bparticles/integrator.cpp
M source/blender/simulations/bparticles/node_frontend.cpp
M source/blender/simulations/bparticles/simulate.cpp
M source/blender/simulations/bparticles/simulate.hpp
===================================================================
diff --git a/release/scripts/startup/nodes/bparticle_nodes/collision_object.py b/release/scripts/startup/nodes/bparticle_nodes/collision_object.py
index 31cdd1f3b34..06298a76b82 100644
--- a/release/scripts/startup/nodes/bparticle_nodes/collision_object.py
+++ b/release/scripts/startup/nodes/bparticle_nodes/collision_object.py
@@ -8,4 +8,5 @@ class CollisionObjectNode(bpy.types.Node, SimulationNode):
def declaration(self, builder: NodeBuilder):
builder.fixed_input("object", "Object", "Object", display_name=False)
+ builder.fixed_input("damping", "Damping", "Float", default=0.5)
builder.influences_output("collider", "Collider")
diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp
index 676e41e13ef..f6ebcb765b3 100644
--- a/source/blender/simulations/bparticles/integrator.cpp
+++ b/source/blender/simulations/bparticles/integrator.cpp
@@ -64,7 +64,7 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
velocity_offsets);
}
-BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &interface,
+BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &UNUSED(interface),
MutableArrayRef<float3> r_force)
{
r_force.fill({0, 0, 0});
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 151cb9889cd..994a659b16e 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -66,7 +66,7 @@ class InfluencesCollector {
StringMultiMap<Event *> m_events;
StringMultiMap<OffsetHandler *> m_offset_handlers;
StringMap<AttributesInfoBuilder *> m_attributes;
- StringMultiMap<Object *> m_collision_objects;
+ StringMultiMap<CollisionObject> m_collision_objects;
};
class FunctionTreeData {
@@ -695,13 +695,16 @@ class FNodeInfluencesBuilder {
}
}
- void add_collision_object(ArrayRef<std::string> system_names, Object *object)
+ void add_collision_object(ArrayRef<std::string> system_names, CollisionObject collision_object)
{
for (StringRef system_name : system_names) {
- if (!m_influences_collector.m_collision_objects.lookup_default(system_name)
- .contains(object)) {
- m_influences_collector.m_collision_objects.add(system_name, object);
+ for (const CollisionObject &existing_collider :
+ m_influences_collector.m_collision_objects.lookup_default(system_name)) {
+ if (existing_collider.object == collision_object.object) {
+ return;
+ }
}
+ m_influences_collector.m_collision_objects.add(system_name, collision_object);
}
}
@@ -1048,18 +1051,27 @@ static void PARSE_collision_object(FNodeInfluencesBuilder &builder)
{
ArrayRef<std::string> system_names = builder.find_target_system_names(0, "Collider");
- Optional<NamedGenericTupleRef> inputs = builder.compute_inputs({0});
+ Optional<NamedGenericTupleRef> inputs = builder.compute_inputs({0, 1});
if (!inputs.has_value()) {
return;
}
ObjectIDHandle object_handle = inputs->relocate_out<ObjectIDHandle>(0, "Object");
Object *object = builder.id_handle_lookup().lookup(object_handle);
+
if (object == nullptr || object->type != OB_MESH) {
return;
}
- builder.add_collision_object(system_names, object);
+ float damping = inputs->get<float>(1, "Damping");
+
+ float4x4 local_to_world_end = object->obmat;
+ float4x4 local_to_world_begin =
+ builder.world_transition().update_float4x4(object->id.name, "obmat", object->obmat).start;
+
+ CollisionObject collision_object = {object, local_to_world_begin, local_to_world_end, damping};
+
+ builder.add_collision_object(system_names, collision_object);
}
static StringMap<ParseNodeCallback, BLI::RawAllocator> create_node_parsers_map()
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index bf19b82cf6d..e28788e15fa 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -143,7 +143,13 @@ void simulate_particles(SimulationState &simulation_state,
systems_to_simulate.foreach_item([](StringRef name, ParticleSystemInfo &system_info) {
system_info.collision_objects.print_as_lines(
- name, [](Object *object) { std::cout << object->id.name; });
+ name, [](const CollisionObject &collision_object) {
+ std::cout << collision_object.object->id.name
+ << " - Damping: " << collision_object.damping << " - Location Old: "
+ << float3(collision_object.local_to_world_start.values[3])
+ << " - Location New: "
+ << float3(collision_object.local_to_world_end.values[3]);
+ });
});
ParticlesState &particles_state = simulation_state.particles();
diff --git a/source/blender/simulations/bparticles/simulate.hpp b/source/blender/simulations/bparticles/simulate.hpp
index 0a79e770308..521bda02d9b 100644
--- a/source/blender/simulations/bparticles/simulate.hpp
+++ b/source/blender/simulations/bparticles/simulate.hpp
@@ -11,11 +11,19 @@
namespace BParticles {
+struct CollisionObject {
+ Object *object;
+ float4x4 local_to_world_start;
+ float4x4 local_to_world_end;
+ float damping;
+};
+
struct ParticleSystemInfo {
ArrayRef<Force *> forces;
ArrayRef<Event *> events;
ArrayRef<OffsetHandler *> offset_handlers;
- ArrayRef<Object *> collision_objects;
+
+ ArrayRef<CollisionObject> collision_objects;
};
void simulate_particles(SimulationState &state,
More information about the Bf-blender-cvs
mailing list