Particles: use CD_PROP_FLOAT3 instead of CD_LOCATION
`CD_LOCATION` was only used temporarily due to the lack of a better alternative. This also removes the name from `CD_LOCATION` again, because at most one layer of this type should exist.
This commit is contained in:
@@ -1868,7 +1868,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
|
|||||||
/* 42: CD_SCULPT_FACE_SETS */
|
/* 42: CD_SCULPT_FACE_SETS */
|
||||||
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
/* 43: CD_LOCATION */
|
/* 43: CD_LOCATION */
|
||||||
{sizeof(float[3]), "vec3f", 1, "Location", NULL, NULL, NULL, NULL, NULL},
|
{sizeof(float[3]), "vec3f", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
/* 44: CD_RADIUS */
|
/* 44: CD_RADIUS */
|
||||||
{sizeof(float), "MFloatProperty", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
{sizeof(float), "MFloatProperty", 1, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
/* 45: CD_HAIRCURVE */
|
/* 45: CD_HAIRCURVE */
|
||||||
|
|||||||
@@ -1900,7 +1900,7 @@ static int ptcache_sim_particle_write(int index, void *state_v, void **data, int
|
|||||||
ParticleSimulationState *state = (ParticleSimulationState *)state_v;
|
ParticleSimulationState *state = (ParticleSimulationState *)state_v;
|
||||||
|
|
||||||
const float *positions = (const float *)CustomData_get_layer_named(
|
const float *positions = (const float *)CustomData_get_layer_named(
|
||||||
&state->attributes, CD_LOCATION, "Position");
|
&state->attributes, CD_PROP_FLOAT3, "Position");
|
||||||
|
|
||||||
PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, positions + (index * 3));
|
PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, positions + (index * 3));
|
||||||
|
|
||||||
@@ -1913,7 +1913,7 @@ static void ptcache_sim_particle_read(
|
|||||||
|
|
||||||
BLI_assert(index < state->tot_particles);
|
BLI_assert(index < state->tot_particles);
|
||||||
float *positions = (float *)CustomData_get_layer_named(
|
float *positions = (float *)CustomData_get_layer_named(
|
||||||
&state->attributes, CD_LOCATION, "Position");
|
&state->attributes, CD_PROP_FLOAT3, "Position");
|
||||||
|
|
||||||
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, positions + (index * 3));
|
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, positions + (index * 3));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,13 +168,13 @@ namespace blender::bke {
|
|||||||
|
|
||||||
static void ensure_attributes_exist(ParticleSimulationState *state)
|
static void ensure_attributes_exist(ParticleSimulationState *state)
|
||||||
{
|
{
|
||||||
if (CustomData_get_layer_named(&state->attributes, CD_LOCATION, "Position") == nullptr) {
|
if (CustomData_get_layer_named(&state->attributes, CD_PROP_FLOAT3, "Position") == nullptr) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&state->attributes, CD_LOCATION, CD_CALLOC, nullptr, state->tot_particles, "Position");
|
&state->attributes, CD_PROP_FLOAT3, CD_CALLOC, nullptr, state->tot_particles, "Position");
|
||||||
}
|
}
|
||||||
if (CustomData_get_layer_named(&state->attributes, CD_LOCATION, "Velocity") == nullptr) {
|
if (CustomData_get_layer_named(&state->attributes, CD_PROP_FLOAT3, "Velocity") == nullptr) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&state->attributes, CD_LOCATION, CD_CALLOC, nullptr, state->tot_particles, "Velocity");
|
&state->attributes, CD_PROP_FLOAT3, CD_CALLOC, nullptr, state->tot_particles, "Velocity");
|
||||||
}
|
}
|
||||||
if (CustomData_get_layer_named(&state->attributes, CD_PROP_INT32, "ID") == nullptr) {
|
if (CustomData_get_layer_named(&state->attributes, CD_PROP_INT32, "ID") == nullptr) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
@@ -288,7 +288,7 @@ class CustomDataAttributesRef {
|
|||||||
builder.add<int32_t>(layer.name, 0);
|
builder.add<int32_t>(layer.name, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CD_LOCATION: {
|
case CD_PROP_FLOAT3: {
|
||||||
builder.add<float3>(layer.name, {0, 0, 0});
|
builder.add<float3>(layer.name, {0, 0, 0});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ static PointCloud *modifyPointCloud(ModifierData *md,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const float3 *positions = (const float3 *)CustomData_get_layer_named(
|
const float3 *positions = (const float3 *)CustomData_get_layer_named(
|
||||||
&state->attributes, CD_LOCATION, "Position");
|
&state->attributes, CD_PROP_FLOAT3, "Position");
|
||||||
memcpy(pointcloud->co, positions, sizeof(float3) * state->tot_particles);
|
memcpy(pointcloud->co, positions, sizeof(float3) * state->tot_particles);
|
||||||
|
|
||||||
for (int i = 0; i < state->tot_particles; i++) {
|
for (int i = 0; i < state->tot_particles; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user