Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oznogon opened this issue Mar 25, 2023 · 0 comments
Open

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

oznogon opened this issue Mar 25, 2023 · 0 comments

Comments

@oznogon
Copy link
Contributor

oznogon commented Mar 25, 2023

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);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant