Skip to content

Commit 4c53677

Browse files
committed
allow props to block suns
1 parent 6139d60 commit 4c53677

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

code/prop/prop.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -626,27 +626,6 @@ void prop_render(object* obj, model_draw_list* scene)
626626
model_render_queue(&render_info, scene, pip->model_num, &obj->orient, &obj->pos);
627627
}
628628

629-
void spawn_test_prop()
630-
{
631-
int prop_idx = prop_info_lookup("TestProp"); // whatever’s in your props.tbl
632-
if (prop_idx < 0) {
633-
mprintf(("TEST: Prop not found!\n"));
634-
return;
635-
}
636-
637-
matrix mtx = vmd_identity_matrix;
638-
vec3d pos = ZERO_VECTOR;
639-
pos.xyz.z = -2000.0f;
640-
641-
int objnum = prop_create(&mtx, &pos, prop_idx, "Test Prop");
642-
643-
if (objnum >= 0) {
644-
mprintf(("TEST: Spawned prop '%s' at objnum %d\n", Prop_info[prop_idx].name, objnum));
645-
} else {
646-
mprintf(("TEST: Failed to create prop\n"));
647-
}
648-
}
649-
650629
void props_level_close()
651630
{
652631
for (auto& opt_prop : Props) {

code/prop/prop.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,4 @@ prop* prop_id_lookup(int id);
7373

7474
void change_prop_type(int n, int prop_type);
7575

76-
int prop_check_collision(object* prop_obj, object* other_obj, vec3d* hitpos, collision_info_struct* prop_hit_info);
77-
78-
void spawn_test_prop();
76+
int prop_check_collision(object* prop_obj, object* other_obj, vec3d* hitpos, collision_info_struct* prop_hit_info);

code/ship/shipfx.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "object/objectsnd.h"
3434
#include "parse/parselo.h"
3535
#include "playerman/player.h"
36+
#include "prop/prop.h"
3637
#include "render/3d.h" // needed for View_position, which is used when playing a 3D sound
3738
#include "render/batching.h"
3839
#include "scripting/hook_api.h"
@@ -828,6 +829,30 @@ bool shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int light_n )
828829
}
829830
}
830831

832+
for (const auto& prop : Props) {
833+
if (prop.has_value()) {
834+
objp = &Objects[prop->objnum];
835+
if (objp->flags[Object::Object_Flags::Should_be_dead])
836+
continue;
837+
838+
if (src_obj != objp) {
839+
vm_vec_scale_add(&rp1, &rp0, &light_dir, objp->radius * 10.0f);
840+
841+
mc.model_instance_num = prop->model_instance_num;
842+
mc.model_num = Prop_info[prop->prop_info_index].model_num;
843+
mc.orient = &objp->orient;
844+
mc.pos = &objp->pos;
845+
mc.p0 = &rp0;
846+
mc.p1 = &rp1;
847+
mc.flags = MC_CHECK_MODEL;
848+
849+
if (model_collide(&mc)) {
850+
return true;
851+
}
852+
}
853+
}
854+
}
855+
831856
// Check all the big hull debris pieces.
832857
for (auto &db: Debris) {
833858
if ( !(db.flags[Debris_Flags::Used]) || !db.is_hull ){

0 commit comments

Comments
 (0)