mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-19 22:27:36 -04:00
Fix portal backface culling
This commit is contained in:
parent
e98a6d8b68
commit
56b278a47f
|
@ -57,9 +57,11 @@ where `/home/james/Blender/blender-2.93.1-linux-x64` is the folder where blender
|
|||
|
||||
## Current TODO list
|
||||
|
||||
Portal culling
|
||||
Doorway collision
|
||||
Implement collider bitmask
|
||||
Cylinder touching bug
|
||||
Blank screen on game start
|
||||
Radio
|
||||
Create radio model
|
||||
Create radio texture
|
||||
Implement 3D sound
|
||||
cube dispenser
|
13
src/main.c
13
src/main.c
|
@ -123,10 +123,13 @@ static void gameProc(void* arg) {
|
|||
OS_VI_DIVOT_OFF |
|
||||
OS_VI_DITHER_FILTER_OFF);
|
||||
|
||||
osViBlack(1);
|
||||
|
||||
u32 pendingGFX = 0;
|
||||
u32 drawBufferIndex = 0;
|
||||
u8 frameControl = 0;
|
||||
u8 inputIgnore = 6;
|
||||
u8 inputIgnore = 5;
|
||||
u8 drawingEnabled = 0;
|
||||
|
||||
u16* memoryEnd = graphicsLayoutScreenBuffers((u16*)PHYS_TO_K0(osMemSize));
|
||||
|
||||
|
@ -162,22 +165,18 @@ static void gameProc(void* arg) {
|
|||
break;
|
||||
}
|
||||
|
||||
static int renderSkip = 1;
|
||||
|
||||
if (pendingGFX < 2 && !renderSkip) {
|
||||
if (pendingGFX < 2 && drawingEnabled) {
|
||||
graphicsCreateTask(&gGraphicsTasks[drawBufferIndex], (GraphicsCallback)sceneRender, &gScene);
|
||||
drawBufferIndex = drawBufferIndex ^ 1;
|
||||
++pendingGFX;
|
||||
} else if (renderSkip) {
|
||||
--renderSkip;
|
||||
}
|
||||
|
||||
controllersTriggerRead();
|
||||
if (inputIgnore) {
|
||||
--inputIgnore;
|
||||
} else {
|
||||
|
||||
sceneUpdate(&gScene);
|
||||
drawingEnabled = 1;
|
||||
}
|
||||
timeUpdateDelta();
|
||||
soundPlayerUpdate();
|
||||
|
|
|
@ -121,7 +121,7 @@ void renderPropsNext(struct RenderProps* current, struct RenderProps* next, stru
|
|||
next->aspectRatio = current->aspectRatio;
|
||||
transformConcat(&portalCombined, ¤t->camera.transform, &next->camera.transform);
|
||||
|
||||
float zBias = (STARTING_RENDER_DEPTH - current->currentDepth - 1) * (-0.01f / STARTING_RENDER_DEPTH);
|
||||
float zBias = (STARTING_RENDER_DEPTH - current->currentDepth - 1) * -0.005f;
|
||||
|
||||
// render any objects halfway through portals
|
||||
cameraSetupMatrices(&next->camera, renderState, next->aspectRatio, &next->perspectiveCorrect, current->viewport, NULL, 0.0f);
|
||||
|
@ -177,12 +177,11 @@ void portalRender(struct Portal* portal, struct Portal* otherPortal, struct Rend
|
|||
struct Vector3 worldForward;
|
||||
quatMultVector(&portal->transform.rotation, &forward, &worldForward);
|
||||
|
||||
struct Quaternion inverseCamera;
|
||||
quatConjugate(&props->camera.transform.rotation, &inverseCamera);
|
||||
quatMultVector(&inverseCamera, &worldForward, &forward);
|
||||
struct Vector3 offsetFromCamera;
|
||||
vector3Sub(&props->camera.transform.position, &portal->transform.position, &offsetFromCamera);
|
||||
|
||||
// don't render the portal if it is facing the wrong way
|
||||
if (forward.z < 0.0f) {
|
||||
if (vector3Dot(&worldForward, &offsetFromCamera) < 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue