mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-06-11 04:35:39 +00:00
Fix one failing test
This commit is contained in:
parent
944d3e1bac
commit
1ae57dc6e8
@ -2,6 +2,7 @@
|
||||
#define __DLUASSERT__H__
|
||||
|
||||
#include <assert.h>
|
||||
#define _DEBUG
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define DluAssert(expression) assert(expression)
|
||||
|
@ -29,7 +29,7 @@ constexpr const char* GetFileNameFromAbsolutePath(const char* path) {
|
||||
// they will not be valid constexpr and will be evaluated at runtime instead of compile time!
|
||||
// The full string is still stored in the binary, however the offset of the filename in the absolute paths
|
||||
// is used in the instruction instead of the start of the absolute path.
|
||||
#define LOG(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->Log(str, message, ##__VA_ARGS__); } while(0)
|
||||
#define LOG(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->Log(str, message, ##__VA_ARGS__); Game::logger->Flush(); } while(0)
|
||||
#define LOG_DEBUG(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->LogDebug(str, message, ##__VA_ARGS__); } while(0)
|
||||
|
||||
// Writer class for writing data to files.
|
||||
|
@ -141,6 +141,7 @@ void PlatformSubComponent::SetupPath(const std::string& pathName, uint32_t start
|
||||
m_InReverse = startsInReverse;
|
||||
m_CurrentWaypointIndex = startingWaypointIndex;
|
||||
m_TimeBasedMovement = m_Path->movingPlatform.timeBasedMovement;
|
||||
m_NextWaypointIndex = m_InReverse ? m_CurrentWaypointIndex - 1 : m_CurrentWaypointIndex + 1;
|
||||
}
|
||||
|
||||
const PathWaypoint& PlatformSubComponent::GetNextWaypoint() const {
|
||||
@ -159,6 +160,8 @@ float PlatformSubComponent::CalculateSpeed() const {
|
||||
float unitizedDirection = 1.0f / (GetNextWaypoint().position - GetCurrentWaypoint().position).Length();
|
||||
speed = unitizedDirection / GetCurrentWaypoint().movingPlatform.speed;
|
||||
} else {
|
||||
LOG("%i %i", m_CurrentWaypointIndex, m_NextWaypointIndex);
|
||||
Game::logger->Flush();
|
||||
speed = (GetNextWaypoint().movingPlatform.speed - GetCurrentWaypoint().movingPlatform.speed) * m_PercentUntilNextWaypoint + GetCurrentWaypoint().movingPlatform.speed;
|
||||
}
|
||||
return speed;
|
||||
|
@ -25,14 +25,17 @@ protected:
|
||||
PathWaypoint waypointStart;
|
||||
waypointStart.position = NiPoint3(1, 2, 3);
|
||||
waypointStart.rotation = NiQuaternion(4, 5, 6, 7);
|
||||
waypointStart.movingPlatform.speed = 16.0f;
|
||||
|
||||
PathWaypoint waypointMiddle;
|
||||
waypointMiddle.position = NiPoint3(4, 5, 6);
|
||||
waypointMiddle.rotation = NiQuaternion(7, 8, 9, 10);
|
||||
waypointStart.movingPlatform.speed = 16.0f;
|
||||
|
||||
PathWaypoint waypointEnd;
|
||||
waypointEnd.position = NiPoint3(4, 5, 7);
|
||||
waypointEnd.rotation = NiQuaternion(7, 8, 9, 10);
|
||||
waypointStart.movingPlatform.speed = 16.0f;
|
||||
|
||||
path.pathWaypoints.push_back(waypointStart);
|
||||
path.pathWaypoints.push_back(waypointMiddle);
|
||||
@ -59,7 +62,6 @@ protected:
|
||||
|
||||
auto* simplePhysicsComponent = baseEntity->AddComponent<SimplePhysicsComponent>(1);
|
||||
auto* movingPlatformComponent = baseEntity->AddComponent<MovingPlatformComponent>("ExamplePath");
|
||||
new MovingPlatformComponent(baseEntity.get(), path.pathName);
|
||||
movingPlatformComponent->LoadConfigData();
|
||||
movingPlatformComponent->LoadDataFromTemplate();
|
||||
}
|
||||
@ -286,17 +288,14 @@ TEST_F(MovingPlatformComponentTests, MovingPlatformSubComponentPathAdvanceTest)
|
||||
|
||||
TEST_F(MovingPlatformComponentTests, MovingPlatformMoverSpeedCalculationTest) {
|
||||
MoverPlatformSubComponent moverPlatformSubComponent(baseEntity->GetComponent<MovingPlatformComponent>());
|
||||
path.pathWaypoints.at(0).position = NiPoint3(99.296440, 419.293335, 207.219498);
|
||||
path.pathWaypoints.at(0).movingPlatform.speed = 16.0f;
|
||||
|
||||
path.pathWaypoints.at(1).position = NiPoint3(141.680099, 419.990051, 208.680450);
|
||||
path.pathWaypoints.at(1).movingPlatform.speed = 16.0f;
|
||||
path.pathBehavior = PathBehavior::Bounce;
|
||||
moverPlatformSubComponent.SetupPath("ExamplePath", 0, false);
|
||||
|
||||
ASSERT_EQ(moverPlatformSubComponent.CalculateSpeed(), 16.0f);
|
||||
NiPoint3 r = moverPlatformSubComponent.CalculateLinearVelocity();
|
||||
ASSERT_FLOAT_EQ(r.x, 15.988346099854);
|
||||
ASSERT_FLOAT_EQ(r.y, 0.26282161474228);
|
||||
ASSERT_FLOAT_EQ(r.z, 0.5511137843132);
|
||||
ASSERT_FLOAT_EQ(r.x, 9.2376051);
|
||||
ASSERT_FLOAT_EQ(r.y, 9.2376051);
|
||||
ASSERT_FLOAT_EQ(r.z, 9.2376051);
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user