Adjust contact constraint
This commit is contained in:
parent
799e613732
commit
7676510a12
|
@ -57,11 +57,7 @@ where `/home/james/Blender/blender-2.93.1-linux-x64` is the folder where blender
|
|||
|
||||
## Current TODO list
|
||||
|
||||
Allow player to press button -- kinda
|
||||
Allow player to press button -- kinda done
|
||||
Cylinder raycasting
|
||||
Radio
|
||||
Create radio model
|
||||
Create radio texture
|
||||
Implement 3D sound
|
||||
cube dispenser
|
||||
nan in overlap
|
Binary file not shown.
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#define Q3_BAUMGARTE 0.1f
|
||||
#define Q3_BAUMGARTE 0.15f
|
||||
|
||||
#define Q3_PENETRATION_SLOP 0.001f
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
#include "../util/time.h"
|
||||
|
||||
void pointConstraintMoveToPoint(struct RigidBody* rigidBody, struct Vector3* worldPoint, float maxImpulse) {
|
||||
void pointConstraintMoveToPoint(struct CollisionObject* object, struct Vector3* worldPoint, float maxImpulse) {
|
||||
struct RigidBody* rigidBody = object->body;
|
||||
|
||||
vector3Sub(worldPoint, &rigidBody->transform.position, &rigidBody->velocity);
|
||||
struct Vector3 targetVelocity;
|
||||
vector3Scale(&rigidBody->velocity, &targetVelocity, 1.0f / FIXED_DELTA_TIME);
|
||||
|
@ -10,6 +12,16 @@ void pointConstraintMoveToPoint(struct RigidBody* rigidBody, struct Vector3* wor
|
|||
struct Vector3 delta;
|
||||
vector3Sub(&targetVelocity, &rigidBody->velocity, &delta);
|
||||
|
||||
// struct ContactManifold* manifold = contactSolverNextManifold(&gContactSolver, object, NULL);
|
||||
|
||||
// while (manifold) {
|
||||
// int isFirst = manifold->shapeA == object;
|
||||
|
||||
|
||||
|
||||
// manifold = contactSolverNextManifold(&gContactSolver, object, manifold);
|
||||
// }
|
||||
|
||||
float deltaSqrd = vector3MagSqrd(&delta);
|
||||
if (deltaSqrd < maxImpulse * maxImpulse) {
|
||||
rigidBody->velocity = targetVelocity;
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#define __POINT_CONSTRAINT_H__
|
||||
|
||||
#include "rigid_body.h"
|
||||
#include "collision_object.h"
|
||||
|
||||
void pointConstraintMoveToPoint(struct RigidBody* rigidBody, struct Vector3* worldPoint, float maxImpulse);
|
||||
void pointConstraintMoveToPoint(struct CollisionObject* object, struct Vector3* worldPoint, float maxImpulse);
|
||||
void pointConstraintRotateTo(struct RigidBody* rigidBody, struct Quaternion* worldRotation, float maxImpulse);
|
||||
|
||||
#endif
|
|
@ -131,7 +131,7 @@ void playerUpdateGrabbedObject(struct Player* player) {
|
|||
player->collisionObject.collisionLayers = 0;
|
||||
|
||||
if (collisionSceneRaycast(&gCollisionScene, player->body.currentRoom, &ray, COLLISION_LAYERS_GRABBABLE | COLLISION_LAYERS_TANGIBLE, GRAB_RAYCAST_DISTANCE, 1, &hit) && hit.object->body && (hit.object->body->flags & RigidBodyFlagsGrabbable)) {
|
||||
player->grabbing = hit.object->body;
|
||||
player->grabbing = hit.object;
|
||||
|
||||
if (hit.throughPortal) {
|
||||
player->grabbingThroughPortal = hit.throughPortal == gCollisionScene.portalTransforms[0] ? 0 : 1;
|
||||
|
@ -153,11 +153,11 @@ void playerUpdateGrabbedObject(struct Player* player) {
|
|||
playerApplyPortalGrab(player, 0);
|
||||
}
|
||||
|
||||
if (player->grabbing->flags & RigidBodyFlagsCrossedPortal0) {
|
||||
if (player->grabbing->body->flags & RigidBodyFlagsCrossedPortal0) {
|
||||
playerApplyPortalGrab(player, 0);
|
||||
}
|
||||
|
||||
if (player->grabbing->flags & RigidBodyFlagsCrossedPortal1) {
|
||||
if (player->grabbing->body->flags & RigidBodyFlagsCrossedPortal1) {
|
||||
playerApplyPortalGrab(player, 1);
|
||||
}
|
||||
|
||||
|
@ -182,8 +182,8 @@ void playerUpdateGrabbedObject(struct Player* player) {
|
|||
grabRotation = finalRotation;
|
||||
}
|
||||
|
||||
pointConstraintMoveToPoint(player->grabbing, &grabPoint, 20.0f);
|
||||
pointConstraintRotateTo(player->grabbing, &grabRotation, 5.0f);
|
||||
pointConstraintMoveToPoint(player->grabbing, &grabPoint, 8.0f);
|
||||
pointConstraintRotateTo(player->grabbing->body, &grabRotation, 5.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ struct Player {
|
|||
struct RigidBody body;
|
||||
struct Transform lookTransform;
|
||||
short grabbingThroughPortal;
|
||||
struct RigidBody* grabbing;
|
||||
struct CollisionObject* grabbing;
|
||||
float pitchVelocity;
|
||||
float yawVelocity;
|
||||
enum PlayerFlags flags;
|
||||
|
|
Loading…
Reference in a new issue