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

Function ShootRayFromPoint

editor/rad_cast.cpp:328–419  ·  view source on GitHub ↗

Returns 1 if a src vector can hit dest vector unobstructed, else 0

Source from the content-addressed store, hash-verified

326
327// Returns 1 if a src vector can hit dest vector unobstructed, else 0
328int ShootRayFromPoint(vector *src, vector *dest, rad_surface *src_surf, rad_surface *dest_surf) {
329 float dist;
330 bool do_backface = 0;
331 fvi_info hit_info;
332 fvi_query fq;
333 vector temp_src = *src;
334 vector temp_dest = *dest;
335 int from_satellite = 0;
336
337 // Trivially reject all rooms
338 if (dest_surf->surface_type == ST_ROOM || dest_surf->surface_type == ST_ROOM_OBJECT) {
339 if (src_surf->surface_type == ST_ROOM || src_surf->surface_type == ST_ROOM_OBJECT) {
340 if (!BOA_IsVisible(dest_surf->roomnum, src_surf->roomnum))
341 return 0;
342 }
343 }
344
345 if (UseBSP) {
346 if (dest_surf->surface_type == ST_ROOM || dest_surf->surface_type == ST_ROOM_OBJECT) {
347 if (src_surf->surface_type == ST_ROOM || src_surf->surface_type == ST_ROOM_OBJECT) {
348 int fate = BSPRayOccluded(src, dest, MineBSP.root);
349 if (!fate)
350 return 1;
351 return 0;
352 }
353 }
354 }
355
356 // If this ray is too high, clip it to the ceiling
357 if (src_surf->surface_type == ST_SATELLITE) {
358 if (1 || dest->y >= MAX_TERRAIN_HEIGHT) {
359 from_satellite = 1;
360 // swap the src/dest the variables because we now want to shoot from the ground to the satellite
361 rad_surface *temp_surf;
362 vector *temp_vec;
363
364 temp_surf = src_surf;
365 src_surf = dest_surf;
366 dest_surf = temp_surf;
367
368 temp_vec = src;
369 src = dest;
370 dest = temp_vec;
371
372 temp_dest = *dest;
373 temp_src = *src;
374
375 ClipSatelliteToTerrain(&temp_src, src, &temp_dest);
376 } else {
377 ClipSatelliteToTerrain(&temp_src, src, &temp_dest);
378 int src_cell = GetTerrainCellFromPos(&temp_src);
379
380 if (src_cell < 0) {
381 src_cell = 0;
382 Int3(); // Get Jason, satellite clipped off terrain?
383 }
384
385 src_surf->roomnum = MAKE_ROOMNUM(src_cell);

Calls 7

BOA_IsVisibleFunction · 0.85
BSPRayOccludedFunction · 0.85
ClipSatelliteToTerrainFunction · 0.85
GetTerrainCellFromPosFunction · 0.85
GetTerrainRoomFromPosFunction · 0.85
fvi_FindIntersectionFunction · 0.85
vm_VectorDistanceFunction · 0.50

Tested by

no test coverage detected