Merge branch 'fix257'
This commit is contained in:
commit
17dd22e677
|
@ -36,6 +36,7 @@
|
|||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <mutex>
|
||||
#include <ctime>
|
||||
|
||||
/// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
@ -80,6 +81,27 @@ class DefaultLogger : public Logger {
|
|||
/// Format a log message
|
||||
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;
|
||||
|
||||
/// 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 {
|
||||
|
@ -101,12 +123,14 @@ class DefaultLogger : public Logger {
|
|||
|
||||
// Get current date
|
||||
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;
|
||||
ss << "ReactPhysics3D Logs" << 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;
|
||||
|
||||
return ss.str();
|
||||
|
@ -117,8 +141,10 @@ class DefaultLogger : public Logger {
|
|||
Level level, Category category, const char* filename, int lineNumber) override {
|
||||
std::stringstream ss;
|
||||
|
||||
auto localTime = getLocalTime(time);
|
||||
|
||||
// Time
|
||||
ss << std::put_time(std::localtime(&time), "%X") << " ";
|
||||
ss << std::put_time(&localTime, "%X") << " ";
|
||||
|
||||
// World
|
||||
ss << "World:" << physicsWorldName << std::endl;
|
||||
|
@ -152,6 +178,7 @@ class DefaultLogger : public Logger {
|
|||
// Get current date
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto time = std::chrono::system_clock::to_time_t(now);
|
||||
auto localTime = getLocalTime(time);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "<!DOCTYPE HTML>" << std::endl;
|
||||
|
@ -164,7 +191,7 @@ class DefaultLogger : public Logger {
|
|||
ss << "<h1>ReactPhysics3D Logs</h1>" << std::endl;
|
||||
ss << "<div class='general_info'>" << 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 << "<hr>";
|
||||
|
||||
|
@ -275,11 +302,13 @@ class DefaultLogger : public Logger {
|
|||
|
||||
std::stringstream ss;
|
||||
|
||||
auto localTime = getLocalTime(time);
|
||||
|
||||
ss << "<div class='line " + toLowerCase(getCategoryName(category)) + " " + toLowerCase(getLevelName(level)) + "'>";
|
||||
|
||||
// Time
|
||||
ss << "<div class='time'>";
|
||||
ss << std::put_time(std::localtime(&time), "%X");
|
||||
ss << std::put_time(&localTime, "%X");
|
||||
ss << "</div>";
|
||||
|
||||
// Message
|
||||
|
|
|
@ -499,8 +499,8 @@ void CollisionDetectionSystem::computeConvexVsConcaveMiddlePhase(OverlappingPair
|
|||
const bool isCollider2Trigger = mCollidersComponents.mIsTrigger[collider2Index];
|
||||
reportContacts = reportContacts && !isCollider1Trigger && !isCollider2Trigger;
|
||||
|
||||
CollisionShape* shape1;
|
||||
CollisionShape* shape2;
|
||||
CollisionShape* shape1 = nullptr;
|
||||
CollisionShape* shape2 = nullptr;
|
||||
|
||||
if (overlappingPair.isShape1Convex) {
|
||||
shape1 = convexShape;
|
||||
|
|
Loading…
Reference in New Issue
Block a user