Fix issue 257
This commit is contained in:
parent
b289487583
commit
f6db3a722e
|
@ -36,6 +36,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
/// ReactPhysics3D namespace
|
/// ReactPhysics3D namespace
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
@ -80,6 +81,27 @@ class DefaultLogger : public Logger {
|
||||||
/// Format a log message
|
/// Format a log message
|
||||||
virtual std::string format(const time_t& time, const std::string& physicsWorldName, const std::string& message, Level level, Category category,
|
virtual std::string format(const time_t& time, const std::string& physicsWorldName, const std::string& message, Level level, Category category,
|
||||||
const char* filename, int lineNumber) = 0;
|
const char* filename, int lineNumber) = 0;
|
||||||
|
|
||||||
|
/// Return the current date and time
|
||||||
|
std::tm getLocalTime(const std::time_t& time) const {
|
||||||
|
|
||||||
|
std::tm bt = std::tm();
|
||||||
|
|
||||||
|
// This is because std::localtime is not thread-safe
|
||||||
|
|
||||||
|
#if defined(__unix__)
|
||||||
|
localtime_r(&time, &bt);
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
localtime_s(&bt, &time);
|
||||||
|
#else
|
||||||
|
static std::mutex mtx;
|
||||||
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
bt = *std::localtime(&time);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return bt;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextFormatter : public Formatter {
|
class TextFormatter : public Formatter {
|
||||||
|
@ -101,12 +123,14 @@ class DefaultLogger : public Logger {
|
||||||
|
|
||||||
// Get current date
|
// Get current date
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
auto time = std::chrono::system_clock::to_time_t(now);
|
std::time_t time = std::chrono::system_clock::to_time_t(now);
|
||||||
|
|
||||||
|
auto localTime = getLocalTime(time);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "ReactPhysics3D Logs" << std::endl;
|
ss << "ReactPhysics3D Logs" << std::endl;
|
||||||
ss << "ReactPhysics3D Version: " << RP3D_VERSION << std::endl;
|
ss << "ReactPhysics3D Version: " << RP3D_VERSION << std::endl;
|
||||||
ss << "Date: " << std::put_time(std::localtime(&time), "%Y-%m-%d") << std::endl;
|
ss << "Date: " << std::put_time(&localTime, "%Y-%m-%d") << std::endl;
|
||||||
ss << "---------------------------------------------------------" << std::endl;
|
ss << "---------------------------------------------------------" << std::endl;
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
@ -117,8 +141,10 @@ class DefaultLogger : public Logger {
|
||||||
Level level, Category category, const char* filename, int lineNumber) override {
|
Level level, Category category, const char* filename, int lineNumber) override {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
|
auto localTime = getLocalTime(time);
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
ss << std::put_time(std::localtime(&time), "%X") << " ";
|
ss << std::put_time(&localTime, "%X") << " ";
|
||||||
|
|
||||||
// World
|
// World
|
||||||
ss << "World:" << physicsWorldName << std::endl;
|
ss << "World:" << physicsWorldName << std::endl;
|
||||||
|
@ -152,6 +178,7 @@ class DefaultLogger : public Logger {
|
||||||
// Get current date
|
// Get current date
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
auto time = std::chrono::system_clock::to_time_t(now);
|
auto time = std::chrono::system_clock::to_time_t(now);
|
||||||
|
auto localTime = getLocalTime(time);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "<!DOCTYPE HTML>" << std::endl;
|
ss << "<!DOCTYPE HTML>" << std::endl;
|
||||||
|
@ -164,7 +191,7 @@ class DefaultLogger : public Logger {
|
||||||
ss << "<h1>ReactPhysics3D Logs</h1>" << std::endl;
|
ss << "<h1>ReactPhysics3D Logs</h1>" << std::endl;
|
||||||
ss << "<div class='general_info'>" << std::endl;
|
ss << "<div class='general_info'>" << std::endl;
|
||||||
ss << "<p>ReactPhysics3D version: " << RP3D_VERSION << "</p>" << std::endl;
|
ss << "<p>ReactPhysics3D version: " << RP3D_VERSION << "</p>" << std::endl;
|
||||||
ss << "<p>Date: " << std::put_time(std::localtime(&time), "%Y-%m-%d") << "</p>" << std::endl;
|
ss << "<p>Date: " << std::put_time(&localTime, "%Y-%m-%d") << "</p>" << std::endl;
|
||||||
ss << "</div>" << std::endl;
|
ss << "</div>" << std::endl;
|
||||||
ss << "<hr>";
|
ss << "<hr>";
|
||||||
|
|
||||||
|
@ -275,11 +302,13 @@ class DefaultLogger : public Logger {
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
|
auto localTime = getLocalTime(time);
|
||||||
|
|
||||||
ss << "<div class='line " + toLowerCase(getCategoryName(category)) + " " + toLowerCase(getLevelName(level)) + "'>";
|
ss << "<div class='line " + toLowerCase(getCategoryName(category)) + " " + toLowerCase(getLevelName(level)) + "'>";
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
ss << "<div class='time'>";
|
ss << "<div class='time'>";
|
||||||
ss << std::put_time(std::localtime(&time), "%X");
|
ss << std::put_time(&localTime, "%X");
|
||||||
ss << "</div>";
|
ss << "</div>";
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
|
|
|
@ -499,8 +499,8 @@ void CollisionDetectionSystem::computeConvexVsConcaveMiddlePhase(OverlappingPair
|
||||||
const bool isCollider2Trigger = mCollidersComponents.mIsTrigger[collider2Index];
|
const bool isCollider2Trigger = mCollidersComponents.mIsTrigger[collider2Index];
|
||||||
reportContacts = reportContacts && !isCollider1Trigger && !isCollider2Trigger;
|
reportContacts = reportContacts && !isCollider1Trigger && !isCollider2Trigger;
|
||||||
|
|
||||||
CollisionShape* shape1;
|
CollisionShape* shape1 = nullptr;
|
||||||
CollisionShape* shape2;
|
CollisionShape* shape2 = nullptr;
|
||||||
|
|
||||||
if (overlappingPair.isShape1Convex) {
|
if (overlappingPair.isShape1Convex) {
|
||||||
shape1 = convexShape;
|
shape1 = convexShape;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user