Fixed build of tests

master
Martin Felis 2020-11-08 12:49:43 +01:00
parent 8ef9a923d8
commit 60ec46d090
6 changed files with 41 additions and 20 deletions

View File

@ -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>)

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -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();

View File

@ -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;
}