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

Function RenderTerrainRooms

Descent3/terrainrender.cpp:1034–1114  ·  view source on GitHub ↗

Render all the rooms out on the terrain for this frame

Source from the content-addressed store, hash-verified

1032}
1033// Render all the rooms out on the terrain for this frame
1034void RenderTerrainRooms() {
1035 object *obj;
1036#ifdef EDITOR
1037 if (!Terrain_render_ext_room_objs)
1038 return;
1039#endif
1040
1041 int room_count = 0;
1042 float zdist;
1043 int use_occlusion = 0;
1044 int src_occlusion_index;
1045 int i;
1046 if (Terrain_from_mine)
1047 return;
1048 if ((Terrain_checksum + 1) == Terrain_occlusion_checksum) {
1049 use_occlusion = 1;
1050 int oz = (Viewer_object->pos.z / TERRAIN_SIZE) / OCCLUSION_SIZE;
1051 int ox = (Viewer_object->pos.x / TERRAIN_SIZE) / OCCLUSION_SIZE;
1052 if (oz < 0 || oz >= OCCLUSION_SIZE || ox < 0 || ox >= OCCLUSION_SIZE)
1053 use_occlusion = 0;
1054 src_occlusion_index = oz * OCCLUSION_SIZE + ox;
1055 }
1056 for (i = 0; i <= Highest_object_index; i++) {
1057 obj = &Objects[i];
1058 if (obj->type != OBJ_ROOM)
1059 continue;
1060
1061 if (obj->flags & OF_DEAD)
1062 continue;
1063 if (obj->render_type == RT_NONE)
1064 continue;
1065 if (!OBJECT_OUTSIDE(obj))
1066 continue;
1067 float size = obj->size;
1068
1069 if (use_occlusion) {
1070 int y1 = (obj->pos.z / TERRAIN_SIZE) / OCCLUSION_SIZE;
1071 int x1 = (obj->pos.x / TERRAIN_SIZE) / OCCLUSION_SIZE;
1072 int dest_occlusion_index = (y1 * OCCLUSION_SIZE);
1073 dest_occlusion_index += x1;
1074 int occ_byte = dest_occlusion_index / 8;
1075 int occ_bit = dest_occlusion_index % 8;
1076 if (obj->pos.y < MAX_TERRAIN_HEIGHT) {
1077 if (!(Terrain_occlusion_map[src_occlusion_index][occ_byte] & (1 << occ_bit)))
1078 continue;
1079 }
1080 }
1081 if (!ExternalRoomVisible(&Rooms[obj->id], &obj->pos, &zdist))
1082 continue;
1083 if (!IsPointVisible(&obj->pos, size, &zdist))
1084 continue;
1085
1086 if (Check_terrain_portal && ObjectOutOfPortal(obj))
1087 continue;
1088 /*if (!Terrain_from_mine)
1089 {
1090 if (!ShootRaysToObject (obj))
1091 continue;

Callers 1

RenderTerrainFunction · 0.85

Calls 5

ExternalRoomVisibleFunction · 0.85
IsPointVisibleFunction · 0.85
ObjectOutOfPortalFunction · 0.85
RenderMineFunction · 0.85
DrawDebugInfoFunction · 0.85

Tested by

no test coverage detected