Wake up objects when portals are shot underneath then
This commit is contained in:
parent
7dc17db4a8
commit
ba67c38665
|
@ -141,12 +141,12 @@ That will generate the rom at `/build/portal64.z64`
|
|||
<br />
|
||||
|
||||
## Current New Feature TODO List
|
||||
- [ ] wake up objects after opening a portal under them
|
||||
- [ ] rumble pak support?
|
||||
- [ ] Investigate crash after falling into death water on test chamber 8
|
||||
- [ ] Add auto save checkpoints
|
||||
- [ ] Correct elevator timing
|
||||
- [ ] pausing while glados is speaking can end her speech early
|
||||
- [x] wake up objects after opening a portal under them
|
||||
- [x] button prompts
|
||||
- [x] investigate no_portals surface under portal pedestal
|
||||
- [x] Adding loading notice between levels #45
|
||||
|
|
|
@ -89,40 +89,4 @@ struct ColliderCallbacks gCollisionCapsuleCallbacks = {
|
|||
collisionCapsuleSolidMofI,
|
||||
collisionCapsuleBoundingBox,
|
||||
collisionCapsuleMinkowsiSum,
|
||||
};
|
||||
|
||||
int collisionCapsuleCheckWithNearestPoint(struct Vector3* nearestPoint, struct CollisionCapsule* otherCapsule, struct Vector3* capsulePos, struct ContactManifold* contact) {
|
||||
vector3Sub(capsulePos, nearestPoint, &contact->normal);
|
||||
|
||||
float distanceSqrd = vector3MagSqrd(&contact->normal);
|
||||
|
||||
if (distanceSqrd > otherCapsule->radius * otherCapsule->radius) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float distance = 0.0f;
|
||||
|
||||
if (distanceSqrd < 0.00001f) {
|
||||
contact->normal = gRight;
|
||||
} else {
|
||||
distance = sqrtf(distanceSqrd);
|
||||
vector3Scale(&contact->normal, &contact->normal, 1.0f / distance);
|
||||
}
|
||||
|
||||
struct ContactPoint* contactPoint = &contact->contacts[0];
|
||||
|
||||
vector3Scale(&contact->normal, &contactPoint->contactAWorld, otherCapsule->radius);
|
||||
vector3Scale(&contact->normal, &contactPoint->contactBWorld, -otherCapsule->radius);
|
||||
|
||||
contactPoint->bias = 0.0f;
|
||||
contactPoint->id = 0;
|
||||
contactPoint->normalImpulse = 0.0f;
|
||||
contactPoint->normalMass = 0.0f;
|
||||
contactPoint->penetration = distance - otherCapsule->radius;
|
||||
contactPoint->tangentImpulse[0] = 0.0f;
|
||||
contactPoint->tangentImpulse[1] = 0.0f;
|
||||
contactPoint->tangentMass[0] = 0.0f;
|
||||
contactPoint->tangentMass[0] = 0.0f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
};
|
|
@ -139,15 +139,18 @@ void contactSolverCheckPortalManifoldContacts(struct ContactManifold* manifold)
|
|||
++writeIndex;
|
||||
}
|
||||
|
||||
manifold->contactCount = writeIndex;
|
||||
if (writeIndex != manifold->contactCount) {
|
||||
manifold->contactCount = writeIndex;
|
||||
manifold->shapeB->body->flags &= ~RigidBodyIsSleeping;
|
||||
}
|
||||
}
|
||||
|
||||
void contactSolverCheckPortalContacts(struct ContactSolver* contactSolver, struct CollisionObject* objectWithNewPortal) {
|
||||
void contactSolverCheckPortalContacts(struct ContactSolver* contactSolver) {
|
||||
struct ContactManifold* curr = contactSolver->activeContacts;
|
||||
struct ContactManifold* prev = NULL;
|
||||
|
||||
while (curr) {
|
||||
if (curr->shapeA == objectWithNewPortal) {
|
||||
if (curr->shapeA->body == NULL) {
|
||||
contactSolverCheckPortalManifoldContacts(curr);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ struct ContactManifold* contactSolverGetContactManifold(struct ContactSolver* so
|
|||
struct ContactManifold* contactSolverNextManifold(struct ContactSolver* solver, struct CollisionObject* forObject, struct ContactManifold* current);
|
||||
|
||||
void contactSolverRemoveUnusedContacts(struct ContactSolver* contactSolver);
|
||||
void contactSolverCheckPortalContacts(struct ContactSolver* contactSolver, struct CollisionObject* objectWithNewPortal);
|
||||
void contactSolverCheckPortalContacts(struct ContactSolver* contactSolver);
|
||||
void contactSolverCleanupManifold(struct ContactManifold* manifold);
|
||||
|
||||
float contactPenetration(struct ContactManifold* contact);
|
||||
|
|
|
@ -48,10 +48,10 @@ void contactConstraintStateDebugDraw(struct ContactManifold* constraintState, st
|
|||
mat[2][2] = constraintState->tangentVectors[1].z;
|
||||
mat[2][3] = 0.0f;
|
||||
|
||||
struct Vector3 pos = contact->contactBLocal;
|
||||
struct Vector3 pos = contact->contactBWorld;
|
||||
|
||||
if (constraintState->shapeB->body) {
|
||||
transformPoint(&constraintState->shapeB->body->transform, &pos, &pos);
|
||||
vector3Add(&constraintState->shapeB->body->transform.position, &pos, &pos);
|
||||
}
|
||||
|
||||
mat[3][0] = pos.x * SCENE_SCALE;
|
||||
|
|
|
@ -301,6 +301,8 @@ void sceneRender(struct Scene* scene, struct RenderState* renderState, struct Gr
|
|||
renderPlanBuild(&renderPlan, scene, renderState);
|
||||
renderPlanExecute(&renderPlan, scene, staticMatrices, renderState);
|
||||
|
||||
// contactSolverDebugDraw(&gContactSolver, renderState);
|
||||
|
||||
if (scene->portalGun.portalGunVisible){
|
||||
portalGunRenderReal(&scene->portalGun, renderState, &scene->camera);
|
||||
}
|
||||
|
@ -317,7 +319,6 @@ void sceneRender(struct Scene* scene, struct RenderState* renderState, struct Gr
|
|||
|
||||
// sceneRenderPerformanceMetrics(scene, renderState, task);
|
||||
|
||||
// contactSolverDebugDraw(&gContactSolver, renderState);
|
||||
}
|
||||
|
||||
|
||||
|
@ -814,7 +815,7 @@ int sceneOpenPortal(struct Scene* scene, struct Transform* at, int transformInde
|
|||
}
|
||||
}
|
||||
|
||||
contactSolverCheckPortalContacts(&gContactSolver, collisionObject);
|
||||
contactSolverCheckPortalContacts(&gContactSolver);
|
||||
ballBurnFilterOnPortal(&portal->rigidBody.transform, portalIndex);
|
||||
playerSignalPortalChanged(&scene->player);
|
||||
return 1;
|
||||
|
|
31
src/util/profile.c
Normal file
31
src/util/profile.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "profile.h"
|
||||
|
||||
#ifdef PORTAL64_WITH_DEBUGGER
|
||||
#include "../debugger/serial.h"
|
||||
#endif
|
||||
|
||||
struct ProfileData {
|
||||
u64 lastReportStart;
|
||||
u64 timeAccumulation[MAX_PROFILE_BINS];
|
||||
};
|
||||
|
||||
struct ProfileData gProfileData;
|
||||
|
||||
void profileEnd(u64 startTime, int bin) {
|
||||
gProfileData.timeAccumulation[bin] += OS_CYCLES_TO_USEC(osGetTime() - startTime);
|
||||
}
|
||||
|
||||
void profileReport() {
|
||||
#ifdef PORTAL64_WITH_DEBUGGER
|
||||
OSTime reportStartTime = osGetTime();
|
||||
|
||||
gProfileData.lastReportStart = OS_CYCLES_TO_USEC(reportStartTime - gProfileData.lastReportStart);
|
||||
// gdbSendMessage(GDBDataTypeRawBinary, (char*)&gProfileData, sizeof(struct ProfileData));
|
||||
|
||||
for (int i = 0; i < MAX_PROFILE_BINS; ++i) {
|
||||
gProfileData.timeAccumulation[i] = 0;
|
||||
}
|
||||
|
||||
gProfileData.lastReportStart = reportStartTime;
|
||||
#endif
|
||||
}
|
13
src/util/profile.h
Normal file
13
src/util/profile.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef __UTIL_PROFILE_H__
|
||||
#define __UTIL_PROFILE_H__
|
||||
|
||||
#include <ultra64.h>
|
||||
|
||||
#define profileStart() osGetTime()
|
||||
void profileEnd(u64 startTime, int bin);
|
||||
|
||||
void profileReport();
|
||||
|
||||
#define MAX_PROFILE_BINS 8
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue