Rename ChipmunkPhysics2D and JoltPhysics3D to Physics[2D|3D]

This commit is contained in:
Lynix
2024-02-09 20:59:53 +01:00
committed by Jérôme Leclercq
parent 139bed2b0a
commit e336c8a514
116 changed files with 3044 additions and 3042 deletions

View File

@@ -0,0 +1,65 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Physics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics3D/Physics3D.hpp>
#include <Nazara/Core/Core.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/Log.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <Jolt/Jolt.h>
#include <Jolt/RegisterTypes.h>
#include <Jolt/Core/Factory.h>
#include <Jolt/Core/JobSystemThreadPool.h>
#include <Jolt/Physics/PhysicsSettings.h>
#include <cstdarg>
#include <Nazara/Physics3D/Debug.hpp>
// Callback for traces, connect this to your own trace function if you have one
static void TraceImpl(const char* inFMT, ...)
{
// Format the message
va_list list;
va_start(list, inFMT);
char buffer[1024];
vsnprintf(buffer, sizeof(buffer), inFMT, list);
va_end(list);
// Print to the TTY
NazaraError(buffer);
}
namespace Nz
{
Physics3D::Physics3D(Config /*config*/) :
ModuleBase("Physics3D", this)
{
JPH::RegisterDefaultAllocator();
JPH::Trace = TraceImpl;
JPH::Factory::sInstance = new JPH::Factory;
JPH::RegisterTypes();
int threadCount = -1; //< system CPU core count
#ifdef NAZARA_PLATFORM_WEB
threadCount = 0; // no thread on web for now
#endif
m_threadPool = std::make_unique<JPH::JobSystemThreadPool>(JPH::cMaxPhysicsJobs, JPH::cMaxPhysicsBarriers, threadCount);
}
Physics3D::~Physics3D()
{
m_threadPool.reset();
JPH::UnregisterTypes();
delete JPH::Factory::sInstance;
JPH::Factory::sInstance = nullptr;
}
JPH::JobSystem& Physics3D::GetThreadPool()
{
return *m_threadPool;
}
Physics3D* Physics3D::s_instance;
}