void ezObjectPickingResult::Reset() { m_PickedComponent = ezUuid(); m_PickedObject = ezUuid(); m_PickedOther = ezUuid(); m_uiPartIndex = 0; m_vPickedPosition.SetZero(); m_vPickedNormal.SetZero(); m_vPickingRayStart.SetZero(); }
void ezSceneViewContext::PickObjectAt(ezUInt16 x, ezUInt16 y) { // remote processes do not support picking, just ignore this if (ezEditorEngineProcessApp::GetSingleton()->IsRemoteMode()) return; ezViewPickingResultMsgToEditor res; ezView* pView = nullptr; if (ezRenderWorld::TryGetView(m_hView, pView) && pView->IsRenderPassReadBackPropertyExisting("EditorPickingPass", "PickingMatrix")) { pView->SetRenderPassProperty("EditorPickingPass", "PickingPosition", ezVec2(x, y)); ezVariant varMat = pView->GetRenderPassReadBackProperty("EditorPickingPass", "PickingMatrix"); if (varMat.IsA<ezMat4>()) { const ezUInt32 uiPickingID = pView->GetRenderPassReadBackProperty("EditorPickingPass", "PickingID").ConvertTo<ezUInt32>(); // const float fPickingDepth = pView->GetRenderPassReadBackProperty("EditorPickingPass", "PickingDepth").ConvertTo<float>(); res.m_vPickedNormal = pView->GetRenderPassReadBackProperty("EditorPickingPass", "PickingNormal").ConvertTo<ezVec3>(); res.m_vPickingRayStartPosition = pView->GetRenderPassReadBackProperty("EditorPickingPass", "PickingRayStartPosition").ConvertTo<ezVec3>(); res.m_vPickedPosition = pView->GetRenderPassReadBackProperty("EditorPickingPass", "PickingPosition").ConvertTo<ezVec3>(); EZ_ASSERT_DEBUG(!res.m_vPickedPosition.IsNaN(), ""); const ezUInt32 uiComponentID = (uiPickingID & 0x00FFFFFF); const ezUInt32 uiPartIndex = (uiPickingID >> 24) & 0x7F; // highest bit indicates whether the object is dynamic, ignore this res.m_ComponentGuid = GetDocumentContext()->m_Context.m_ComponentPickingMap.GetGuid(uiComponentID); res.m_OtherGuid = GetDocumentContext()->m_Context.m_OtherPickingMap.GetGuid(uiComponentID); if (res.m_ComponentGuid.IsValid()) { ezComponentHandle hComponent = GetDocumentContext()->m_Context.m_ComponentMap.GetHandle(res.m_ComponentGuid); ezEngineProcessDocumentContext* pDocumentContext = GetDocumentContext(); // check whether the component is still valid ezComponent* pComponent = nullptr; if (pDocumentContext->GetWorld()->TryGetComponent<ezComponent>(hComponent, pComponent)) { // if yes, fill out the parent game object guid res.m_ObjectGuid = GetDocumentContext()->m_Context.m_GameObjectMap.GetGuid(pComponent->GetOwner()->GetHandle()); res.m_uiPartIndex = uiPartIndex; } else { res.m_ComponentGuid = ezUuid(); } } } }
void ezCollisionMeshComponentDragDropHandler::OnDragBegin(const ezDragDropInfo* pInfo) { ezComponentDragDropHandler::OnDragBegin(pInfo); if (pInfo->m_sTargetContext == "viewport") CreateDropObject(pInfo->m_vDropPosition, "ezPxStaticActorComponent", "CollisionMesh", GetAssetGuidString(pInfo), ezUuid(), -1); else { if (pInfo->m_iTargetObjectInsertChildIndex == -1) // dropped directly on a node -> attach component only { AttachComponentToObject("ezPxStaticActorComponent", "CollisionMesh", GetAssetGuidString(pInfo), pInfo->m_TargetObject); // make sure this object gets selected m_DraggedObjects.PushBack(pInfo->m_TargetObject); } else CreateDropObject(pInfo->m_vDropPosition, "ezPxStaticActorComponent", "CollisionMesh", GetAssetGuidString(pInfo), pInfo->m_TargetObject, pInfo->m_iTargetObjectInsertChildIndex); } SelectCreatedObjects(); BeginTemporaryCommands(); }
void ezProceduralPlacementComponentDragDropHandler::OnDragBegin(const ezDragDropInfo* pInfo) { ezComponentDragDropHandler::OnDragBegin(pInfo); if (pInfo->m_sTargetContext == "viewport") CreateDropObject(pInfo->m_vDropPosition, "ezProceduralPlacementComponent", "Resource", GetAssetGuidString(pInfo), ezUuid(), -1); else CreateDropObject(pInfo->m_vDropPosition, "ezProceduralPlacementComponent", "Resource", GetAssetGuidString(pInfo), pInfo->m_TargetObject, pInfo->m_iTargetObjectInsertChildIndex); SelectCreatedObjects(); BeginTemporaryCommands(); }