Fixed build of tests
parent
8ef9a923d8
commit
60ec46d090
|
@ -73,10 +73,11 @@ target_sources(vissim PRIVATE
|
|||
# Tests
|
||||
add_executable(runtests)
|
||||
|
||||
target_sources(runtests PRIVATE tests/runtests.cc tests/CollisionTests.cc)
|
||||
target_sources(runtests PRIVATE tests/runtests.cc tests/CollisionTests.cc src/utils.cc)
|
||||
target_include_directories(
|
||||
runtests
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/rbdl/include>
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/rbdl/include>)
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ bool CheckPenetrationSphereVsPlane(
|
|||
SimBody CreateSphereBody(
|
||||
double mass,
|
||||
double radius,
|
||||
double restitution,
|
||||
const Vector3d& pos,
|
||||
const Vector3d& vel);
|
||||
|
||||
|
@ -110,8 +111,8 @@ void PrepareConstraintImpulse(
|
|||
SimBody* body_b,
|
||||
CollisionInfo& cinfo);
|
||||
void CalcCollisions(
|
||||
const SimBody& body_a,
|
||||
const SimBody& body_b,
|
||||
SimBody& body_a,
|
||||
SimBody& body_b,
|
||||
std::vector<CollisionInfo>& collisions);
|
||||
void CalcConstraintImpulse(
|
||||
SimBody* body_a,
|
||||
|
|
13
src/utils.cc
13
src/utils.cc
|
@ -4,8 +4,21 @@
|
|||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
|
||||
static Timer sTimer;
|
||||
Timer* gTimer = &sTimer;
|
||||
double gTimeAtStart = 0;
|
||||
|
||||
FILE* gLogFile = NULL;
|
||||
|
||||
void gTimerInit() {
|
||||
sTimer.mCurrentTime = 0.;
|
||||
sTimer.mDeltaTime = 0.;
|
||||
sTimer.mFrameTime = 0.;
|
||||
sTimer.mPaused = false;
|
||||
|
||||
gTimeAtStart = gGetCurrentTime();
|
||||
}
|
||||
|
||||
void GuiInputState_Init(GuiInputState* input_state) {
|
||||
input_state->mouseX = 0;
|
||||
input_state->mouseY = 0;
|
||||
|
|
10
src/utils.h
10
src/utils.h
|
@ -40,6 +40,16 @@ inline void gGetFileModTime(const char* filename, int* sec, int* nsec) {
|
|||
*nsec = attr.st_mtim.tv_nsec;
|
||||
}
|
||||
|
||||
typedef struct Timer {
|
||||
float mCurrentTime;
|
||||
float mFrameTime;
|
||||
float mDeltaTime;
|
||||
bool mPaused;
|
||||
}Timer;
|
||||
|
||||
extern Timer* gTimer;
|
||||
void gTimerInit();
|
||||
|
||||
inline double gGetCurrentTime() {
|
||||
struct timespec spec;
|
||||
clock_gettime(CLOCK_REALTIME, &spec);
|
||||
|
|
|
@ -21,17 +21,8 @@
|
|||
#include "srender.h"
|
||||
#include "simulator.h"
|
||||
|
||||
struct Timer {
|
||||
float mCurrentTime = 0.0f;
|
||||
float mFrameTime = 0.0f;
|
||||
float mDeltaTime = 0.0f;
|
||||
bool mPaused = false;
|
||||
};
|
||||
|
||||
Timer* gTimer = nullptr;
|
||||
GLFWwindow* gWindow = nullptr;
|
||||
GuiInputState* gGuiInputState = nullptr;
|
||||
double gTimeAtStart = 0;
|
||||
|
||||
// Rendering
|
||||
srndr* gRndr = nullptr;
|
||||
|
@ -41,8 +32,6 @@ srcmdbuf* gRndrCmds = nullptr;
|
|||
double mouse_scroll_x = 0.;
|
||||
double mouse_scroll_y = 0.;
|
||||
|
||||
static Timer sTimer;
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void error_callback(int error, const char* description) {
|
||||
|
@ -215,10 +204,7 @@ void DoRender() {
|
|||
}
|
||||
|
||||
int main(void) {
|
||||
gTimeAtStart = gGetCurrentTime();
|
||||
std::cout << "Time at start: " << gTimeAtStart << std::endl;
|
||||
|
||||
gTimer = &sTimer;
|
||||
gTimerInit();
|
||||
|
||||
LoggingInit();
|
||||
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
||||
#define CATCH_CONFIG_RUNNER // This tells Catch to provide a main() - only do this in one cpp file
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
LoggingInit();
|
||||
|
||||
int result = Catch::Session().run(argc, argv);
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Reference in New Issue