-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d57ca91
commit 968b753
Showing
38 changed files
with
1,830 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "BoxCollider.h" | ||
#include "GameObject.h" | ||
|
||
using namespace std; | ||
using namespace moddingApi; | ||
|
||
bool BoxCollider::isColliding(BoxCollider a, BoxCollider b) | ||
{ | ||
GameObject* gA = (GameObject*)(a.gameObjectPtr); | ||
GameObject* gB = (GameObject*)(b.gameObjectPtr); | ||
|
||
Vector3 aMin = Vector3( | ||
gA->transform.position.x - (a.scale.x / 2) + a.center.x, | ||
gA->transform.position.y - (a.scale.y / 2) + a.center.y, | ||
gA->transform.position.z - (a.scale.z / 2) + a.center.z | ||
); | ||
|
||
Vector3 aMax = Vector3( | ||
gA->transform.position.x + (a.scale.x / 2) + a.center.x, | ||
gA->transform.position.y + (a.scale.y / 2) + a.center.y, | ||
gA->transform.position.z + (a.scale.z / 2) + a.center.z | ||
); | ||
|
||
Vector3 bMin = Vector3( | ||
gB->transform.position.x - (b.scale.x / 2) + b.center.x, | ||
gB->transform.position.y - (b.scale.y / 2) + b.center.y, | ||
gB->transform.position.z - (b.scale.z / 2) + b.center.z | ||
); | ||
|
||
Vector3 bMax = Vector3( | ||
gB->transform.position.x + (b.scale.x / 2) + b.center.x, | ||
gB->transform.position.y + (b.scale.y / 2) + b.center.y, | ||
gB->transform.position.z + (b.scale.z / 2) + b.center.z | ||
); | ||
|
||
return (aMin.x <= bMax.x && aMax.x >= bMin.x) && (aMin.y <= bMax.y && aMax.y >= bMin.y) && (aMin.z <= bMax.z && aMax.z >= bMin.z); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include "Vector3.h" | ||
#include <cstdint> | ||
|
||
namespace moddingApi | ||
{ | ||
class BoxCollider | ||
{ | ||
public: | ||
uintptr_t gameObjectPtr; | ||
Vector3 center; | ||
Vector3 scale; | ||
|
||
BoxCollider(uintptr_t gameObject, Vector3 _center, Vector3 _scale) : gameObjectPtr(gameObject), center(_center), scale(_scale) | ||
{ | ||
|
||
} | ||
|
||
static bool isColliding(BoxCollider a, BoxCollider b); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.