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:
Diffstat (limited to 'source/blender/modifiers/intern/MOD_simulation.cc')
-rw-r--r--source/blender/modifiers/intern/MOD_simulation.cc104
1 files changed, 45 insertions, 59 deletions
diff --git a/source/blender/modifiers/intern/MOD_simulation.cc b/source/blender/modifiers/intern/MOD_simulation.cc
index d009eef00e6..0766c59cda6 100644
--- a/source/blender/modifiers/intern/MOD_simulation.cc
+++ b/source/blender/modifiers/intern/MOD_simulation.cc
@@ -32,6 +32,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "DNA_defaults.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
@@ -64,18 +65,28 @@
using blender::float3;
-static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
+static void initData(ModifierData *md)
+{
+ SimulationModifierData *smd = (SimulationModifierData *)md;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(smd, modifier));
+
+ MEMCPY_STRUCT_AFTER(smd, DNA_struct_default_get(SimulationModifierData), modifier);
+}
+
+static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *UNUSED(ctx))
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
- if (smd->simulation) {
- DEG_add_simulation_relation(ctx->node, smd->simulation, "Accessed Simulation");
- }
+ UNUSED_VARS(smd);
}
-static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
+static void foreachIDLink(ModifierData *md,
+ Object *UNUSED(ob),
+ IDWalkFunc UNUSED(walk),
+ void *UNUSED(userData))
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
- walk(userData, ob, (ID **)&smd->simulation, IDWALK_CB_USER);
+ UNUSED_VARS(smd);
}
static bool isDisabled(const struct Scene *UNUSED(scene),
@@ -83,41 +94,16 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
bool UNUSED(useRenderParams))
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
- return smd->simulation == nullptr;
-}
-
-static const ParticleSimulationState *find_particle_state(SimulationModifierData *smd)
-{
- return reinterpret_cast<const ParticleSimulationState *>(
- BKE_simulation_state_try_find_by_name_and_type(
- smd->simulation, smd->data_path, SIM_TYPE_NAME_PARTICLE_SIMULATION));
+ UNUSED_VARS(smd);
+ return false;
}
static PointCloud *modifyPointCloud(ModifierData *md,
const ModifierEvalContext *UNUSED(ctx),
- PointCloud *input_pointcloud)
+ PointCloud *pointcloud)
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
- const ParticleSimulationState *state = find_particle_state(smd);
- if (state == nullptr) {
- return input_pointcloud;
- }
-
- PointCloud *pointcloud = BKE_pointcloud_new_for_eval(input_pointcloud, state->tot_particles);
- if (state->tot_particles == 0) {
- return pointcloud;
- }
-
- const float3 *positions = static_cast<const float3 *>(
- CustomData_get_layer_named(&state->attributes, CD_PROP_FLOAT3, "Position"));
- const float *radii = static_cast<const float *>(
- CustomData_get_layer_named(&state->attributes, CD_PROP_FLOAT, "Radius"));
- memcpy(pointcloud->co, positions, sizeof(float3) * state->tot_particles);
-
- for (int i = 0; i < state->tot_particles; i++) {
- pointcloud->radius[i] = radii[i];
- }
-
+ UNUSED_VARS(smd);
return pointcloud;
}
@@ -131,8 +117,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
- uiItemR(layout, ptr, "simulation", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "data_path", 0, NULL, ICON_NONE);
+ uiItemL(layout, "This modifier does nothing currently", ICON_INFO);
modifier_panel_end(layout, ptr);
}
@@ -145,63 +130,64 @@ static void panelRegister(ARegionType *region_type)
static void blendWrite(BlendWriter *writer, const ModifierData *md)
{
const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md);
- BLO_write_string(writer, smd->data_path);
+ UNUSED_VARS(smd, writer);
}
static void blendRead(BlendDataReader *reader, ModifierData *md)
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
- BLO_read_data_address(reader, &smd->data_path);
+ UNUSED_VARS(smd, reader);
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md);
SimulationModifierData *tsmd = reinterpret_cast<SimulationModifierData *>(target);
+ UNUSED_VARS(smd, tsmd);
BKE_modifier_copydata_generic(md, target, flag);
- if (smd->data_path != nullptr) {
- tsmd->data_path = BLI_strdup(smd->data_path);
- }
}
static void freeData(ModifierData *md)
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
- if (smd->data_path) {
- MEM_freeN(smd->data_path);
- }
+ UNUSED_VARS(smd);
}
ModifierTypeInfo modifierType_Simulation = {
/* name */ "Simulation",
/* structName */ "SimulationModifierData",
/* structSize */ sizeof(SimulationModifierData),
+#ifdef WITH_GEOMETRY_NODES
+ /* srna */ &RNA_SimulationModifier,
+#else
+ /* srna */ &RNA_Modifier,
+#endif
/* type */ eModifierTypeType_None,
/* flags */ (ModifierTypeFlag)0,
+ /* icon */ ICON_PHYSICS, /* TODO: Use correct icon. */
/* copyData */ copyData,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* modifyMesh */ NULL,
- /* modifyHair */ NULL,
+ /* deformVerts */ nullptr,
+ /* deformMatrices */ nullptr,
+ /* deformVertsEM */ nullptr,
+ /* deformMatricesEM */ nullptr,
+ /* modifyMesh */ nullptr,
+ /* modifyHair */ nullptr,
/* modifyPointCloud */ modifyPointCloud,
- /* modifyVolume */ NULL,
+ /* modifyVolume */ nullptr,
- /* initData */ NULL,
- /* requiredDataMask */ NULL,
+ /* initData */ initData,
+ /* requiredDataMask */ nullptr,
/* freeData */ freeData,
/* isDisabled */ isDisabled,
/* updateDepsgraph */ updateDepsgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
- /* foreachObjectLink */ NULL,
+ /* dependsOnTime */ nullptr,
+ /* dependsOnNormals */ nullptr,
/* foreachIDLink */ foreachIDLink,
- /* foreachTexLink */ NULL,
- /* freeRuntimeData */ NULL,
+ /* foreachTexLink */ nullptr,
+ /* freeRuntimeData */ nullptr,
/* panelRegister */ panelRegister,
/* blendWrite */ blendWrite,
/* blendRead */ blendRead,