allow custom orbit rotations directions

This commit is contained in:
2026-06-17 20:36:11 +02:00
parent 1324a320e2
commit 0cf3d64983
8 changed files with 139 additions and 56 deletions

View File

@@ -9,6 +9,7 @@
#include "EntityAdmin.h"
#include "FacingComponent.h"
#include "MovementIntentComponent.h"
#include "OrbitMath.h"
#include "PositionComponent.h"
#include "tracing.h"
@@ -45,7 +46,19 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
return;
}
const QVector2D delta = intent.target - pos.value;
// Resolve the steering destination. For orbit intents, pick the orbit
// sense from the ship's current velocity (so ships circling the same
// target spread to both sides) and aim at a point on the orbit circle.
QVector2D destination = intent.target;
if (intent.orbitRadius_tiles > 0.0f)
{
const float sign = OrbitMath::resolveOrbitSign(pos.value, intent.target,
body.velocity_tpt);
destination = OrbitMath::computeOrbitDestination(
pos.value, intent.target, intent.orbitRadius_tiles, sign);
}
const QVector2D delta = destination - pos.value;
const float dist = delta.length();
if (dist < 0.001f)