MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnRegroundButton

Method OnRegroundButton

editor/ObjectDialog.cpp:1188–1236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1186}
1187
1188void CObjectDialog::OnRegroundButton() {
1189 if (Reground_id >= 0 && Object_info[Reground_id].type != OBJ_NONE) {
1190 int i;
1191 for (i = 0; i <= Highest_object_index; i++) {
1192 vector gp;
1193 object *obj = &Objects[i];
1194
1195 if (obj->type == OBJ_ROBOT || obj->type == OBJ_CLUTTER || obj->type == OBJ_POWERUP || obj->type == OBJ_BUILDING) {
1196 if (obj->id == Reground_id && PhysCalcGround(&gp, NULL, &Objects[i], 0)) {
1197 fvi_info hit_info;
1198 fvi_query fq;
1199 int fate;
1200 vector start = obj->pos + obj->size * 0.8f * obj->orient.uvec;
1201 vector end = obj->pos - obj->size * 2.0f * obj->orient.uvec;
1202
1203 fq.p0 = &start;
1204 fq.p1 = &end;
1205 fq.startroom = obj->roomnum;
1206
1207 fq.rad = 0.0f;
1208 fq.flags = FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS | FQ_IGNORE_WEAPONS | FQ_IGNORE_MOVING_OBJECTS;
1209 fq.thisobjnum = OBJNUM(obj);
1210 fq.ignore_obj_list = NULL;
1211
1212 fate = fvi_FindIntersection(&fq, &hit_info);
1213
1214 if (fate != HIT_NONE) {
1215 float ps;
1216 float pr;
1217 float diff;
1218
1219 ps = (gp - obj->pos) * obj->orient.uvec;
1220 pr = (hit_info.hit_pnt - obj->pos) * obj->orient.uvec;
1221
1222 if (ps != pr) {
1223 diff = ps - pr;
1224 obj->pos -= diff * obj->orient.uvec;
1225 ObjSetPos(obj, &obj->pos, obj->roomnum, NULL, false);
1226
1227 World_changed = 1;
1228 }
1229 }
1230 }
1231 }
1232 }
1233 }
1234
1235 UpdateDialog();
1236}
1237
1238extern bool RotateObject(int objnum, angle p, angle h, angle b);
1239

Callers

nothing calls this directly

Calls 3

PhysCalcGroundFunction · 0.85
fvi_FindIntersectionFunction · 0.85
ObjSetPosFunction · 0.85

Tested by

no test coverage detected