Geometry Nodes: make function for mixing baked data more reusable
The bake node will need this as well (#115466).
This commit is contained in:
@@ -120,6 +120,11 @@ void copy_with_checked_indices(const GVArray &src,
|
||||
const IndexMask &mask,
|
||||
GMutableSpan dst);
|
||||
|
||||
void mix_baked_data_item(const eNodeSocketDatatype socket_type,
|
||||
void *prev,
|
||||
const void *next,
|
||||
const float factor);
|
||||
|
||||
namespace enums {
|
||||
|
||||
const EnumPropertyItem *attribute_type_type_with_socket_fn(bContext * /*C*/,
|
||||
|
||||
@@ -168,11 +168,7 @@ bke::bake::BakeState move_values_to_simulation_state(
|
||||
return bake_state;
|
||||
}
|
||||
|
||||
} // namespace blender::nodes
|
||||
|
||||
namespace blender::nodes::node_geo_simulation_output_cc {
|
||||
|
||||
NODE_STORAGE_FUNCS(NodeGeometrySimulationOutput);
|
||||
namespace mix_baked_data_details {
|
||||
|
||||
static bool sharing_info_equal(const ImplicitSharingInfo *a, const ImplicitSharingInfo *b)
|
||||
{
|
||||
@@ -388,12 +384,15 @@ static void mix_geometries(GeometrySet &prev, const GeometrySet &next, const flo
|
||||
}
|
||||
}
|
||||
|
||||
static void mix_simulation_state(const NodeSimulationItem &item,
|
||||
void *prev,
|
||||
const void *next,
|
||||
const float factor)
|
||||
} // namespace mix_baked_data_details
|
||||
|
||||
void mix_baked_data_item(const eNodeSocketDatatype socket_type,
|
||||
void *prev,
|
||||
const void *next,
|
||||
const float factor)
|
||||
{
|
||||
switch (eNodeSocketDatatype(item.socket_type)) {
|
||||
using namespace mix_baked_data_details;
|
||||
switch (socket_type) {
|
||||
case SOCK_GEOMETRY: {
|
||||
mix_geometries(
|
||||
*static_cast<GeometrySet *>(prev), *static_cast<const GeometrySet *>(next), factor);
|
||||
@@ -405,7 +404,7 @@ static void mix_simulation_state(const NodeSimulationItem &item,
|
||||
case SOCK_BOOLEAN:
|
||||
case SOCK_ROTATION:
|
||||
case SOCK_RGBA: {
|
||||
const CPPType &type = get_simulation_item_cpp_type(item);
|
||||
const CPPType &type = get_simulation_item_cpp_type(socket_type);
|
||||
const bke::ValueOrFieldCPPType &value_or_field_type =
|
||||
*bke::ValueOrFieldCPPType::get_from_self(type);
|
||||
if (value_or_field_type.is_field(prev) || value_or_field_type.is_field(next)) {
|
||||
@@ -427,6 +426,12 @@ static void mix_simulation_state(const NodeSimulationItem &item,
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::nodes
|
||||
|
||||
namespace blender::nodes::node_geo_simulation_output_cc {
|
||||
|
||||
NODE_STORAGE_FUNCS(NodeGeometrySimulationOutput);
|
||||
|
||||
class LazyFunctionForSimulationOutputNode final : public LazyFunction {
|
||||
const bNode &node_;
|
||||
Span<NodeSimulationItem> simulation_items_;
|
||||
@@ -578,7 +583,10 @@ class LazyFunctionForSimulationOutputNode final : public LazyFunction {
|
||||
simulation_items_, next_state, self_object, compute_context, node_, next_values);
|
||||
|
||||
for (const int i : simulation_items_.index_range()) {
|
||||
mix_simulation_state(simulation_items_[i], output_values[i], next_values[i], mix_factor);
|
||||
mix_baked_data_item(eNodeSocketDatatype(simulation_items_[i].socket_type),
|
||||
output_values[i],
|
||||
next_values[i],
|
||||
mix_factor);
|
||||
}
|
||||
|
||||
for (const int i : simulation_items_.index_range()) {
|
||||
|
||||
Reference in New Issue
Block a user