Files
NazaraEngine/src/Nazara/Physics/PhysWorld.cpp
Lynix df8da275c4 Switch from Nz prefix to namespace Nz
What a huge commit


Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
2015-09-25 19:20:05 +02:00

66 lines
1.2 KiB
C++

// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics/PhysWorld.hpp>
#include <Newton/Newton.h>
#include <Nazara/Physics/Debug.hpp>
namespace Nz
{
PhysWorld::PhysWorld() :
m_gravity(Vector3f::Zero()),
m_stepSize(0.005f),
m_timestepAccumulator(0.f)
{
m_world = NewtonCreate();
NewtonWorldSetUserData(m_world, this);
}
PhysWorld::~PhysWorld()
{
NewtonDestroy(m_world);
}
Vector3f PhysWorld::GetGravity() const
{
return m_gravity;
}
NewtonWorld* PhysWorld::GetHandle() const
{
return m_world;
}
float PhysWorld::GetStepSize() const
{
return m_stepSize;
}
void PhysWorld::SetGravity(const Vector3f& gravity)
{
m_gravity = gravity;
}
void PhysWorld::SetSolverModel(unsigned int model)
{
NewtonSetSolverModel(m_world, model);
}
void PhysWorld::SetStepSize(float stepSize)
{
m_stepSize = stepSize;
}
void PhysWorld::Step(float timestep)
{
m_timestepAccumulator += timestep;
while (m_timestepAccumulator >= m_stepSize)
{
NewtonUpdate(m_world, m_stepSize);
m_timestepAccumulator -= m_stepSize;
}
}
}