EmptyEpsilon icon indicating copy to clipboard operation
EmptyEpsilon copied to clipboard

[Planet] Collision radius isn't updated with object radius

Open oznogon opened this issue 1 year ago • 0 comments

Steps to reproduce:

  1. Launch EE with scenario_10_empty.lua and the HTTP API enabled.

  2. Open the GM station and select the large blue planet.

  3. Run:

    planet = getGMSelection()[1]
    planet:setPlanetRadius(10000)
    
  4. Create a ship and put it south of the resized planet.

  5. 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.

image

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);
    }

oznogon avatar Mar 25 '23 18:03 oznogon