/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #pragma once #pragma warning( disable : 6286 ) // ( || ) is always a non-zero constant. is never evaluated and might have side #pragma warning( disable : 6237 ) // ( && ) is always zero. is never evaluated and might have side effects #pragma warning( disable : 6236 ) // ( || ) is always a non-zero constant #pragma warning( disable : 6235 ) // ( || ) is always a non-zero constant #pragma warning( disable : 6239 ) // ( && ) always evaluates to the result of #pragma warning( disable : 6240 ) // ( && ) always evaluates to the result of const int nThreadsNum = 3; #include #include //#define DEFINE_MODULE_NAME "Cry3DEngine" //#define FORCE_STANDARD_ASSERT // fix edit and continue #if defined(WIN64) #define CRY_INTEGRATE_DX12 #endif ////////////////////////////////////////////////////////////////////////////////////////////// // Highlevel defines // deferred cull queue handling - currently disabled // #define USE_CULL_QUEUE // Compilation (Export to Engine) not needed on consoles #if defined(CONSOLE) # define ENGINE_ENABLE_COMPILATION 0 #else # define ENGINE_ENABLE_COMPILATION 1 #endif #pragma warning( error: 4018 ) #include #include #include #define MAX_PATH_LENGTH 512 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Cry3DEngineBase.h" #include #include "CryArray.h" #include "cvars.h" #include #include #include #include "Material.h" #include "3dEngine.h" #include "ObjMan.h" #include "Vegetation.h" #include #include #include "BasicArea.h" #include "Environment/OceanEnvironmentBus.h" #include "ObjectsTree.h" // TODO refactor! // 1. This is not the right place for defining a function like 'vsnprintf()'. // 2. Subtle changes to the semantics of 'vsnprintf()' (null-termination) are // _not_ nice. Should use a different function name for that! #ifdef _MSC_VER inline int vsnprintf(char* buf, int size, const char* format, va_list& args) { int res = _vsnprintf_s(buf, size, size, format, args); assert(res >= 0 && res < size); // just to know if there was problems in past buf[size - 1] = 0; return res; } #else namespace std { // 'vsnprintf_safe()' must be within the 'std' namespace, otherwise the // #define below would break standard includes. inline int vsnprintf_safe(char* buf, int size, const char* format, va_list ap) { int res = vsnprintf(buf, size, format, ap); buf[size - 1] = 0; return res; } } using std::vsnprintf_safe; #undef vsnprintf #define vsnprintf vsnprintf_safe #endif // _MSC_VER inline int snprintf(char* buf, int size, const char* format, ...) { va_list arglist; va_start(arglist, format); int res = vsnprintf(buf, size, format, arglist); va_end(arglist); return res; } template void AddToPtr(byte*& pPtr, T& rObj, EEndian eEndian) { PREFAST_SUPPRESS_WARNING(6326) COMPILE_TIME_ASSERT(((sizeof(T) % 4) == 0)); assert(!((INT_PTR)pPtr & 3)); memcpy(pPtr, &rObj, sizeof(rObj)); SwapEndian(*(T*)pPtr, eEndian); pPtr += sizeof(rObj); assert(!((INT_PTR)pPtr & 3)); } template void AddToPtr(byte*& pPtr, int& nDataSize, T& rObj, EEndian eEndian) { PREFAST_SUPPRESS_WARNING(6326) COMPILE_TIME_ASSERT(((sizeof(T) % 4) == 0)); assert(!((INT_PTR)pPtr & 3)); memcpy(pPtr, &rObj, sizeof(rObj)); SwapEndian(*(T*)pPtr, eEndian); pPtr += sizeof(rObj); nDataSize -= sizeof(rObj); assert(nDataSize >= 0); assert(!((INT_PTR)pPtr & 3)); } inline void FixAlignment(byte*& pPtr, int& nDataSize) { while ((UINT_PTR)pPtr & 3) { *pPtr = 222; pPtr++; nDataSize--; } } inline void FixAlignment(byte*& pPtr) { while ((UINT_PTR)pPtr & 3) { *pPtr = 222; pPtr++; } } template void AddToPtr(byte*& pPtr, int& nDataSize, const T* pArray, int nElemNum, EEndian eEndian, bool bFixAlignment = false) { assert(!((INT_PTR)pPtr & 3)); memcpy(pPtr, pArray, nElemNum * sizeof(T)); SwapEndian((T*)pPtr, nElemNum, eEndian); pPtr += nElemNum * sizeof(T); nDataSize -= nElemNum * sizeof(T); assert(nDataSize >= 0); if (bFixAlignment) { FixAlignment(pPtr, nDataSize); } else { assert(!((INT_PTR)pPtr & 3)); } } template void AddToPtr(byte*& pPtr, const T* pArray, int nElemNum, EEndian eEndian, bool bFixAlignment = false) { assert(!((INT_PTR)pPtr & 3)); memcpy(pPtr, pArray, nElemNum * sizeof(T)); SwapEndian((T*)pPtr, nElemNum, eEndian); pPtr += nElemNum * sizeof(T); if (bFixAlignment) { FixAlignment(pPtr); } else { assert(!((INT_PTR)pPtr & 3)); } } struct TriangleIndex { TriangleIndex() { ZeroStruct(*this); } uint16& operator [] (const int& n) { assert(n >= 0 && n < 3); return idx[n]; } const uint16& operator [] (const int& n) const { assert(n >= 0 && n < 3); return idx[n]; } uint16 idx[3]; uint16 nCull; }; #define FUNCTION_PROFILER_3DENGINE FUNCTION_PROFILER_FAST(gEnv->pSystem, PROFILE_3DENGINE, m_bProfilerEnabled) #define FUNCTION_PROFILER_3DENGINE_LEGACYONLY FUNCTION_PROFILER_LEGACYONLY(gEnv->pSystem, PROFILE_3DENGINE) #if !defined(CONSOLE) # define INCLUDE_SAVECGF #endif #if !ENABLE_CRY_PHYSICS #include #endif