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

Method OnViewMoveCameraToCurrentObject

editor/MainFrm.cpp:3402–3433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3400#define OBJECT_PLACE_DIST 10.0
3401bool MoveObject(object *obj, vector *newpos);
3402
3403void CMainFrame::OnViewMoveCameraToCurrentObject() {
3404 object *objp = &Objects[Cur_object_index];
3405 vector pos;
3406 matrix orient;
3407 fvi_query fq;
3408 fvi_info hit_info;
3409
3410 // Turn the viewer around so facing the object
3411 orient.fvec = -objp->orient.fvec;
3412 orient.rvec = -objp->orient.rvec;
3413 orient.uvec = objp->orient.uvec;
3414
3415 // Move the viewer to the object
3416 MoveViewer(&objp->pos, objp->roomnum, &orient);
3417
3418 // Calculate a position a little in front of the object
3419 pos = Viewer_object->pos - (Viewer_object->orient.fvec * OBJECT_PLACE_DIST);
3420
3421 // Follow vector from start position to desired end position, & move as far as we can
3422 fq.p0 = &Viewer_object->pos;
3423 fq.startroom = Viewer_object->roomnum;
3424 fq.p1 = &pos;
3425 fq.thisobjnum = OBJNUM(Viewer_object);
3426 fq.ignore_obj_list = NULL;
3427 fq.flags = 0;
3428 fq.rad = 0.0;
3429
3430 fvi_FindIntersection(&fq, &hit_info);
3431
3432 // Move the viewer to the new position
3433 MoveViewer(&hit_info.hit_pnt, hit_info.hit_room, NULL);
3434}
3435
3436void SelectObject(int objnum);

Callers

nothing calls this directly

Calls 2

MoveViewerFunction · 0.85
fvi_FindIntersectionFunction · 0.85

Tested by

no test coverage detected