Can now build with JoltPhysics

This commit is contained in:
Antoine Pilote
2022-09-25 15:27:43 -04:00
parent 289a25f9e8
commit f5c5497122
12 changed files with 64 additions and 40 deletions

3
.gitmodules vendored
View File

@@ -13,3 +13,6 @@
[submodule "Nuake/dependencies/freetype"]
path = Nuake/dependencies/freetype
url = https://github.com/freetype/freetype.git
[submodule "Nuake/dependencies/JoltPhysics"]
path = Nuake/dependencies/JoltPhysics
url = https://github.com/antopilo/JoltPhysics.git

View File

@@ -10,7 +10,11 @@ project 'JoltPhysics'
objdir ("JoltPhysics/bin-obj/" .. outputdir .. "/%{prj.name}")
pchheader "Jolt/Jolt.h"
pchsource "../Jolt.cpp"
pchsource "JoltPhysics/Jolt.cpp"
defines {
}
includedirs {
"JoltPhysics"
@@ -19,17 +23,15 @@ project 'JoltPhysics'
files {
"JoltPhysics/Jolt/**.h",
"JoltPhysics/Jolt/**.cpp",
"Jolt.cpp"
"JoltPhysics/Jolt.cpp",
}
defines {
}
filter "configurations:Debug"
cppdialect "C++17"
runtime "Debug"
symbols "on"
filter "configurations:Release"
cppdialect "C++17"
runtime "Release"
optimize "on"

View File

@@ -1,7 +0,0 @@
#include "../../Rendering/Renderer.h"
#include <GL/glew.h>
namespace Nuake
{
}

View File

@@ -1,6 +0,0 @@
#pragma once
namespace Nuake
{
}

View File

@@ -4,11 +4,15 @@
#include <src/Vendors/glm/ext/quaternion_common.hpp>
#include <src/Core/Logger.h>
#include <Jolt/Jolt.h>
namespace Nuake
{
namespace Physics
{
DynamicWorld::DynamicWorld() {
DynamicWorld::DynamicWorld()
{
///collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration.
SetGravity(Vector3(0, -10000, 0));

View File

@@ -2,11 +2,18 @@
#include "PhysicsShapes.h"
#include "../Core/Core.h"
#include <Jolt/Jolt.h>
#include <Jolt/RegisterTypes.h>
#include <Jolt/Core/Factory.h>
#include <Jolt/Core/TempAllocator.h>
namespace Nuake
{
PhysicsManager* PhysicsManager::m_Instance;
void PhysicsManager::RegisterBody(Ref<Physics::RigidBody> rb) {
void PhysicsManager::RegisterBody(Ref<Physics::RigidBody> rb)
{
m_World->AddRigidbody(rb);
}
@@ -16,7 +23,8 @@ namespace Nuake
}
void PhysicsManager::RegisterCharacterController(Ref<Physics::CharacterController> cc) {
void PhysicsManager::RegisterCharacterController(Ref<Physics::CharacterController> cc)
{
m_World->AddCharacterController(cc);
}
@@ -33,7 +41,6 @@ namespace Nuake
RaycastResult PhysicsManager::Raycast(glm::vec3 from, glm::vec3 to)
{
return m_World->Raycast(from, to);
}
@@ -44,7 +51,32 @@ namespace Nuake
m_World->DrawDebug();
}
void PhysicsManager::Init() {
void PhysicsManager::Init()
{
JPH::RegisterDefaultAllocator();
JPH::Factory::sInstance = new JPH::Factory();
JPH::RegisterTypes();
// This is the max amount of rigid bodies that you can add to the physics system. If you try to add more you'll get an error.
// Note: This value is low because this is a simple test. For a real project use something in the order of 65536.
const uint32_t cMaxBodies = 1024;
// This determines how many mutexes to allocate to protect rigid bodies from concurrent access. Set it to 0 for the default settings.
const uint32_t cNumBodyMutexes = 0;
// This is the max amount of body pairs that can be queued at any time (the broad phase will detect overlapping
// body pairs based on their bounding boxes and will insert them into a queue for the narrowphase). If you make this buffer
// too small the queue will fill up and the broad phase jobs will start to do narrow phase work. This is slightly less efficient.
// Note: This value is low because this is a simple test. For a real project use something in the order of 65536.
const uint32_t cMaxBodyPairs = 1024;
// This is the maximum size of the contact constraint buffer. If more contacts (collisions between bodies) are detected than this
// number then these contacts will be ignored and bodies will start interpenetrating / fall through the world.
// Note: This value is low because this is a simple test. For a real project use something in the order of 10240.
const uint32_t cMaxContactConstraints = 1024;
m_World = new Physics::DynamicWorld();
m_World->SetGravity(glm::vec3(0, -3, 0));

View File

@@ -9,7 +9,7 @@ namespace Nuake
class VertexBuffer;
class VertexArray;
class Material;
class Vertex;
struct Vertex;
class Shader;
class Mesh : ISerializable, Resource

View File

@@ -11,12 +11,8 @@
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <bitset>
namespace Nuake
{
class Model;
class ModelLoader
{
@@ -25,9 +21,7 @@ namespace Nuake
~ModelLoader();
Ref<Model> LoadModel(const std::string& path);
private:
std::bitset<8> _flags;
std::string modelDir;
std::vector<Ref<Mesh>> m_Meshes;

View File

@@ -5,7 +5,7 @@
#include <map>
#include <string>
class WrenHandle;
struct WrenHandle;
namespace Nuake {
class WrenScript

View File

@@ -62,7 +62,7 @@ namespace Nuake
// Selectors
KatanaStyleRule* stylerule = (KatanaStyleRule*)rule;
for (int j = 0; j < stylerule->selectors->length; j++)
for (uint32_t j = 0; j < stylerule->selectors->length; j++)
{
KatanaSelector* selector = (KatanaSelector*)stylerule->selectors->data[j];
std::string name = selector->data->value;
@@ -82,7 +82,7 @@ namespace Nuake
}
// Declarations
for (int k = 0; k < stylerule->declarations->length; k++)
for (uint32_t k = 0; k < stylerule->declarations->length; k++)
{
KatanaDeclaration* declaration = (KatanaDeclaration*)(stylerule->declarations->data[k]);
std::string value = declaration->raw;
@@ -253,7 +253,7 @@ namespace Nuake
{
std::string content = FileSystem::ReadFile(this->Path, true);
Data = katana_parse(content.c_str(), content.length(), KatanaParserModeStylesheet);
for (int i = 0; i < Data->stylesheet->rules.length; i++)
for (uint32_t i = 0; i < Data->stylesheet->rules.length; i++)
{
KatanaRule* rule = (KatanaRule*)Data->stylesheet->rules.data[i];
ParseRule(rule);

View File

@@ -21,8 +21,6 @@ project "Nuake"
defines
{
"BT_THREADSAFE=1",
"BT_USE_DOUBLE_PRECISION",
"GLEW_STATIC",
"_MBCS"
}
@@ -55,11 +53,12 @@ project "Nuake"
"%{prj.name}/../Nuake/Dependencies/GLEW/include",
"%{prj.name}/../Nuake/Dependencies/GLFW/include",
"%{prj.name}/../Nuake/Dependencies/assimp/include",
"%{prj.name}/../Nuake/Dependencies/JoltPhysics/Jolt",
"%{prj.name}/../Nuake/Dependencies/JoltPhysics",
"%{prj.name}/../Nuake/src/Vendors/msdfgen/include",
"%{prj.name}/../Nuake/src/Vendors/msdfgen/freetype/include",
"%{prj.name}/../Nuake/src/Vendors/msdfgen",
"%{prj.name}/../Nuake/src/Vendors/wren/src/include",
"%{prj.name}/../Nuake/Dependencies/build"
}
links
@@ -103,7 +102,8 @@ project "Editor"
"%{prj.name}/../Nuake/Dependencies/assimp/include",
"%{prj.name}/../Nuake/Dependencies/build",
"%{prj.name}/../Nuake/src/Vendors/msdfgen",
"%{prj.name}/../Nuake/Dependencies/JoltPhysics/Jolt"
"%{prj.name}/../Nuake/Dependencies/JoltPhysics",
"%{prj.name}/../Nuake/Dependencies/build"
}
libdirs
@@ -116,6 +116,7 @@ project "Editor"
"%{prj.name}/../Nuake/src/Vendors/msdfgen/freetype/win64",
"%{prj.name}/../Nuake/src/Vendors/msdfgen",
"%{prj.name}/../Nuake/src/Vendors/wren/src/include",
"%{prj.name}/../Nuake/dependencies/JoltPhysics/bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}/JoltPhysics/"
}
links
@@ -126,7 +127,7 @@ project "Editor"
"glew32s.lib",
"opengl32.lib",
"Freetype",
"JoltPhysics",
"JoltPhysics"
}
filter "system:windows"