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

Function ShootRayForTerrainLight

editor/editor_lighting.cpp:1686–1721  ·  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

1684
1685// Returns 1 if a src vector can hit dest vector unobstructed, else 0
1686int ShootRayForTerrainLight(vector *src, vector *dest, int cellnum) {
1687 fvi_info hit_info;
1688 fvi_query fq;
1689 vector temp_dest = *dest;
1690
1691 if (temp_dest.y >= MAX_TERRAIN_HEIGHT * 3) {
1692 float mag;
1693 float ydiff;
1694 vector ray = temp_dest - *src;
1695
1696 mag = vm_GetMagnitude(&ray);
1697 ray /= mag;
1698
1699 ydiff = ((MAX_TERRAIN_HEIGHT * 3) - src->y) / ray.y;
1700
1701 temp_dest = *src + (ray * ydiff);
1702 }
1703
1704 // shoot a ray from the light position to the current vertex
1705 fq.p0 = src;
1706 fq.p1 = &temp_dest;
1707 fq.startroom = MAKE_ROOMNUM(cellnum);
1708
1709 fq.rad = 0.0f;
1710 fq.flags = FQ_CHECK_OBJS | FQ_IGNORE_NON_LIGHTMAP_OBJECTS | FQ_OBJ_BACKFACE | FQ_NO_RELINK |
1711 FQ_IGNORE_RENDER_THROUGH_PORTALS;
1712 fq.thisobjnum = -1;
1713 fq.ignore_obj_list = NULL;
1714
1715 int fate = fvi_FindIntersection(&fq, &hit_info);
1716
1717 if (fate == HIT_OUT_OF_TERRAIN_BOUNDS || fate == HIT_NONE)
1718 return 1;
1719
1720 return 0;
1721}
1722
1723#define AREA_X (TERRAIN_WIDTH - 1)
1724#define AREA_Z (TERRAIN_DEPTH - 1)

Callers 2

DoTerrainDynamicTableFunction · 0.85
ComputeTerrainSpeedTableFunction · 0.85

Calls 2

fvi_FindIntersectionFunction · 0.85
vm_GetMagnitudeFunction · 0.50

Tested by

no test coverage detected