Camera Collision fix. Still have some minor bugs #345
|
@ -1,4 +1,4 @@
|
|||
Start Maximized: true
|
||||
Working Scene ID: 91685359
|
||||
Working Scene ID: 86098106
|
||||
Window Size: {x: 1920, y: 1013}
|
||||
Style: 0
|
|
@ -1,16 +1,16 @@
|
|||
[Window][MainStatusBar]
|
||||
Pos=0,981
|
||||
Size=1920,20
|
||||
Pos=0,989
|
||||
Size=2560,20
|
||||
Collapsed=0
|
||||
|
||||
[Window][SHEditorMenuBar]
|
||||
Pos=0,48
|
||||
Size=1920,933
|
||||
Size=2560,941
|
||||
Collapsed=0
|
||||
|
||||
[Window][Hierarchy Panel]
|
||||
Pos=0,186
|
||||
Size=300,795
|
||||
Pos=0,187
|
||||
Size=300,802
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
|
||||
|
@ -20,14 +20,14 @@ Size=400,400
|
|||
Collapsed=0
|
||||
|
||||
[Window][Inspector]
|
||||
Pos=1434,48
|
||||
Size=486,933
|
||||
Pos=2074,48
|
||||
Size=486,941
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Window][Profiler]
|
||||
Pos=0,48
|
||||
Size=300,136
|
||||
Size=300,137
|
||||
Collapsed=0
|
||||
DockId=0x00000003,0
|
||||
|
||||
|
@ -76,7 +76,7 @@ DockId=0x0000000B,0
|
|||
|
||||
[Window][ Viewport]
|
||||
Pos=302,48
|
||||
Size=1130,697
|
||||
Size=1770,705
|
||||
Collapsed=0
|
||||
DockId=0x0000000B,0
|
||||
|
||||
|
@ -93,14 +93,14 @@ Collapsed=0
|
|||
DockId=0x0000000A,0
|
||||
|
||||
[Window][ Asset Browser]
|
||||
Pos=302,747
|
||||
Size=1130,234
|
||||
Pos=302,755
|
||||
Size=1770,234
|
||||
Collapsed=0
|
||||
DockId=0x0000000C,0
|
||||
|
||||
[Window][Material Inspector]
|
||||
Pos=1434,48
|
||||
Size=486,933
|
||||
Pos=2074,48
|
||||
Size=486,941
|
||||
Collapsed=0
|
||||
DockId=0x00000006,1
|
||||
|
||||
|
@ -116,13 +116,13 @@ Collapsed=0
|
|||
|
||||
[Window][Collider Tag Panel]
|
||||
Pos=302,48
|
||||
Size=1130,697
|
||||
Size=1770,705
|
||||
Collapsed=0
|
||||
DockId=0x0000000B,1
|
||||
|
||||
[Window][Input Bindings Panel]
|
||||
Pos=1434,48
|
||||
Size=486,933
|
||||
Pos=2074,48
|
||||
Size=486,941
|
||||
Collapsed=0
|
||||
DockId=0x00000006,2
|
||||
|
||||
|
@ -151,7 +151,7 @@ Column 15 Weight=0.8632
|
|||
Column 16 Weight=1.3510
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,77 Size=1920,933 Split=X
|
||||
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=2560,941 Split=X
|
||||
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1432,1036 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=300,1036 Split=Y Selected=0x1E6EB881
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,147 Selected=0x1E6EB881
|
||||
|
@ -159,9 +159,9 @@ DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,77 Size=1920,933 Split
|
|||
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1130,1036 Split=Y Selected=0xB41284E7
|
||||
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7
|
||||
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7
|
||||
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0x69428B24
|
||||
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0xB41284E7
|
||||
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,234 Selected=0xB128252A
|
||||
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6
|
||||
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532
|
||||
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=486,1036 Selected=0xD3697FB6
|
||||
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=486,1036 Selected=0xE7039252
|
||||
|
||||
|
|
|
@ -9719,7 +9719,7 @@
|
|||
Camera Arm Component:
|
||||
Arm Pitch: 0
|
||||
Arm Yaw: 0
|
||||
Arm Length: 1
|
||||
Arm Length: 3
|
||||
Look At Camera Origin: true
|
||||
Target Offset: {x: 0, y: 0, z: 0}
|
||||
Camera Collision: true
|
||||
|
@ -9727,7 +9727,7 @@
|
|||
Scripts:
|
||||
- Type: SHADE_Scripting.ThirdPersonCamera
|
||||
Enabled: true
|
||||
armLength: 1
|
||||
armLength: 3
|
||||
turnSpeedPitch: 0.300000012
|
||||
turnSpeedYaw: 0.5
|
||||
pitchClamp: 45
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace SHADE
|
|||
//info.layers = (SHCollisionTagMatrix::GetTag("7")->GetMask());
|
||||
info.layers = (uint16_t)(SHCollisionTag::Layer::ALL);
|
||||
info.distance = 1000000.0f;
|
||||
info.continuous = true;
|
||||
info.continuous = false;
|
||||
info.ray.position = cameraTarget;
|
||||
info.SetColliderID(2);
|
||||
info.ray.direction = SHVec3::Normalise(cameraPos - cameraTarget);
|
||||
|
@ -200,16 +200,20 @@ namespace SHADE
|
|||
newOffset = SHVec3::RotateY(newOffset, (SHMath::DegreesToRadians(pivot.GetYaw())));
|
||||
newOffset = SHVec3::Normalise(newOffset) * (hitResult.distance);
|
||||
pivot.offset = newOffset;
|
||||
cameraPos = camera->position + pivot.offset;
|
||||
SHLOG_INFO("CAMERA COLLISION HIT, {} armlength: {}, true armlength: {}", hitResult.distance, hitResult.distance, (cameraPos - camera->position).Length());
|
||||
//cameraPos = camera->position + pivot.offset;
|
||||
//SHLOG_INFO("CAMERA COLLISION HIT, {} armlength: {}, true armlength: {}", hitResult.distance, hitResult.distance, (cameraPos - camera->position).Length());
|
||||
//SHLOG_INFO("Racoon Position {}, {}, {}, Camera Position: {}, {}, {}, Distance {}", cameraTarget.x, cameraTarget.y, cameraTarget.z, cameraPos.x, cameraPos.y, cameraPos.z, SHVec3::Distance(cameraTarget, cameraPos));
|
||||
SHLOG_INFO("Camera Position: {}, {}, {}", cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
auto otherTransform = SHComponentManager::GetComponent_s<SHTransformComponent>(hitResult.entityHit);
|
||||
SHVec3 otherPos = hitResult.position;
|
||||
|
||||
|
||||
|
||||
//SHLOG_INFO("hit distance{} other pos: {},{},{}, distance between: {}", hitResult.distance, otherPos.x, otherPos.y, otherPos.z, SHVec3::Distance(cameraTarget,otherPos));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////auto result = physicsSystem->Raycast(pivot.ray);
|
||||
//if (result && result.distance < pivot.GetArmLength())
|
||||
//{
|
||||
|
@ -262,6 +266,7 @@ namespace SHADE
|
|||
camera.offset = arm->GetOffset();
|
||||
if (arm->lookAtCameraOrigin)
|
||||
CameraLookAt(camera, camera.position);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -445,7 +450,7 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
|
||||
void SHCameraSystem::DecomposeViewMatrix(SHMatrix const& viewMatrix, float& pitch, float& yaw, float& roll, SHVec3& pos) noexcept
|
||||
void SHCameraSystem::DecomposeViewMatrix(SHMatrix const& viewMatrix, float& pitch, float& yaw, float& roll, SHVec3& pos, bool takePos) noexcept
|
||||
{
|
||||
|
||||
float initPitch = pitch;
|
||||
|
@ -468,15 +473,18 @@ namespace SHADE
|
|||
mtx = SHMatrix::Inverse(mtx);
|
||||
SHVec4 translate = mtx* dotPos;
|
||||
|
||||
pos.x = translate.x;
|
||||
pos.y = translate.y;
|
||||
pos.z = translate.z;
|
||||
if (takePos)
|
||||
{
|
||||
pos.x = translate.x;
|
||||
pos.y = translate.y;
|
||||
pos.z = translate.z;
|
||||
}
|
||||
|
||||
}
|
||||
void SHCameraSystem::SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix) noexcept
|
||||
void SHCameraSystem::SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix, bool takePos) noexcept
|
||||
{
|
||||
SHVec3 pos;
|
||||
DecomposeViewMatrix(viewMatrix, camera.pitch, camera.yaw, camera.roll, camera.position);
|
||||
DecomposeViewMatrix(viewMatrix, camera.pitch, camera.yaw, camera.roll, camera.position, takePos);
|
||||
|
||||
camera.dirtyView = true;
|
||||
}
|
||||
|
@ -484,7 +492,7 @@ namespace SHADE
|
|||
void SHCameraSystem::CameraLookAt(SHCameraComponent& camera, SHVec3 target) noexcept
|
||||
{
|
||||
|
||||
if (camera.position == target)
|
||||
if (camera.position + camera.offset == target)
|
||||
{
|
||||
//lets off set it abit so the view is nt fked
|
||||
target.z -= 0.0001f;
|
||||
|
@ -526,7 +534,7 @@ namespace SHADE
|
|||
viewMtx(2, 3) = -forward.Dot(camera.position + camera.offset);
|
||||
|
||||
|
||||
SetCameraViewMatrix(camera, viewMtx);
|
||||
SetCameraViewMatrix(camera, viewMtx,false);
|
||||
}
|
||||
|
||||
SHVec2 SHCameraSystem::GetCameraWidthHeight(size_t index) noexcept
|
||||
|
|
|
@ -54,8 +54,8 @@ namespace SHADE
|
|||
void ClampCameraRotation(SHCameraComponent& camera) noexcept;
|
||||
void UpdateEditorCamera(double dt) noexcept;
|
||||
void SetMainCamera(EntityID eid, size_t directorIndex) noexcept;
|
||||
void DecomposeViewMatrix(SHMatrix const& matrix, float& pitch, float& yaw, float& roll, SHVec3& pos) noexcept;
|
||||
void SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix) noexcept;
|
||||
void DecomposeViewMatrix(SHMatrix const& matrix, float& pitch, float& yaw, float& roll, SHVec3& pos, bool takePos) noexcept;
|
||||
void SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix, bool takePos) noexcept;
|
||||
void CameraLookAt(SHCameraComponent& camera, SHVec3 target) noexcept;
|
||||
void UpdateEditorArm(double dt,bool active ,SHVec3 const& targetPos) noexcept;
|
||||
|
||||
|
|
Loading…
Reference in New Issue