Untitled
Loading...
Searching...
No Matches
physics.c File Reference

PhysicsComponent impulse resolution and collision detection and acceleration structure traversal. More...

#include "core/camera.h"
#include "core/engine_types.h"
#include "utilities/types.h"
#include "load/init.h"
#include <float.h>
#include <math.h>
#include <stdio.h>
#include "utilities/mathf.h"
#include "utilities/engine_utilities.h"
#include "core/mesh.h"
#include "physics/GJK.h"
#include "utilities/utilities.h"
#include "render/render.h"

Go to the source code of this file.

Functions

void PC_apply_velocity (PhysicsComponent *pc, float dt)
 Applies gravity to a PhysicsComponent.
int generate_capsule_hull_manifold (CapsuleData *cap, mat4 cap_transform, vec3 hull_normal, float hull_plane_dist, Manifold *manifold, PhysicsComponent *pcA, PhysicsComponent *pcB)
 Generates a manifold between a capsule and a hull plane.
void clip_manifold (Manifold *manifold, CollisionPoints *p, CollisionData a_cd, mat4 modelA, CollisionData b_cd, mat4 modelB)
 Clips a manifold based on two different sets of points and faces with separate transforms.
Manifold * find_manifold_for_pair (int mn0, int mn1)
 Finds a current Manifold if there is one from MANIFOLDS for a given pair of MeshNodes.
Manifold * create_new_manifold (PhysicsComponent *a, int mn0, PhysicsComponent *b, int mn1)
 Finds a free Manifold and initializes it between two MeshNodes.
bool PC_process_collision_node (MeshNode *mn, PhysicsComponent *pc, Mesh *m0, MeshNode *mn0, BVHNode *node, CollisionData cd, mat4 mat, mat4 mat0, mat4 mat_inv, mat4 mat0_inv, Manifold *manifold)
 Processes a collision against one BVHNode inside of a COL_TRIANGLE static MeshNode.
bool PC_traverse_collision_bvh (MeshNode *mn, PhysicsComponent *pc, Mesh *m0, MeshNode *mn0, BVHNode *nodes, CollisionData cd, mat4 mat, mat4 mat0, mat4 mat_inv, mat4 mat0_inv, AABB tr_aabb, Manifold *manifold)
 Traverses the BVH for a static MeshNode with a PhysicsComponent to detect collisions.
void PC_traverse_scene_bvh (MeshNode *mn, PhysicsComponent *pc, CollisionData cd, SceneData *sd, mat4 mat, mat4 mat_inv, AABB aabb)
 Traverses the scene BVH to detect collisions from a PhysicsComponent.
void search_collisions_from_pc (MeshNode *mn, PhysicsComponent *pc)
 Searches for collisions from a PhysicsComponent that has no corresponding Mesh.
void search_collisions_from_hull (MeshNode *mn, PhysicsComponent *pc)
 Searches for collisions from a PhysicsComponent that has a corresponding Mesh.
void PC_find_collision (MeshNode *mn, PhysicsComponent *pc)
 Searches for collisions from a PhysicsComponent and determines how based on if its corresponding Mesh exists or not.
void player_resolve_impulse_static (PhysicsComponent *pcA, CollisionPoints *p)
 Solves an impulse for a Player PhysicsComponent against a static Mesh.
void player_resolve_impulse (PhysicsComponent *pcA, PhysicsComponent *pcB, CollisionPoints *p)
 Solves an impulse for a Player PhysicsComponent against another PhysicsComponent.
void PC_resolve_impulse_static (PhysicsComponent *pcA, CollisionPoints *p)
 Solves an impulse for a PhysicsComponent against a static Mesh.
void PC_resolve_impulse (PhysicsComponent *pcA, PhysicsComponent *pcB, CollisionPoints *p)
 Solves an impulse for a PhysicsComponent against another.
void update_physics_components ()
 The main PhysicsComponent loop that determines velocity, solves collisions, then integrates position.
mat3 calc_inverse_inertia (PhysicsComponent *pc)
 Calculates the mat3 IIA for a PhysicsComponent, using AABB bounds and mass.
void init_PC (int mesh_node, PhysicsComponent *pc, AABB ai_aabb, CollisionType collision_type, PhysicsType physics_type)
 Initializes a PhysicsComponent.

Variables

float normal_impulse0 = 0.0f
float normal_impulse1 = 0.0f
float normal_impulse2 = 0.0f
float normal_impulse3 = 0.0f
vec3 torque_sum = (vec3){0,0,0}
vec3 friction_sum = (vec3){0,0,0}
vec3 impulse_sum = (vec3){0,0,0}
vec3 ang_impulse_sum = (vec3){0,0,0}

Detailed Description

PhysicsComponent impulse resolution and collision detection and acceleration structure traversal.

Definition in file physics.c.