Glitter: Don't reference ParticleInst in new RenderElement

This commit is contained in:
korenkonder
2024-07-29 10:08:10 +03:00
parent f666e76287
commit c7c14fa911
5 changed files with 79 additions and 80 deletions
+3 -4
View File
@@ -608,7 +608,6 @@ namespace Glitter {
void CalcDisp();
void CalcDisp(RenderGroup* rend_group);
void CheckUseCamera();
void Disp(Glitter::DispType disp_type);
void Disp(RenderGroup* rend_group);
@@ -1125,7 +1124,7 @@ namespace Glitter {
void Copy(ParticleInstX* dst, float_t emission);
void Emit(int32_t dup_count, int32_t count, float_t emission, float_t frame);
void EmitParticle(RenderElementX* rend_elem, EmitterInstX* emit_inst,
ParticleInstX::Data* ptcl_inst_data, int32_t index, uint8_t step, RandomX* random);
ParticleX::Data* ptcl_data, int32_t index, uint8_t step, RandomX* random);
void GetColor(RenderElementX* rend_elem, float_t color_scale);
bool GetExtAnimScale(vec3* ext_anim_scale, float_t* ext_scale);
void GetExtColor(float_t& r, float_t& g, float_t& b, float_t& a);
@@ -1235,7 +1234,7 @@ namespace Glitter {
void Ctrl(float_t delta_frame, bool copy_mats);
void CtrlParticle(RenderElementX* rend_elem, float_t delta_frame);
void DeleteBuffers(bool a2);
void Emit(ParticleInstX::Data* ptcl_inst_data,
void Emit(ParticleX::Data* ptcl_data,
EmitterInstX* emit_inst, int32_t dup_count, int32_t count, float_t frame);
void Free();
void FreeData();
@@ -1322,7 +1321,7 @@ namespace Glitter {
void InitLocusHistory(ParticleInstX* ptcl_inst, RandomX* random);
void InitMesh(EmitterInstX* emit_inst,
ParticleInstX::Data* ptcl_inst_data, int32_t index, RandomX* random);
ParticleX::Data* ptcl_data, int32_t index, RandomX* random);
};
struct SceneEffect {
+2 -2
View File
@@ -40,8 +40,8 @@ namespace Glitter {
deceleration(), deceleration_random(), reflection_coeff(), reflection_coeff_random(), rebound_plane_y(),
uv_index_type(), uv_index(), frame_step_uv(), uv_index_start(), uv_index_end(), uv_index_count(),
uv_scroll_add_scale(), uv_scroll_2nd_add_scale(), split_u(), split_v(), blend_mode(), mask_blend_mode(),
sub_flags(), count(), locus_history_size(), locus_history_size_random(), draw_flags(), emission(),
tex_hash(), mask_tex_hash(), texture(), mask_texture(), unk0(), unk1(), unk2(), unk3(), unk4(), mesh() {
sub_flags(), count(), locus_history_size(), locus_history_size_random(), draw_flags(), emission(), tex_hash(),
mask_tex_hash(), texture(), mask_texture(), unk0(), unk1(), unk2(), unk3(), unk4(), mesh() {
}
+46 -46
View File
@@ -193,46 +193,46 @@ namespace Glitter {
}
if (ptcl->data.render_group)
ptcl->data.render_group->Emit(&ptcl->data, ptcl->data.emitter, dup_count, count, frame);
ptcl->data.render_group->Emit(&ptcl->data.data, ptcl->data.emitter, dup_count, count, frame);
}
void ParticleInstX::EmitParticle(RenderElementX* rend_elem, EmitterInstX* emit_inst,
ParticleInstX::Data* ptcl_inst_data, int32_t index, uint8_t step, RandomX* random) {
ParticleX::Data* ptcl_data, int32_t index, uint8_t step, RandomX* random) {
rend_elem->random = random->GetValue();
rend_elem->frame = 0.0f;
rend_elem->rebound_time = 0.0f;
rend_elem->uv = 0.0f;
rend_elem->uv_index = ptcl_inst_data->data.uv_index;
rend_elem->uv_index = ptcl_data->uv_index;
rend_elem->step = step;
rend_elem->fade_in_frames = random->GetFloat((float_t)ptcl_inst_data->data.fade_in_random)
+ (float_t)ptcl_inst_data->data.fade_in;
rend_elem->fade_in_frames = random->GetFloat((float_t)ptcl_data->fade_in_random)
+ (float_t)ptcl_data->fade_in;
if (rend_elem->fade_in_frames < 0.0f)
rend_elem->fade_in_frames = 0.0f;
rend_elem->fade_out_frames = random->GetFloat((float_t)ptcl_inst_data->data.fade_out_random)
+ (float_t)ptcl_inst_data->data.fade_out;
rend_elem->fade_out_frames = random->GetFloat((float_t)ptcl_data->fade_out_random)
+ (float_t)ptcl_data->fade_out;
if (rend_elem->fade_out_frames < 0.0f)
rend_elem->fade_out_frames = 0.0f;
rend_elem->life_time = random->GetFloat((float_t)ptcl_inst_data->data.life_time_random)
+ (float_t)ptcl_inst_data->data.life_time;
rend_elem->life_time = random->GetFloat((float_t)ptcl_data->life_time_random)
+ (float_t)ptcl_data->life_time;
if (rend_elem->life_time < 0.0f)
rend_elem->life_time = 0.0f;
rend_elem->life_time += rend_elem->fade_in_frames + rend_elem->fade_out_frames;
rend_elem->color = ptcl_inst_data->data.color;
if (ptcl_inst_data->data.draw_type == DIRECTION_PARTICLE_ROTATION
|| ptcl_inst_data->data.type == PARTICLE_MESH) {
rend_elem->rotation.x = random->GetFloat(ptcl_inst_data->data.rotation_random.x)
+ ptcl_inst_data->data.rotation.x;
rend_elem->rotation_add.x = random->GetFloat(ptcl_inst_data->data.rotation_add_random.x)
+ ptcl_inst_data->data.rotation_add.x;
rend_elem->rotation.y = random->GetFloat(ptcl_inst_data->data.rotation_random.y)
+ ptcl_inst_data->data.rotation.y;
rend_elem->rotation_add.y = random->GetFloat(ptcl_inst_data->data.rotation_add_random.y)
+ ptcl_inst_data->data.rotation_add.y;
rend_elem->color = ptcl_data->color;
if (ptcl_data->draw_type == DIRECTION_PARTICLE_ROTATION
|| ptcl_data->type == PARTICLE_MESH) {
rend_elem->rotation.x = random->GetFloat(ptcl_data->rotation_random.x)
+ ptcl_data->rotation.x;
rend_elem->rotation_add.x = random->GetFloat(ptcl_data->rotation_add_random.x)
+ ptcl_data->rotation_add.x;
rend_elem->rotation.y = random->GetFloat(ptcl_data->rotation_random.y)
+ ptcl_data->rotation.y;
rend_elem->rotation_add.y = random->GetFloat(ptcl_data->rotation_add_random.y)
+ ptcl_data->rotation_add.y;
}
else {
rend_elem->rotation.x = 0.0f;
@@ -242,48 +242,48 @@ namespace Glitter {
}
rend_elem->rot_z_cos = 1.0f;
rend_elem->rot_z_sin = 0.0f;
rend_elem->rotation.z = random->GetFloat(ptcl_inst_data->data.rotation_random.z)
+ ptcl_inst_data->data.rotation.z;
rend_elem->rotation_add.z = random->GetFloat(ptcl_inst_data->data.rotation_add_random.z)
+ ptcl_inst_data->data.rotation_add.z;
rend_elem->rotation.z = random->GetFloat(ptcl_data->rotation_random.z)
+ ptcl_data->rotation.z;
rend_elem->rotation_add.z = random->GetFloat(ptcl_data->rotation_add_random.z)
+ ptcl_data->rotation_add.z;
rend_elem->uv_scroll = 0.0f;
rend_elem->uv_scroll_2nd = 0.0f;
rend_elem->scale = 1.0f;
rend_elem->scale_all = 1.0f;
rend_elem->frame_step_uv = (float_t)ptcl_inst_data->data.frame_step_uv;
rend_elem->frame_step_uv = (float_t)ptcl_data->frame_step_uv;
rend_elem->scale_particle.x = random->GetFloat(ptcl_inst_data->data.scale_random.x)
+ ptcl_inst_data->data.scale.x;
if (ptcl_inst_data->data.flags & PARTICLE_SCALE_Y_BY_X) {
rend_elem->scale_particle.x = random->GetFloat(ptcl_data->scale_random.x)
+ ptcl_data->scale.x;
if (ptcl_data->flags & PARTICLE_SCALE_Y_BY_X) {
rend_elem->scale_particle.y = rend_elem->scale_particle.x;
random->StepValue();
}
else
rend_elem->scale_particle.y = random->GetFloat(ptcl_inst_data->data.scale_random.y)
+ ptcl_inst_data->data.scale.y;
rend_elem->scale_particle.y = random->GetFloat(ptcl_data->scale_random.y)
+ ptcl_data->scale.y;
int32_t max_uv = ptcl_inst_data->data.split_u * ptcl_inst_data->data.split_v;
if (max_uv > 1 && ptcl_inst_data->data.uv_index_count > 1) {
switch (ptcl_inst_data->data.uv_index_type) {
int32_t max_uv = ptcl_data->split_u * ptcl_data->split_v;
if (max_uv > 1 && ptcl_data->uv_index_count > 1) {
switch (ptcl_data->uv_index_type) {
case UV_INDEX_INITIAL_RANDOM_FIXED:
case UV_INDEX_INITIAL_RANDOM_FORWARD:
case UV_INDEX_INITIAL_RANDOM_REVERSE:
rend_elem->uv_index = ptcl_inst_data->data.uv_index_start
+ random->GetInt(ptcl_inst_data->data.uv_index_count);
rend_elem->uv_index = ptcl_data->uv_index_start
+ random->GetInt(ptcl_data->uv_index_count);
break;
}
rend_elem->uv_index = min_def(rend_elem->uv_index, ptcl_inst_data->data.uv_index_end);
rend_elem->uv_index = min_def(rend_elem->uv_index, ptcl_data->uv_index_end);
rend_elem->uv.x = (float_t)(rend_elem->uv_index
% ptcl_inst_data->data.split_u) * ptcl_inst_data->data.split_uv.x;
% ptcl_data->split_u) * ptcl_data->split_uv.x;
rend_elem->uv.y = (float_t)(rend_elem->uv_index
/ ptcl_inst_data->data.split_u) * ptcl_inst_data->data.split_uv.y;
/ ptcl_data->split_u) * ptcl_data->split_uv.y;
}
rend_elem->InitMesh(emit_inst, ptcl_inst_data, index, random);
rend_elem->InitMesh(emit_inst, ptcl_data, index, random);
bool copy_mat = false;
if (ptcl_inst_data->data.flags & PARTICLE_ROTATE_BY_EMITTER
|| ptcl_inst_data->data.draw_type == DIRECTION_EMITTER_ROTATION) {
if (ptcl_data->flags & PARTICLE_ROTATE_BY_EMITTER
|| ptcl_data->draw_type == DIRECTION_EMITTER_ROTATION) {
switch (emit_inst->data.type) {
case EMITTER_CYLINDER:
if (emit_inst->data.cylinder.direction != EMITTER_EMISSION_DIRECTION_NONE)
@@ -305,17 +305,17 @@ namespace Glitter {
if (copy_mat) {
rend_elem->mat = emit_inst->mat;
if (ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
if (ptcl_data->flags & PARTICLE_EMITTER_LOCAL)
mat4_clear_trans(&rend_elem->mat, &rend_elem->mat);
}
else
rend_elem->mat = mat4_identity;
if (ptcl_inst_data->data.type == PARTICLE_LOCUS) {
if (ptcl_data->type == PARTICLE_LOCUS) {
uint32_t locus_history_size = random->GetInt(
-ptcl_inst_data->data.locus_history_size_random,
ptcl_inst_data->data.locus_history_size_random)
+ ptcl_inst_data->data.locus_history_size;
-ptcl_data->locus_history_size_random,
ptcl_data->locus_history_size_random)
+ ptcl_data->locus_history_size;
rend_elem->locus_history = new LocusHistoryX(locus_history_size);
}
random->StepValue();
+11 -11
View File
@@ -25,15 +25,15 @@ namespace Glitter {
}
void RenderElementX::InitMesh(EmitterInstX* emit_inst,
ParticleInstX::Data* ptcl_inst_data, int32_t index, RandomX* random) {
if (ptcl_inst_data->data.flags & (PARTICLE_EMITTER_LOCAL | PARTICLE_ROTATE_BY_EMITTER))
ParticleX::Data* ptcl_data, int32_t index, RandomX* random) {
if (ptcl_data->flags & (PARTICLE_EMITTER_LOCAL | PARTICLE_ROTATE_BY_EMITTER))
base_translation = 0.0f;
else
mat4_get_translation(&emit_inst->mat, &base_translation);
vec3 direction = ptcl_inst_data->data.direction;
vec3 direction = ptcl_data->direction;
vec3 scale;
if (ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
if (ptcl_data->flags & PARTICLE_EMITTER_LOCAL)
scale = 1.0f;
else
scale = emit_inst->scale * emit_inst->scale_all;
@@ -41,7 +41,7 @@ namespace Glitter {
vec3 position = 0.0f;
emit_inst->InitMesh(index, scale, position, direction, random);
if (!(ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL))
if (!(ptcl_data->flags & PARTICLE_EMITTER_LOCAL))
mat4_transform_vector(&emit_inst->mat_rot, &position, &position);
base_translation += position;
@@ -49,22 +49,22 @@ namespace Glitter {
translation_prev = base_translation;
direction = vec3::normalize(direction
+ random->GetVec3(ptcl_inst_data->data.direction_random));
+ random->GetVec3(ptcl_data->direction_random));
if (!(ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL))
if (!(ptcl_data->flags & PARTICLE_EMITTER_LOCAL))
mat4_transform_vector(&emit_inst->mat_rot, &direction, &direction);
base_direction = direction;
this->direction = direction;
float_t speed = random->GetFloat(
ptcl_inst_data->data.speed_random) + ptcl_inst_data->data.speed;
ptcl_data->speed_random) + ptcl_data->speed;
float_t deceleration = random->GetFloat(
ptcl_inst_data->data.deceleration_random) + ptcl_inst_data->data.deceleration;
ptcl_data->deceleration_random) + ptcl_data->deceleration;
base_speed = speed;
this->speed = speed;
this->deceleration = max_def(deceleration, 0.0f);
this->acceleration = ptcl_inst_data->data.acceleration + ptcl_inst_data->data.gravity
+ random->GetVec3(ptcl_inst_data->data.acceleration_random);
this->acceleration = ptcl_data->acceleration + ptcl_data->gravity
+ random->GetVec3(ptcl_data->acceleration_random);
}
}
+17 -17
View File
@@ -254,21 +254,21 @@ namespace Glitter {
if (!particle)
return;
ParticleInstX::Data* data = &particle->data;
blend_mode = data->data.blend_mode;
mask_blend_mode = data->data.mask_blend_mode;
texture = data->data.texture;
mask_texture = data->data.mask_texture;
object.set_id = (uint16_t)data->data.mesh.object_set;
object.id = (uint16_t)data->data.mesh.object;
split_u = data->data.split_u;
split_v = data->data.split_v;
split_uv = data->data.split_uv;
type = data->data.type;
draw_type = data->data.draw_type;
z_offset = data->data.z_offset;
pivot = data->data.pivot;
flags = data->data.flags;
ParticleX::Data* ptcl_data = &particle->data.data;
blend_mode = ptcl_data->blend_mode;
mask_blend_mode = ptcl_data->mask_blend_mode;
texture = ptcl_data->texture;
mask_texture = ptcl_data->mask_texture;
object.set_id = (uint16_t)ptcl_data->mesh.object_set;
object.id = (uint16_t)ptcl_data->mesh.object;
split_u = ptcl_data->split_u;
split_v = ptcl_data->split_v;
split_uv = ptcl_data->split_uv;
type = ptcl_data->type;
draw_type = ptcl_data->draw_type;
z_offset = ptcl_data->z_offset;
pivot = ptcl_data->pivot;
flags = ptcl_data->flags;
if (copy_mats && particle->data.emitter) {
EmitterInstX* emitter = particle->data.emitter;
@@ -373,7 +373,7 @@ namespace Glitter {
}
}
void RenderGroupX::Emit(ParticleInstX::Data* ptcl_inst_data,
void RenderGroupX::Emit(ParticleX::Data* ptcl_data,
EmitterInstX* emit_inst, int32_t dup_count, int32_t count, float_t frame) {
RenderElementX* element;
int64_t i;
@@ -390,7 +390,7 @@ namespace Glitter {
emit_inst->RandomStepValue();
element->frame = frame;
particle->EmitParticle(element, emit_inst, ptcl_inst_data, index, step, random_ptr);
particle->EmitParticle(element, emit_inst, ptcl_data, index, step, random_ptr);
}
}