THE FUCKING COLLISION MATHS ARE CORRECT \o/
This commit is contained in:
parent
15ec5f71d6
commit
6ccf25476c
@ -54,52 +54,69 @@ bool qColl(float obesity, Vector3 futurePos, Morault::Maps::Map* map, float rend
|
|||||||
|
|
||||||
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
||||||
// check wall collisions
|
// check wall collisions
|
||||||
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 100.0f, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
if (
|
if (map->MapTriangles[i].wallAB != "pms:none") {
|
||||||
(map->MapTriangles[i].wallAB != "pms:none" ||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }))) {
|
||||||
(map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor
|
|
||||||
? -(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) < 10 : false))
|
|
||||||
&& Vector2DotProduct({ -(map->MapTriangles[i].b.y - map->MapTriangles[i].a.y), (map->MapTriangles[i].b.x - map->MapTriangles[i].a.x) }, normalizedVelocity) > 0) {
|
|
||||||
|
|
||||||
int highestFloor = map->MapTriangles[i].heightFloor < map->MapTriangles[currsec].heightFloor ? map->MapTriangles[currsec].heightFloor : map->MapTriangles[i].heightFloor;
|
|
||||||
if (futurePos.y - 5 >= highestFloor * renderScale && map->MapTriangles[i].wallAB == "pms:none") {}
|
|
||||||
|
|
||||||
else if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }))) {
|
|
||||||
// futurePos = camera.position;
|
// futurePos = camera.position;
|
||||||
|
return true;
|
||||||
// check which is highest
|
}
|
||||||
|
}
|
||||||
|
if (map->MapTriangles[i].wallBC != "pms:none") {
|
||||||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (
|
if (map->MapTriangles[i].wallCA != "pms:none") {
|
||||||
(map->MapTriangles[i].wallBC != "pms:none" ||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
||||||
(map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor
|
|
||||||
? -(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) < 10 : false))
|
return true;
|
||||||
&& Vector2DotProduct({ -(map->MapTriangles[i].c.y - map->MapTriangles[i].b.y), (map->MapTriangles[i].c.x - map->MapTriangles[i].b.x) }, normalizedVelocity) > 0) {
|
}
|
||||||
|
}
|
||||||
|
if (map->MapTriangles[i].heightFloor > map->MapTriangles[currsec].heightFloor) {
|
||||||
int highestFloor = map->MapTriangles[i].heightFloor < map->MapTriangles[currsec].heightFloor ? map->MapTriangles[currsec].heightFloor : map->MapTriangles[i].heightFloor;
|
int highestFloor = map->MapTriangles[i].heightFloor < map->MapTriangles[currsec].heightFloor ? map->MapTriangles[currsec].heightFloor : map->MapTriangles[i].heightFloor;
|
||||||
if (futurePos.y - 5 >= highestFloor * renderScale && map->MapTriangles[i].wallAB == "pms:none") {}
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].a, { renderScale, renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale, renderScale }))) {
|
||||||
|
if (Vector2DotProduct({ -(map->MapTriangles[i].b.y - map->MapTriangles[i].a.y), (map->MapTriangles[i].b.x - map->MapTriangles[i].a.x) }, normalizedVelocity) > 0) {
|
||||||
|
|
||||||
else if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }))) {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
// check which is highest
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(map->MapTriangles[i].wallCA != "pms:none" ||
|
|
||||||
(map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor
|
|
||||||
? -(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) < 10 : false))
|
|
||||||
&& Vector2DotProduct({ -(map->MapTriangles[i].a.y - map->MapTriangles[i].c.y), (map->MapTriangles[i].a.x - map->MapTriangles[i].c.x) }, normalizedVelocity) > 0) {
|
|
||||||
int highestFloor = map->MapTriangles[i].heightFloor < map->MapTriangles[currsec].heightFloor ? map->MapTriangles[currsec].heightFloor : map->MapTriangles[i].heightFloor;
|
|
||||||
if (futurePos.y - 5 >= highestFloor * renderScale && map->MapTriangles[i].wallAB == "pms:none") {}
|
|
||||||
else if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
|
||||||
|
|
||||||
// check which is highest
|
if (futurePos.y - 5 > highestFloor * renderScale) {
|
||||||
return true;
|
|
||||||
|
}
|
||||||
|
else return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].b, { renderScale, renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale, renderScale }))) {
|
||||||
|
if (Vector2DotProduct({ -(map->MapTriangles[i].c.y - map->MapTriangles[i].b.y), (map->MapTriangles[i].c.x - map->MapTriangles[i].b.x) }, normalizedVelocity) > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
|
||||||
|
if (futurePos.y - 5 > highestFloor * renderScale) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].c, { renderScale, renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale, renderScale }))) {
|
||||||
|
if (Vector2DotProduct({ -(map->MapTriangles[i].a.y - map->MapTriangles[i].c.y), (map->MapTriangles[i].a.x - map->MapTriangles[i].c.x) }, normalizedVelocity) > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
|
||||||
|
if (futurePos.y - 5 > highestFloor * renderScale) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
switch(eState){
|
switch(eState){
|
||||||
case GAME: {
|
case GAME: {
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_E)) {
|
if (IsKeyPressed(KEY_E)) {
|
||||||
eState = EDITOR;
|
eState = EDITOR;
|
||||||
EnableCursor();
|
EnableCursor();
|
||||||
@ -82,6 +83,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
DrawRectangleGradientV(0, 0, GetScreenWidth(), GetScreenHeight(), SKYBLUE, BLUE);
|
||||||
BeginMode3D(player.controller.camera);
|
BeginMode3D(player.controller.camera);
|
||||||
// DrawGrid(100, 10);
|
// DrawGrid(100, 10);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user