@@ -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 );
0 commit comments