void PerspectiveImpl::SetFOVAngle (float a, float width) { // make sure we have valid angles if (a >= 180) { a = 180 - SMALL_EPSILON; } else if (a <= 0) { a = SMALL_EPSILON; } // This is our reference point. // It must be somewhere on the function graph. // This reference point was composed by testing. // If anyone knows a 100 percent correct reference point, please put it here. // But for now it's about 99% correct float vRefFOVAngle = 53; float vRefFOV = width; // We calculate the new aspect relative to a reference point aspect = ((tan((vRefFOVAngle * 0.5) / 180 * PI) * vRefFOV) / tan((a * 0.5) / 180 * PI)); // set the other neccessary variables inv_aspect = 1.0f / aspect; fov_angle = a; Dirtify(); }
void PerspectiveImpl::ComputeAngle (float width) { float rview_fov = (float)GetFOV () * 0.5f; float disp_width = (float)width * 0.5f; float inv_disp_radius = csQisqrt ( rview_fov * rview_fov + disp_width * disp_width); fov_angle = 2.0f * (float)acos (disp_width * inv_disp_radius) * (360.0f / TWO_PI); Dirtify(); }
void CLevelEntity::RemoveParameter(const tstring& sKey) { m_asParameters.erase(sKey); Dirtify(); }
void CLevelEntity::SetParameterValue(const tstring& sKey, const tstring& sValue) { auto it = m_asParameters.find(sKey); if (it == m_asParameters.end()) { if (!sValue.length()) return; m_asParameters[sKey] = sValue; } else { if (!sValue.length()) { m_asParameters.erase(sKey); Dirtify(); return; } tstring& sCurrentValue = it->second; if (sCurrentValue == sValue) return; sCurrentValue = sValue; } Dirtify(); CSaveData oSaveData; CSaveData* pSaveData = CBaseEntity::FindSaveDataValuesByHandle(("C" + GetClass()).c_str(), sKey.c_str(), &oSaveData); if (!pSaveData) TMsg("Level entity " + GetClass() + ":" + GetName() + " has unregistered savedata value: " + sKey + "\n"); if (pSaveData && pSaveData->m_pszHandle && pSaveData->m_bDefault) { // Special case. if (strcmp(pSaveData->m_pszHandle, "Model") == 0) { m_hMaterialModel = CMaterialLibrary::AddMaterial(sValue); // Don't continue to erasing the default parameters if it's a model, since models have special processing. return; } if (strcmp(pSaveData->m_pszType, "bool") == 0) { bool bValue = UnserializeString_bool(sValue); bool b = *((bool*)&pSaveData->m_oDefault[0]); if (bValue == b) m_asParameters.erase(sKey); } else { if (strcmp(pSaveData->m_pszType, "size_t") == 0) { size_t i = *((size_t*)&pSaveData->m_oDefault[0]); if (stoi(sValue) == i) m_asParameters.erase(sKey); } else if (strcmp(pSaveData->m_pszType, "float") == 0) { float f = *((float*)&pSaveData->m_oDefault[0]); if (stof(sValue) == f) m_asParameters.erase(sKey); } else if (strcmp(pSaveData->m_pszType, "Vector") == 0) { if (CanUnserializeString_TVector(sValue)) { Vector v = *((Vector*)&pSaveData->m_oDefault[0]); if (UnserializeString_TVector(sValue) == v) m_asParameters.erase(sKey); } } else if (strcmp(pSaveData->m_pszType, "Vector2D") == 0) { if (CanUnserializeString_Vector2D(sValue)) { Vector2D v = *((Vector2D*)&pSaveData->m_oDefault[0]); if (UnserializeString_Vector2D(sValue) == v) m_asParameters.erase(sKey); } } else if (strcmp(pSaveData->m_pszType, "EAngle") == 0) { if (CanUnserializeString_EAngle(sValue)) { EAngle v = *((EAngle*)&pSaveData->m_oDefault[0]); if (UnserializeString_EAngle(sValue) == v) m_asParameters.erase(sKey); } } else if (strcmp(pSaveData->m_pszType, "Matrix4x4") == 0) { if (CanUnserializeString_Matrix4x4(sValue)) { Matrix4x4 m = *((Matrix4x4*)&pSaveData->m_oDefault[0]); if (UnserializeString_Matrix4x4(sValue) == m) m_asParameters.erase(sKey); } } else if (strcmp(pSaveData->m_pszType, "AABB") == 0) { if (CanUnserializeString_AABB(sValue)) { AABB b = *((AABB*)&pSaveData->m_oDefault[0]); if (UnserializeString_AABB(sValue) == b) m_asParameters.erase(sKey); } } else { TUnimplemented(); } } } }