Merge remote-tracking branch 'origin/master' into 1.10
This commit is contained in:
@@ -48,9 +48,9 @@ void CapsuleCollider::DrawPhysicsDebug(RenderView& view)
|
||||
const float radius = Math::Max(Math::Abs(_radius) * scaling, minSize);
|
||||
const float height = Math::Max(Math::Abs(_height) * scaling, minSize);
|
||||
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
|
||||
DEBUG_DRAW_TUBE(_transform.LocalToWorld(_center), rotation, radius, height, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
|
||||
DEBUG_DRAW_CAPSULE(_transform.LocalToWorld(_center), rotation, radius, height, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
|
||||
else
|
||||
DEBUG_DRAW_WIRE_TUBE(_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::OnDebugDrawSelected()
|
||||
@@ -62,11 +62,11 @@ void CapsuleCollider::OnDebugDrawSelected()
|
||||
const float radius = Math::Max(Math::Abs(_radius) * scaling, minSize);
|
||||
const float height = Math::Max(Math::Abs(_height) * scaling, minSize);
|
||||
const Vector3 position = _transform.LocalToWorld(_center);
|
||||
DEBUG_DRAW_WIRE_TUBE(position, rotation, radius, height, Color::GreenYellow, 0, false);
|
||||
DEBUG_DRAW_WIRE_CAPSULE(position, rotation, radius, height, Color::GreenYellow, 0, false);
|
||||
|
||||
if (_contactOffset > 0)
|
||||
{
|
||||
DEBUG_DRAW_WIRE_TUBE(position, rotation, radius + _contactOffset, height, Color::Blue.AlphaMultiplied(0.2f), 0, false);
|
||||
DEBUG_DRAW_WIRE_CAPSULE(position, rotation, radius + _contactOffset, height, Color::Blue.AlphaMultiplied(0.2f), 0, false);
|
||||
}
|
||||
|
||||
// Base
|
||||
|
||||
@@ -192,9 +192,9 @@ void CharacterController::DrawPhysicsDebug(RenderView& view)
|
||||
const float height = Math::Max(Math::Abs(_height) * scaling, CC_MIN_SIZE);
|
||||
const Vector3 position = _transform.LocalToWorld(_center);
|
||||
if (view.Mode == ViewMode::PhysicsColliders)
|
||||
DEBUG_DRAW_TUBE(position, Quaternion::Euler(90, 0, 0), radius, height, Color::LightYellow, 0, true);
|
||||
DEBUG_DRAW_CAPSULE(position, Quaternion::Euler(90, 0, 0), radius, height, Color::LightYellow, 0, true);
|
||||
else
|
||||
DEBUG_DRAW_WIRE_TUBE(position, Quaternion::Euler(90, 0, 0), radius, height, Color::GreenYellow * 0.8f, 0, true);
|
||||
DEBUG_DRAW_WIRE_CAPSULE(position, Quaternion::Euler(90, 0, 0), radius, height, Color::GreenYellow * 0.8f, 0, true);
|
||||
}
|
||||
|
||||
void CharacterController::OnDebugDrawSelected()
|
||||
@@ -203,7 +203,7 @@ void CharacterController::OnDebugDrawSelected()
|
||||
const float radius = Math::Max(Math::Abs(_radius) * scaling, CC_MIN_SIZE);
|
||||
const float height = Math::Max(Math::Abs(_height) * scaling, CC_MIN_SIZE);
|
||||
const Vector3 position = _transform.LocalToWorld(_center);
|
||||
DEBUG_DRAW_WIRE_TUBE(position, Quaternion::Euler(90, 0, 0), radius, height, Color::GreenYellow, 0, false);
|
||||
DEBUG_DRAW_WIRE_CAPSULE(position, Quaternion::Euler(90, 0, 0), radius, height, Color::GreenYellow, 0, false);
|
||||
|
||||
// Base
|
||||
Collider::OnDebugDrawSelected();
|
||||
|
||||
@@ -216,7 +216,21 @@ bool CollisionCooking::CookCollision(const Argument& arg, CollisionData::Seriali
|
||||
const int32 vertexCount = vertexCounts[i];
|
||||
if (vertexCount == 0)
|
||||
continue;
|
||||
Platform::MemoryCopy(finalVertexData.Get() + firstVertexIndex, vData.Get(), vertexCount * sizeof(Float3));
|
||||
const int32 vStride = vData.Length() / vertexCount;
|
||||
if (vStride == sizeof(Float3))
|
||||
Platform::MemoryCopy(finalVertexData.Get() + firstVertexIndex, vData.Get(), vertexCount * sizeof(Float3));
|
||||
else
|
||||
{
|
||||
// This assumes that each vertex structure contains position as Float3 in the beginning
|
||||
auto dst = finalVertexData.Get() + firstVertexIndex;
|
||||
auto src = vData.Get();
|
||||
for (int32 j = 0; j < vertexCount; j++)
|
||||
{
|
||||
*dst++ = *(Float3*)src;
|
||||
src += vStride;
|
||||
|
||||
}
|
||||
}
|
||||
vertexCounter += vertexCount;
|
||||
|
||||
if (needIndexBuffer)
|
||||
|
||||
@@ -536,15 +536,6 @@ protected:
|
||||
hitInfo = hit.shape ? static_cast<PhysicsColliderActor*>(hit.shape->userData) : nullptr; \
|
||||
}
|
||||
|
||||
#define SCENE_QUERY_COLLECT_OVERLAP_COLLIDER() results.Clear(); \
|
||||
results.Resize(buffer.getNbTouches(), false); \
|
||||
for (int32 i = 0; i < results.Count(); i++) \
|
||||
{ \
|
||||
auto& hitInfo = results[i]; \
|
||||
const auto& hit = buffer.getTouch(i); \
|
||||
hitInfo = hit.shape ? static_cast<Collider*>(hit.shape->userData) : nullptr; \
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
PxFoundation* Foundation = nullptr;
|
||||
@@ -2266,51 +2257,6 @@ bool PhysicsBackend::CheckConvex(void* scene, const Vector3& center, const Colli
|
||||
return scenePhysX->Scene->overlap(geometry, pose, buffer, filterData, &QueryFilter);
|
||||
}
|
||||
|
||||
bool PhysicsBackend::OverlapBox(void* scene, const Vector3& center, const Vector3& halfExtents, Array<Collider*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
SCENE_QUERY_SETUP_OVERLAP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxBoxGeometry geometry(C2P(halfExtents));
|
||||
if (!scenePhysX->Scene->overlap(geometry, pose, buffer, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_OVERLAP_COLLIDER();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PhysicsBackend::OverlapSphere(void* scene, const Vector3& center, const float radius, Array<Collider*>& results, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
SCENE_QUERY_SETUP_OVERLAP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin));
|
||||
const PxSphereGeometry geometry(radius);
|
||||
if (!scenePhysX->Scene->overlap(geometry, pose, buffer, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_OVERLAP_COLLIDER();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PhysicsBackend::OverlapCapsule(void* scene, const Vector3& center, const float radius, const float height, Array<Collider*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
SCENE_QUERY_SETUP_OVERLAP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxCapsuleGeometry geometry(radius, height * 0.5f);
|
||||
if (!scenePhysX->Scene->overlap(geometry, pose, buffer, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_OVERLAP_COLLIDER();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PhysicsBackend::OverlapConvex(void* scene, const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, Array<Collider*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
CHECK_RETURN(convexMesh && convexMesh->GetOptions().Type == CollisionDataType::ConvexMesh, false)
|
||||
SCENE_QUERY_SETUP_OVERLAP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxConvexMeshGeometry geometry((PxConvexMesh*)convexMesh->GetConvex(), PxMeshScale(C2P(scale)));
|
||||
if (!scenePhysX->Scene->overlap(geometry, pose, buffer, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_OVERLAP_COLLIDER();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PhysicsBackend::OverlapBox(void* scene, const Vector3& center, const Vector3& halfExtents, Array<PhysicsColliderActor*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
SCENE_QUERY_SETUP_OVERLAP();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "PhysicalMaterial.h"
|
||||
#include "PhysicsSettings.h"
|
||||
#include "PhysicsStatistics.h"
|
||||
#include "Colliders/Collider.h"
|
||||
#include "Engine/Engine/Time.h"
|
||||
#include "Engine/Engine/EngineService.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
@@ -660,22 +661,66 @@ bool PhysicsScene::CheckConvex(const Vector3& center, const CollisionData* conve
|
||||
|
||||
bool PhysicsScene::OverlapBox(const Vector3& center, const Vector3& halfExtents, Array<Collider*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
return PhysicsBackend::OverlapBox(_scene, center, halfExtents, results, rotation, layerMask, hitTriggers);
|
||||
Array<PhysicsColliderActor*> tmp;
|
||||
if (PhysicsBackend::OverlapBox(_scene, center, halfExtents, tmp, rotation, layerMask, hitTriggers))
|
||||
{
|
||||
results.EnsureCapacity(tmp.Count());
|
||||
for (PhysicsColliderActor* e : tmp)
|
||||
{
|
||||
if (e && e->Is<Collider>())
|
||||
results.Add((Collider*)e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PhysicsScene::OverlapSphere(const Vector3& center, const float radius, Array<Collider*>& results, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
return PhysicsBackend::OverlapSphere(_scene, center, radius, results, layerMask, hitTriggers);
|
||||
Array<PhysicsColliderActor*> tmp;
|
||||
if (PhysicsBackend::OverlapSphere(_scene, center, radius, tmp, layerMask, hitTriggers))
|
||||
{
|
||||
results.EnsureCapacity(tmp.Count());
|
||||
for (PhysicsColliderActor* e : tmp)
|
||||
{
|
||||
if (e && e->Is<Collider>())
|
||||
results.Add((Collider*)e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PhysicsScene::OverlapCapsule(const Vector3& center, const float radius, const float height, Array<Collider*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
return PhysicsBackend::OverlapCapsule(_scene, center, radius, height, results, rotation, layerMask, hitTriggers);
|
||||
Array<PhysicsColliderActor*> tmp;
|
||||
if (PhysicsBackend::OverlapCapsule(_scene, center, radius, height, tmp, rotation, layerMask, hitTriggers))
|
||||
{
|
||||
results.EnsureCapacity(tmp.Count());
|
||||
for (PhysicsColliderActor* e : tmp)
|
||||
{
|
||||
if (e && e->Is<Collider>())
|
||||
results.Add((Collider*)e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PhysicsScene::OverlapConvex(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, Array<Collider*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
return PhysicsBackend::OverlapConvex(_scene, center, convexMesh, scale, results, rotation, layerMask, hitTriggers);
|
||||
Array<PhysicsColliderActor*> tmp;
|
||||
if (PhysicsBackend::OverlapConvex(_scene, center, convexMesh, scale, tmp, rotation, layerMask, hitTriggers))
|
||||
{
|
||||
results.EnsureCapacity(tmp.Count());
|
||||
for (PhysicsColliderActor* e : tmp)
|
||||
{
|
||||
if (e && e->Is<Collider>())
|
||||
results.Add((Collider*)e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PhysicsScene::OverlapBox(const Vector3& center, const Vector3& halfExtents, Array<PhysicsColliderActor*>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
|
||||
|
||||
@@ -139,10 +139,6 @@ public:
|
||||
static bool CheckSphere(void* scene, const Vector3& center, float radius, uint32 layerMask, bool hitTriggers);
|
||||
static bool CheckCapsule(void* scene, const Vector3& center, float radius, float height, const Quaternion& rotation, uint32 layerMask, bool hitTriggers);
|
||||
static bool CheckConvex(void* scene, const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, const Quaternion& rotation, uint32 layerMask, bool hitTriggers);
|
||||
static bool OverlapBox(void* scene, const Vector3& center, const Vector3& halfExtents, Array<Collider*, HeapAllocation>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers);
|
||||
static bool OverlapSphere(void* scene, const Vector3& center, float radius, Array<Collider*, HeapAllocation>& results, uint32 layerMask, bool hitTriggers);
|
||||
static bool OverlapCapsule(void* scene, const Vector3& center, float radius, float height, Array<Collider*, HeapAllocation>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers);
|
||||
static bool OverlapConvex(void* scene, const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, Array<Collider*, HeapAllocation>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers);
|
||||
static bool OverlapBox(void* scene, const Vector3& center, const Vector3& halfExtents, Array<PhysicsColliderActor*, HeapAllocation>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers);
|
||||
static bool OverlapSphere(void* scene, const Vector3& center, float radius, Array<PhysicsColliderActor*, HeapAllocation>& results, uint32 layerMask, bool hitTriggers);
|
||||
static bool OverlapCapsule(void* scene, const Vector3& center, float radius, float height, Array<PhysicsColliderActor*, HeapAllocation>& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers);
|
||||
|
||||
Reference in New Issue
Block a user