Scene changes and Bug fixes #336

Merged
glencelow merged 6 commits from PlayerController into main 2023-02-03 22:08:18 +08:00
6 changed files with 55 additions and 26 deletions
Showing only changes of commit 2ee46f33df - Show all commits

View File

@ -12,7 +12,6 @@ public class Breakable : Script
private Transform trans;
public bool isBreak { get; set; }
private List<GameObject> itemPieces = new List<GameObject>();
public bool print = false;
protected override void awake()
{
@ -44,9 +43,6 @@ public class Breakable : Script
if (ignoreRaccoon && info.GameObject.GetScript<PlayerController>())
return;
if(print)
Debug.Log($"COLLIED {rb.LinearVelocity.GetSqrMagnitude()} with EiD: {info.GameObject.Name}");
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold && !info.GameObject.GetScript<PlayerController>())
{
isBreak = true;

View File

@ -208,12 +208,23 @@ public class PickAndThrow : Script
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
if (rayList1.Count > 0 && rayList2.Count > 0 && rayList3.Count > 0)
if (rayList1.Count > 0)
{
RaycastHit ray1 = rayList1[0];
inRange = CheckForItem(ray1);
return;
}
else if (rayList2.Count > 0)
{
RaycastHit ray2 = rayList2[0];
inRange = CheckForItem(ray2);
return;
}
else if (rayList3.Count > 0)
{
RaycastHit ray3 = rayList3[0];
inRange = CheckForItem(ray1) || CheckForItem(ray2) || CheckForItem(ray3);
inRange = CheckForItem(ray3);
return;
}
else
{

View File

@ -11,6 +11,7 @@ namespace SHADE
{
if (Begin())
{
DrawMenuBar();
ImGui::BeginTable("CollisionMtxTable", SHCollisionTag::NUM_LAYERS + 1, ImGuiTableRowFlags_Headers);
ImGui::TableNextRow();
ImGui::PushID("CollisionTagNames");
@ -56,7 +57,10 @@ namespace SHADE
if(i == idx)
continue;
std::string label = std::format("##{} vs {}", tagName, tagName2);
SHEditorWidgets::CheckBox(label, [tag, &idx]{return tag->GetLayerState(idx);}, [tag, i, idx](bool const& value){tag->SetLayerState(idx, value); SHCollisionTagMatrix::GetTag(idx)->SetLayerState(i, value);}, label.substr(2));
if (SHEditorWidgets::CheckBox(label, [tag, &idx] {return tag->GetLayerState(idx); }, [tag, i, idx](bool const& value) {tag->SetLayerState(idx, value); SHCollisionTagMatrix::GetTag(idx)->SetLayerState(i, value); }, label.substr(2)))
{
isDirty = true;
}
}
}
ImGui::EndTable();
@ -64,4 +68,21 @@ namespace SHADE
ImGui::End();
}
void SHColliderTagPanel::DrawMenuBar()
{
if (ImGui::BeginMenuBar())
{
ImGui::BeginDisabled(!isDirty);
if (ImGui::Button("Save"))
{
std::filesystem::path defaultCollisionTagNameFilePath{ ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::Exit(defaultCollisionTagNameFilePath);
isDirty = false;
}
ImGui::EndDisabled();
ImGui::EndMenuBar();
}
}
}

View File

@ -14,6 +14,7 @@ namespace SHADE
//void Exit();
private:
void DrawMenuBar();
bool isDirty;
};
}

View File

@ -94,8 +94,8 @@ namespace SHADE
{
const bool CLEAR_EVENT = C_INFO.GetCollisionState() == SHCollisionInfo::State::EXIT || C_INFO.GetCollisionState() == SHCollisionInfo::State::INVALID;
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
if (CLEAR_EVENT || INACTIVE_OBJECT)
{

View File

@ -155,7 +155,7 @@ namespace SHADE
// Load start and end points into the container for debug drawing
#ifdef SHEDITOR
SHVec3 endPos = info.ray.position + info.ray.direction * SHRay::MAX_RAYCAST_DIST;
SHVec3 endPos = info.ray.position + info.ray.direction * std::clamp(info.distance,0.0f, SHRay::MAX_RAYCAST_DIST);
if (!results.empty())
endPos = results.back().position;