Fixed build of tests
parent
8ef9a923d8
commit
60ec46d090
|
@ -73,10 +73,11 @@ target_sources(vissim PRIVATE
|
||||||
# Tests
|
# Tests
|
||||||
add_executable(runtests)
|
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(
|
target_include_directories(
|
||||||
runtests
|
runtests
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
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_SOURCE_DIR}/3rdparty/rbdl/include>
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/rbdl/include>)
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/rbdl/include>)
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ bool CheckPenetrationSphereVsPlane(
|
||||||
SimBody CreateSphereBody(
|
SimBody CreateSphereBody(
|
||||||
double mass,
|
double mass,
|
||||||
double radius,
|
double radius,
|
||||||
|
double restitution,
|
||||||
const Vector3d& pos,
|
const Vector3d& pos,
|
||||||
const Vector3d& vel);
|
const Vector3d& vel);
|
||||||
|
|
||||||
|
@ -110,8 +111,8 @@ void PrepareConstraintImpulse(
|
||||||
SimBody* body_b,
|
SimBody* body_b,
|
||||||
CollisionInfo& cinfo);
|
CollisionInfo& cinfo);
|
||||||
void CalcCollisions(
|
void CalcCollisions(
|
||||||
const SimBody& body_a,
|
SimBody& body_a,
|
||||||
const SimBody& body_b,
|
SimBody& body_b,
|
||||||
std::vector<CollisionInfo>& collisions);
|
std::vector<CollisionInfo>& collisions);
|
||||||
void CalcConstraintImpulse(
|
void CalcConstraintImpulse(
|
||||||
SimBody* body_a,
|
SimBody* body_a,
|
||||||
|
|
13
src/utils.cc
13
src/utils.cc
|
@ -4,8 +4,21 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
static Timer sTimer;
|
||||||
|
Timer* gTimer = &sTimer;
|
||||||
|
double gTimeAtStart = 0;
|
||||||
|
|
||||||
FILE* gLogFile = NULL;
|
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) {
|
void GuiInputState_Init(GuiInputState* input_state) {
|
||||||
input_state->mouseX = 0;
|
input_state->mouseX = 0;
|
||||||
input_state->mouseY = 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;
|
*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() {
|
inline double gGetCurrentTime() {
|
||||||
struct timespec spec;
|
struct timespec spec;
|
||||||
clock_gettime(CLOCK_REALTIME, &spec);
|
clock_gettime(CLOCK_REALTIME, &spec);
|
||||||
|
|
|
@ -21,17 +21,8 @@
|
||||||
#include "srender.h"
|
#include "srender.h"
|
||||||
#include "simulator.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;
|
GLFWwindow* gWindow = nullptr;
|
||||||
GuiInputState* gGuiInputState = nullptr;
|
GuiInputState* gGuiInputState = nullptr;
|
||||||
double gTimeAtStart = 0;
|
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
srndr* gRndr = nullptr;
|
srndr* gRndr = nullptr;
|
||||||
|
@ -41,8 +32,6 @@ srcmdbuf* gRndrCmds = nullptr;
|
||||||
double mouse_scroll_x = 0.;
|
double mouse_scroll_x = 0.;
|
||||||
double mouse_scroll_y = 0.;
|
double mouse_scroll_y = 0.;
|
||||||
|
|
||||||
static Timer sTimer;
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static void error_callback(int error, const char* description) {
|
static void error_callback(int error, const char* description) {
|
||||||
|
@ -215,10 +204,7 @@ void DoRender() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
gTimeAtStart = gGetCurrentTime();
|
gTimerInit();
|
||||||
std::cout << "Time at start: " << gTimeAtStart << std::endl;
|
|
||||||
|
|
||||||
gTimer = &sTimer;
|
|
||||||
|
|
||||||
LoggingInit();
|
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 "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