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

Function RenderAllTerrainObjects

Descent3/terrainrender.cpp:1116–1245  ·  view source on GitHub ↗

Renders every visible terrain object

Source from the content-addressed store, hash-verified

1114}
1115// Renders every visible terrain object
1116void RenderAllTerrainObjects() {
1117 object *obj;
1118 int snows[500];
1119 int num_snows = 0;
1120 int obj_count = 0;
1121 float zdist;
1122 int use_occlusion = 0;
1123 int src_occlusion_index;
1124 int i;
1125 if ((Terrain_checksum + 1) == Terrain_occlusion_checksum) {
1126 use_occlusion = 1;
1127 int oz = (Viewer_object->pos.z / TERRAIN_SIZE) / OCCLUSION_SIZE;
1128 int ox = (Viewer_object->pos.x / TERRAIN_SIZE) / OCCLUSION_SIZE;
1129 if (oz < 0 || oz >= OCCLUSION_SIZE || ox < 0 || ox >= OCCLUSION_SIZE)
1130 use_occlusion = 0;
1131 src_occlusion_index = oz * OCCLUSION_SIZE + ox;
1132 }
1133 for (i = 0; i <= Highest_object_index; i++) {
1134 obj = &Objects[i];
1135 if (obj == Viewer_object)
1136 continue;
1137 // Don't draw piggybacked objects
1138 if (Viewer_object->type == OBJ_OBSERVER && i == Players[Viewer_object->id].piggy_objnum)
1139 continue;
1140 if (obj->type == OBJ_ROOM)
1141 continue;
1142
1143 if (obj->type == OBJ_NONE)
1144 continue;
1145 if (obj->flags & OF_DEAD)
1146 continue;
1147 if (obj->render_type == RT_NONE)
1148 continue;
1149 if (!OBJECT_OUTSIDE(obj))
1150 continue;
1151 float size = obj->size;
1152
1153 // Special case weapons with streamers
1154 if (obj->type == OBJ_WEAPON && (Weapons[obj->id].flags & WF_STREAMER))
1155 size = Weapons[obj->id].phys_info.velocity.z;
1156 if (use_occlusion) {
1157 int y1 = (obj->pos.z / TERRAIN_SIZE) / OCCLUSION_SIZE;
1158 int x1 = (obj->pos.x / TERRAIN_SIZE) / OCCLUSION_SIZE;
1159 int dest_occlusion_index = (y1 * OCCLUSION_SIZE);
1160 dest_occlusion_index += x1;
1161 int occ_byte = dest_occlusion_index / 8;
1162 int occ_bit = dest_occlusion_index % 8;
1163 if (obj->pos.y + obj->size < MAX_TERRAIN_HEIGHT) {
1164 if (!(Terrain_occlusion_map[src_occlusion_index][occ_byte] & (1 << occ_bit)))
1165 continue;
1166 }
1167 }
1168 if (obj->type == OBJ_WEAPON && Weapons[obj->id].flags & WF_ELECTRICAL) {
1169 // Automatically render all electrical objects
1170 zdist = 0;
1171 } else {
1172 if (!IsPointVisible(&obj->pos, size, &zdist))
1173 continue;

Callers 1

RenderTerrainFunction · 0.85

Calls 7

IsPointVisibleFunction · 0.85
ObjectOutOfPortalFunction · 0.85
DrawVisEffectFunction · 0.85
RenderObjectFunction · 0.85
rend_SetZBufferWriteMaskFunction · 0.50
rend_SetZBufferStateFunction · 0.50
rend_SetWrapTypeFunction · 0.50

Tested by

no test coverage detected