|
@@ -185,50 +185,39 @@ namespace AppleKraken
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- const float scan_step = 0.1f;
|
|
|
|
- // TODO whole scaning here is hack to deal with maximum number of 32 results that this
|
|
|
|
- // CreateBoxOverlapRequest can handle. It supposed to be adjusted in but it is not
|
|
|
|
- // AzPhysics::SceneConfiguration. We create small box and go from -1 to 1 in Z.
|
|
|
|
-
|
|
|
|
- AZ::Vector3 small_box_size;
|
|
|
|
- small_box_size.SetX(2.0f * globalBox.GetHalfLengths().GetX());
|
|
|
|
- small_box_size.SetY(2.0f * globalBox.GetHalfLengths().GetY());
|
|
|
|
- small_box_size.SetZ(scan_step * globalBox.GetHalfLengths().GetZ());
|
|
|
|
-
|
|
|
|
- for (float f = -1.f; f < 1.f; f += scan_step)
|
|
|
|
|
|
+ AzPhysics::OverlapRequest request = AzPhysics::OverlapRequestHelpers::CreateBoxOverlapRequest(
|
|
|
|
+ 2.0f * globalBox.GetHalfLengths(),
|
|
|
|
+ AZ::Transform::CreateFromQuaternionAndTranslation(
|
|
|
|
+ globalBox.GetRotation(), globalBox.GetPosition()));
|
|
|
|
+ // we want maximum overlap buffer set in `physxsystemconfiguration.setreg`
|
|
|
|
+ request.m_maxResults = physicsSystem->GetConfiguration()->m_overlapBufferSize;
|
|
|
|
+ AzPhysics::SceneQueryHits results = physicScene->QueryScene(&request);
|
|
|
|
+ for (auto& r : results.m_hits)
|
|
{
|
|
{
|
|
- AzPhysics::OverlapRequest request = AzPhysics::OverlapRequestHelpers::CreateBoxOverlapRequest(
|
|
|
|
- small_box_size,
|
|
|
|
- AZ::Transform::CreateFromQuaternionAndTranslation(
|
|
|
|
- globalBox.GetRotation(), globalBox.GetPosition() + AZ::Vector3(0.f, 0.f, f)));
|
|
|
|
-
|
|
|
|
- AzPhysics::SceneQueryHits results = physicScene->QueryScene(&request);
|
|
|
|
- for (auto& r : results.m_hits)
|
|
|
|
|
|
+ auto* entity = AzToolsFramework::GetEntity(r.m_entityId);
|
|
|
|
+ AZ_Printf("ApplePickerComponent", "hit to %s : %s", r.m_entityId.ToString().c_str(), entity->GetName().c_str());
|
|
|
|
+ if (entity->GetName() != "Apple")
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (found_apples.contains(r.m_entityId))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ bool is_visible = false;
|
|
|
|
+ AZ::Render::MeshComponentRequestBus::EventResult(
|
|
|
|
+ is_visible, r.m_entityId, &AZ::Render::MeshComponentRequests::GetVisibility);
|
|
|
|
+ if (!is_visible)
|
|
{
|
|
{
|
|
- auto* entity = AzToolsFramework::GetEntity(r.m_entityId);
|
|
|
|
- AZ_Printf("ApplePickerComponent", "hit to %s : %s", r.m_entityId.ToString().c_str(), entity->GetName().c_str());
|
|
|
|
- if (entity->GetName() != "Apple")
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (found_apples.contains(r.m_entityId))
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- bool is_visible = false;
|
|
|
|
- AZ::Render::MeshComponentRequestBus::EventResult(
|
|
|
|
- is_visible, r.m_entityId, &AZ::Render::MeshComponentRequests::GetVisibility);
|
|
|
|
- if (!is_visible)
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- PickAppleTask t;
|
|
|
|
- t.m_appleEntityId = r.m_entityId;
|
|
|
|
- t.m_appleBoundingBox = r.m_shape->GetAabb(entity->GetTransform()->GetWorldTM());
|
|
|
|
- m_currentAppleTasks.push(t);
|
|
|
|
- found_apples.emplace(r.m_entityId);
|
|
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ PickAppleTask t;
|
|
|
|
+ t.m_appleEntityId = r.m_entityId;
|
|
|
|
+ t.m_appleBoundingBox = r.m_shape->GetAabb(entity->GetTransform()->GetWorldTM());
|
|
|
|
+ m_currentAppleTasks.push(t);
|
|
|
|
+ found_apples.emplace(r.m_entityId);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
AZ_Printf("ApplePickerComponent", "There are %d apples in reach box \n", m_currentAppleTasks.size());
|
|
AZ_Printf("ApplePickerComponent", "There are %d apples in reach box \n", m_currentAppleTasks.size());
|
|
}
|
|
}
|