bool RPG_Projectile::ShouldHit(RPG_DamageableEntity* target) { VASSERT_MSG(m_characterOwner, "Please set your projectile's character owner."); if(!target || !m_characterOwner) { return true; } if(target->IsFrom(RPG_Character)) { RPG_Character* targetCharacter = static_cast<RPG_Character*>(target); if(targetCharacter->GetTeam() != m_characterOwner->GetTeam()) { return true; } } else if(target->Components().GetComponentOfType(V_RUNTIME_CLASS(RPG_AttackableComponent))) { return true; } return false; }
bool RPG_VisionEffectHelper::LoadMesh(char const* fileName) { VResourceManager *resourceManager = Vision::ResourceSystem.GetResourceManagerByName(VIS_RESOURCEMANAGER_MESHES); VASSERT_MSG (resourceManager, "RPG: No resource manager found."); if (!resourceManager) return NULL; VManagedResource *resource = resourceManager->GetResourceByName(fileName); if (!resource) { VMeshManager *meshManager = static_cast<VMeshManager*>(resourceManager); resource = meshManager->LoadDynamicMeshFile(fileName); if (!resource) { Vision::Error.Warning("[RPG] Resource is missing: %s", fileName); return NULL; } Vision::Error.SystemMessage("[RPG] Resource is not cached: %s", fileName); } return resource; }
void RPG_Projectile::CreateShapePhantom() { hkReal const radius = RPG_VisionHavokConversion::VisionToHavokScalar(RPG_PROJECTILE_DEFAULT_RADIUS); hkpSphereShape* sphere = new hkpSphereShape(radius); hkVector4 havokPosition; RPG_VisionHavokConversion::VisionToHavokPoint(GetPosition(), havokPosition); hkQuaternion havokRotation; RPG_VisionHavokConversion::VisionToHavokRotationQuaternion(GetRotationMatrix(), havokRotation); hkTransform transform; { transform.setRotation(havokRotation); transform.setTranslation(havokPosition); } vHavokConversionUtils::VisMatVecToPhysTransform(GetRotationMatrix(), GetPosition(), transform); m_shapePhantom = new hkpSimpleShapePhantom(sphere, transform, hkpGroupFilter::calcFilterInfo(vHavokPhysicsModule::HK_LAYER_COLLIDABLE_DYNAMIC, 0, 0, 0)); sphere->removeReference(); hkpWorld* world = vHavokPhysicsModule::GetInstance()->GetPhysicsWorld(); VASSERT_MSG(world, "Please create a physics world before creating any projectiles."); if(world) { vHavokPhysicsModule::GetInstance()->MarkForWrite(); world->addPhantom(m_shapePhantom); vHavokPhysicsModule::GetInstance()->UnmarkForWrite(); } else { V_SAFE_DELETE(m_shapePhantom); m_shapePhantom = NULL; } }
hkResult hkvTextureTransformationRule::determineOutputsIos(Context& context) const { hkvTextureCompression compression = (hkvTextureCompression)m_compressionInstance.getDefinitionId(); hkvImageDataFormat dataFormat; hkvImageFileFormat fileFormat; switch (compression) { case HKV_TEXTURE_COMPRESSION_NONE: { dataFormat = (context.m_sourceHasAlpha && !m_removeAlphaChannel) ? HKV_IMAGE_DATA_FORMAT_A8R8G8B8 : HKV_IMAGE_DATA_FORMAT_X8R8G8B8; fileFormat = HKV_IMAGE_FILE_FORMAT_RGBA; break; } case HKV_TEXTURE_COMPRESSION_QUALITY: { dataFormat = HKV_IMAGE_DATA_FORMAT_PVRTC4; fileFormat = HKV_IMAGE_FILE_FORMAT_PVR; break; } //case HKV_TEXTURE_COMPRESSION_SIZE: // { // dataFormat = HKV_IMAGE_DATA_FORMAT_PVRTC2; // fileFormat = HKV_IMAGE_FILE_FORMAT_PVR; // break; // } default: { VASSERT_MSG(FALSE, "Missing compression case!"); return HK_FAILURE; } } context.m_outputVariants.pushBack(hkvTextureVariant("", dataFormat, fileFormat, "", false)); return HK_SUCCESS; }
void VDialog::Serialize( VArchive &ar ) { VWindowBase::Serialize(ar); char iLocalVersion = 0; if (ar.IsLoading()) { ar >> iLocalVersion; VASSERT_MSG(iLocalVersion==0,"Invalid version"); ar >> m_uiDialogFlags >> (int &)m_eStartPos; ar >> m_fFadeInPos >> m_fFadeInSpeed >> m_iBackColor >> m_bFadeBack; ar >> m_iBackFadeColor >> m_fBackFadePos >> m_fBackFadeSpeed; V_SAFE_DELETE(m_pImage); bool bHasImg = false; ar >> bHasImg; if (bHasImg) { m_pImage = new VImageStates(); ar >> *m_pImage; } ar >> m_Frame; // item list: m_Items.SerializeX(ar); } else
hkResult hkvTextureTransformationRule::determineOutputsWiiU(Context& context) const { hkvTextureCompression compression = (hkvTextureCompression)m_compressionInstance.getDefinitionId(); hkvImageDataFormat dataFormat; switch (compression) { case HKV_TEXTURE_COMPRESSION_NONE: { dataFormat = (context.m_sourceHasAlpha && !m_removeAlphaChannel) ? HKV_IMAGE_DATA_FORMAT_A8R8G8B8 : HKV_IMAGE_DATA_FORMAT_X8R8G8B8; break; } case HKV_TEXTURE_COMPRESSION_QUALITY: { dataFormat = (context.m_sourceHasAlpha && !m_removeAlphaChannel) ? HKV_IMAGE_DATA_FORMAT_DXT5 : HKV_IMAGE_DATA_FORMAT_DXT1; break; } //case HKV_TEXTURE_COMPRESSION_SIZE: // { // dataFormat = (context.m_sourceHasAlpha && !m_removeAlphaChannel) ? HKV_IMAGE_DATA_FORMAT_DXT3 : HKV_IMAGE_DATA_FORMAT_DXT1; // break; // } default: { VASSERT_MSG(FALSE, "Missing compression case!"); return HK_FAILURE; } } context.m_outputVariants.pushBack(hkvTextureVariant("", dataFormat, HKV_IMAGE_FILE_FORMAT_GTX, "", false)); // Add a DXT/RAW variant as editor preview determineOutputsDxt(context, true); return HK_SUCCESS; }
inline virtual ~vHavokAiElementManager() { VASSERT_MSG(m_iListIndex==VIS_INVALID, "Object may not be deleted. Use DisposeObject instead"); }
void SetDefaultTechnique(VCompiledTechnique *pTechnique) { VASSERT_MSG(false, "The terrain sector mesh's default technique shouldn't be used - did you mean use to the technique of one of the sector's pages instead?"); }
/// \brief /// Sets a portal vertex with the specified index to the given position. /// /// May only be called inside a BeginUpdate/EndUpdate block. /// /// Vertices have to be provided in counter-clockwise order. In order for a portal to be valid, /// it has to contain at least three non-colinear vertices. /// /// \param iIndex /// Vertex index. Has to be inside the range from 0 to the number of vertices reserved with /// CreateVertices. /// /// \param vVertex /// Position of the portal vertex. inline void SetVertex(int iIndex, const hkvVec3& vVertex) { VASSERT_MSG(m_iUpdateCtr>0, "only allowed inside BeginUpdate/EndUpdate block"); VASSERT(iIndex>=0 && iIndex<(int)m_iVertexCount); m_pVertices[iIndex] = vVertex; }
/// \brief /// Pops an object from the stack /// /// \return /// The object on the top of the stack T Pop() { VASSERT_MSG(m_uiSize > 0,"stack out of bounds"); return m_pData[--m_uiSize]; }
VCompiledTechnique *GetDefaultTechnique() const { VASSERT_MSG(false, "The terrain sector mesh's default technique shouldn't be used - did you mean use to the technique of one of the sector's pages instead?"); return NULL; }
VReadResult_e VisDataHistory_cl<dataType, iHistoryLength, Mix>::Interpolate (dataType* out_pData, __int64 iInterpolationPoint) { if (m_iHistoryEntries == 0) return VRR_None; __int64 iOldestTime = m_history[m_iHistoryStart].m_iTime; __int64 iNewestTime = m_history[(m_iHistoryStart + m_iHistoryEntries - 1) % iHistoryLength].m_iTime; VASSERT (iOldestTime <= iNewestTime); // 'iInterpolationPoint' is too old, taking earliest known value (extrapolate in the past?) if (iInterpolationPoint <= iOldestTime) { //hkvLog::Info(" oldest = %d, newest = %d, iInterpolationPoint: %d", (int)iOldestTime, (int)iNewestTime, (int)iInterpolationPoint); *out_pData = m_history[m_iHistoryStart].m_data; return VRR_Oldest; } // 'iInterpolationPoint' is newer than the history, so we have to extrapolate the value else if (iInterpolationPoint >= iNewestTime) { // Taking the last value for the time being if (m_iHistoryEntries == 1) { *out_pData = m_history[(m_iHistoryStart + m_iHistoryEntries - 1) % iHistoryLength].m_data; return VRR_Extrapolated; } //extrapolate to the future else { const VisDataHistoryCell<dataType> ¤t = m_history[(m_iHistoryStart + m_iHistoryEntries - 1) % iHistoryLength]; const VisDataHistoryCell<dataType> &prev = m_history[(m_iHistoryStart + m_iHistoryEntries - 2) % iHistoryLength]; float fDivisor = float(current.m_iTime - prev.m_iTime); float fStep = float(iInterpolationPoint - current.m_iTime); //*out_pData = current.m_data + diff * (fStep / fDivisor); *out_pData = Mix() (prev.m_data, current.m_data, 1.0f + (fStep / fDivisor) ); return VRR_Extrapolated; } } else { for (int i = m_iHistoryEntries-1; i > 0; --i) { const VisDataHistoryCell<dataType> ¤t = m_history[(m_iHistoryStart + i) % iHistoryLength]; const VisDataHistoryCell<dataType> &prev = m_history[(m_iHistoryStart + i - 1) % iHistoryLength]; VASSERT (prev.m_iTime < current.m_iTime); if (iInterpolationPoint > prev.m_iTime) { float fDivisor = float(current.m_iTime - prev.m_iTime); float fLerp = float(iInterpolationPoint - prev.m_iTime); float fLerpFactor = fLerp / fDivisor; *out_pData = Mix()(current.m_data, prev.m_data, 1.0f - fLerpFactor); return VRR_Interpolated; } else continue; } } VASSERT_MSG (false, "Unreachable code reached!"); return VRR_None; //impossible to reach }
inline void VGroupInstanceFile::ReadInstance(VGroupInstance &instance) { VASSERT_MSG(m_iInstanceCount>0, "read too many instances"); m_iInstanceCount--; instance.Read(m_pIn,m_eFlags); }
/// \brief /// Checks if the resource has been modified. /// /// The stream manager is used to retrieve the new time stamp. /// /// For further details on the passed parameters, see VResourceManager::ReloadModifiedResourceFiles. /// /// \param bUnload /// If TRUE, the resource will be unloaded in case it has been modified (calls EnsureUnloaded /// on the resource). /// /// \param bReload /// If TRUE, the resource will be reloaded in case it has been modified (calls EnsureLoaded on /// the resource). /// /// \return /// TRUE if the resource has been detected to be modified inline HKV_DEPRECATED_2013_2 BOOL CheckFileModified(BOOL bUnload, BOOL bReload) { VASSERT_MSG(bUnload || bReload, "at least one option has to be set"); return CheckFileModified(bReload ? VURO_COLD_RELOAD : VURO_ONLY_UNLOAD); }
/// \brief /// Sets the priority of the message. /// /// \param messagePriority /// Priority of the corresponding message, \sa VMessagePriority_e /// /// \sa VMessagePriority_e inline void SetPriority (VMessagePriority_e messagePriority) { VASSERT_MSG (messagePriority >= 0 && messagePriority <= VMP_LowPriority, "VMessageSettings::SetPriority: parameter messagePriority out of range!"); m_iPriority = (BYTE)messagePriority; }
bool hkvTextureTransformationSettings::ensureDimensionIntegrity(hkArray<hkvAssetLogMessage>& out_messages) { if (m_sourceWidth == 0 || m_sourceHeight == 0) { out_messages.pushBack(hkvAssetLogMessage(HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_ERROR, "Size of source texture is invalid; cannot continue!")); return false; } // Perform sanity checks if (m_validationNeedsPowerOfTwo && m_validationNeedsMultipleOf > 1) { if (hkvMath::isPowerOf2(m_validationNeedsMultipleOf)) { // Both Power-of-Two and Multiple-of restrictions are given. However, multiple-of is a power of two, // so we can drop the multiple-of constraint as long as we limit the minimum size. m_validationMinSize = hkvMath::Max(m_validationMinSize, m_validationNeedsMultipleOf); } else { VASSERT_MSG(false, "Both Power-of-Two and Multiple-of restrictions are specified, but Multiple-of is not a power of two. Ignoring Multiple-of."); } m_validationNeedsMultipleOf = 1; } if (m_validationNeedsPowerOfTwo) { if (m_validationMinSize > 0 && !hkvMath::isPowerOf2(m_validationMinSize)) { VASSERT_MSG(false, "According to set restrictions, system minimum size needs to be Power-of-Two. Adjusting."); m_validationMinSize = hkvMath::powerOf2_ceil(m_validationMinSize); } if (m_userMinSize > 0) { m_userMinSize = adjustToNearestPowerOfTwo(m_userMinSize); } if (m_validationMaxSize > 0 && !hkvMath::isPowerOf2(m_validationMaxSize)) { VASSERT_MSG(false, "According to set restrictions, system maximum size needs to be Power-of-Two. Adjusting."); m_validationMaxSize = hkvMath::powerOf2_floor(m_validationMaxSize); } if (m_userMaxSize > 0) { m_userMaxSize = adjustToNearestPowerOfTwo(m_userMaxSize); } } if (m_validationNeedsMultipleOf > 1) { if ((m_validationMinSize % m_validationNeedsMultipleOf) != 0) { VASSERT_MSG(false, "According to set restrictions, system minimum size needs to be Multiple-of. Adjusting."); m_validationMinSize = ((m_validationMinSize + m_validationNeedsMultipleOf - 1) / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf; } m_userMinSize = ((m_userMinSize + m_validationNeedsMultipleOf - 1) / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf; if (m_validationMaxSize % m_validationNeedsMultipleOf != 0) { VASSERT_MSG(false, "According to set restrictions, system maximum size needs to be Multiple-of. Adjusting."); m_validationMaxSize = (m_validationMaxSize / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf; } m_userMaxSize = (m_userMaxSize / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf; } if ((m_validationMinSize > 0) && (m_validationMaxSize > 0) && (m_validationMaxSize < m_validationMinSize)) { VASSERT_MSG(false, "System maximum size less than system minimum size; adjusting."); m_validationMinSize = m_validationMaxSize; } if ((m_userMinSize > 0) && (m_userMaxSize > 0) && (m_userMaxSize < m_userMinSize)) { m_userMinSize = m_userMaxSize; } if ((m_validationMinSize > 0) && (m_userMinSize > 0) && (m_userMinSize < m_validationMinSize)) { m_userMinSize = m_validationMinSize; } if ((m_validationMaxSize > 0) && (m_userMaxSize > 0) && (m_userMaxSize > m_validationMaxSize)) { m_userMaxSize = m_validationMaxSize; } return true; }
/// \brief /// Returns the topmost object from the stack (without popping it) /// /// \return /// The object on the top of the stack const T& Top() const { VASSERT_MSG(m_uiSize > 0,"nothing on the stack"); return m_pData[m_uiSize-1]; }
hkResult hkvTextureTransformationRule::determineOutputsAndroid(Context& context) const { hkvTextureCompression compression = (hkvTextureCompression)m_compressionInstance.getDefinitionId(); const char* const variantDefault = (getPlatform() == HKV_TARGET_PLATFORM_TIZEN) ? VARIANT_TIZEN_DEFAULT : VARIANT_ANDROID_DEFAULT; const char* const variantPvr = (getPlatform() == HKV_TARGET_PLATFORM_TIZEN) ? VARIANT_TIZEN_PVR : VARIANT_ANDROID_PVR; switch (compression) { case HKV_TEXTURE_COMPRESSION_NONE: { if (context.m_sourceHasAlpha && !m_removeAlphaChannel) { context.m_outputVariants.pushBack(hkvTextureVariant(variantDefault, HKV_IMAGE_DATA_FORMAT_A8R8G8B8, HKV_IMAGE_FILE_FORMAT_RGBA, "", false)); context.m_outputVariants.pushBack(hkvTextureVariant(variantPvr, HKV_IMAGE_DATA_FORMAT_A8R8G8B8, HKV_IMAGE_FILE_FORMAT_RGBA, "", false)); } else { context.m_outputVariants.pushBack(hkvTextureVariant(variantDefault, HKV_IMAGE_DATA_FORMAT_X8R8G8B8, HKV_IMAGE_FILE_FORMAT_RGBA, "", false)); context.m_outputVariants.pushBack(hkvTextureVariant(variantPvr, HKV_IMAGE_DATA_FORMAT_X8R8G8B8, HKV_IMAGE_FILE_FORMAT_RGBA, "", false)); } break; } case HKV_TEXTURE_COMPRESSION_QUALITY: { if (context.m_sourceHasAlpha && !m_removeAlphaChannel) { context.m_outputVariants.pushBack(hkvTextureVariant(variantDefault, HKV_IMAGE_DATA_FORMAT_R4G4B4A4_GL, HKV_IMAGE_FILE_FORMAT_RGBA, "", false)); context.m_outputVariants.pushBack(hkvTextureVariant(variantPvr, HKV_IMAGE_DATA_FORMAT_PVRTC4, HKV_IMAGE_FILE_FORMAT_PVR, "", false)); } else { if (m_usageInstance.getDefinitionId() == HKV_TEXTURE_USAGE_NORMAL_MAP) { context.m_outputVariants.pushBack(hkvTextureVariant(variantDefault, HKV_IMAGE_DATA_FORMAT_R5G6B5, HKV_IMAGE_FILE_FORMAT_RGBA, "", false)); } else { context.m_outputVariants.pushBack(hkvTextureVariant(variantDefault, HKV_IMAGE_DATA_FORMAT_ETC1, HKV_IMAGE_FILE_FORMAT_ETC, "", false)); } context.m_outputVariants.pushBack(hkvTextureVariant(variantPvr, HKV_IMAGE_DATA_FORMAT_PVRTC4, HKV_IMAGE_FILE_FORMAT_PVR, "", false)); } break; } //case HKV_TEXTURE_COMPRESSION_SIZE: // { // if (context.m_sourceHasAlpha && !m_removeAlphaChannel) // { // context.m_outputVariants.pushBack(hkvTextureVariant(variantDefault, // HKV_IMAGE_DATA_FORMAT_A4R4G4B4, HKV_IMAGE_FILE_FORMAT_RGBA, "", false)); // context.m_outputVariants.pushBack(hkvTextureVariant(variantPvr, // HKV_IMAGE_DATA_FORMAT_PVRTC2, HKV_IMAGE_FILE_FORMAT_PVR, "", false)); // } // else // { // context.m_outputVariants.pushBack(hkvTextureVariant(variantDefault, // HKV_IMAGE_DATA_FORMAT_ETC1, HKV_IMAGE_FILE_FORMAT_ETC, "", false)); // context.m_outputVariants.pushBack(hkvTextureVariant(variantPvr, // HKV_IMAGE_DATA_FORMAT_PVRTC2, HKV_IMAGE_FILE_FORMAT_PVR, "", false)); // } // break; // } default: { VASSERT_MSG(FALSE, "Missing compression case!"); return HK_FAILURE; } } return HK_SUCCESS; }
/// \brief /// Defines how near/far clipping is determined on this instance /// /// \param iFlags /// Determines the clipping behavior. There are 5 valid combinations: /// \li VIS_LOD_TEST_NONE: No clipping is performed /// \li VIS_LOD_TEST_CLIPPOSITION: Clipping is performed relative to clip position (passed to SetClipSettings) /// \li VIS_LOD_TEST_CLIPPOSITION|VIS_LOD_TEST_APPLYLODSCALING: Additionally applies the context's LOD scaling factor to the distance /// \li VIS_LOD_TEST_BOUNDINGBOX: Distance is measured against the bounding biox /// \li VIS_LOD_TEST_BOUNDINGBOX|VIS_LOD_TEST_APPLYLODSCALING: Additionally applies the context's LOD scaling factor to the distance inline void SetClipMode(int iFlags=VIS_LOD_TEST_CLIPPOSITION) { VASSERT_MSG((iFlags&VIS_PERFORM_LODTEST)==iFlags,"Invalid constants passed to this function"); m_iPerformTestFlags &= (~VIS_PERFORM_LODTEST); m_iPerformTestFlags |= iFlags; }
/// \brief /// Index operator for randomly accessing elements on the stack /// /// \param index /// The index of the element to return /// /// \return /// The value of the element at index T& operator [](size_t index) { VASSERT_MSG(index < m_uiSize, "Out of bounds"); return m_pData[index]; }
void hkvTextureAsset::handleProjectLoaded() { hkvAsset::handleProjectLoaded(); hkvAssetManager* assetManager = hkvAssetManager::getGlobalInstance(); hkvProfileManager* profileManager = hkvProfileManager::getGlobalInstance(); hkvCriticalSectionLock lock(assetManager->acquireLock()); // Migrate texture usage hkvTextureUsage usage = (hkvTextureUsage)m_usageInstance.getDefinitionId(); if (usage == HKV_TEXTURE_USAGE_DIFFUSE_MAP || usage == HKV_TEXTURE_USAGE_NORMAL_MAP) { const hkUint32 iTemplateIdx = getTransformTemplate(); hkvProperty usageProperty("Usage", m_usageInstance.getString(), hkvProperty::TYPE_STRING); touch(); // Migrate usage setting to 'Custom' template. if (hasCustomTransformRule()) { // Serialization path from the asset to the custom transform rule. If the asset has a different rule set, the setProperty call will simply be ignored. hkArray<hkStringPtr> path; path.pushBack("Transformations"); path.pushBack("PROFILENAME"); path.pushBack("TextureTransformationRule"); hkUint32 iProfiles = profileManager->getNumberOfProfiles(); for (hkUint32 iProfileIdx = 0; iProfileIdx < iProfiles; ++iProfileIdx) { hkvProfile::RefCPtr profile = profileManager->getProfileByIndex(iProfileIdx); path[1] = profile->getName(); setProperty(usageProperty, path, 0, hkvProperty::PURPOSE_SERIALIZATION); } } // Migrate usage setting to template else { // Serialization path from the asset to the custom transform rule. If the asset has a different rule set, the setProperty call will simply be ignored. hkArray<hkStringPtr> path; path.pushBack("PROFILENAME"); path.pushBack("TextureTransformationRule"); const hkvTransformRuleTemplate* templateRule = profileManager->getTransformRuleTemplateByIndex(getTypeName(), iTemplateIdx); VASSERT_MSG(templateRule != NULL, "hkvTextureAsset::handleProjectLoaded: Could not resolve transform template via index!"); // Build name of new template hkStringBuf newTemplateName(templateRule->getName(), (usage == HKV_TEXTURE_USAGE_DIFFUSE_MAP) ? "_DIFFUSE_USAGE" : "_NORMAL_USAGE"); hkUint32 newTemplateIndex = profileManager->getTransformRuleTemplateIndexByName(getTypeName(), newTemplateName.cString()); // If it does not exist yet, duplicate the current template and set the usage setting if (newTemplateIndex == HKV_INVALID_INDEX) { newTemplateIndex = profileManager->duplicateTransformRuleTemplate(getTypeName(), iTemplateIdx, newTemplateName.cString()); hkvTransformRuleTemplate* newTemplateRule = profileManager->getTransformRuleTemplateByIndex(getTypeName(), newTemplateIndex); VASSERT_MSG(newTemplateRule != NULL, "hkvTextureAsset::handleProjectLoaded: Could not resolve transform template via index!"); hkUint32 iProfiles = profileManager->getNumberOfProfiles(); for (hkUint32 iProfileIdx = 0; iProfileIdx < iProfiles; ++iProfileIdx) { hkvProfile::RefCPtr profile = profileManager->getProfileByIndex(iProfileIdx); path[0] = profile->getName(); newTemplateRule->setProperty(usageProperty, path, 0, hkvProperty::PURPOSE_SERIALIZATION); } } setTransformTemplate(newTemplateIndex); } } }
hkResult hkvTextureTransformationRule::prepareTransformationSettings(Context& context, const hkvTextureVariant& variant) const { // Construct the settings for the final output. hkvTextureTransformationSettings finalSettings(getPlatform()); finalSettings.setSourceProperties(context.m_sourceSrgb, context.m_sourceHasAlpha, context.m_sourceWidth, context.m_sourceHeight); finalSettings.setUsage((hkvTextureUsage)m_usageInstance.getDefinitionId()); finalSettings.setTargetFormat(variant.m_dataFormat, variant.m_fileFormat); finalSettings.setDiscardAlpha(m_removeAlphaChannel); finalSettings.setCreateMipMaps(m_createMipMaps); finalSettings.setDownscaleLevel(m_downscaleLevel); finalSettings.setUserMinSize(m_minSize); finalSettings.setUserMaxSize(m_maxSize); if (variant.m_isEditorPreview) { finalSettings.setIgnoreTargetFormatRestrictions(true); } if (finalSettings.validate(context.m_output.m_messages) != HK_SUCCESS) { return HK_FAILURE; } // Determine all steps that need to be executed to arrive at the target format context.m_transformationSteps.clear(); // First, determine the final step that leads us to our output format. TransformationStepInfo finalStep; switch (finalSettings.getTargetFileFormat()) { case HKV_IMAGE_FILE_FORMAT_DDS: case HKV_IMAGE_FILE_FORMAT_RGBA: { switch (finalSettings.getTargetDataFormat()) { case HKV_IMAGE_DATA_FORMAT_DXT1: case HKV_IMAGE_DATA_FORMAT_DXT3: case HKV_IMAGE_DATA_FORMAT_DXT5: case HKV_IMAGE_DATA_FORMAT_A1R5G5B5: case HKV_IMAGE_DATA_FORMAT_R5G6B5: case HKV_IMAGE_DATA_FORMAT_A8R8G8B8: case HKV_IMAGE_DATA_FORMAT_X8R8G8B8: { finalStep = TransformationStepInfo(STEP_TYPE_TEXCONV, "dds", finalSettings); break; } case HKV_IMAGE_DATA_FORMAT_A4R4G4B4: case HKV_IMAGE_DATA_FORMAT_R4G4B4A4_GL: case HKV_IMAGE_DATA_FORMAT_R8G8B8: { finalStep = TransformationStepInfo(STEP_TYPE_IMAGE_TO_DDS, "dds", finalSettings); break; } default: { VASSERT_MSG(false, "Forgotten uncompressed DDS format?"); return HK_FAILURE; } } break; } case HKV_IMAGE_FILE_FORMAT_ETC: case HKV_IMAGE_FILE_FORMAT_PVR: { finalStep = TransformationStepInfo(STEP_TYPE_PVRTEXTOOL, "pvr", finalSettings); break; } case HKV_IMAGE_FILE_FORMAT_GTX: { finalStep = TransformationStepInfo(STEP_TYPE_WIIU_TEXCONV2, "gtx", finalSettings); break; } default: { VASSERT_MSG(FALSE, "Missing case for texture file format"); return HK_FAILURE; } } // In ALL cases, add a step first that converts whatever input format we have to A8R8G8B8 DDS without // mipmaps. Yes, even texconv will fail to process a file under certain conditions even if can read the // input format and write the output format without problems. hkvTextureTransformationSettings preparationSettings(HKV_TARGET_PLATFORM_ANY); preparationSettings.setSourceProperties(context.m_sourceSrgb, context.m_sourceHasAlpha, context.m_sourceWidth, context.m_sourceHeight); preparationSettings.setUsage((hkvTextureUsage)m_usageInstance.getDefinitionId()); preparationSettings.setExplicitTargetSize(context.m_sourceWidth, context.m_sourceHeight); preparationSettings.setTargetFormat(HKV_IMAGE_DATA_FORMAT_A8R8G8B8, HKV_IMAGE_FILE_FORMAT_DDS); preparationSettings.setCreateMipMaps(false); preparationSettings.setDiscardAlpha(false); preparationSettings.setDownscaleLevel(0); // PVRTexTool will not parse some DDS files (e.g. cubemaps) correctly unless they are saved as DXT10 DDS files. TransformationStepType preparationStepType = finalStep.getStepType() == STEP_TYPE_PVRTEXTOOL ? STEP_TYPE_TEXCONV_FORCE_DXT10 : STEP_TYPE_TEXCONV; context.m_transformationSteps.pushBack(TransformationStepInfo(preparationStepType, "dds", preparationSettings)); // In case of WiiU, the Cafe TexConv2 tool will pass through the input format. So use TexConv again to // get to the target format (without mipmaps, though, as the Cafe tool will take care of it) if (finalStep.getStepType() == STEP_TYPE_WIIU_TEXCONV2) { hkvTextureTransformationSettings cafeSettings(HKV_TARGET_PLATFORM_ANY); cafeSettings.assignFrom(finalStep.getSettings(), true); cafeSettings.setTargetFormat(cafeSettings.getTargetDataFormat(), HKV_IMAGE_FILE_FORMAT_DDS); if (cafeSettings.getCreateMipMaps()) { cafeSettings.setCreateMipMaps(false); // Not needed here, as the final step needs to creates them cafeSettings.setApplyMipMapRestrictions(true); // However, take restrictions into account already } context.m_transformationSteps.pushBack(TransformationStepInfo(STEP_TYPE_TEXCONV, "dds", cafeSettings)); } // If the final step is our internal functionality to write uncompressed DDS files, all the other // operations (Downscaling, MipMaps) still need to be done. Use texconv for that. if (finalStep.getStepType() == STEP_TYPE_IMAGE_TO_DDS) { hkvTextureTransformationSettings texconvSettings(HKV_TARGET_PLATFORM_ANY); texconvSettings.assignFrom(finalStep.getSettings(), true); texconvSettings.setTargetFormat(HKV_IMAGE_DATA_FORMAT_A8R8G8B8, HKV_IMAGE_FILE_FORMAT_DDS); context.m_transformationSteps.pushBack(TransformationStepInfo(STEP_TYPE_TEXCONV, "dds", texconvSettings)); } context.m_transformationSteps.pushBack(finalStep); // Determine the name of the output file const char* extension = hkvImageFileFormatExtensions[variant.m_fileFormat]; hkStringBuf nameAdditionBuf(variant.m_filenameAddition, ".", extension); hkStringBuf filePathBuf; context.m_targetFile = makeAbsoluteTargetFilePath(context, nameAdditionBuf, filePathBuf); return HK_SUCCESS; }
/// \brief /// Unloads and reloads the resource, based on the flags passed. Additionally triggers any /// registered callbacks for before/after file modified. inline HKV_DEPRECATED_2013_2 void UnloadAndReload(BOOL bUnload, BOOL bReload) { VASSERT_MSG(bUnload || bReload, "at least one option has to be set"); UnloadAndReload(bReload ? VURO_COLD_RELOAD : VURO_ONLY_UNLOAD); }
hkResult hkvTextureTransformationRule::runConversion(Context& context) const { context.m_stepSourceFile = context.m_tempOriginalFile; int numSteps = context.m_transformationSteps.getSize(); for (int stepIdx = 0; stepIdx < numSteps; ++stepIdx) { TransformationStepInfo& stepInfo = context.m_transformationSteps[stepIdx]; // Check if this step's transformation settings are valid. If not, try to validate them. hkvTextureTransformationSettings& settings = stepInfo.getSettings(); if (!settings.isValid() && (settings.validate(context.m_output.m_messages) != HK_SUCCESS)) { context.m_output.m_messages.pushBack(hkvAssetLogMessage( HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_ERROR, "Failed to validate transformation settings of a transformation step!")); return HK_FAILURE; } // If this is not the first step, take the output of the previous step as the // input of this step if (stepIdx > 0) { context.m_stepSourceFile = context.m_stepTargetFile; } // The new output file name is a generated base name with the step-specific extension hkStringBuf nameBuf; context.m_stepTargetFile = makeIntermediateFileName(context, stepInfo.getTargetExtension(), nameBuf); hkRefPtr<hkvFileTransformationStep> step; switch (stepInfo.getStepType()) { case STEP_TYPE_WIIU_TEXCONV2: { step = hkRefNew<hkvFileTransformationStep>( new hkvExternalToolWiiUTexConv2(stepInfo.getSettings(), context.m_stepSourceFile, context.m_stepTargetFile)); break; } case STEP_TYPE_IMAGE_TO_DDS: { step = hkRefPtr<hkvFileTransformationStep>( new hkvTransformationStepImageToDds(stepInfo.getSettings(), context.m_stepSourceFile, context.m_stepTargetFile)); break; } case STEP_TYPE_PVRTEXTOOL: { step = hkRefNew<hkvFileTransformationStep>( new hkvExternalToolPvrTexTool(stepInfo.getSettings(), context.m_stepSourceFile, context.m_stepTargetFile)); break; } case STEP_TYPE_TEXCONV: { step = hkRefNew<hkvFileTransformationStep>( new hkvExternalToolTexConv(stepInfo.getSettings(), context.m_stepSourceFile, context.m_stepTargetFile, false)); break; } case STEP_TYPE_TEXCONV_FORCE_DXT10: { step = hkRefNew<hkvFileTransformationStep>( new hkvExternalToolTexConv(stepInfo.getSettings(), context.m_stepSourceFile, context.m_stepTargetFile, true)); break; } default: { VASSERT_MSG(FALSE, "Missing tool case!"); return HK_FAILURE; } } // Some tools want to create output files with a name of their choosing. Now that we // know the concrete step to execute, query it for its output file name. context.m_stepTargetFile = step->getTargetFile(); context.m_tempFileNames.pushBack(context.m_stepTargetFile); { hkvCriticalSectionLock lock(s_protect); context.m_currentTransformationStep = step; } hkResult stepResult = step->run(); { hkvCriticalSectionLock lock(s_protect); context.m_currentTransformationStep = NULL; } context.m_output.m_messages.append(step->getMessages()); if (stepResult != HK_SUCCESS) { if (context.m_canceled) { context.m_output.m_messages.pushBack(hkvAssetLogMessage( HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_WARNING, "Transformation step was canceled.")); } else { context.m_output.m_messages.pushBack(hkvAssetLogMessage( HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_ERROR, "Transformation step failed!")); } return HK_FAILURE; } } return HK_SUCCESS; }
/// \brief /// Sets the ordering channel of the message. inline void SetOrderingChannel (BYTE iOrderingChannel) { VASSERT_MSG (iOrderingChannel < iNUMBER_OF_ORDERING_CHANNELS, "VMessageSettings::SetOrderingChannel: parameter iOrderingChannel out of range!"); m_iOrderingChannel = iOrderingChannel; }
void SetChannelTexture(VTextureObject *pTextureObject, int iChannel) { VASSERT_MSG(false, "The terrain sector mesh's channel textures shouldn't be used - did you mean to use the channel textures of one of the sector's pages instead?"); }
inline void VGroupInstanceFile::WriteInstance(const VGroupInstance &instance) { VASSERT_MSG(m_iInstanceCount>0, "written too many instances"); m_iInstanceCount--; instance.Write(m_pOut,m_eFlags); }
VTextureObject* SetChannelTexture(const char *szFilename, int iChannel) { VASSERT_MSG(false, "The terrain sector mesh's channel textures shouldn't be used - did you mean to use the channel textures of one of the sector's pages instead?"); return NULL; }
wchar_t* VArabicSupport_cl::UniformToContextualLine(VisFont_cl * pArabicFont, const wchar_t * pUniformArabic, bool duplicateSpaces) { if(pUniformArabic==NULL) return NULL; //length of the current line int iLength = VArrayHelper_cl<wchar_t>::Length(pUniformArabic); //count spaces int iNumSpaces = 0; if(duplicateSpaces) { for(int i=0;i<iLength;i++) { if(pUniformArabic[i]==L' ') iNumSpaces++; } } //allocate the target buffer (original length + number of duplicates space + terminator) wchar_t *pContextualArabic = (wchar_t *) vMemAlloc(sizeof(wchar_t)*(iLength+iNumSpaces+1)); //pre-terminate buffer pContextualArabic[iLength+iNumSpaces] = 0; wchar_t wcCurLetter = pUniformArabic[0]; //start with the first letter wchar_t wcPrevLetter = 0; //init wcPrevLetter, because the assignment is done at the end of the for loop //is the current (first) letter an Arabic letter? bool bCurIsArabic = isUniformArabic(pUniformArabic[0]); bool bPrevIsArabic = false; //at the beginning the previous letter is never Arabic bool bNextIsArabic; //calculated inside the loop //transform and terminate the target buffer for(int i=0;i<iLength;i++) { //start at the right side with the first character at index 0 (because Arabic is RTL) wcCurLetter = pUniformArabic[i]; bNextIsArabic = i<(iLength-1) ? isUniformArabic(pUniformArabic[i+1]) : false; if(bCurIsArabic) { //first uniform letter is 'alif madda: 0x0622 (maps to contextual representation 0xFE81) int iIndex = wcCurLetter-0x0622; //number of iterations wchar_t wcContextual = 0xFE81; //contextual representation of 'alif madda //calculate contextual representation of current uniform representation //(count up transformation steps) for(int j=0;j<iIndex;j++) { if(s_pArabicLetterMap[j]==0) wcContextual +=2; else if(s_pArabicLetterMap[j]==1) wcContextual +=4; //else skip (-1) } //now adjust character according to the in-word position wchar_t wcCandidate = wcContextual; //we experiment with a candidate character since it's not sure that the candidate exists! //end character if( bPrevIsArabic && isInnerLetter(wcPrevLetter) && (!bNextIsArabic || isEndLetter(wcCurLetter)) ) { wcCandidate+=1; //start character } else if( bNextIsArabic && (!bPrevIsArabic || isEndLetter(wcPrevLetter)) ) { if(s_pArabicLetterMap[iIndex]!=0) wcCandidate+=2; //inner character } else if( i>0 && bPrevIsArabic && bNextIsArabic && isInnerLetter(wcPrevLetter) && isInnerLetter(wcCurLetter) ) { if(s_pArabicLetterMap[iIndex]!=0) wcCandidate+=3; } //else isolated (default) //candidate check (do we have this character in the font..?) VRectanglef requiredSpace = GetCharacterDimension(wcCandidate, pArabicFont); if(requiredSpace.GetSizeX()<=0) { wcCandidate = wcContextual; //restore from backup (because the character is missing) //just in case: fall-back to non-contextual VRectanglef requiredSpace = GetCharacterDimension(wcCandidate, pArabicFont); if(requiredSpace.GetSizeX()<=0) wcCandidate = wcCurLetter; } #ifdef HK_DEBUG_SLOW requiredSpace = GetCharacterDimension(wcCandidate, pArabicFont); VASSERT_MSG(requiredSpace.GetSizeX()>0, "Your text contains a character which is not present in your font!") #endif //candidate approved: pContextualArabic[iLength+iNumSpaces-i-1] = wcCandidate; } else { //invert directional symbols switch(wcCurLetter) { case L'(': wcCurLetter = L')'; break; case L')': wcCurLetter = L'('; break; case L'<': wcCurLetter = L'>'; break; case L'>': wcCurLetter = L'<'; break; case L'{': wcCurLetter = L'}'; break; case L'}': wcCurLetter = L'{'; break; case L'[': wcCurLetter = L']'; break; case L']': wcCurLetter = L'['; break; case L'/': wcCurLetter = L'\\'; break; case L'\\': wcCurLetter = L'/'; break; case L' ': if(duplicateSpaces) { pContextualArabic[iLength+iNumSpaces-i-1] = L' '; iNumSpaces--; } break; default: break; } pContextualArabic[iLength+iNumSpaces-i-1] = wcCurLetter; } //prepare for next loop iteration wcPrevLetter = wcCurLetter; bPrevIsArabic = bCurIsArabic; bCurIsArabic = bNextIsArabic; } return pContextualArabic; }
VTextureObject* GetChannelTexture(int iChannel) const { VASSERT_MSG(false, "The terrain sector mesh's channel textures shouldn't be used - did you mean use to the channel textures of one of the sector's pages instead?"); return NULL; }