Merge remote-tracking branch 'origin/master' into 1.11
# Conflicts: # Source/Engine/Physics/Colliders/Collider.h
This commit is contained in:
@@ -176,10 +176,10 @@ namespace FlaxEditor.Surface
|
|||||||
if (connectedNodes.Count == 0)
|
if (connectedNodes.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < connectedNodes.Count - 1; i++)
|
for (int i = 0; i < connectedNodes.Count; i++)
|
||||||
{
|
{
|
||||||
SurfaceNode nodeA = connectedNodes[i];
|
SurfaceNode nodeA = connectedNodes[i];
|
||||||
List<Box> connectedOutputBoxes = nodeA.GetBoxes().Where(b => b.IsOutput && b.HasAnyConnection).ToList();
|
List<Box> connectedOutputBoxes = nodeA.GetBoxes().Where(b => b.HasAnyConnection).ToList();
|
||||||
|
|
||||||
for (int j = 0; j < connectedOutputBoxes.Count; j++)
|
for (int j = 0; j < connectedOutputBoxes.Count; j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ bool Texture::Save(const StringView& path)
|
|||||||
|
|
||||||
bool Texture::Save(const StringView& path, const InitData* customData)
|
bool Texture::Save(const StringView& path, const InitData* customData)
|
||||||
{
|
{
|
||||||
if (OnCheckSave())
|
if (OnCheckSave(path))
|
||||||
return true;
|
return true;
|
||||||
ScopeLock lock(Locker);
|
ScopeLock lock(Locker);
|
||||||
|
|
||||||
|
|||||||
@@ -159,9 +159,10 @@ void RigidBody::SetCenterOfMassOffset(const Float3& value)
|
|||||||
{
|
{
|
||||||
if (value == _centerOfMassOffset)
|
if (value == _centerOfMassOffset)
|
||||||
return;
|
return;
|
||||||
|
Float3 delta = value - _centerOfMassOffset;
|
||||||
_centerOfMassOffset = value;
|
_centerOfMassOffset = value;
|
||||||
if (_actor)
|
if (_actor)
|
||||||
PhysicsBackend::SetRigidDynamicActorCenterOfMassOffset(_actor, _centerOfMassOffset);
|
PhysicsBackend::AddRigidDynamicActorCenterOfMassOffset(_actor, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetConstraints(const RigidbodyConstraints value)
|
void RigidBody::SetConstraints(const RigidbodyConstraints value)
|
||||||
@@ -338,6 +339,32 @@ void RigidBody::AddMovement(const Vector3& translation, const Quaternion& rotati
|
|||||||
SetTransform(t);
|
SetTransform(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_EDITOR
|
||||||
|
|
||||||
|
#include "Engine/Debug/DebugDraw.h"
|
||||||
|
|
||||||
|
void RigidBody::OnDebugDrawSelected()
|
||||||
|
{
|
||||||
|
// Draw center of mass
|
||||||
|
if (!_centerOfMassOffset.IsZero())
|
||||||
|
{
|
||||||
|
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(GetPosition() + (GetOrientation() * (GetCenterOfMass() - GetCenterOfMassOffset())), 5.0f), Color::Red, 0, false);
|
||||||
|
}
|
||||||
|
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(GetPosition() + (GetOrientation() * GetCenterOfMass()), 2.5f), Color::Aqua, 0, false);
|
||||||
|
|
||||||
|
// Draw all attached colliders
|
||||||
|
for (Actor* child : Children)
|
||||||
|
{
|
||||||
|
const auto collider = Cast<Collider>(child);
|
||||||
|
if (collider && collider->GetAttachedRigidBody() == this)
|
||||||
|
collider->OnDebugDrawSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
Actor::OnDebugDrawSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void RigidBody::OnCollisionEnter(const Collision& c)
|
void RigidBody::OnCollisionEnter(const Collision& c)
|
||||||
{
|
{
|
||||||
CollisionEnter(c);
|
CollisionEnter(c);
|
||||||
@@ -514,7 +541,7 @@ void RigidBody::BeginPlay(SceneBeginData* data)
|
|||||||
|
|
||||||
// Apply the Center Of Mass offset
|
// Apply the Center Of Mass offset
|
||||||
if (!_centerOfMassOffset.IsZero())
|
if (!_centerOfMassOffset.IsZero())
|
||||||
PhysicsBackend::SetRigidDynamicActorCenterOfMassOffset(_actor, _centerOfMassOffset);
|
PhysicsBackend::AddRigidDynamicActorCenterOfMassOffset(_actor, _centerOfMassOffset);
|
||||||
|
|
||||||
// Register actor
|
// Register actor
|
||||||
PhysicsBackend::AddSceneActor(scene, _actor);
|
PhysicsBackend::AddSceneActor(scene, _actor);
|
||||||
|
|||||||
@@ -487,6 +487,9 @@ public:
|
|||||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||||
void AddMovement(const Vector3& translation, const Quaternion& rotation) override;
|
void AddMovement(const Vector3& translation, const Quaternion& rotation) override;
|
||||||
|
#if USE_EDITOR
|
||||||
|
void OnDebugDrawSelected() override;
|
||||||
|
#endif
|
||||||
|
|
||||||
// [IPhysicsActor]
|
// [IPhysicsActor]
|
||||||
void* GetPhysicsActor() const override;
|
void* GetPhysicsActor() const override;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void BoxCollider::OnDebugDraw()
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
OrientedBoundingBox GetWriteBox(const Vector3& min, const Vector3& max, const float margin)
|
OrientedBoundingBox GetWireBox(const Vector3& min, const Vector3& max, const float margin)
|
||||||
{
|
{
|
||||||
OrientedBoundingBox box;
|
OrientedBoundingBox box;
|
||||||
const Vector3 vec = max - min;
|
const Vector3 vec = max - min;
|
||||||
@@ -111,11 +111,40 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxCollider::OnDebugDrawSelected()
|
void BoxCollider::OnDebugDrawSelf()
|
||||||
{
|
{
|
||||||
const Color color = Color::GreenYellow;
|
const Color color = Color::GreenYellow;
|
||||||
DEBUG_DRAW_WIRE_BOX(_bounds, color * 0.3f, 0, false);
|
DEBUG_DRAW_WIRE_BOX(_bounds, color * 0.3f, 0, false);
|
||||||
|
|
||||||
|
Vector3 corners[8];
|
||||||
|
_bounds.GetCorners(corners);
|
||||||
|
const float margin = Math::Min(1.0f, (float)_bounds.GetSize().MinValue() * 0.01f);
|
||||||
|
const Color wiresColor = color.AlphaMultiplied(0.6f);
|
||||||
|
if (margin > 0.05f)
|
||||||
|
{
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[0], corners[1], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[0], corners[3], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[0], corners[4], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[1], corners[2], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[1], corners[5], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[2], corners[3], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[2], corners[6], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[3], corners[7], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[4], corners[5], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[4], corners[7], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[5], corners[6], margin), wiresColor, 0, true);
|
||||||
|
DEBUG_DRAW_BOX(GetWireBox(corners[6], corners[7], margin), wiresColor, 0, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG_DRAW_WIRE_BOX(_bounds, wiresColor, 0, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoxCollider::OnDebugDrawSelected()
|
||||||
|
{
|
||||||
|
OnDebugDrawSelf();
|
||||||
|
|
||||||
if (_contactOffset > 0)
|
if (_contactOffset > 0)
|
||||||
{
|
{
|
||||||
OrientedBoundingBox contactBounds = _bounds;
|
OrientedBoundingBox contactBounds = _bounds;
|
||||||
@@ -123,24 +152,6 @@ void BoxCollider::OnDebugDrawSelected()
|
|||||||
DEBUG_DRAW_WIRE_BOX(contactBounds, Color::Blue.AlphaMultiplied(0.2f), 0, false);
|
DEBUG_DRAW_WIRE_BOX(contactBounds, Color::Blue.AlphaMultiplied(0.2f), 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 corners[8];
|
|
||||||
_bounds.GetCorners(corners);
|
|
||||||
const float margin = 1.0f;
|
|
||||||
const Color wiresColor = color.AlphaMultiplied(0.6f);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[0], corners[1], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[0], corners[3], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[0], corners[4], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[1], corners[2], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[1], corners[5], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[2], corners[3], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[2], corners[6], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[3], corners[7], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[4], corners[5], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[4], corners[7], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[5], corners[6], margin), wiresColor, 0, true);
|
|
||||||
DEBUG_DRAW_BOX(GetWriteBox(corners[6], corners[7], margin), wiresColor, 0, true);
|
|
||||||
|
|
||||||
// Base
|
|
||||||
Collider::OnDebugDrawSelected();
|
Collider::OnDebugDrawSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
// [Collider]
|
// [Collider]
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
void OnDebugDraw() override;
|
void OnDebugDraw() override;
|
||||||
|
void OnDebugDrawSelf() override;
|
||||||
void OnDebugDrawSelected() override;
|
void OnDebugDrawSelected() override;
|
||||||
#endif
|
#endif
|
||||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||||
|
|||||||
@@ -52,6 +52,17 @@ void CapsuleCollider::DrawPhysicsDebug(RenderView& view)
|
|||||||
DEBUG_DRAW_WIRE_CAPSULE(_transform.LocalToWorld(_center), rotation, radius, height, Color::GreenYellow * 0.8f, 0, true);
|
DEBUG_DRAW_WIRE_CAPSULE(_transform.LocalToWorld(_center), rotation, radius, height, Color::GreenYellow * 0.8f, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CapsuleCollider::OnDebugDrawSelf()
|
||||||
|
{
|
||||||
|
Quaternion rotation;
|
||||||
|
Quaternion::Multiply(_transform.Orientation, Quaternion::Euler(0, 90, 0), rotation);
|
||||||
|
const float minSize = 0.001f;
|
||||||
|
const float radius = Math::Max(Math::Abs(_radius) * _cachedScale, minSize);
|
||||||
|
const float height = Math::Max(Math::Abs(_height) * _cachedScale, minSize);
|
||||||
|
const Vector3 position = _transform.LocalToWorld(_center);
|
||||||
|
DEBUG_DRAW_WIRE_CAPSULE(position, rotation, radius, height, Color::GreenYellow, 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
void CapsuleCollider::OnDebugDrawSelected()
|
void CapsuleCollider::OnDebugDrawSelected()
|
||||||
{
|
{
|
||||||
Quaternion rotation;
|
Quaternion rotation;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
// [Collider]
|
// [Collider]
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
|
void OnDebugDrawSelf() override;
|
||||||
void OnDebugDrawSelected() override;
|
void OnDebugDrawSelected() override;
|
||||||
#endif
|
#endif
|
||||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||||
|
|||||||
@@ -158,6 +158,12 @@ protected:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void RemoveStaticActor();
|
void RemoveStaticActor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend RigidBody;
|
||||||
|
#if USE_EDITOR
|
||||||
|
virtual void OnDebugDrawSelf() {}
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// [PhysicsColliderActor]
|
// [PhysicsColliderActor]
|
||||||
RigidBody* GetAttachedRigidBody() const override;
|
RigidBody* GetAttachedRigidBody() const override;
|
||||||
|
|||||||
@@ -85,13 +85,18 @@ void MeshCollider::DrawPhysicsDebug(RenderView& view)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshCollider::OnDebugDrawSelected()
|
void MeshCollider::OnDebugDrawSelf()
|
||||||
{
|
{
|
||||||
if (CollisionData && CollisionData->IsLoaded())
|
if (CollisionData && CollisionData->IsLoaded())
|
||||||
{
|
{
|
||||||
const auto& debugLines = CollisionData->GetDebugLines();
|
const auto& debugLines = CollisionData->GetDebugLines();
|
||||||
DEBUG_DRAW_LINES(Span<Float3>(debugLines.Get(), debugLines.Count()), _transform.GetWorld(), Color::GreenYellow, 0, false);
|
DEBUG_DRAW_LINES(Span<Float3>(debugLines.Get(), debugLines.Count()), _transform.GetWorld(), Color::GreenYellow, 0, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeshCollider::OnDebugDrawSelected()
|
||||||
|
{
|
||||||
|
OnDebugDrawSelf();
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
Collider::OnDebugDrawSelected();
|
Collider::OnDebugDrawSelected();
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
bool CanAttach(RigidBody* rigidBody) const override;
|
bool CanAttach(RigidBody* rigidBody) const override;
|
||||||
bool CanBeTrigger() const override;
|
bool CanBeTrigger() const override;
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
|
void OnDebugDrawSelf() override;
|
||||||
void OnDebugDrawSelected() override;
|
void OnDebugDrawSelected() override;
|
||||||
#endif
|
#endif
|
||||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||||
|
|||||||
@@ -35,9 +35,14 @@ void SphereCollider::DrawPhysicsDebug(RenderView& view)
|
|||||||
DEBUG_DRAW_WIRE_SPHERE(_sphere, Color::GreenYellow * 0.8f, 0, true);
|
DEBUG_DRAW_WIRE_SPHERE(_sphere, Color::GreenYellow * 0.8f, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SphereCollider::OnDebugDrawSelected()
|
void SphereCollider::OnDebugDrawSelf()
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_WIRE_SPHERE(_sphere, Color::GreenYellow, 0, false);
|
DEBUG_DRAW_WIRE_SPHERE(_sphere, Color::GreenYellow, 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SphereCollider::OnDebugDrawSelected()
|
||||||
|
{
|
||||||
|
OnDebugDrawSelf();
|
||||||
|
|
||||||
if (_contactOffset > 0)
|
if (_contactOffset > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
// [Collider]
|
// [Collider]
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
|
void OnDebugDrawSelf() override;
|
||||||
void OnDebugDrawSelected() override;
|
void OnDebugDrawSelected() override;
|
||||||
#endif
|
#endif
|
||||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||||
|
|||||||
@@ -2518,7 +2518,7 @@ Vector3 PhysicsBackend::GetRigidDynamicActorCenterOfMass(void* actor)
|
|||||||
return P2C(actorPhysX->getCMassLocalPose().p);
|
return P2C(actorPhysX->getCMassLocalPose().p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsBackend::SetRigidDynamicActorCenterOfMassOffset(void* actor, const Float3& value)
|
void PhysicsBackend::AddRigidDynamicActorCenterOfMassOffset(void* actor, const Float3& value)
|
||||||
{
|
{
|
||||||
auto actorPhysX = (PxRigidDynamic*)actor;
|
auto actorPhysX = (PxRigidDynamic*)actor;
|
||||||
auto pose = actorPhysX->getCMassLocalPose();
|
auto pose = actorPhysX->getCMassLocalPose();
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public:
|
|||||||
static Vector3 GetRigidDynamicActorAngularVelocity(void* actor);
|
static Vector3 GetRigidDynamicActorAngularVelocity(void* actor);
|
||||||
static void SetRigidDynamicActorAngularVelocity(void* actor, const Vector3& value, bool wakeUp);
|
static void SetRigidDynamicActorAngularVelocity(void* actor, const Vector3& value, bool wakeUp);
|
||||||
static Vector3 GetRigidDynamicActorCenterOfMass(void* actor);
|
static Vector3 GetRigidDynamicActorCenterOfMass(void* actor);
|
||||||
static void SetRigidDynamicActorCenterOfMassOffset(void* actor, const Float3& value);
|
static void AddRigidDynamicActorCenterOfMassOffset(void* actor, const Float3& value);
|
||||||
static bool GetRigidDynamicActorIsSleeping(void* actor);
|
static bool GetRigidDynamicActorIsSleeping(void* actor);
|
||||||
static void RigidDynamicActorSleep(void* actor);
|
static void RigidDynamicActorSleep(void* actor);
|
||||||
static void RigidDynamicActorWakeUp(void* actor);
|
static void RigidDynamicActorWakeUp(void* actor);
|
||||||
|
|||||||
@@ -388,7 +388,10 @@ int32 Font::HitTestText(const StringView& text, const Float2& location, const Te
|
|||||||
if (dst < smallestDst)
|
if (dst < smallestDst)
|
||||||
{
|
{
|
||||||
// Pointer is behind the last character in the line
|
// Pointer is behind the last character in the line
|
||||||
smallestIndex = line.LastCharIndex + 1;
|
if (text[line.LastCharIndex] == '\n' && lineIndex != lines.Count() - 1)
|
||||||
|
smallestIndex = line.LastCharIndex;
|
||||||
|
else
|
||||||
|
smallestIndex = line.LastCharIndex + 1;
|
||||||
|
|
||||||
// Fix for last line
|
// Fix for last line
|
||||||
//if (lineIndex == lines.Count() - 1)
|
//if (lineIndex == lines.Count() - 1)
|
||||||
|
|||||||
1
Source/ThirdParty/rapidjson/prettywriter.h
vendored
1
Source/ThirdParty/rapidjson/prettywriter.h
vendored
@@ -108,7 +108,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool String(const Ch* str, SizeType length, bool copy = false) {
|
bool String(const Ch* str, SizeType length, bool copy = false) {
|
||||||
RAPIDJSON_ASSERT(str != 0);
|
|
||||||
(void)copy;
|
(void)copy;
|
||||||
PrettyPrefix(kStringType);
|
PrettyPrefix(kStringType);
|
||||||
return Base::EndValue(Base::WriteString(str, length));
|
return Base::EndValue(Base::WriteString(str, length));
|
||||||
|
|||||||
Reference in New Issue
Block a user