Skip to content

Commit 24a14be

Browse files
authored
fixes issue with low sleep times and float math (#24)
1 parent 26fc757 commit 24a14be

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Game/AEntity.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ void AEntity::AddPod(const std::string& strUUID)
133133

134134
LOG_F(6, "Reset the mass data (pPod -> B2D Entity -> B2D Pod");
135135
pPod->m_pB2DEntity->m_pb2Body->ResetMassData();
136+
137+
pPod->m_pB2DEntity->m_pb2Body->SetLinearDamping(0.0f);
138+
pPod->m_pB2DEntity->m_pb2Body->SetAngularDamping(0.0f);
139+
136140
LOG_F(6, "The Pod's current mass: %f", pPod->m_pB2DEntity->m_pb2Body->GetMass());
137141
LOG_F(6, "The Pod's current inertia: %f", pPod->m_pB2DEntity->m_pb2Body->GetInertia());
138142

src/Game/B2DPod.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,19 @@ void B2DPod::Update()
111111
// turn rate is in degrees per second
112112
// server cycle is in milliseconds, so divide it by 1000
113113
// effective turn per tick = turn rate * server cycle / 1000
114-
float m_fDegreesPerTick = 45 * Configuration::Instance().SleepCycle / 1000;
114+
float m_fDegreesPerTick = 45.0f * float(Configuration::Instance().SleepCycle) / 1000.0f;
115115

116116
// for really high sleep cycles, even with a single button press, this
117117
// ends up being a really high value, so max it out at 5 degrees
118118

119-
if (m_fDegreesPerTick > 5) {
120-
m_fDegreesPerTick = 5;
119+
if (m_fDegreesPerTick > 5.0f) {
120+
m_fDegreesPerTick = 5.0f;
121121
}
122122
LOG_F(6, "Turn degrees per tick: %f", m_fDegreesPerTick);
123123

124124
// depending on whether the player is requesting left or right rotation, multiply by
125125
// the received y value
126-
m_fDegreesPerTick *= ab2Vec2Move.y;
126+
m_fDegreesPerTick *= float(ab2Vec2Move.y);
127127
LOG_F(6, "Turn in Degrees: %f", ab2Vec2Move.y);
128128

129129
// convert to radians

0 commit comments

Comments
 (0)