ezResult ezImageConversion::Convert(const ezImageView& source, ezImage& target, ezArrayPtr<ConversionPathNode> path, ezUInt32 numScratchBuffers) { EZ_ASSERT_DEV(path.GetCount() > 0, "Invalid conversion path"); EZ_ASSERT_DEV(path[0].m_sourceFormat == source.GetImageFormat(), "Invalid conversion path"); ezHybridArray<ezImage, 16> intermediates; intermediates.SetCount(numScratchBuffers); const ezImageView* pSource = &source; for (ezUInt32 i = 0; i < path.GetCount(); ++i) { ezUInt32 targetIndex = path[i].m_targetBufferIndex; ezImage* pTarget = targetIndex == 0 ? &target : &intermediates[targetIndex - 1]; if (ConvertSingleStep(path[i].m_step, *pSource, *pTarget, path[i].m_targetFormat).Failed()) { return EZ_FAILURE; } pSource = pTarget; } return EZ_SUCCESS; }
void ezInputDeviceController::SetVibrationStrength(ezUInt8 uiVirtual, Motor::Enum eMotor, float fValue) { EZ_ASSERT_DEV(uiVirtual < MaxControllers, "Controller Index {0} is larger than allowed ({1}).", uiVirtual, MaxControllers); EZ_ASSERT_DEV(eMotor < Motor::ENUM_COUNT, "Invalid Vibration Motor Index."); m_fVibrationStrength[uiVirtual][eMotor] = ezMath::Clamp(fValue, 0.0f, 1.0f); }
void ezInputDeviceController::SetControllerMapping(ezUInt8 uiVirtualController, ezInt8 iTakeInputFromPhysical) { EZ_ASSERT_DEV(uiVirtualController < MaxControllers, "Virtual Controller Index {0} is larger than allowed ({1}).", uiVirtualController, MaxControllers); EZ_ASSERT_DEV(iTakeInputFromPhysical < MaxControllers, "Physical Controller Index {0} is larger than allowed ({1}).", iTakeInputFromPhysical, MaxControllers); if (iTakeInputFromPhysical < 0) { // deactivates this virtual controller m_iControllerMapping[uiVirtualController] = -1; } else { // if any virtual controller already maps to the given physical controller, let it use the physical controller that // uiVirtualController is currently mapped to for (ezInt32 c = 0; c < MaxControllers; ++c) { if (m_iControllerMapping[c] == iTakeInputFromPhysical) { m_iControllerMapping[c] = m_iControllerMapping[uiVirtualController]; break; } } m_iControllerMapping[uiVirtualController] = iTakeInputFromPhysical; } }
float ezInputDeviceController::GetVibrationStrength(ezUInt8 uiVirtual, Motor::Enum eMotor) { EZ_ASSERT_DEV(uiVirtual < MaxControllers, "Controller Index {0} is larger than allowed ({1}).", uiVirtual, MaxControllers); EZ_ASSERT_DEV(eMotor < Motor::ENUM_COUNT, "Invalid Vibration Motor Index."); return m_fVibrationStrength[uiVirtual][eMotor]; }
ezResult ezPreprocessor::OpenFile(const char* szFile, const ezTokenizer** pTokenizer) { EZ_ASSERT_DEV(m_FileOpenCallback.IsValid(), "OpenFile callback has not been set"); EZ_ASSERT_DEV(m_FileLocatorCallback.IsValid(), "File locator callback has not been set"); *pTokenizer = nullptr; auto it = m_pUsedFileCache->Lookup(szFile); if (it.IsValid()) { *pTokenizer = &it.Value().m_Tokens; return EZ_SUCCESS; } ezTimestamp stamp; ezDynamicArray<ezUInt8> Content; if (m_FileOpenCallback(szFile, Content, stamp).Failed()) { ezLog::Error(m_pLog, "Could not open file '%s'", szFile); return EZ_FAILURE; } *pTokenizer = m_pUsedFileCache->Tokenize(szFile, Content, stamp, m_pLog); return EZ_SUCCESS; }
void ezRTTI::VerifyCorrectness() const { if (m_fnVerifyParent != nullptr) { EZ_ASSERT_DEV(m_fnVerifyParent() == m_pParentType, "Type '{0}': The given parent type '{1}' does not match the actual parent type '{2}'", m_szTypeName, (m_pParentType != nullptr) ? m_pParentType->GetTypeName() : "null", (m_fnVerifyParent() != nullptr) ? m_fnVerifyParent()->GetTypeName() : "null"); } { ezSet<ezStringView> Known; const ezRTTI* pInstance = this; while (pInstance != nullptr) { for (ezUInt32 i = 0; i < pInstance->m_Properties.GetCount(); ++i) { const bool bNewProperty = !Known.Find(pInstance->m_Properties[i]->GetPropertyName()).IsValid(); Known.Insert(pInstance->m_Properties[i]->GetPropertyName()); EZ_ASSERT_DEV(bNewProperty, "{0}: The property with name '{1}' is already defined in type '{2}'.", m_szTypeName, pInstance->m_Properties[i]->GetPropertyName(), pInstance->GetTypeName()); } pInstance = pInstance->m_pParentType; } } }
void ezWorld::SetParent(ezGameObject* pObject, ezGameObject* pNewParent, ezGameObject::TransformPreservation preserve) { EZ_ASSERT_DEV(pObject != pNewParent, "Object can't be its own parent!"); EZ_ASSERT_DEV(pNewParent == nullptr || pObject->IsDynamic() || pNewParent->IsStatic(), "Can't attach a static object to a dynamic parent!"); CheckForWriteAccess(); if (GetObjectUnchecked(pObject->m_ParentIndex) == pNewParent) return; UnlinkFromParent(pObject); // UnlinkFromParent does not clear these as they are still needed in DeleteObjectNow to allow deletes while iterating. pObject->m_NextSiblingIndex = 0; pObject->m_PrevSiblingIndex = 0; if (pNewParent != nullptr) { // Ensure that the parent's global transform is up-to-date otherwise the object's local transform will be wrong afterwards. pNewParent->UpdateGlobalTransform(); pObject->m_ParentIndex = pNewParent->m_InternalId.m_InstanceIndex; LinkToParent(pObject); } PatchHierarchyData(pObject, preserve); }
void ezWorld::RegisterUpdateFunction(const ezComponentManagerBase::UpdateFunctionDesc& desc) { CheckForWriteAccess(); EZ_ASSERT_DEV(desc.m_Phase == ezComponentManagerBase::UpdateFunctionDesc::Phase::Async || desc.m_uiGranularity == 0, "Granularity must be 0 for synchronous update functions"); EZ_ASSERT_DEV(desc.m_Phase != ezComponentManagerBase::UpdateFunctionDesc::Phase::Async || desc.m_DependsOn.GetCount() == 0, "Asynchronous update functions must not have dependencies"); m_Data.m_UpdateFunctionsToRegister.PushBack(desc); }
void ezWorld::ProcessUpdateFunctionsToRegister() { CheckForWriteAccess(); if (m_Data.m_UpdateFunctionsToRegister.IsEmpty()) return; EZ_PROFILE_SCOPE("Register update functions"); while (!m_Data.m_UpdateFunctionsToRegister.IsEmpty()) { const ezUInt32 uiNumFunctionsToRegister = m_Data.m_UpdateFunctionsToRegister.GetCount(); for (ezUInt32 i = uiNumFunctionsToRegister; i-- > 0;) { if (RegisterUpdateFunctionInternal(m_Data.m_UpdateFunctionsToRegister[i]).Succeeded()) { m_Data.m_UpdateFunctionsToRegister.RemoveAtAndCopy(i); } } EZ_ASSERT_DEV(m_Data.m_UpdateFunctionsToRegister.GetCount() < uiNumFunctionsToRegister, "No functions have been registered because the dependencies could not be found."); } }
ezResourceLoadDesc ezMaterialResource::UpdateContent(ezStreamReader* Stream) { m_Desc.Clear(); m_OriginalDesc.Clear(); ezResourceLoadDesc res; res.m_uiQualityLevelsDiscardable = 0; res.m_uiQualityLevelsLoadable = 0; res.m_State = ezResourceState::Loaded; if (Stream == nullptr) { res.m_State = ezResourceState::LoadedResourceMissing; return res; } ezStringBuilder sAbsFilePath; (*Stream) >> sAbsFilePath; if (sAbsFilePath.HasExtension("ezMaterialBin")) { ezStringBuilder sTemp, sTemp2; ezAssetFileHeader AssetHash; AssetHash.Read(*Stream); ezUInt8 uiVersion = 0; (*Stream) >> uiVersion; EZ_ASSERT_DEV(uiVersion <= 6, "Unknown ezMaterialBin version {0}", uiVersion); ezUInt8 uiCompressionMode = 0; if (uiVersion >= 6) { *Stream >> uiCompressionMode; }
ezResult ezFileWriter::WriteBytes(const void* pWriteBuffer, ezUInt64 uiBytesToWrite) { EZ_ASSERT_DEV(m_pDataDirWriter != nullptr, "The file has not been opened (successfully)."); ezUInt8* pBuffer = (ezUInt8*)pWriteBuffer; while (uiBytesToWrite > 0) { // determine chunk size to be written ezUInt64 uiChunkSize = uiBytesToWrite; const ezUInt64 uiRemainingCache = m_Cache.GetCount() - m_uiCacheWritePosition; if (uiRemainingCache < uiBytesToWrite) uiChunkSize = uiRemainingCache; // copy memory ezMemoryUtils::Copy(&m_Cache[(ezUInt32)m_uiCacheWritePosition], pBuffer, (ezUInt32)uiChunkSize); pBuffer += uiChunkSize; m_uiCacheWritePosition += uiChunkSize; uiBytesToWrite -= uiChunkSize; // if the cache is full or nearly full, flush it to disk if (m_uiCacheWritePosition + 32 >= m_Cache.GetCount()) { if (Flush() == EZ_FAILURE) return EZ_FAILURE; } } return EZ_SUCCESS; }
void ezQtEngineViewWidget::InterpolateCameraTo(const ezVec3& vPosition, const ezVec3& vDirection, float fFovOrDim, const ezVec3* pNewUpDirection) { m_vCameraStartPosition = m_pViewConfig->m_Camera.GetPosition(); m_vCameraTargetPosition = vPosition; m_vCameraStartDirection = m_pViewConfig->m_Camera.GetCenterDirForwards(); m_vCameraTargetDirection = vDirection; if (pNewUpDirection) m_vCameraUp = *pNewUpDirection; else m_vCameraUp = m_pViewConfig->m_Camera.GetCenterDirUp(); m_vCameraStartDirection.Normalize(); m_vCameraTargetDirection.Normalize(); m_vCameraUp.Normalize(); m_fCameraStartFovOrDim = m_pViewConfig->m_Camera.GetFovOrDim(); if (fFovOrDim > 0.0f) m_fCameraTargetFovOrDim = fFovOrDim; EZ_ASSERT_DEV(m_fCameraTargetFovOrDim > 0, "Invalid FOV or ortho dimension"); if (m_vCameraStartPosition == m_vCameraTargetPosition && m_vCameraStartDirection == m_vCameraTargetDirection && m_fCameraStartFovOrDim == m_fCameraTargetFovOrDim) return; m_LastCameraUpdate = ezTime::Now(); m_fCameraLerp = 0.0f; }
void ezSkeleton::Load(ezStreamReader& stream) { m_Joints.Clear(); ezUInt32 uiVersion = 0; stream >> uiVersion; EZ_ASSERT_DEV(uiVersion <= ezSkeletonVersion::Version_Current, "Skeleton versioning corrupt!"); ezUInt32 uiNumJoints = 0; stream >> uiNumJoints; m_Joints.Reserve(uiNumJoints); if (uiVersion == 1) { for (ezUInt32 i = 0; i < uiNumJoints; ++i) { ezSkeletonJoint& joint = m_Joints.ExpandAndGetRef(); ezUInt32 dummy; stream >> joint.m_sName; stream >> dummy; joint.m_uiParentIndex = dummy; stream >> joint.m_BindPoseLocal; stream >> joint.m_InverseBindPoseGlobal; } } else { for (ezUInt32 i = 0; i < uiNumJoints; ++i)
void ezStringWChar::operator=(const char* szUtf8) { EZ_ASSERT_DEV(ezUnicodeUtils::IsValidUtf8(szUtf8), "Input Data is not a valid Utf8 string. Did you intend to use a Wide-String and forget the 'L' prefix?"); m_Data.Clear(); if (szUtf8 != nullptr) { // skip any Utf8 Byte Order Mark ezUnicodeUtils::SkipUtf8Bom(szUtf8); while (*szUtf8 != '\0') { // decode utf8 to utf32 const ezUInt32 uiUtf32 = ezUnicodeUtils::DecodeUtf8ToUtf32(szUtf8); // encode utf32 to wchar_t ezUnicodeUtils::UtfInserter<wchar_t, ezHybridArray<wchar_t, BufferSize> > tempInserter(&m_Data); ezUnicodeUtils::EncodeUtf32ToWChar(uiUtf32, tempInserter); } } // append terminator m_Data.PushBack('\0'); }
ezResult ezTextureAtlasCreationDesc::Deserialize(ezStreamReader& stream) { const ezTypeVersion uiVersion = stream.ReadVersion(1); EZ_ASSERT_DEV(uiVersion == 1, "Invalid texture atlas desc file version {0}", uiVersion); ezUInt8 uiNumLayers = 0; stream >> uiNumLayers; m_Layers.SetCount(uiNumLayers); for (ezUInt32 l = 0; l < uiNumLayers; ++l) { stream >> m_Layers[l].m_Usage; stream >> m_Layers[l].m_uiNumChannels; } ezUInt32 uiNumItems = 0; stream >> uiNumItems; m_Items.SetCount(uiNumItems); for (auto& item : m_Items) { stream >> item.m_uiUniqueID; for (ezUInt32 l = 0; l < uiNumLayers; ++l) { stream >> item.m_sLayerInput[l]; } } return EZ_SUCCESS; }
ezResult ezTaskSystem::CancelTask(ezTask* pTask, ezOnTaskRunning::Enum OnTaskRunning) { if (pTask->IsTaskFinished()) return EZ_SUCCESS; EZ_PROFILE_SCOPE("CancelTask"); EZ_ASSERT_DEV(pTask->m_BelongsToGroup.m_pTaskGroup->m_uiGroupCounter == pTask->m_BelongsToGroup.m_uiGroupCounter, "The task to be removed is in an invalid group."); // we set the cancel flag, to make sure that tasks that support canceling will terminate asap pTask->m_bCancelExecution = true; { EZ_LOCK(s_TaskSystemMutex); // if the task is still in the queue of its group, it had not yet been scheduled if (!pTask->m_bTaskIsScheduled && pTask->m_BelongsToGroup.m_pTaskGroup->m_Tasks.RemoveAndSwap(pTask)) { // we set the task to finished, even though it was not executed pTask->m_bIsFinished = true; return EZ_SUCCESS; } // check if the task has already been scheduled for execution // if so, remove it from the work queue { for (ezUInt32 i = 0; i < ezTaskPriority::ENUM_COUNT; ++i) { auto it = s_Tasks[i].GetIterator(); while (it.IsValid()) { if (it->m_pTask == pTask) { s_Tasks[i].Remove(it); // we set the task to finished, even though it was not executed pTask->m_bIsFinished = true; // tell the system that one task of that group is 'finished', to ensure its dependencies will get scheduled TaskHasFinished(it->m_pTask, it->m_pBelongsToGroup); return EZ_SUCCESS; } ++it; } } } } // if we made it here, the task was already running // thus we just wait for it to finish if (OnTaskRunning == ezOnTaskRunning::WaitTillFinished) WaitForTask(pTask); return EZ_FAILURE; }
void ezExpression::Stream::ValidateDataSize(ezUInt32 uiNumInstances, const char* szDataName) const { ezUInt32 uiElementSize = GetElementSize(); ezUInt32 uiExpectedSize = m_uiByteStride * (uiNumInstances - 1) + uiElementSize; EZ_ASSERT_DEV(m_Data.GetCount() >= uiExpectedSize, "{0} data size must be {1} bytes or more. Only {2} bytes given", szDataName, uiExpectedSize, m_Data.GetCount()); }
ezToolsProject::ezToolsProject(const char* szProjectPath) : m_SingletonRegistrar(this) { m_bIsClosing = false; m_sProjectPath = szProjectPath; EZ_ASSERT_DEV(!m_sProjectPath.IsEmpty(), "Path cannot be empty."); }
void ezImguiRenderer::RenderBatch(const ezRenderViewContext& renderContext, ezRenderPipelinePass* pPass, const ezRenderDataBatch& batch) { if (ezImgui::GetSingleton() == nullptr) return; SetupRenderer(); ezRenderContext* pRenderContext = renderContext.m_pRenderContext; ezGALContext* pGALContext = pRenderContext->GetGALContext(); pRenderContext->BindShader(m_hShader); const auto& textures = ezImgui::GetSingleton()->m_hTextures; const ezUInt32 numTextures = textures.GetCount(); for (auto it = batch.GetIterator<ezImguiRenderData>(); it.IsValid(); ++it) { const ezImguiRenderData* pRenderData = pRenderData = it; EZ_ASSERT_DEV(pRenderData->m_Vertices.GetCount() < VertexBufferSize, "GUI has too many elements to render in one drawcall"); EZ_ASSERT_DEV(pRenderData->m_Indices.GetCount() < IndexBufferSize, "GUI has too many elements to render in one drawcall"); pGALContext->UpdateBuffer(m_hVertexBuffer, 0, ezMakeArrayPtr(pRenderData->m_Vertices.GetPtr(), pRenderData->m_Vertices.GetCount()).ToByteArray()); pGALContext->UpdateBuffer(m_hIndexBuffer, 0, ezMakeArrayPtr(pRenderData->m_Indices.GetPtr(), pRenderData->m_Indices.GetCount()).ToByteArray()); pRenderContext->BindMeshBuffer(m_hVertexBuffer, m_hIndexBuffer, &m_VertexDeclarationInfo, ezGALPrimitiveTopology::Triangles, pRenderData->m_Indices.GetCount() / 3); ezUInt32 uiFirstIndex = 0; const ezUInt32 numBatches = pRenderData->m_Batches.GetCount(); for (ezUInt32 batchIdx = 0; batchIdx < numBatches; ++batchIdx) { const ezImguiBatch& batch = pRenderData->m_Batches[batchIdx]; if (batch.m_uiVertexCount > 0 && batch.m_uiTextureID < numTextures) { pGALContext->SetScissorRect(batch.m_ScissorRect); pRenderContext->BindTexture2D("BaseTexture", textures[batch.m_uiTextureID]); pRenderContext->DrawMeshBuffer(batch.m_uiVertexCount / 3, uiFirstIndex / 3); } uiFirstIndex += batch.m_uiVertexCount; } } }
void ezDynamicQuadtree::FindVisibleObjects(const ezFrustum& Viewfrustum, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough) const { EZ_ASSERT_DEV(m_uiMaxTreeDepth > 0, "ezDynamicQuadtree::FindVisibleObjects: You have to first create the tree."); if (m_NodeMap.IsEmpty()) return; FindVisibleObjects(Viewfrustum, Callback, pPassThrough, m_BBox.m_vMin.x, m_BBox.m_vMax.x, m_BBox.m_vMin.z, m_BBox.m_vMax.z, 0, m_uiAddIDTopLevel, ezMath::Pow (4, m_uiMaxTreeDepth-1), 0xFFFFFFFF); }
void ezGameObjectSelectionActions::MapContextMenuActions(const char* szMapping, const char* szPath) { ezActionMap* pMap = ezActionMapManager::GetActionMap(szMapping); EZ_ASSERT_DEV(pMap != nullptr, "The given mapping ('{0}') does not exist, mapping the actions failed!", szMapping); ezStringBuilder sSubPath(szPath, "/SelectionCategory"); pMap->MapAction(s_hSelectionCategory, szPath, 5.0f); pMap->MapAction(s_hFocusOnSelectionAllViews, sSubPath, 1.0f); }
void ezPropertyAnimResourceDescriptor::Load(ezStreamReader& stream) { ezUInt8 uiVersion = 0; ezUInt8 uiIdentifier = 0; ezUInt16 uiNumAnimations = 0; stream >> uiVersion; stream >> uiIdentifier; EZ_ASSERT_DEV(uiIdentifier == 0x0A, "File does not contain a valid ezPropertyAnimResourceDescriptor"); EZ_ASSERT_DEV(uiVersion == 4 || uiVersion == 5 || uiVersion == 6, "Invalid file version {0}", uiVersion); stream >> m_AnimationDuration; if (uiVersion == 4) { ezEnum<ezPropertyAnimMode> mode; stream >> mode; }
ezResult ezImageConversion::ConvertRaw(ezArrayPtr<const void> source, ezArrayPtr<void> target, ezUInt32 numElements, ezArrayPtr<ConversionPathNode> path, ezUInt32 numScratchBuffers) { EZ_ASSERT_DEV(path.GetCount() > 0, "Path of length 0 is invalid."); if (numElements == 0) { return EZ_SUCCESS; } if (ezImageFormat::IsCompressed(path.GetPtr()->m_sourceFormat) || ezImageFormat::IsCompressed((path.GetEndPtr() - 1)->m_targetFormat)) { return EZ_FAILURE; } ezHybridArray<ezDynamicArray<char>, 16> intermediates; intermediates.SetCount(numScratchBuffers); for (ezUInt32 i = 0; i < path.GetCount(); ++i) { ezUInt32 targetIndex = path[i].m_targetBufferIndex; ezUInt32 targetBpp = ezImageFormat::GetBitsPerPixel(path[i].m_targetFormat); ezArrayPtr<void> stepTarget; if (targetIndex == 0) { stepTarget = target; } else { ezUInt32 expectedSize = static_cast<ezUInt32>(targetBpp * numElements / 8); intermediates[targetIndex - 1].SetCount(expectedSize); stepTarget = ezArrayPtr<void>(intermediates[targetIndex - 1].GetData(), intermediates[targetIndex - 1].GetCount()); } if (path[i].m_step == nullptr) { memcpy(stepTarget.GetPtr(), source.GetPtr(), numElements * targetBpp / 8); } else { if (static_cast<const ezImageConversionStepLinear*>(path[i].m_step) ->ConvertPixels(source, stepTarget, numElements, path[i].m_sourceFormat, path[i].m_targetFormat) .Failed()) { return EZ_FAILURE; } } source = stepTarget; } return EZ_SUCCESS; }
ezResult ezDataDirectoryType::InitializeDataDirectory(const char* szDataDirPath) { ezStringBuilder sPath = szDataDirPath; sPath.MakeCleanPath(); EZ_ASSERT_DEV(sPath.IsEmpty() || sPath.EndsWith("/"), "Data directory path must end with a slash."); m_sDataDirectoryPath = sPath; return InternalInitializeDataDirectory(m_sDataDirectoryPath.GetData()); }
ezInt32 ezCommandLineUtils::GetOptionIndex(const char* szOption, bool bCaseSensitive) const { EZ_ASSERT_DEV(ezStringUtils::StartsWith(szOption, "-"), "All command line option names must start with a hyphen (e.g. -file)"); for (ezUInt32 i = 0; i < m_Commands.GetCount(); ++i) { if ((bCaseSensitive && m_Commands[i].IsEqual(szOption)) || (!bCaseSensitive && m_Commands[i].IsEqual_NoCase(szOption))) return i; } return -1; }
/// The object lies at vCenter and has vHalfExtents as its bounding box. /// If bOnlyIfInside is false, the object is ALWAYS inserted, even if it is outside the tree. /// \note In such a case it is inserted at the root-node and thus ALWAYS returned in range/view-frustum queries. /// /// If bOnlyIfInside is true, the object is discarded, if it is not inside the actual bounding box of the tree. /// /// The min and max Y value of the tree's bounding box is updated, if the object lies above/below previously inserted objects. ezResult ezDynamicQuadtree::InsertObject(const ezVec3& vCenter, const ezVec3& vHalfExtents, ezInt32 iObjectType, ezInt32 iObjectInstance, ezDynamicTreeObject* out_Object, bool bOnlyIfInside) { EZ_ASSERT_DEV(m_uiMaxTreeDepth > 0, "ezDynamicQuadtree::InsertObject: You have to first create the tree."); if (out_Object) *out_Object = ezDynamicTreeObject(); if (bOnlyIfInside) { if (vCenter.x + vHalfExtents.x < m_fRealMinX) return EZ_FAILURE; if (vCenter.x - vHalfExtents.x > m_fRealMaxX) return EZ_FAILURE; if (vCenter.z + vHalfExtents.z < m_fRealMinZ) return EZ_FAILURE; if (vCenter.z - vHalfExtents.z > m_fRealMaxZ) return EZ_FAILURE; } // update the bounding boxes min/max Y values m_BBox.m_vMin.y = ezMath::Min(m_BBox.m_vMin.y, vCenter.y - vHalfExtents.y); m_BBox.m_vMax.y = ezMath::Max(m_BBox.m_vMax.y, vCenter.y + vHalfExtents.y); ezDynamicTree::ezObjectData oData; oData.m_iObjectType = iObjectType; oData.m_iObjectInstance = iObjectInstance; // insert the object into the best child if (!InsertObject(vCenter, vHalfExtents, oData, m_BBox.m_vMin.x, m_BBox.m_vMax.x, m_BBox.m_vMin.z, m_BBox.m_vMax.z, 0, m_uiAddIDTopLevel, ezMath::Pow(4, m_uiMaxTreeDepth-1), out_Object)) { if (!bOnlyIfInside) { ezDynamicTree::ezMultiMapKey mmk; mmk.m_uiKey = 0; mmk.m_uiCounter = m_uiMultiMapCounter++; auto key = m_NodeMap.Insert(mmk, oData); if (out_Object) *out_Object = key; return EZ_SUCCESS; } return EZ_FAILURE; } return EZ_SUCCESS; }
void ezCollectionResourceDescriptor::Load(ezStreamReader& stream) { ezUInt8 uiVersion = 0; ezUInt8 uiIdentifier = 0; ezUInt16 uiNumResources = 0; stream >> uiVersion; stream >> uiIdentifier; stream >> uiNumResources; EZ_ASSERT_DEV(uiIdentifier == 0xC0, "File does not contain a valid ezCollectionResourceDescriptor"); EZ_ASSERT_DEV(uiVersion == 1, "Invalid file version {0}", uiVersion); m_Resources.SetCount(uiNumResources); for (ezUInt32 i = 0; i < uiNumResources; ++i) { stream >> m_Resources[i].m_sResourceTypeName; stream >> m_Resources[i].m_sLookupName; stream >> m_Resources[i].m_sRedirectionName; } }
void ezDirectionVisualizerAdapter::Finalize() { auto* pDoc = m_pObject->GetDocumentObjectManager()->GetDocument(); const ezAssetDocument* pAssetDocument = ezDynamicCast<const ezAssetDocument*>(pDoc); EZ_ASSERT_DEV(pAssetDocument != nullptr, "Visualizers are only supported in ezAssetDocument."); const ezDirectionVisualizerAttribute* pAttr = static_cast<const ezDirectionVisualizerAttribute*>(m_pVisualizerAttr); m_Gizmo.Configure(nullptr, ezEngineGizmoHandleType::Arrow, pAttr->m_Color, false, false, true); pAssetDocument->AddSyncObject(&m_Gizmo); m_Gizmo.SetVisible(m_bVisualizerIsVisible); }
ezViewHandle ezEditorEngineProcessApp::CreateRemoteWindowAndView(ezCamera* pCamera) { EZ_ASSERT_DEV(IsRemoteMode(), "Incorrect app mode"); CreateRemoteWindow(); if (m_hRemoteView.IsInvalidated()) { ezGALDevice* pDevice = ezGALDevice::GetDefaultDevice(); ezWindowOutputTargetGAL* pOutputTarget = static_cast<ezWindowOutputTargetGAL*>(ezGameApplicationBase::GetGameApplicationBaseInstance()->AddWindow(m_pRemoteWindow.Borrow())); const ezGALSwapChain* pPrimarySwapChain = pDevice->GetSwapChain(pOutputTarget->m_hSwapChain); EZ_ASSERT_DEV(pPrimarySwapChain != nullptr, "Failed to init swapchain"); auto hSwapChainRTV = pDevice->GetDefaultRenderTargetView(pPrimarySwapChain->GetBackBufferTexture()); ezGALRenderTagetSetup BackBufferRenderTargetSetup; BackBufferRenderTargetSetup.SetRenderTarget(0, hSwapChainRTV); // setup view { ezView* pView = nullptr; m_hRemoteView = ezRenderWorld::CreateView("Remote Process", pView); // EditorRenderPipeline.ezRenderPipelineAsset pView->SetRenderPipelineResource( ezResourceManager::LoadResource<ezRenderPipelineResource>("{ da463c4d-c984-4910-b0b7-a0b3891d0448 }")); pView->SetRenderTargetSetup(BackBufferRenderTargetSetup); pView->SetViewport( ezRectFloat(0.0f, 0.0f, (float)m_pRemoteWindow->GetClientAreaSize().width, (float)m_pRemoteWindow->GetClientAreaSize().height)); pView->SetCamera(pCamera); } } return m_hRemoteView; }
void ezVirtualThumbStick::SetTriggerInputSlot(ezVirtualThumbStick::Input::Enum Input, const ezInputActionConfig* pCustomConfig) { for (ezInt32 i = 0; i < ezInputActionConfig::MaxInputSlotAlternatives; ++i) { m_ActionConfig.m_sFilterByInputSlotX[i] = ezInputSlot_None; m_ActionConfig.m_sFilterByInputSlotY[i] = ezInputSlot_None; m_ActionConfig.m_sInputSlotTrigger[i] = ezInputSlot_None; } switch (Input) { case ezVirtualThumbStick::Input::Touchpoint: { m_ActionConfig.m_sFilterByInputSlotX[0] = ezInputSlot_TouchPoint0_PositionX; m_ActionConfig.m_sFilterByInputSlotY[0] = ezInputSlot_TouchPoint0_PositionY; m_ActionConfig.m_sInputSlotTrigger[0] = ezInputSlot_TouchPoint0; m_ActionConfig.m_sFilterByInputSlotX[1] = ezInputSlot_TouchPoint1_PositionX; m_ActionConfig.m_sFilterByInputSlotY[1] = ezInputSlot_TouchPoint1_PositionY; m_ActionConfig.m_sInputSlotTrigger[1] = ezInputSlot_TouchPoint1; m_ActionConfig.m_sFilterByInputSlotX[2] = ezInputSlot_TouchPoint2_PositionX; m_ActionConfig.m_sFilterByInputSlotY[2] = ezInputSlot_TouchPoint2_PositionY; m_ActionConfig.m_sInputSlotTrigger[2] = ezInputSlot_TouchPoint2; } break; case ezVirtualThumbStick::Input::MousePosition: { m_ActionConfig.m_sFilterByInputSlotX[0] = ezInputSlot_MousePositionX; m_ActionConfig.m_sFilterByInputSlotY[0] = ezInputSlot_MousePositionY; m_ActionConfig.m_sInputSlotTrigger[0] = ezInputSlot_MouseButton0; } break; case ezVirtualThumbStick::Input::Custom: { EZ_ASSERT_DEV(pCustomConfig != nullptr, "Must pass a custom config, if you want to have a custom config."); for (ezInt32 i = 0; i < ezInputActionConfig::MaxInputSlotAlternatives; ++i) { m_ActionConfig.m_sFilterByInputSlotX[i] = pCustomConfig->m_sFilterByInputSlotX[i]; m_ActionConfig.m_sFilterByInputSlotY[i] = pCustomConfig->m_sFilterByInputSlotY[i]; m_ActionConfig.m_sInputSlotTrigger[i] = pCustomConfig->m_sInputSlotTrigger[i]; } } break; } m_bConfigChanged = true; }