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 ezRemoteEngineProcessViewContext::HandleViewMessage(const ezEditorEngineViewMsg* pMsg) { if (pMsg->GetDynamicRTTI()->IsDerivedFrom<ezActivateRemoteViewMsgToEngine>()) { if (m_hView.IsInvalidated()) { m_hView = ezEditorEngineProcessApp::GetSingleton()->CreateRemoteWindowAndView(&m_Camera); } s_pActiveRemoteViewContext = this; ezView* pView = nullptr; if (ezRenderWorld::TryGetView(m_hView, pView)) { ezEngineProcessDocumentContext* pDocumentContext = GetDocumentContext(); pView->SetWorld(pDocumentContext->GetWorld()); pView->SetCamera(&m_Camera); s_uiActiveViewID = pMsg->m_uiViewID; } } // ignore all messages for views that are currently not activated if (pMsg->m_uiViewID != s_uiActiveViewID) return; if (pMsg->GetDynamicRTTI()->IsDerivedFrom<ezViewRedrawMsgToEngine>()) { const ezViewRedrawMsgToEngine* pMsg2 = static_cast<const ezViewRedrawMsgToEngine*>(pMsg); SetCamera(pMsg2); // skip the on-message redraw, in remote mode it will just render as fast as it can // Redraw(false); #ifdef BUILDSYSTEM_ENABLE_MIXEDREALITY_SUPPORT auto pHoloFramework = ezMixedRealityFramework::GetSingleton(); if (pHoloFramework) { if (pMsg2->m_bUseCameraTransformOnDevice) { ezMat4 m = pMsg2->m_ViewMatrix; m.SetRow(1, -pMsg2->m_ViewMatrix.GetRow(2)); m.SetRow(2, pMsg2->m_ViewMatrix.GetRow(1)); ezTransform tf; tf.SetFromMat4(m); tf.m_vScale.Set(0.5f / (1.0f + tf.m_vPosition.GetLength())); tf.m_vPosition.SetZero(); pHoloFramework->SetAdditionalCameraTransform(tf); } else { pHoloFramework->SetAdditionalCameraTransform(ezTransform::IdentityTransform()); } } #endif } }
ezViewHandle ezAnimationClipViewContext::CreateView() { ezView* pView = nullptr; ezRenderWorld::CreateView("Animation Clip Editor - View", pView); pView->SetRenderPipelineResource(CreateDefaultRenderPipeline()); ezEngineProcessDocumentContext* pDocumentContext = GetDocumentContext(); pView->SetWorld(pDocumentContext->GetWorld()); pView->SetCamera(&m_Camera); return pView->GetHandle(); }
void ezSceneViewContext::Redraw(bool bRenderEditorGizmos) { ezView* pView = nullptr; if (ezRenderWorld::TryGetView(m_hView, pView)) { const ezTag& tagNoOrtho = ezTagRegistry::GetGlobalRegistry().RegisterTag("NotInOrthoMode"); if (pView->GetCamera()->IsOrthographic()) { pView->m_ExcludeTags.Set(tagNoOrtho); } else { pView->m_ExcludeTags.Remove(tagNoOrtho); } pView->SetRenderPassProperty("SimplePass.ezGizmoRenderer", "HighlightID", GetDocumentContext()->m_Context.m_uiHighlightID); } ezEngineProcessViewContext::Redraw(bRenderEditorGizmos); }
HRESULT StackFrame::GetCodeContext( IDebugCodeContext2** ppCodeCxt ) { if ( ppCodeCxt == NULL ) return E_INVALIDARG; HRESULT hr = S_OK; RefPtr<CodeContext> codeContext; hr = MakeCComObject( codeContext ); if ( FAILED( hr ) ) return hr; CComPtr<IDebugDocumentContext2> docContext; hr = GetDocumentContext( &docContext ); // there doesn't have to be a document context hr = codeContext->Init( mPC, mModule, docContext, mPtrSize ); if ( FAILED( hr ) ) return hr; return codeContext->QueryInterface( __uuidof( IDebugCodeContext2 ), (void**) ppCodeCxt ); }
ezViewHandle ezSceneViewContext::CreateView() { ezView* pView = nullptr; ezRenderWorld::CreateView("Editor - View", pView); pView->SetRenderPipelineResource(CreateDefaultRenderPipeline()); ezVariant sceneContextVariant(m_pSceneContext); pView->SetExtractorProperty("EditorSelectedObjectsExtractor", "SceneContext", sceneContextVariant); pView->SetExtractorProperty("EditorShapeIconsExtractor", "SceneContext", sceneContextVariant); pView->SetExtractorProperty("EditorGridExtractor", "SceneContext", sceneContextVariant); ezEngineProcessDocumentContext* pDocumentContext = GetDocumentContext(); pView->SetWorld(pDocumentContext->GetWorld()); pView->SetCamera(&m_Camera); pView->SetCullingCamera(&m_CullingCamera); pView->SetCameraUsageHint(ezCameraUsageHint::EditorView); const ezTag& tagHidden = ezTagRegistry::GetGlobalRegistry().RegisterTag("EditorHidden"); pView->m_ExcludeTags.Set(tagHidden); return pView->GetHandle(); }