Skip to content

Commit 3b5b786

Browse files
committed
UPBGE: Fix Linear velocity in KX_ObjectActuator
1 parent 104b398 commit 3b5b786

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

source/gameengine/Ketsji/KX_ObjectActuator.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -280,25 +280,27 @@ bool KX_ObjectActuator::Update()
280280
{
281281
if (m_bitLocalFlag.AddOrSetLinV) {
282282
parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
283-
} else {
283+
}
284+
else {
284285
m_active_combined_velocity = true;
285286
if (m_damping > 0) {
286-
MT_Vector3 angV;
287-
if (!m_angular_damping_active) {
287+
MT_Vector3 linV;
288+
if (!m_linear_damping_active) {
288289
// delta and the start speed (depends on the existing speed in that direction)
289-
angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity);
290+
linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
290291
// keep only the projection along the desired direction
291-
m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2;
292-
m_angular_damping_active = true;
292+
m_current_linear_factor = linV.dot(m_linear_velocity) / m_linear_length2;
293+
m_linear_damping_active = true;
293294
}
294-
if (m_current_angular_factor < 1.0f)
295-
m_current_angular_factor += 1.0f/m_damping;
296-
if (m_current_angular_factor > 1.0f)
297-
m_current_angular_factor = 1.0f;
298-
angV = m_current_angular_factor * m_angular_velocity;
299-
parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0);
300-
} else {
301-
parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0);
295+
if (m_current_linear_factor < 1.0f)
296+
m_current_linear_factor += 1.0f / m_damping;
297+
if (m_current_linear_factor > 1.0f)
298+
m_current_linear_factor = 1.0f;
299+
linV = m_current_linear_factor * m_linear_velocity;
300+
parent->setLinearVelocity(linV, (m_bitLocalFlag.LinearVelocity) != 0);
301+
}
302+
else {
303+
parent->setLinearVelocity(m_linear_velocity, (m_bitLocalFlag.LinearVelocity) != 0);
302304
}
303305
}
304306
}

0 commit comments

Comments
 (0)