Skip to content

Commit 9c8d02b

Browse files
authored
Add 'alignment' for poofs (#6072)
* add poof alignment * put this back * review fixes
1 parent 055cc6e commit 9c8d02b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

code/nebula/neb.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,16 @@ void parse_nebula_table(const char* filename)
288288
poofp->density = 1 / (poofp->density * poofp->density * poofp->density);
289289
}
290290

291+
if (optional_string("$Alignment:")) {
292+
SCP_string type;
293+
stuff_string(type, F_NAME);
294+
295+
if (!stricmp(type.c_str(), "VERTICAL"))
296+
poofp->alignment = vmd_y_vector;
297+
else
298+
Warning(LOCATION, "Unrecognized alignment type '%s' for nebula poof %s", type.c_str(), poofp->name);
299+
}
300+
291301
if (optional_string("$Rotation:"))
292302
poofp->rotation = ::util::parseUniformRange<float>(-1000.0f, 1000.0f);
293303

@@ -833,7 +843,10 @@ void new_poof(size_t poof_info_idx, vec3d* pos) {
833843
new_poof.rot_speed = fl_radians(pinfo->rotation.next());
834844
new_poof.alpha = pinfo->alpha.next();
835845
new_poof.anim_time = frand_range(0.0f, pinfo->bitmap.total_time);
836-
vm_vec_rand_vec(&new_poof.up_vec);
846+
if (pinfo->alignment != vmd_zero_vector)
847+
vm_vec_rand_vec(&new_poof.up_vec);
848+
else
849+
new_poof.up_vec = pinfo->alignment;
837850

838851
Neb2_poofs.push_back(new_poof);
839852
}
@@ -974,10 +987,16 @@ void neb2_render_poofs()
974987
vec3d view_pos;
975988
{
976989
float scalar = -1 / powf((vm_vec_dist(&eye_pos, &pf.pt) / (10 * pf.radius)), 3.f);
990+
if (pinfo->alignment != vmd_zero_vector)
991+
scalar = 0.0f;
977992

978993
vm_vec_scale_add(&view_pos, &eye_pos, &eye_orient.vec.fvec, scalar);
979994

980995
view_pos -= pf.pt;
996+
997+
if (pinfo->alignment != vmd_zero_vector)
998+
vm_project_point_onto_plane(&view_pos, &view_pos, &pinfo->alignment, &vmd_zero_vector);
999+
9811000
vm_vec_normalize(&view_pos);
9821001

9831002
vm_vector_2_matrix(&orient, &view_pos, &pf.up_vec, nullptr);

code/nebula/neb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ typedef struct poof_info {
7272
::util::UniformFloatRange rotation;
7373
float view_dist;
7474
::util::UniformFloatRange alpha;
75+
vec3d alignment;
7576

7677
// These values are dynamic, unlike the above and can change during a mission.
7778
// They are used for fading poof types in and out via sexp
@@ -92,6 +93,7 @@ typedef struct poof_info {
9293
fade_duration = -1;
9394
fade_in = true;
9495
fade_multiplier = -1.0f;
96+
alignment = vmd_zero_vector;
9597
}
9698
} poof_info;
9799

0 commit comments

Comments
 (0)