mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-19 22:27:36 -04:00
Switch over to rendering from bvh index
This commit is contained in:
parent
0a65dd3fb2
commit
eaf12bbad9
|
@ -319,7 +319,6 @@ struct LevelDefinition {
|
|||
struct Rangeu16 *signalToStaticRanges;
|
||||
u16 *signalToStaticIndices;
|
||||
struct Rangeu16 *roomStaticMapping;
|
||||
struct BoundingBoxs16* staticBoundingBoxes;
|
||||
struct PortalSurface* portalSurfaces;
|
||||
// maps index of a collisionQuads to indices in portalSurfaces
|
||||
struct PortalSurfaceMappingRange* portalSurfaceMappingRange;
|
||||
|
|
|
@ -45,7 +45,6 @@ struct LevelDefinition* levelFixPointers(struct LevelDefinition* from, int point
|
|||
|
||||
result->staticContent = ADJUST_POINTER_POS(result->staticContent, pointerOffset);
|
||||
result->roomStaticMapping = ADJUST_POINTER_POS(result->roomStaticMapping, pointerOffset);
|
||||
result->staticBoundingBoxes = ADJUST_POINTER_POS(result->staticBoundingBoxes, pointerOffset);
|
||||
result->signalToStaticRanges = ADJUST_POINTER_POS(result->signalToStaticRanges, pointerOffset);
|
||||
result->signalToStaticIndices = ADJUST_POINTER_POS(result->signalToStaticIndices, pointerOffset);
|
||||
result->portalSurfaces = ADJUST_POINTER_POS(result->portalSurfaces, pointerOffset);
|
||||
|
@ -72,6 +71,7 @@ struct LevelDefinition* levelFixPointers(struct LevelDefinition* from, int point
|
|||
}
|
||||
|
||||
result->locations = ADJUST_POINTER_POS(result->locations, pointerOffset);
|
||||
result->roomBvhList = ADJUST_POINTER_POS(result->roomBvhList, pointerOffset);
|
||||
result->world.rooms = ADJUST_POINTER_POS(result->world.rooms, pointerOffset);
|
||||
result->world.doorways = ADJUST_POINTER_POS(result->world.doorways, pointerOffset);
|
||||
|
||||
|
@ -79,6 +79,9 @@ struct LevelDefinition* levelFixPointers(struct LevelDefinition* from, int point
|
|||
result->world.rooms[i].quadIndices = ADJUST_POINTER_POS(result->world.rooms[i].quadIndices, pointerOffset);
|
||||
result->world.rooms[i].cellContents = ADJUST_POINTER_POS(result->world.rooms[i].cellContents, pointerOffset);
|
||||
result->world.rooms[i].doorwayIndices = ADJUST_POINTER_POS(result->world.rooms[i].doorwayIndices, pointerOffset);
|
||||
|
||||
result->roomBvhList[i].boxIndex = ADJUST_POINTER_POS(result->roomBvhList[i].boxIndex, pointerOffset);
|
||||
result->roomBvhList[i].animatedBoxes = ADJUST_POINTER_POS(result->roomBvhList[i].animatedBoxes, pointerOffset);
|
||||
}
|
||||
|
||||
result->doors = ADJUST_POINTER_POS(result->doors, pointerOffset);
|
||||
|
|
|
@ -9,7 +9,13 @@
|
|||
|
||||
#include "../build/assets/materials/static.h"
|
||||
|
||||
void staticRenderTraverseIndex(struct StaticContentBox* box, struct StaticContentBox* boxEnd, struct StaticContentElement* staticContent, struct FrustrumCullingInformation* cullingInfo, struct RenderScene* renderScene) {
|
||||
void staticRenderTraverseIndex(
|
||||
struct StaticContentBox* box,
|
||||
struct StaticContentBox* boxEnd,
|
||||
struct StaticContentElement* staticContent,
|
||||
struct FrustrumCullingInformation* cullingInfo,
|
||||
struct RenderScene* renderScene
|
||||
) {
|
||||
while (box < boxEnd) {
|
||||
if (isOutsideFrustrum(cullingInfo, &box->box)) {
|
||||
// skip all children
|
||||
|
@ -39,55 +45,49 @@ void staticRenderPopulateRooms(struct FrustrumCullingInformation* cullingInfo, M
|
|||
|
||||
while (visibleRooms) {
|
||||
if (0x1 & visibleRooms) {
|
||||
struct Rangeu16 staticRange = gCurrentLevel->roomStaticMapping[currentRoom];
|
||||
struct StaticIndex* roomIndex = &gCurrentLevel->roomBvhList[currentRoom];
|
||||
|
||||
staticRenderTraverseIndex(roomIndex->boxIndex, roomIndex->boxIndex + roomIndex->boxCount, gCurrentLevel->staticContent, cullingInfo, renderScene);
|
||||
|
||||
for (int i = staticRange.min; i < staticRange.max; ++i) {
|
||||
struct BoundingBoxs16* box = &gCurrentLevel->staticBoundingBoxes[i];
|
||||
struct BoundingBoxs16* animatedBox = roomIndex->animatedBoxes;
|
||||
|
||||
Mtx* matrix = NULL;
|
||||
for (int i = roomIndex->animatedRange.min; i < roomIndex->animatedRange.max; ++i, ++animatedBox) {
|
||||
struct StaticContentElement* staticElement = &gCurrentLevel->staticContent[i];
|
||||
|
||||
int transformIndex = gCurrentLevel->staticContent[i].transformIndex;
|
||||
Mtx* matrix = &staticTransforms[staticElement->transformIndex];
|
||||
|
||||
short* mtxAsShorts = (short*)matrix;
|
||||
|
||||
int x = mtxAsShorts[12];
|
||||
int y = mtxAsShorts[13];
|
||||
int z = mtxAsShorts[14];
|
||||
|
||||
struct BoundingBoxs16 shiftedBox;
|
||||
shiftedBox.minX = animatedBox->minX + x;
|
||||
shiftedBox.minY = animatedBox->minY + y;
|
||||
shiftedBox.minZ = animatedBox->minZ + z;
|
||||
|
||||
shiftedBox.maxX = animatedBox->maxX + x;
|
||||
shiftedBox.maxY = animatedBox->maxY + y;
|
||||
shiftedBox.maxZ = animatedBox->maxZ + z;
|
||||
|
||||
if (isOutsideFrustrum(cullingInfo, &shiftedBox)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct Vector3 boxCenter;
|
||||
boxCenter.x = (float)(shiftedBox.minX + shiftedBox.maxX) * (0.5f / SCENE_SCALE);
|
||||
boxCenter.y = (float)(shiftedBox.minY + shiftedBox.maxY) * (0.5f / SCENE_SCALE);
|
||||
boxCenter.z = (float)(shiftedBox.minZ + shiftedBox.maxZ) * (0.5f / SCENE_SCALE);
|
||||
|
||||
if (transformIndex == NO_TRANSFORM_INDEX) {
|
||||
if (isOutsideFrustrum(cullingInfo, box)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boxCenter.x = (float)((box->minX + box->maxX) * (0.5f / SCENE_SCALE));
|
||||
boxCenter.y = (float)(box->minY + box->maxY) * (0.5f / SCENE_SCALE);
|
||||
boxCenter.z = (float)(box->minZ + box->maxZ) * (0.5f / SCENE_SCALE);
|
||||
} else {
|
||||
matrix = &staticTransforms[transformIndex];
|
||||
|
||||
short* mtxAsShorts = (short*)matrix;
|
||||
|
||||
boxCenter = gZeroVec;
|
||||
|
||||
int x = mtxAsShorts[12];
|
||||
int y = mtxAsShorts[13];
|
||||
int z = mtxAsShorts[14];
|
||||
|
||||
struct BoundingBoxs16 shiftedBox;
|
||||
shiftedBox.minX = box->minX + x;
|
||||
shiftedBox.minY = box->minY + y;
|
||||
shiftedBox.minZ = box->minZ + z;
|
||||
|
||||
shiftedBox.maxX = box->maxX + x;
|
||||
shiftedBox.maxY = box->maxY + y;
|
||||
shiftedBox.maxZ = box->maxZ + z;
|
||||
|
||||
if (isOutsideFrustrum(cullingInfo, &shiftedBox)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boxCenter.x = (float)(shiftedBox.minX + shiftedBox.maxX) * (0.5f / SCENE_SCALE);
|
||||
boxCenter.y = (float)(shiftedBox.minY + shiftedBox.maxY) * (0.5f / SCENE_SCALE);
|
||||
boxCenter.z = (float)(shiftedBox.minZ + shiftedBox.maxZ) * (0.5f / SCENE_SCALE);
|
||||
}
|
||||
|
||||
renderSceneAdd(renderScene, gCurrentLevel->staticContent[i].displayList, matrix, gCurrentLevel->staticContent[i].materialIndex, &boxCenter, NULL);
|
||||
renderSceneAdd(
|
||||
renderScene,
|
||||
staticElement->displayList,
|
||||
matrix,
|
||||
staticElement->materialIndex,
|
||||
&boxCenter,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ sk_definition_writer.add_definition("level", "struct LevelDefinition", "_geo", {
|
|||
signalToStaticRanges = sk_definition_writer.reference_to(static_export.signal_ranges, 1),
|
||||
signalToStaticIndices = sk_definition_writer.reference_to(static_export.signal_indices, 1),
|
||||
signalToStaticCount = #static_export.signal_ranges,
|
||||
staticBoundingBoxes = sk_definition_writer.reference_to(static_export.static_bounding_boxes, 1),
|
||||
roomStaticMapping = sk_definition_writer.reference_to(static_export.room_ranges, 1),
|
||||
portalSurfaces = sk_definition_writer.reference_to(portal_surfaces.portal_surfaces, 1),
|
||||
portalSurfaceCount = #portal_surfaces.portal_surfaces,
|
||||
|
|
|
@ -412,7 +412,6 @@ local static_nodes, room_bvh_list = process_static_nodes(sk_scene.nodes_for_type
|
|||
local static_content_elements = {}
|
||||
|
||||
local room_ranges = {}
|
||||
local static_bounding_boxes = {}
|
||||
|
||||
local bb_scale_inv = 1 / sk_input.settings.fixed_point_scale
|
||||
|
||||
|
@ -433,7 +432,6 @@ for index, static_node in pairs(static_nodes) do
|
|||
materialIndex = static_node.material_index,
|
||||
transformIndex = static_node.transform_index and (static_node.transform_index - 1) or sk_definition_writer.raw('NO_TRANSFORM_INDEX'),
|
||||
})
|
||||
table.insert(static_bounding_boxes, bb_list(static_node.mesh_bb))
|
||||
|
||||
good_index = index - 1
|
||||
|
||||
|
@ -451,7 +449,6 @@ end
|
|||
|
||||
sk_definition_writer.add_definition("static", "struct StaticContentElement[]", "_geo", static_content_elements)
|
||||
sk_definition_writer.add_definition("room_mapping", "struct Rangeu16[]", "_geo", room_ranges)
|
||||
sk_definition_writer.add_definition('bounding_boxes', 'struct BoundingBoxs16[]', '_geo', static_bounding_boxes)
|
||||
|
||||
local signal_indices = {}
|
||||
local signal_ranges = {}
|
||||
|
@ -470,7 +467,6 @@ sk_definition_writer.add_definition('signal_indices', 'u16[]', '_geo', signal_in
|
|||
return {
|
||||
static_nodes = static_nodes,
|
||||
static_content_elements = static_content_elements,
|
||||
static_bounding_boxes = static_bounding_boxes,
|
||||
room_ranges = room_ranges,
|
||||
signal_ranges = signal_ranges,
|
||||
signal_indices = signal_indices,
|
||||
|
|
Loading…
Reference in a new issue