EmptyEpsilon
EmptyEpsilon copied to clipboard
[Planet] Collision radius isn't updated with object radius
Steps to reproduce:
-
Launch EE with scenario_10_empty.lua and the HTTP API enabled.
-
Open the GM station and select the large blue planet.
-
Run:
planet = getGMSelection()[1] planet:setPlanetRadius(10000)
-
Create a ship and put it south of the resized planet.
-
Unpause the scenario.
Expected behavior:
- The planet collides with the ship and pushes it.
- On the GM screen and player radar, the planet's blue circle reflecting its collision radius is resized.
Observed behavior:
- The ship passes through and into the planet.
- The blue circle doesn't change in size.
Likely cause:
In planet.cpp this sets the collision radius:
void Planet::updateCollisionSize()
{
setRadius(planet_size);
if (std::abs(distance_from_movement_plane) >= planet_size)
{
collision_size = -1.0;
}else{
collision_size = sqrt((planet_size * planet_size) - (distance_from_movement_plane * distance_from_movement_plane)) * 1.1f;
setCollisionRadius(collision_size);
setCollisionPhysics(true, true);
}
}
but it only seems to be triggered in update()
and only if collision_size == -2.0f
, which is the default value upon instantiation.
void Planet::update(float delta)
{
if (collision_size == -2.0f)
{
updateCollisionSize();
if (collision_size > 0.0f)
PathPlannerManager::getInstance()->addAvoidObject(this, collision_size);
}