Add LookingAt to Actor
This commit is contained in:
@@ -1424,10 +1424,24 @@ Actor* Actor::Intersects(const Ray& ray, float& distance, Vector3& normal)
|
||||
}
|
||||
|
||||
void Actor::LookAt(const Vector3& worldPos)
|
||||
{
|
||||
const Quaternion orientation = LookingAt(worldPos);
|
||||
|
||||
SetOrientation(orientation);
|
||||
}
|
||||
|
||||
void Actor::LookAt(const Vector3& worldPos, const Vector3& worldUp)
|
||||
{
|
||||
const Quaternion orientation = LookingAt(worldPos, worldUp);
|
||||
|
||||
SetOrientation(orientation);
|
||||
}
|
||||
|
||||
Quaternion Actor::LookingAt(const Vector3& worldPos)
|
||||
{
|
||||
const Vector3 direction = worldPos - _transform.Translation;
|
||||
if (direction.LengthSquared() < ZeroTolerance)
|
||||
return;
|
||||
return _parent->GetOrientation();
|
||||
|
||||
const Vector3 newForward = Vector3::Normalize(direction);
|
||||
const Vector3 oldForward = _transform.Orientation * Vector3::Forward;
|
||||
@@ -1447,26 +1461,25 @@ void Actor::LookAt(const Vector3& worldPos)
|
||||
orientation = rotQuat * _transform.Orientation;
|
||||
}
|
||||
|
||||
SetOrientation(orientation);
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void Actor::LookAt(const Vector3& worldPos, const Vector3& worldUp)
|
||||
Quaternion Actor::LookingAt(const Vector3& worldPos, const Vector3& worldUp)
|
||||
{
|
||||
const Vector3 direction = worldPos - _transform.Translation;
|
||||
if (direction.LengthSquared() < ZeroTolerance)
|
||||
return;
|
||||
return _parent->GetOrientation();
|
||||
const Vector3 forward = Vector3::Normalize(direction);
|
||||
const Vector3 up = Vector3::Normalize(worldUp);
|
||||
|
||||
if (Math::IsOne(Vector3::Dot(forward, up)))
|
||||
{
|
||||
LookAt(worldPos);
|
||||
return;
|
||||
return LookingAt(worldPos);
|
||||
}
|
||||
|
||||
Quaternion orientation;
|
||||
Quaternion::LookRotation(direction, up, orientation);
|
||||
SetOrientation(orientation);
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void WriteObjectToBytes(SceneObject* obj, rapidjson_flax::StringBuffer& buffer, MemoryWriteStream& output)
|
||||
|
||||
Reference in New Issue
Block a user