Skip to content

Commit 4b76144

Browse files
authored
Merge pull request scp-fs2open#7598 from Goober5000/fix/prop_selection
fix prop selection using model geometry instead of bounding sphere in FRED
2 parents b4a321d + dd83a20 commit 4b76144

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

fred2/fredrender.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,21 +1424,29 @@ int object_check_collision(object *objp, vec3d *p0, vec3d *p1, vec3d *hitpos) {
14241424
return 0;
14251425
}
14261426

1427-
// PROP HERE?
1427+
if (objp->type == OBJ_PROP) {
1428+
if (!Props[objp->instance].has_value())
1429+
return 0;
1430+
}
14281431

14291432
if (objp->flags[Object::Object_Flags::Hidden, Object::Object_Flags::Locked_from_editing])
14301433
return 0;
14311434

1432-
if ((Show_ship_models || Show_outlines) && (objp->type == OBJ_SHIP)) {
1433-
mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; // Fill in the model to check
1435+
mc.model_instance_num = -1;
1436+
1437+
if ((Show_ship_models || Show_outlines) && (objp->type == OBJ_SHIP || objp->type == OBJ_START)) {
1438+
auto& shp = Ships[objp->instance];
1439+
mc.model_num = Ship_info[shp.ship_info_index].model_num; // Fill in the model to check
1440+
mc.model_instance_num = shp.model_instance_num;
14341441

1435-
} else if ((Show_ship_models || Show_outlines) && (objp->type == OBJ_START)) {
1436-
mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; // Fill in the model to check
1442+
} else if ((Show_ship_models || Show_outlines) && (objp->type == OBJ_PROP)) {
1443+
auto& prp = Props[objp->instance].value();
1444+
mc.model_num = Prop_info[prp.prop_info_index].model_num; // Fill in the model to check
1445+
mc.model_instance_num = prp.model_instance_num;
14371446

14381447
} else
14391448
return fvi_ray_sphere(hitpos, p0, p1, &objp->pos, (objp->radius > 0.1f) ? objp->radius : LOLLIPOP_SIZE);
14401449

1441-
mc.model_instance_num = -1;
14421450
mc.orient = &objp->orient; // The object's orient
14431451
mc.pos = &objp->pos; // The object's position
14441452
mc.p0 = p0; // Point 1 of ray to check

qtfred/src/mission/EditorViewport.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -720,15 +720,19 @@ int EditorViewport::object_check_collision(object* objp, vec3d* p0, vec3d* p1, v
720720
return 0;
721721
}
722722

723-
if ((view.Show_ship_models || view.Show_outlines) && (objp->type == OBJ_SHIP)) {
724-
mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; // Fill in the model to check
725-
} else if ((view.Show_ship_models || view.Show_outlines) && (objp->type == OBJ_START)) {
726-
mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; // Fill in the model to check
723+
mc.model_instance_num = -1;
724+
725+
if ((view.Show_ship_models || view.Show_outlines) && (objp->type == OBJ_SHIP || objp->type == OBJ_START)) {
726+
auto& shp = Ships[objp->instance];
727+
mc.model_num = Ship_info[shp.ship_info_index].model_num; // Fill in the model to check
728+
mc.model_instance_num = shp.model_instance_num;
729+
} else if ((view.Show_ship_models || view.Show_outlines) && (objp->type == OBJ_PROP)) {
730+
auto& prp = Props[objp->instance].value();
731+
mc.model_num = Prop_info[prp.prop_info_index].model_num; // Fill in the model to check
732+
mc.model_instance_num = prp.model_instance_num;
727733
} else {
728734
return fvi_ray_sphere(hitpos, p0, p1, &objp->pos, (objp->radius > 0.1f) ? objp->radius : LOLLIPOP_SIZE);
729735
}
730-
731-
mc.model_instance_num = -1;
732736
mc.orient = &objp->orient; // The object's orient
733737
mc.pos = &objp->pos; // The object's position
734738
mc.p0 = p0; // Point 1 of ray to check

0 commit comments

Comments
 (0)