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

Function ShootRaysToObject

Descent3/terrainrender.cpp:980–1009  ·  view source on GitHub ↗

Checks to see if this object can even be seen from our current viewpoint By shooting rays to it Returns true if any of the rays hit

Source from the content-addressed store, hash-verified

978// By shooting rays to it
979// Returns true if any of the rays hit
980int ShootRaysToObject(object *obj) {
981 vector corners[8];
982 if (obj->type == OBJ_ROOM) {
983 room *rp = &Rooms[obj->id];
984 MakePointsFromMinMax(corners, &rp->min_xyz, &rp->max_xyz);
985 } else {
986 MakePointsFromMinMax(corners, &obj->min_xyz, &obj->max_xyz);
987 }
988 fvi_info hit_info;
989 fvi_query fq;
990 fq.p0 = &Viewer_object->pos;
991 fq.startroom = Viewer_object->roomnum;
992 fq.rad = 0.0f;
993 fq.flags = FQ_NO_RELINK | FQ_EXTERNAL_ROOMS_AS_SPHERE | FQ_IGNORE_EXTERNAL_ROOMS;
994 fq.thisobjnum = Viewer_object - Objects;
995 fq.ignore_obj_list = NULL;
996
997 for (int i = 0; i < 8; i++) {
998 fq.p1 = &corners[i];
999 int fate = fvi_FindIntersection(&fq, &hit_info);
1000 /*g3Point pnt1,pnt2;
1001 vector fpnt = *fq.p0 + 3.0 * Viewer_object->orient.fvec;
1002 g3_RotatePoint (&pnt1,&fpnt);
1003 g3_RotatePoint (&pnt2,&hit_info.hit_pnt);
1004 g3_DrawLine ((GR_RGB(255,255,255)),&pnt1,&pnt2);*/
1005 if (fate == HIT_NONE)
1006 return 1;
1007 }
1008 return 0;
1009}
1010// Returns true if the external room is in the view cone
1011// Else returns false
1012bool ExternalRoomVisible(room *rp, vector *center, float *zdist) {

Callers

nothing calls this directly

Calls 2

MakePointsFromMinMaxFunction · 0.85
fvi_FindIntersectionFunction · 0.85

Tested by

no test coverage detected