Merge branch 'main' into non-uniform-scale-ux

This commit is contained in:
greerdv
2021-05-07 15:20:29 +01:00
837 changed files with 18633 additions and 36983 deletions
@@ -1,77 +0,0 @@
/*
* 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.
// Description : declaration of struct CryEngineDecalInfo.
// Note:
// 3D Engine and Character Animation subsystems (as well as perhaps
// some others) transfer data about the decals that need to be spawned
// via this structure. This is to avoid passing many parameters through
// each function call, and to save on copying these parameters when just
// simply passing the structure from one function to another.
#ifndef CRYINCLUDE_CRYCOMMON_CRYENGINEDECALINFO_H
#define CRYINCLUDE_CRYCOMMON_CRYENGINEDECALINFO_H
#pragma once
#include "Cry_Math.h"
// Summary:
// Structure containing common parameters that describe a decal
struct SDecalOwnerInfo
{
SDecalOwnerInfo() { memset(this, 0, sizeof(*this)); nRenderNodeSlotId = nRenderNodeSlotSubObjectId = -1; }
struct IStatObj* GetOwner(Matrix34A& objMat);
struct IRenderNode* pRenderNode; // Owner (decal will be attached to or wrapped around of this object)
PodArray<struct SRNInfo>* pDecalReceivers;
int nRenderNodeSlotId; // is set internally by 3dengine
int nRenderNodeSlotSubObjectId; // is set internally by 3dengine
int nMatID;
};
struct CryEngineDecalInfo
{
SDecalOwnerInfo ownerInfo;
Vec3 vPos; // Decal position (world coordinates)
Vec3 vNormal; // Decal/face normal
float fSize; // Decal size
float fLifeTime; // Decal life time (in seconds)
float fAngle; // Angle of rotation
struct IStatObj* pIStatObj; // Decal geometry
Vec3 vHitDirection; // Direction from weapon/player position to decal position (bullet direction)
float fGrowTime, fGrowTimeAlpha;// Used for blood pools
unsigned int nGroupId; // Used for multi-component decals
bool bSkipOverlappingTest; // Always spawn decals even if there are a lot of other decals in same place
bool bAssemble; // Assemble to bigger decals if more than 1 decal is on the same place
bool bForceEdge; // force the decal to the nearest edge of the owner mesh and project it accordingly
bool bForceSingleOwner; // Do not attempt to cast the decal into the environment even if it's large enough
bool bDeferred;
uint8 sortPrio;
char szMaterialName[_MAX_PATH]; // name of material used for rendering the decal (in favor of szTextureName/nTid and the default decal shader)
bool preventDecalOnGround; // mainly for decal placement support
const Matrix33* pExplicitRightUpFront; // mainly for decal placement support
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const{}
// the constructor fills in some non-obligatory fields; the other fields must be filled in by the client
CryEngineDecalInfo ()
{
memset(this, 0, sizeof(*this));
ownerInfo.nRenderNodeSlotId = ownerInfo.nRenderNodeSlotSubObjectId = -1;
sortPrio = 255;
}
};
#endif // CRYINCLUDE_CRYCOMMON_CRYENGINEDECALINFO_H
-98
View File
@@ -1,98 +0,0 @@
/*
* 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.
*
*/
#pragma once
#include <platform.h>
#if defined(AZ_RESTRICTED_PLATFORM)
#include AZ_RESTRICTED_FILE(Gem_h)
#endif
#if defined(LINUX) || defined(APPLE) || defined(ANDROID)
#define OPENGL 1
#endif
#include <Common/RendererDefs.h>
#include <Cry_Math.h>
#include <Cry_XOptimise.h>
#include <Cry_Math.h>
#include <Cry_Geo.h>
#include <CryArray.h>
#include <CryHeaders.h>
#include <CrySizer.h>
#include <CryArray.h>
#include <IProcess.h>
#include <ITimer.h>
#include <ISystem.h>
#include <ILog.h>
#include <IConsole.h>
#include <IRenderer.h>
#include <IRenderAuxGeom.h>
#include <IEntityRenderState.h>
#include <I3DEngine.h>
#include <IStreamEngine.h>
#include <CryArray2d.h>
#include <PoolAllocator.h>
#include <Cry3DEngineBase.h>
#include <cvars.h>
#include <Material.h>
#include <3dEngine.h>
#include <ObjMan.h>
#include <StlUtils.h>
#include <Common/CommonRender.h>
#include <Common/Shaders/ShaderComponents.h>
#include <Common/Shaders/Shader.h>
#include <Common/Shaders/CShader.h>
#include <Common/RenderMesh.h>
#include <Common/RenderPipeline.h>
#include <Common/RenderThread.h>
#include <Common/Renderer.h>
#include <Common/Textures/Texture.h>
#include <Common/Shaders/Parser.h>
#include <RenderDll/Common/OcclQuery.h>
#include <RenderDll/Common/DeferredRenderUtils.h>
#include <RenderDll/Common/Textures/TextureManager.h>
#include <RenderDll/Common/FrameProfiler.h>
#include <RenderDll/XRenderD3D9/DeviceManager/DeviceManagerInline.h>
#include <RenderDll/XRenderD3D9/DriverD3D.h>
#include <RenderDll/XRenderD3D9/DeviceManager/TempDynBuffer.h>
#include <AzCore/PlatformDef.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Asset/AssetManager.h>
#include <AzCore/Asset/AssetManagerBus.h>
#include <AzCore/Asset/AssetTypeInfoBus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/ComponentBus.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/IO/GenericStreams.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Math/Quaternion.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/XML/rapidxml.h>
#include <AzFramework/Asset/SimpleAsset.h>
#include <AzFramework/Asset/AssetCatalogBus.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <LmbrCentral/Rendering/RenderNodeBus.h>
File diff suppressed because it is too large Load Diff
-53
View File
@@ -1,53 +0,0 @@
/*
* 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.
#ifndef CRYINCLUDE_CRYCOMMON_I3DENGINE_INFO_H
#define CRYINCLUDE_CRYCOMMON_I3DENGINE_INFO_H
#pragma once
#include "TypeInfo_impl.h"
#include "IShader_info.h"
#include <I3DEngine.h> // <> required for Interfuscator
STRUCT_INFO_BEGIN(SVisAreaManChunkHeader)
STRUCT_VAR_INFO(nVersion, TYPE_INFO(int8))
STRUCT_VAR_INFO(nDummy, TYPE_INFO(int8))
STRUCT_VAR_INFO(nFlags, TYPE_INFO(int8))
STRUCT_VAR_INFO(nFlags2, TYPE_INFO(int8))
STRUCT_VAR_INFO(nChunkSize, TYPE_INFO(int))
STRUCT_VAR_INFO(nVisAreasNum, TYPE_INFO(int))
STRUCT_VAR_INFO(nPortalsNum, TYPE_INFO(int))
STRUCT_VAR_INFO(nOcclAreasNum, TYPE_INFO(int))
STRUCT_INFO_END(SVisAreaManChunkHeader)
STRUCT_INFO_BEGIN(SOcTreeNodeChunk)
STRUCT_VAR_INFO(nChunkVersion, TYPE_INFO(int16))
STRUCT_VAR_INFO(ucChildsMask, TYPE_INFO(int16))
STRUCT_VAR_INFO(nodeBox, TYPE_INFO(AABB))
STRUCT_VAR_INFO(nObjectsBlockSize, TYPE_INFO(int32))
STRUCT_INFO_END(SOcTreeNodeChunk)
STRUCT_INFO_BEGIN(SHotUpdateInfo)
STRUCT_VAR_INFO(nHeigtmap, TYPE_INFO(uint32))
STRUCT_VAR_INFO(nObjTypeMask, TYPE_INFO(uint32))
STRUCT_VAR_INFO(areaBox, TYPE_INFO(AABB))
STRUCT_INFO_END(SHotUpdateInfo)
STRUCT_INFO_BEGIN(SCommonFileHeader)
STRUCT_VAR_INFO(signature, TYPE_ARRAY(4, TYPE_INFO(char)))
STRUCT_VAR_INFO(file_type, TYPE_INFO(uint8))
STRUCT_VAR_INFO(flags, TYPE_INFO(uint8))
STRUCT_VAR_INFO(version, TYPE_INFO(uint16))
STRUCT_INFO_END(SCommonFileHeader)
#endif // CRYINCLUDE_CRYCOMMON_I3DENGINE_INFO_H
@@ -286,7 +286,6 @@ struct IRenderNode
// Physicalizes node.
virtual void Physicalize([[maybe_unused]] bool bInstant = false) {}
// Make sure I3DEngine::FreeRenderNodeState(this) is called in destructor of derived class.
virtual ~IRenderNode() { assert(!m_pRNTmpData); };
// Summary:
@@ -1,33 +0,0 @@
/*
* 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.
// Description : Interface for LocalMemoryUsage
#ifndef CRYINCLUDE_CRYCOMMON_ILOCALMEMORYUSAGE_H
#define CRYINCLUDE_CRYCOMMON_ILOCALMEMORYUSAGE_H
#pragma once
class CCamera;
struct IRenderer;
struct ILocalMemoryUsage
{
virtual ~ILocalMemoryUsage(){}
virtual void OnRender(IRenderer* pRenderer, const CCamera* camera) = 0;
virtual void OnUpdate() = 0;
virtual void DeleteGlobalData() = 0;
};
#endif // CRYINCLUDE_CRYCOMMON_ILOCALMEMORYUSAGE_H
+1 -2
View File
@@ -273,7 +273,7 @@ struct IMaterial
//////////////////////////////////////////////////////////////////////////
// material name
//////////////////////////////////////////////////////////////////////////
//! Set material name, (Do not use this directly, to change material name use I3DEngine::RenameMatInfo method).
//! Set material name, (Do not use this directly
virtual void SetName(const char* pName) = 0;
//! Returns material name.
virtual const char* GetName() const = 0;
@@ -404,7 +404,6 @@ struct IMaterial
//////////////////////////////////////////////////////////////////////////
// Makes this specific material enter sketch mode.
// Se also: I3DEngine::LoadCGF, in I3DEngine.h.
// Current supported sketch modes:
// - 0, no sketch.
// - 1, normal sketch mode.
-1
View File
@@ -26,7 +26,6 @@
#include <ISplines.h>
#include <IRenderer.h>
#include <IRenderAuxGeom.h>
#include <I3DEngine.h>
#include <VectorSet.h>
#include <CryName.h>
-1
View File
@@ -202,7 +202,6 @@ struct IObjManager
// time counters
virtual bool IsAfterWater(const Vec3& vPos, const SRenderingPassInfo& passInfo) = 0;
virtual void GetObjectsStreamingStatus(I3DEngine::SObjectsStreamingStatus& outStatus) = 0;
virtual void FreeNotUsedCGFs() = 0;
virtual void MakeUnitCube() = 0;
-22
View File
@@ -66,7 +66,6 @@ struct IConsole;
struct IRemoteConsole;
struct IRenderer;
struct IProcess;
struct I3DEngine;
struct ITimer;
struct ICryFont;
struct IMovieSystem;
@@ -123,8 +122,6 @@ namespace Serialization {
struct IArchiveHost;
}
struct ILocalMemoryUsage;
typedef void* WIN_HWND;
class CCamera;
@@ -793,7 +790,6 @@ struct SSystemUpdateStats
// ISystem
struct SSystemGlobalEnvironment
{
I3DEngine* p3DEngine;
AZ::IO::IArchive* pCryPak;
AZ::IO::FileIOBase* pFileIO;
IFileChangeMonitor* pFileChangeMonitor;
@@ -801,7 +797,6 @@ struct SSystemGlobalEnvironment
IOpticsManager* pOpticsManager;
ITimer* pTimer;
ICryFont* pCryFont;
ILocalMemoryUsage* pLocalMemoryUsage;
::IConsole* pConsole;
ISystem* pSystem = nullptr;
ILog* pLog;
@@ -1113,25 +1108,9 @@ struct ISystem
virtual void DoWorkDuringOcclusionChecks() = 0;
virtual bool NeedDoWorkDuringOcclusionChecks() = 0;
// Summary:
// Renders subsystems.
virtual void Render() = 0;
// Summary:
// Begins rendering frame.
virtual void RenderBegin() = 0;
// Summary:
// Ends rendering frame and swap back buffer.
virtual void RenderEnd(bool bRenderStats = true, bool bMainWindow = true) = 0;
//! Update screen and call some important tick functions during loading.
virtual void SynchronousLoadingTick(const char* pFunc, int line) = 0;
// Description:
// Renders the statistics; this is called from RenderEnd, but if the
// Host application (Editor) doesn't employ the Render cycle in ISystem,
// it may call this method to render the essential statistics.
virtual void RenderStatistics() = 0;
// Summary:
// Returns the current used memory.
virtual uint32 GetUsedMemory() = 0;
@@ -1229,7 +1208,6 @@ struct ISystem
virtual ICryFont* GetICryFont() = 0;
virtual IMemoryManager* GetIMemoryManager() = 0;
virtual IMovieSystem* GetIMovieSystem() = 0;
virtual I3DEngine* GetI3DEngine() = 0;
virtual ::IConsole* GetIConsole() = 0;
virtual IRemoteConsole* GetIRemoteConsole() = 0;
// Returns:
-286
View File
@@ -1,286 +0,0 @@
/*
* 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
struct SBezierKey;
struct ITimeOfDayUpdateCallback;
struct ISplineInterpolator;
//! Interface to the Time Of Day functionality.
struct ITimeOfDay
{
enum ETimeOfDayParamID
{
PARAM_SUN_COLOR,
PARAM_SUN_INTENSITY,
PARAM_SUN_SPECULAR_MULTIPLIER,
PARAM_FOG_COLOR,
PARAM_FOG_COLOR_MULTIPLIER,
PARAM_VOLFOG_HEIGHT,
PARAM_VOLFOG_DENSITY,
PARAM_FOG_COLOR2,
PARAM_FOG_COLOR2_MULTIPLIER,
PARAM_VOLFOG_HEIGHT2,
PARAM_VOLFOG_DENSITY2,
PARAM_VOLFOG_HEIGHT_OFFSET,
PARAM_FOG_RADIAL_COLOR,
PARAM_FOG_RADIAL_COLOR_MULTIPLIER,
PARAM_VOLFOG_RADIAL_SIZE,
PARAM_VOLFOG_RADIAL_LOBE,
PARAM_VOLFOG_FINAL_DENSITY_CLAMP,
PARAM_VOLFOG_GLOBAL_DENSITY,
PARAM_VOLFOG_RAMP_START,
PARAM_VOLFOG_RAMP_END,
PARAM_VOLFOG_RAMP_INFLUENCE,
PARAM_VOLFOG_SHADOW_DARKENING,
PARAM_VOLFOG_SHADOW_DARKENING_SUN,
PARAM_VOLFOG_SHADOW_DARKENING_AMBIENT,
PARAM_VOLFOG_SHADOW_RANGE,
PARAM_VOLFOG2_HEIGHT,
PARAM_VOLFOG2_DENSITY,
PARAM_VOLFOG2_HEIGHT2,
PARAM_VOLFOG2_DENSITY2,
PARAM_VOLFOG2_GLOBAL_DENSITY,
PARAM_VOLFOG2_RAMP_START,
PARAM_VOLFOG2_RAMP_END,
PARAM_VOLFOG2_COLOR1,
PARAM_VOLFOG2_ANISOTROPIC1,
PARAM_VOLFOG2_COLOR2,
PARAM_VOLFOG2_ANISOTROPIC2,
PARAM_VOLFOG2_BLEND_FACTOR,
PARAM_VOLFOG2_BLEND_MODE,
PARAM_VOLFOG2_COLOR,
PARAM_VOLFOG2_ANISOTROPIC,
PARAM_VOLFOG2_RANGE,
PARAM_VOLFOG2_INSCATTER,
PARAM_VOLFOG2_EXTINCTION,
PARAM_VOLFOG2_GLOBAL_FOG_VISIBILITY,
PARAM_VOLFOG2_FINAL_DENSITY_CLAMP,
PARAM_SKYLIGHT_SUN_INTENSITY,
PARAM_SKYLIGHT_SUN_INTENSITY_MULTIPLIER,
PARAM_SKYLIGHT_KM,
PARAM_SKYLIGHT_KR,
PARAM_SKYLIGHT_G,
PARAM_SKYLIGHT_WAVELENGTH_R,
PARAM_SKYLIGHT_WAVELENGTH_G,
PARAM_SKYLIGHT_WAVELENGTH_B,
PARAM_NIGHSKY_HORIZON_COLOR,
PARAM_NIGHSKY_HORIZON_COLOR_MULTIPLIER,
PARAM_NIGHSKY_ZENITH_COLOR,
PARAM_NIGHSKY_ZENITH_COLOR_MULTIPLIER,
PARAM_NIGHSKY_ZENITH_SHIFT,
PARAM_NIGHSKY_START_INTENSITY,
PARAM_NIGHSKY_MOON_COLOR,
PARAM_NIGHSKY_MOON_COLOR_MULTIPLIER,
PARAM_NIGHSKY_MOON_INNERCORONA_COLOR,
PARAM_NIGHSKY_MOON_INNERCORONA_COLOR_MULTIPLIER,
PARAM_NIGHSKY_MOON_INNERCORONA_SCALE,
PARAM_NIGHSKY_MOON_OUTERCORONA_COLOR,
PARAM_NIGHSKY_MOON_OUTERCORONA_COLOR_MULTIPLIER,
PARAM_NIGHSKY_MOON_OUTERCORONA_SCALE,
PARAM_CLOUDSHADING_SUNLIGHT_MULTIPLIER,
PARAM_CLOUDSHADING_SUNLIGHT_CUSTOM_COLOR,
PARAM_CLOUDSHADING_SUNLIGHT_CUSTOM_COLOR_MULTIPLIER,
PARAM_CLOUDSHADING_SUNLIGHT_CUSTOM_COLOR_INFLUENCE,
PARAM_SUN_SHAFTS_VISIBILITY,
PARAM_SUN_RAYS_VISIBILITY,
PARAM_SUN_RAYS_ATTENUATION,
PARAM_SUN_RAYS_SUNCOLORINFLUENCE,
PARAM_SUN_RAYS_CUSTOMCOLOR,
PARAM_OCEANFOG_COLOR, // Remove when ocean related feature toggle is removed.
PARAM_OCEANFOG_COLOR_MULTIPLIER, // Remove when ocean related feature toggle is removed.
PARAM_OCEANFOG_DENSITY, // Remove when ocean related feature toggle is removed.
PARAM_SKYBOX_MULTIPLIER,
PARAM_HDR_FILMCURVE_SHOULDER_SCALE,
PARAM_HDR_FILMCURVE_LINEAR_SCALE,
PARAM_HDR_FILMCURVE_TOE_SCALE,
PARAM_HDR_FILMCURVE_WHITEPOINT,
PARAM_HDR_COLORGRADING_COLOR_SATURATION,
PARAM_HDR_COLORGRADING_COLOR_BALANCE,
PARAM_HDR_EYEADAPTATION_SCENEKEY,
PARAM_HDR_EYEADAPTATION_MIN_EXPOSURE,
PARAM_HDR_EYEADAPTATION_MAX_EXPOSURE,
PARAM_HDR_EYEADAPTATION_EV_MIN,
PARAM_HDR_EYEADAPTATION_EV_MAX,
PARAM_HDR_EYEADAPTATION_EV_AUTO_COMPENSATION,
PARAM_HDR_BLOOM_AMOUNT,
PARAM_COLORGRADING_FILTERS_GRAIN,
PARAM_COLORGRADING_FILTERS_PHOTOFILTER_COLOR,
PARAM_COLORGRADING_FILTERS_PHOTOFILTER_DENSITY,
PARAM_COLORGRADING_DOF_FOCUSRANGE,
PARAM_COLORGRADING_DOF_BLURAMOUNT,
PARAM_SHADOWSC0_BIAS,
PARAM_SHADOWSC0_SLOPE_BIAS,
PARAM_SHADOWSC1_BIAS,
PARAM_SHADOWSC1_SLOPE_BIAS,
PARAM_SHADOWSC2_BIAS,
PARAM_SHADOWSC2_SLOPE_BIAS,
PARAM_SHADOWSC3_BIAS,
PARAM_SHADOWSC3_SLOPE_BIAS,
PARAM_SHADOWSC4_BIAS,
PARAM_SHADOWSC4_SLOPE_BIAS,
PARAM_SHADOWSC5_BIAS,
PARAM_SHADOWSC5_SLOPE_BIAS,
PARAM_SHADOWSC6_BIAS,
PARAM_SHADOWSC6_SLOPE_BIAS,
PARAM_SHADOWSC7_BIAS,
PARAM_SHADOWSC7_SLOPE_BIAS,
PARAM_SHADOW_JITTERING,
PARAM_HDR_DYNAMIC_POWER_FACTOR,
PARAM_TERRAIN_OCCL_MULTIPLIER,
PARAM_SUN_COLOR_MULTIPLIER,
PARAM_TOTAL
};
struct SPresetInfo
{
const char* m_pName;
bool m_bCurrent;
};
enum EVariableType
{
TYPE_FLOAT,
TYPE_COLOR
};
struct SVariableInfo
{
const char* name; //!< Variable name.
const char* displayName; //!< Variable user readable name.
const char* group; //!< Group name.
int nParamId;
EVariableType type;
float fValue[3]; //!< Value of the variable (3 needed for color type).
ISplineInterpolator* pInterpolator; //!< Splines that control variable value.
};
struct SAdvancedInfo
{
float fStartTime;
float fEndTime;
float fAnimSpeed;
};
struct SEnvironmentInfo
{
SEnvironmentInfo()
: bSunLinkedToTOD(true)
, sunRotationLatitude(0)
, sunRotationLongitude(0){}
bool bSunLinkedToTOD;
float sunRotationLatitude;
float sunRotationLongitude;
};
// <interfuscator:shuffle>
virtual ~ITimeOfDay(){}
virtual int GetPresetCount() const = 0;
virtual bool GetPresetsInfos(SPresetInfo* resultArray, unsigned int arraySize) const = 0;
virtual bool SetCurrentPreset(const char* szPresetName) = 0;
virtual bool AddNewPreset(const char* szPresetName) = 0;
virtual bool RemovePreset(const char* szPresetName) = 0;
virtual bool SavePreset(const char* szPresetName) const = 0;
virtual bool LoadPreset(const char* szFilePath) = 0;
virtual void ResetPreset(const char* szPresetName) = 0;
virtual bool ImportPreset(const char* szPresetName, const char* szFilePath) = 0;
virtual bool ExportPreset(const char* szPresetName, const char* szFilePath) const = 0;
//! Access to variables that control time of the day appearance.
virtual int GetVariableCount() const = 0;
virtual bool GetVariableInfo(int nIndex, SVariableInfo& varInfo) const = 0;
virtual void SetVariableValue(int nIndex, float fValue[3]) = 0;
//! Editor interface.
virtual bool InterpolateVarInRange(int nIndex, float fMin, float fMax, unsigned int nCount, Vec3* resultArray) const = 0;
virtual uint GetSplineKeysCount(int nIndex, int nSpline) const = 0;
virtual bool GetSplineKeysForVar(int nIndex, int nSpline, SBezierKey* keysArray, unsigned int keysArraySize) const = 0;
virtual bool SetSplineKeysForVar(int nIndex, int nSpline, const SBezierKey* keysArray, unsigned int keysArraySize) = 0;
virtual bool UpdateSplineKeyForVar(int nIndex, int nSpline, float fTime, float newValue) = 0;
virtual void ResetVariables() = 0;
//! Sets the time of the day specified in hours.
virtual void SetTime(float fHour, bool bForceUpdate = false, bool bForceEnvUpdate = true) = 0;
virtual float GetTime() = 0;
//! Sun position.
virtual void SetSunPos(float longitude, float latitude) = 0;
virtual float GetSunLatitude() = 0;
virtual float GetSunLongitude() = 0;
//! Updates the current ToD.
virtual void Tick() = 0;
virtual void SetPaused(bool paused) = 0;
virtual void SetAdvancedInfo(const SAdvancedInfo& advInfo) = 0;
virtual void GetAdvancedInfo(SAdvancedInfo& advInfo) = 0;
//! Updates engine parameters after variable values have been changed.
virtual void Update(bool bInterpolate = true, bool bForceUpdate = false, bool bForceEnvUpdate = true) = 0;
virtual void SetUpdateCallback(ITimeOfDayUpdateCallback* pCallback) = 0;
virtual void BeginEditMode() = 0;
virtual void EndEditMode() = 0;
virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0;
virtual void Serialize(TSerialize ser) = 0;
virtual void SetTimer(ITimer* pTimer) = 0;
virtual void SetEnvironmentSettings(const SEnvironmentInfo& envInfo) = 0;
virtual void LerpWith(const ITimeOfDay& other, float lerpValue, ITimeOfDay& output) const = 0;
//! Multiplayer serialization.
static const int NETSER_FORCESET = BIT(0);
static const int NETSER_COMPENSATELAG = BIT(1);
static const int NETSER_STATICPROPS = BIT(2);
virtual void NetSerialize(TSerialize ser, float lag, uint32 flags) = 0;
};
struct ITimeOfDayUpdateCallback
{
// <interfuscator:shuffle>
virtual ~ITimeOfDayUpdateCallback(){}
virtual void BeginUpdate() = 0;
virtual bool GetCustomValue(ITimeOfDay::ETimeOfDayParamID paramID, int dim, float* pValues, float& blendWeight) = 0;
virtual void EndUpdate() = 0;
// </interfuscator:shuffle>
};
@@ -1,528 +0,0 @@
/*
* 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.
*
*/
#pragma once
#include <AzCore/Math/Aabb.h>
#include <I3DEngine.h>
#include <ISerialize.h>
#include <gmock/gmock.h>
// the following was generated using google's python script to autogenerate mocks.
// however, it needed some hand-editing to make it work, so if you add functions to I3DEngine,
// it will probably be better to just manually add them here than try to run the script again.
class I3DEngineMock
: public I3DEngine
{
public:
// From IProcess
MOCK_METHOD1(SetFlags,
void(int));
MOCK_METHOD0(GetFlags,
int(void));
// From I3DEngine
MOCK_METHOD0(Init,
bool());
MOCK_METHOD1(SetLevelPath,
void(const char* szFolderName));
MOCK_METHOD1(CheckMinSpec,
bool(uint32 nMinSpec));
MOCK_METHOD1(PrepareOcclusion,
void(const CCamera& rCamera));
MOCK_METHOD0(EndOcclusion,
void());
MOCK_METHOD2(LoadLevel,
bool(const char* szFolderName, const char* szMissionName));
MOCK_METHOD2(InitLevelForEditor,
bool(const char* szFolderName, const char* szMissionName));
MOCK_METHOD0(LevelLoadingInProgress,
bool());
MOCK_METHOD0(OnFrameStart,
void());
MOCK_METHOD0(PostLoadLevel,
void());
MOCK_METHOD0(LoadEmptyLevel,
void());
MOCK_METHOD0(UnloadLevel,
void());
MOCK_METHOD0(Update,
void());
MOCK_CONST_METHOD0(GetRenderingCamera,
const CCamera&());
MOCK_CONST_METHOD0(GetZoomFactor,
float());
MOCK_METHOD0(Tick,
void());
MOCK_METHOD0(UpdateShaderItems,
void());
MOCK_METHOD0(Release,
void());
MOCK_METHOD3(RenderWorld,
void(int nRenderFlags, const SRenderingPassInfo& passInfo, const char* szDebugName));
MOCK_METHOD2(RenderSceneReflection,
void(int nRenderFlags, const SRenderingPassInfo& passInfo));
MOCK_METHOD1(PreWorldStreamUpdate,
void(const CCamera& cam));
MOCK_METHOD0(WorldStreamUpdate,
void());
MOCK_METHOD0(ShutDown,
void());
MOCK_METHOD7(LoadStatObjUnsafeManualRef,
IStatObj*(const char* fileName, const char* geomName, IStatObj::SSubObject** subObject,
bool useStreaming, unsigned long loadingFlags, const void* data, int dataSize));
MOCK_METHOD7(LoadStatObjAutoRef,
_smart_ptr<IStatObj>(const char* fileName, const char* geomName, IStatObj::SSubObject** subObject,
bool useStreaming, unsigned long loadingFlags, const void* data, int dataSize));
MOCK_METHOD0(ProcessAsyncStaticObjectLoadRequests,
void());
MOCK_METHOD5(LoadStatObjAsync,
void(LoadStaticObjectAsyncResult resultCallback, const char* szFileName, const char* szGeomName, bool bUseStreaming, unsigned long nLoadingFlags));
MOCK_METHOD1(FindStatObjectByFilename,
IStatObj*(const char* filename));
MOCK_METHOD0(GetGSMRange,
const float());
MOCK_METHOD0(GetGSMRangeStep,
const float());
MOCK_METHOD0(GetLoadedObjectCount,
int());
MOCK_METHOD2(GetLoadedStatObjArray,
void(IStatObj** pObjectsArray, int& nCount));
MOCK_METHOD1(GetObjectsStreamingStatus,
void(SObjectsStreamingStatus& outStatus));
MOCK_METHOD2(GetStreamingSubsystemData,
void(int subsystem, SStremaingBandwidthData& outData));
MOCK_METHOD3(RegisterEntity,
void(IRenderNode* pEntity, int nSID, int nSIDConsideredSafe));
MOCK_METHOD1(SelectEntity,
void(IRenderNode* pEntity));
MOCK_METHOD0(IsSunShadows,
bool());
MOCK_METHOD2(MakeSystemMaterialFromShaderHelper
, _smart_ptr<IMaterial>(const char* sShaderName, SInputShaderResources* Res));
MOCK_METHOD1(CheckMinSpecHelper
, bool(uint32 nMinSpec));
MOCK_METHOD1(OnCasterDeleted
, void(IShadowCaster* pCaster));
MOCK_METHOD4(GetStatObjAndMatTables,
void(DynArray<IStatObj*>* pStatObjTable, DynArray<_smart_ptr<IMaterial>>* pMatTable, DynArray<IStatInstGroup*>* pStatInstGroupTable, uint32 nObjTypeMask));
#ifndef _RELEASE
MOCK_METHOD1(AddObjToDebugDrawList,
void(SObjectInfoToAddToDebugDrawList& objInfo));
MOCK_CONST_METHOD0(IsDebugDrawListEnabled,
bool());
#endif
MOCK_METHOD1(UnRegisterEntityDirect,
void(IRenderNode* pEntity));
MOCK_METHOD1(UnRegisterEntityAsJob,
void(IRenderNode* pEnt));
MOCK_CONST_METHOD1(IsUnderWater,
bool(const Vec3& vPos));
MOCK_METHOD1(SetOceanRenderFlags,
void(uint8 nFlags));
MOCK_CONST_METHOD0(GetOceanRenderFlags,
uint8());
MOCK_CONST_METHOD0(GetOceanVisiblePixelsCount,
uint32());
MOCK_METHOD3(GetBottomLevel,
float(const Vec3& referencePos, float maxRelevantDepth, int objtypes));
MOCK_METHOD2(GetBottomLevel,
float(const Vec3& referencePos, float maxRelevantDepth));
MOCK_METHOD2(GetBottomLevel,
float(const Vec3& referencePos, int objflags));
MOCK_METHOD0(GetWaterLevel,
float());
MOCK_METHOD3(GetWaterLevel,
float(const Vec3* pvPos, IPhysicalEntity* pent, bool bAccurate));
MOCK_CONST_METHOD1(GetAccurateOceanHeight,
float(const Vec3& pCurrPos));
MOCK_CONST_METHOD0(GetCausticsParams,
CausticsParams());
MOCK_CONST_METHOD0(GetOceanAnimationParams,
OceanAnimationData());
MOCK_CONST_METHOD1(GetHDRSetupParams,
void(Vec4 pParams[5]));
MOCK_METHOD0(ResetParticlesAndDecals,
void());
MOCK_METHOD1(CreateDecal,
void(const CryEngineDecalInfo& Decal));
MOCK_METHOD2(DeleteDecalsInRange,
void(AABB* pAreaBox, IRenderNode* pEntity));
MOCK_METHOD1(SetSunColor,
void(Vec3 vColor));
MOCK_METHOD0(GetSunAnimColor,
Vec3());
MOCK_METHOD1(SetSunAnimColor,
void(const Vec3& color));
MOCK_METHOD0(GetSunAnimSpeed,
float());
MOCK_METHOD1(SetSunAnimSpeed,
void(float sunAnimSpeed));
MOCK_METHOD0(GetSunAnimPhase,
AZ::u8());
MOCK_METHOD1(SetSunAnimPhase,
void(AZ::u8 sunAnimPhase));
MOCK_METHOD0(GetSunAnimIndex,
AZ::u8());
MOCK_METHOD1(SetSunAnimIndex,
void(AZ::u8 sunAnimIndex));
MOCK_METHOD1(SetRainParams,
void(const SRainParams& rainParams));
MOCK_METHOD1(GetRainParams,
bool(SRainParams& rainParams));
MOCK_METHOD5(SetSnowSurfaceParams,
void(const Vec3& vCenter, float fRadius, float fSnowAmount, float fFrostAmount, float fSurfaceFreezing));
MOCK_METHOD5(GetSnowSurfaceParams,
bool(Vec3& vCenter, float& fRadius, float& fSnowAmount, float& fFrostAmount, float& fSurfaceFreezing));
MOCK_METHOD7(SetSnowFallParams,
void(int nSnowFlakeCount, float fSnowFlakeSize, float fSnowFallBrightness, float fSnowFallGravityScale, float fSnowFallWindScale, float fSnowFallTurbulence, float fSnowFallTurbulenceFreq));
MOCK_METHOD7(GetSnowFallParams,
bool(int& nSnowFlakeCount, float& fSnowFlakeSize, float& fSnowFallBrightness, float& fSnowFallGravityScale, float& fSnowFallWindScale, float& fSnowFallTurbulence, float& fSnowFallTurbulenceFreq));
MOCK_METHOD1(SetMaxViewDistanceScale,
void(float fScale));
MOCK_METHOD1(GetMaxViewDistance,
float(bool));
MOCK_CONST_METHOD0(GetFrameLodInfo,
const SFrameLodInfo&());
MOCK_METHOD1(SetFrameLodInfo,
void(const SFrameLodInfo& frameLodInfo));
MOCK_METHOD1(SetFogColor,
void(const Vec3& vFogColor));
MOCK_METHOD0(GetFogColor,
Vec3());
MOCK_METHOD6(GetSkyLightParameters,
void(Vec3& sunDir, Vec3& sunIntensity, float& Km, float& Kr, float& g, Vec3& rgbWaveLengths));
MOCK_METHOD7(SetSkyLightParameters,
void(const Vec3& sunDir, const Vec3& sunIntensity, float Km, float Kr, float g, const Vec3& rgbWaveLengths, bool forceImmediateUpdate));
MOCK_CONST_METHOD0(GetLightsHDRDynamicPowerFactor,
float());
MOCK_CONST_METHOD3(IsTessellationAllowed,
bool(const CRenderObject* pObj, const SRenderingPassInfo& passInfo, bool bIgnoreShadowPass));
MOCK_METHOD3(SetRenderNodeMaterialAtPosition,
void(EERType eNodeType, const Vec3& vPos, _smart_ptr<IMaterial> pMat));
MOCK_METHOD1(OverrideCameraPrecachePoint,
void(const Vec3& vPos));
MOCK_METHOD4(AddPrecachePoint,
int(const Vec3& vPos, const Vec3& vDir, float fTimeOut, float fImportanceFactor));
MOCK_METHOD1(ClearPrecachePoint,
void(int id));
MOCK_METHOD0(ClearAllPrecachePoints,
void());
MOCK_METHOD1(GetPrecacheRoundIds,
void(int pRoundIds[MAX_STREAM_PREDICTION_ZONES]));
MOCK_METHOD5(TraceFogVolumes,
void(const Vec3& vPos, const AABB& objBBox, SFogVolumeData& fogVolData, const SRenderingPassInfo& passInfo, bool fogVolumeShadingQuality));
MOCK_METHOD1(RemoveAllStaticObjects,
void(int));
MOCK_METHOD3(SetStatInstGroup,
bool(int nGroupId, const IStatInstGroup& siGroup, int nSID));
MOCK_METHOD3(GetStatInstGroup,
bool(int, IStatInstGroup&, int));
MOCK_METHOD3(OnExplosion,
void(Vec3, float, bool));
MOCK_METHOD1(SetPhysMaterialEnumerator,
void(IPhysMaterialEnumerator* pPhysMaterialEnumerator));
MOCK_METHOD0(GetPhysMaterialEnumerator,
IPhysMaterialEnumerator*());
MOCK_METHOD0(SetupDistanceFog,
void());
MOCK_METHOD1(LoadMissionDataFromXMLNode,
void(const char* szMissionName));
MOCK_METHOD2(LoadEnvironmentSettingsFromXML,
void(XmlNodeRef, int));
MOCK_METHOD0(LoadCompiledOctreeForEditor,
bool());
MOCK_CONST_METHOD0(GetSunDir,
Vec3());
MOCK_CONST_METHOD0(GetSunDirNormalized,
Vec3());
MOCK_CONST_METHOD0(GetRealtimeSunDirNormalized,
Vec3());
MOCK_METHOD0(GetDistanceToSectorWithWater,
float());
MOCK_CONST_METHOD0(GetSunColor,
Vec3());
MOCK_CONST_METHOD0(GetSSAOAmount,
float());
MOCK_CONST_METHOD0(GetSSAOContrast,
float());
MOCK_METHOD1(FreeRenderNodeState,
void(IRenderNode* pEntity));
MOCK_METHOD1(GetLevelFilePath,
const char*(const char* szFileName));
MOCK_METHOD4(DisplayInfo,
void(float& fTextPosX, float& fTextPosY, float& fTextStepY, bool bEnhanced));
MOCK_METHOD0(DisplayMemoryStatistics,
void());
// Can't mock methods with variable parameters so just create empty bodies for them.
void DrawTextRightAligned([[maybe_unused]] const float x, [[maybe_unused]] const float y, [[maybe_unused]] const char* format, ...) override {}
void DrawTextRightAligned([[maybe_unused]] const float x, [[maybe_unused]] const float y, [[maybe_unused]] const float scale, [[maybe_unused]] const ColorF& color, [[maybe_unused]] const char* format, ...) override {}
MOCK_METHOD3(DrawBBoxHelper
, void (const Vec3& vMin, const Vec3& vMax, ColorB col));
MOCK_METHOD2(DrawBBoxHelper
, void (const AABB& box, ColorB col));
MOCK_METHOD3(ActivatePortal,
void(const Vec3& vPos, bool bActivate, const char* szEntityName));
MOCK_CONST_METHOD1(GetMemoryUsage,
void(ICrySizer* pSizer));
MOCK_METHOD2(GetResourceMemoryUsage,
void(ICrySizer* pSizer, const AABB& cstAABB));
MOCK_METHOD1(CreateVisArea,
IVisArea*(uint64 visGUID));
MOCK_METHOD1(DeleteVisArea,
void(IVisArea* pVisArea));
MOCK_METHOD6(UpdateVisArea,
void(IVisArea* pArea, const Vec3* pPoints, int nCount, const char* szName, const SVisAreaInfo& info, bool bReregisterObjects));
MOCK_METHOD4(IsVisAreasConnected,
bool(IVisArea* pArea1, IVisArea* pArea2, int nMaxRecursion, bool bSkipDisabledPortals));
MOCK_METHOD0(CreateClipVolume,
IClipVolume*());
MOCK_METHOD1(DeleteClipVolume,
void(IClipVolume* pClipVolume));
MOCK_METHOD7(UpdateClipVolume,
void(IClipVolume* pClipVolume, _smart_ptr<IRenderMesh> pRenderMesh, IBSPTree3D* pBspTree, const Matrix34& worldTM, bool bActive, uint32 flags, const char* szName));
MOCK_METHOD1(CreateRenderNode,
IRenderNode*(EERType type));
MOCK_METHOD1(DeleteRenderNode,
void(IRenderNode* pRenderNode));
MOCK_METHOD1(SetWind,
void(const Vec3& vWind));
MOCK_CONST_METHOD2(GetWind,
Vec3(const AABB& box, bool bIndoors));
MOCK_CONST_METHOD1(GetGlobalWind,
Vec3(bool bIndoors));
MOCK_CONST_METHOD4(SampleWind,
bool(Vec3* pSamples, int nSamples, const AABB& volume, bool bIndoors));
MOCK_METHOD1(GetVisAreaFromPos,
IVisArea*(const Vec3& vPos));
MOCK_METHOD2(IntersectsVisAreas,
bool(const AABB& box, void** pNodeCache));
MOCK_METHOD4(ClipToVisAreas,
bool(IVisArea* pInside, Sphere& sphere, Vec3 const& vNormal, void* pNodeCache));
MOCK_METHOD1(EnableOceanRendering,
void(bool bOcean));
MOCK_METHOD1(AddTextureLoadHandler,
void(ITextureLoadHandler* pHandler));
MOCK_METHOD1(RemoveTextureLoadHandler,
void(ITextureLoadHandler* pHandler));
MOCK_METHOD1(GetTextureLoadHandlerForImage,
ITextureLoadHandler*(const char* ext));
MOCK_METHOD0(CreateLightSource,
struct ILightSource*());
MOCK_METHOD1(DeleteLightSource,
void(ILightSource* pLightSource));
MOCK_METHOD0(GetLightEntities,
const PodArray<ILightSource*>* ());
MOCK_METHOD3(GetLightVolumes,
void(threadID nThreadID, SLightVolume*& pLightVols, uint32& nNumVols));
MOCK_METHOD4(RegisterVolumeForLighting,
uint16(const Vec3& vPos, f32 fRadius, uint8 nClipVolumeRef, const SRenderingPassInfo& passInfo));
MOCK_METHOD1(RestoreTerrainFromDisk,
bool(int));
MOCK_METHOD1(GetFilePath,
const char*(const char* szFileName));
MOCK_CONST_METHOD0(GetPostEffectGroups,
class IPostEffectGroupManager*());
MOCK_CONST_METHOD0(GetPostEffectBaseGroup,
class IPostEffectGroup*());
MOCK_CONST_METHOD3(SetPostEffectParam,
void(const char* pParam, float fValue, bool bForceValue));
MOCK_CONST_METHOD3(SetPostEffectParamVec4,
void(const char* pParam, const Vec4& pValue, bool bForceValue));
MOCK_CONST_METHOD2(SetPostEffectParamString,
void(const char* pParam, const char* pszArg));
MOCK_CONST_METHOD2(GetPostEffectParam,
void(const char* pParam, float& fValue));
MOCK_CONST_METHOD2(GetPostEffectParamVec4,
void(const char* pParam, Vec4& pValue));
MOCK_CONST_METHOD2(GetPostEffectParamString,
void(const char* pParam, const char*& pszArg));
MOCK_METHOD1(GetPostEffectID,
int32(const char* pPostEffectName));
MOCK_METHOD1(ResetPostEffects,
void(bool));
MOCK_METHOD0(DisablePostEffects,
void());
MOCK_METHOD1(SetShadowsGSMCache,
void(bool bCache));
MOCK_METHOD2(SetCachedShadowBounds,
void(const AABB& shadowBounds, float fAdditionalCascadesScale));
MOCK_METHOD1(SetRecomputeCachedShadows,
void(uint));
MOCK_METHOD0(CheckMemoryHeap,
void());
MOCK_METHOD1(DeleteEntityDecals,
void(IRenderNode* pEntity));
MOCK_METHOD0(LockCGFResources,
void());
MOCK_METHOD0(UnlockCGFResources,
void());
MOCK_METHOD0(FreeUnusedCGFResources,
void());
MOCK_METHOD0(CreateStatObj,
IStatObj*());
MOCK_METHOD1(CreateStatObjOptionalIndexedMesh,
IStatObj*(bool createIndexedMesh));
MOCK_METHOD0(CreateIndexedMesh,
IIndexedMesh*());
MOCK_METHOD1(SerializeState,
void(TSerialize ser));
MOCK_METHOD1(PostSerialize,
void(bool bReading));
MOCK_METHOD0(GetMaterialHelpers,
IMaterialHelpers&());
MOCK_METHOD0(GetMaterialManager,
IMaterialManager*());
MOCK_METHOD0(GetObjManager,
IObjManager*());
MOCK_METHOD1(CreateChunkfileContent,
CContentCGF*(const char* filename));
MOCK_METHOD1(ReleaseChunkfileContent,
void(CContentCGF*));
MOCK_METHOD4(LoadChunkFileContent,
bool(CContentCGF* pCGF, const char* filename, bool bNoWarningMode, bool bCopyChunkFile));
MOCK_METHOD6(LoadChunkFileContentFromMem,
bool(CContentCGF* pCGF, const void* pData, size_t nDataLen, uint32 nLoadingFlags, bool bNoWarningMode, bool bCopyChunkFile));
MOCK_METHOD1(CreateChunkFile,
IChunkFile*(bool));
MOCK_CONST_METHOD3(CreateChunkFileWriter,
ChunkFile::IChunkFileWriter*(EChunkFileFormat eFormat, AZ::IO::IArchive* pPak, const char* filename));
MOCK_CONST_METHOD1(ReleaseChunkFileWriter,
void(ChunkFile::IChunkFileWriter* p));
MOCK_METHOD2(CreateOcean,
bool(_smart_ptr<IMaterial> pTerrainWaterMat, float waterLevel));
MOCK_METHOD0(DeleteOcean,
void());
MOCK_METHOD1(ChangeOceanMaterial,
void(_smart_ptr<IMaterial> pMat));
MOCK_METHOD1(ChangeOceanWaterLevel,
void(float fWaterLevel));
MOCK_METHOD1(InitMaterialDefautMappingAxis
, void(_smart_ptr<IMaterial> pMat));
MOCK_METHOD0(GetIVisAreaManager,
IVisAreaManager*());
MOCK_METHOD3(PrecacheLevel,
void(bool bPrecacheAllVisAreas, Vec3* pPrecachePoints, int nPrecachePointsNum));
MOCK_METHOD0(ProposeContentPrecache,
void());
MOCK_METHOD0(GetTimeOfDay,
ITimeOfDay*());
MOCK_METHOD1(SetSkyMaterialPath,
void(const string& skyMaterialPath));
MOCK_METHOD1(SetSkyLowSpecMaterialPath,
void(const string& skyMaterialPath));
MOCK_METHOD0(LoadSkyMaterial,
void());
MOCK_METHOD0(GetSkyMaterial,
_smart_ptr<IMaterial>());
MOCK_METHOD1(SetSkyMaterial,
void(_smart_ptr<IMaterial> pSkyMat));
MOCK_METHOD2(SetGlobalParameter,
void(E3DEngineParameter param, const Vec3& v));
MOCK_METHOD2(GetGlobalParameter,
void(E3DEngineParameter param, Vec3& v));
MOCK_METHOD1(SetShadowMode,
void(EShadowMode shadowMode));
MOCK_CONST_METHOD0(GetShadowMode,
EShadowMode());
MOCK_METHOD6(AddPerObjectShadow,
void(IShadowCaster* pCaster, float fConstBias, float fSlopeBias, float fJitter, const Vec3& vBBoxScale, uint nTexSize));
MOCK_METHOD1(RemovePerObjectShadow,
void(IShadowCaster* pCaster));
MOCK_METHOD1(GetPerObjectShadow,
struct SPerObjectShadow*(IShadowCaster* pCaster));
MOCK_METHOD2(GetCustomShadowMapFrustums,
void(struct ShadowMapFrustum*& arrFrustums, int& nFrustumCount));
MOCK_METHOD2(SaveStatObj,
int(IStatObj* pStatObj, TSerialize ser));
MOCK_METHOD1(LoadStatObj,
IStatObj*(TSerialize ser));
MOCK_METHOD2(CheckIntersectClouds,
bool(const Vec3& p1, const Vec3& p2));
MOCK_METHOD1(OnRenderMeshDeleted,
void(IRenderMesh* pRenderMesh));
MOCK_METHOD0(DebugDraw_UpdateDebugNode,
void());
MOCK_METHOD4(RayObjectsIntersection2D,
bool(Vec3 vStart, Vec3 vEnd, Vec3& vHitPoint, EERType eERType));
MOCK_METHOD3(RenderMeshRayIntersection,
bool(IRenderMesh* pRenderMesh, SRayHitInfo& hitInfo, _smart_ptr<IMaterial> pCustomMtl));
MOCK_METHOD3(CheckCreateRNTmpData
, void(CRNTmpData** ppInfo, IRenderNode* pRNode, const SRenderingPassInfo& passInfo));
MOCK_METHOD1(FreeRNTmpData,
void(CRNTmpData** ppInfo));
MOCK_METHOD0(IsObjectTreeReady
, bool());
MOCK_METHOD0(GetIObjectTree
, IOctreeNode*());
MOCK_METHOD2(GetObjectsByType,
uint32(EERType, IRenderNode**));
MOCK_METHOD4(GetObjectsByTypeInBox,
uint32(EERType objType, const AABB& bbox, IRenderNode** pObjects, ObjectTreeQueryFilterCallback filterCallback));
MOCK_METHOD2(GetObjectsInBox,
uint32(const AABB& bbox, IRenderNode** pObjects));
MOCK_METHOD2(GetObjectsByFlags,
uint32(uint, IRenderNode**));
MOCK_METHOD4(GetObjectsByTypeInBox,
void(EERType objType, const AABB& bbox, PodArray<IRenderNode*>* pLstObjects, ObjectTreeQueryFilterCallback filterCallback));
MOCK_METHOD2(OnObjectModified,
void(IRenderNode* pRenderNode, uint dwFlags));
MOCK_METHOD1(FillDebugFPSInfo,
void(SDebugFPSInfo&));
MOCK_METHOD0(GetLevelFolder,
const char*());
MOCK_METHOD0(IsAreaActivationInUse,
bool());
MOCK_METHOD3(RenderRenderNode_ShadowPass,
void(IShadowCaster* pRNode, const SRenderingPassInfo& passInfo, AZ::LegacyJobExecutor* pJobExecutor));
MOCK_METHOD0(GetOpticsManager,
IOpticsManager*());
MOCK_METHOD0(SyncProcessStreamingUpdate,
void());
MOCK_METHOD1(SetScreenshotCallback,
void(IScreenshotCallback* pCallback));
MOCK_METHOD8(ActivateObjectsLayer,
void(uint16 nLayerId, bool bActivate, bool bPhys, bool bObjects, bool bStaticLights, const char* pLayerName, IGeneralMemoryHeap* pHeap, bool bCheckLayerActivation));
MOCK_CONST_METHOD4(GetLayerMemoryUsage,
void(uint16 nLayerId, ICrySizer* pSizer, int* pNumBrushes, int* pNumDecals));
MOCK_METHOD2(SkipLayerLoading,
void(uint16 nLayerId, bool bClearList));
MOCK_METHOD2(PrecacheRenderNode,
void(IRenderNode* pObj, float fEntDistanceReal));
MOCK_METHOD0(GetDeferredPhysicsEventManager,
IDeferredPhysicsEventManager*());
MOCK_METHOD1(SetStreamableListener,
void(IStreamedObjectListener* pListener));
MOCK_METHOD1(GetRenderingPassCamera,
CCamera*(const CCamera& rCamera));
MOCK_METHOD3(GetSvoStaticTextures,
void(I3DEngine::SSvoStaticTexInfo& svoInfo, PodArray<I3DEngine::SLightTI>* pLightsTI_S, PodArray<I3DEngine::SLightTI>* pLightsTI_D));
MOCK_METHOD2(GetSvoBricksForUpdate,
void(PodArray<SSvoNodeInfo>& arrNodeInfo, bool getDynamic));
#if defined(USE_GEOM_CACHES)
MOCK_METHOD1(LoadGeomCache,
IGeomCache*(const char* szFileName));
MOCK_METHOD1(FindGeomCacheByFilename,
IGeomCache*(const char* szFileName));
#endif
MOCK_METHOD3(LoadDesignerObject,
IStatObj*(int nVersion, const char* szBinaryStream, int size));
MOCK_METHOD0(WaitForCullingJobsCompletion,
void());
};
@@ -12,11 +12,15 @@
#pragma once
#include <IRenderer.h>
#include <I3DEngine.h> // needed for SRenderingPassInfo definition
#include <IVideoRenderer.h>
#include <IImage.h>
#include <gmock/gmock.h>
struct SRendItemSorter {};
struct SRenderingPassInfo {};
struct SClipVolumeBlendInfo {};
struct SFogVolumeData {};
// the following was generated using google's python script to autogenerate mocks.
// however, it needed some hand-editing to make it work, so if you add functions to IRenderer,
// it will probably be better to just manually add them here than try to run the script again
@@ -37,12 +37,6 @@ public:
void());
MOCK_METHOD0(NeedDoWorkDuringOcclusionChecks,
bool());
MOCK_METHOD0(Render,
void());
MOCK_METHOD0(RenderBegin,
void());
MOCK_METHOD2(RenderEnd,
void(bool, bool));
MOCK_METHOD2(SynchronousLoadingTick,
void(const char* pFunc, int line));
MOCK_METHOD0(RenderStatistics,
@@ -124,8 +118,6 @@ public:
IMovieSystem * ());
MOCK_METHOD0(GetIAudioSystem,
Audio::IAudioSystem * ());
MOCK_METHOD0(GetI3DEngine,
I3DEngine * ());
MOCK_METHOD0(GetIConsole,
::IConsole * ());
MOCK_METHOD0(GetIRemoteConsole,
@@ -11,6 +11,8 @@
*/
#pragma once
#include <ITimer.h>
//! Simple stub timer that exposes a single simple interface for setting the current time.
class StubTimer
: public ITimer
-215
View File
@@ -1,215 +0,0 @@
/*
* 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
#if defined(WIN32)
#include "CryWindows.h"
#include "IRenderer.h"
#include "IImage.h"
#include "smartptr.h"
#include "ImageExtensionHelper.h"
// Types supported by CreateResourceFromTexture
enum EResourceType
{
eResourceType_IconBig,
eResourceType_IconSmall,
eResourceType_Cursor,
};
// Loads a (DDS) texture resource from the renderer into a Win32 GDI resource.
// Returns a HICON that must be closed with DestroyIcon(), or NULL on failure.
static HICON CreateResourceFromTexture(IRenderer* pRenderer, const char* path, EResourceType type)
{
if (!pRenderer || !path || !*path)
{
// Invalid parameter passed
return NULL;
}
// Find the target dimensions of the GDI resource
const int nRequestedWidth = GetSystemMetrics(type == eResourceType_IconBig ? SM_CXICON : type == eResourceType_IconSmall ? SM_CXSMICON : SM_CXCURSOR);
const int nRequestedHeight = GetSystemMetrics(type == eResourceType_IconBig ? SM_CYICON : type == eResourceType_IconSmall ? SM_CYSMICON : SM_CYCURSOR);
if (nRequestedWidth != nRequestedHeight || nRequestedHeight <= 0 || nRequestedWidth <= 0)
{
// Don't support non-squares icons or cursors
return NULL;
}
// Load texture.
// in this case, we want to fall back on a null, not substiture the missing texture.
_smart_ptr<IImageFile> pImage = pRenderer->EF_LoadImage(path, FIM_NOFALLBACKS);
if (!pImage || pImage->mfGet_depth() != 1 || pImage->mfGet_NumSides() != 1 || pImage->mfGetTileMode() != eTM_None)
{
// Can't load texture, or texture is a cube-map or volume texture, or uses tiling of some kind
return NULL;
}
byte* pImgRaw = pImage->mfGet_image(0);
const ETEX_Format texFormat = pImage->mfGetFormat();
// Pick first mip level smaller than the GDI resource
int nMip = 0;
size_t offset = 0;
int nMipWidth = pImage->mfGet_width();
int nMipHeight = pImage->mfGet_height();
while (nMipWidth > nRequestedWidth)
{
++nMip;
offset += pRenderer->GetTextureFormatDataSize(nMipWidth, nMipHeight, 1, 1, texFormat);
nMipWidth = max(nMipWidth / 2, 1);
nMipHeight = max(nMipHeight / 2, 1);
}
pImgRaw += offset;
if (nMip >= pImage->mfGet_numMips())
{
// No appropriate mip in the texture
// Note: Consider creating a full mip-chain on the texture so this can't happen
return NULL;
}
const size_t nRawSize = pRenderer->GetTextureFormatDataSize(nMipWidth, nMipHeight, 1, 1, texFormat);
#if 0
// Check that DDS indexing is correct here
offset += nRawSize;
for (int nIdx = nMip + 1; nIdx < pImage->mfGet_numMips(); ++nIdx)
{
const int w = max(nMipWidth >> (nIdx - nMip), 1);
const int h = max(nMipHeight >> (nIdx - nMip), 1);
offset += pRenderer->GetTextureFormatDataSize(w, h, 1, 1, texFormat);
}
assert(offset == pImage->mfGet_ImageSize());
#endif
// Type of bitmap to create
BITMAPV5HEADER bi = { 0 };
bi.bV5Size = sizeof(BITMAPV5HEADER);
bi.bV5Width = nRequestedWidth;
bi.bV5Height = -nRequestedHeight;
bi.bV5Planes = 1;
bi.bV5BitCount = 32;
bi.bV5Compression = BI_BITFIELDS;
// The following mask specification specifies a supported 32 BPP alpha format for Windows XP+
bi.bV5AlphaMask = 0xFF000000;
bi.bV5RedMask = 0x00FF0000;
bi.bV5GreenMask = 0x0000FF00;
bi.bV5BlueMask = 0x000000FF;
// Create the DIB section with an alpha channel
const HDC hdc = GetDC(NULL);
void* lpBits;
const HBITMAP hBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, &lpBits, NULL, 0);
ReleaseDC(NULL, hdc);
if (!hBitmap || !lpBits)
{
// Can't allocate OS bitmap
return NULL;
}
GdiFlush();
// Decompress texture
const bool bTryDecompress = texFormat != eTF_R8G8B8A8 && texFormat != eTF_B8G8R8A8 && texFormat != eTF_B8G8R8X8;
byte* const pImgDecomp = bTryDecompress ? new byte[nMipWidth * nMipHeight * sizeof(int32)] : pImgRaw;
const bool bImgDecompressed = bTryDecompress && pRenderer->DXTDecompress(pImgRaw, nRawSize, pImgDecomp, nMipWidth, nMipHeight, 1, texFormat, false, sizeof(int32));
// Check which conversions need to be performed
const bool bSRGB = (pImage->mfGet_Flags() & CImageExtensionHelper::EIF_SRGBRead) != 0;
const bool bSwap = (texFormat == eTF_R8G8B8A8) || bTryDecompress;
HICON result = NULL;
if (!bTryDecompress || bImgDecompressed)
{
// Assign texture data with mismatching sizes
// Note: Any pixels not in the selected mip will become 100% transparent black, no resizing is performed
const size_t sourceRowStride = nMipWidth;
const size_t targetRowStride = nRequestedWidth;
const uint32* pSourceRow = (uint32*)pImgDecomp;
uint32* pTargetRow = (uint32*)lpBits;
assert(sourceRowStride <= targetRowStride);
assert(nMipHeight <= nRequestedHeight);
assert(pSourceRow != pTargetRow);
assert(pSourceRow && pTargetRow);
uint8 gammaTable[256];
if (!bSRGB)
{
// Linear to sRGB table
const float gamma = 1.0f / 2.2f;
const float gammaMultiplier = 255.0f / powf(255.0f, gamma);
for (int i = 0; i < 256; ++i)
{
gammaTable[i] = uint8(powf(float(i), gamma) * gammaMultiplier);
}
}
else if (bSwap)
{
// sRGB to sRGB table (no change)
for (int i = 0; i < 256; ++i)
{
gammaTable[i] = uint8(i);
}
}
for (int y = 0; y < nMipHeight; ++y, pSourceRow += sourceRowStride, pTargetRow += targetRowStride)
{
if (!bSwap && bSRGB)
{
memcpy(pTargetRow, pSourceRow, sourceRowStride * sizeof(uint32));
}
else
{
const uint32* pSourceTexel = pSourceRow;
uint32* pTargetTexel = pTargetRow;
for (int x = 0; x < nMipWidth; ++x, ++pSourceTexel, ++pTargetTexel)
{
const uint8 red = gammaTable[uint8(*pSourceTexel >> 0)];
const uint8 green = gammaTable[uint8(*pSourceTexel >> 8)];
const uint8 blue = gammaTable[uint8(*pSourceTexel >> 16)];
const uint32 alpha = *pSourceTexel & 0xFF000000;
*pTargetTexel = (red << (bSwap ? 16 : 0)) | (green << 8) | (blue << (bSwap ? 0 : 16)) | alpha;
}
}
// Fill remaining columns with zeros
memset(pTargetRow + sourceRowStride, 0, (targetRowStride - sourceRowStride) * sizeof(uint32));
}
// Fill remaining rows with zeros
for (int y = nMipHeight; y < nRequestedHeight; ++y)
{
memset(pTargetRow, 0, targetRowStride * sizeof(uint32));
pTargetRow += targetRowStride;
}
// Convert to GDI icon
ICONINFO iconinfo = {0};
iconinfo.fIcon = type == eResourceType_Cursor ? FALSE : TRUE;
iconinfo.hbmMask = ::CreateBitmap(nRequestedWidth, nRequestedHeight, 1, 1, NULL);
iconinfo.hbmColor = hBitmap;
result = ::CreateIconIndirect(&iconinfo);
DeleteObject(iconinfo.hbmMask);
}
// Clean up
DeleteObject(hBitmap);
if (bTryDecompress)
{
delete[] pImgDecomp;
}
pImage.reset();
return result;
}
#endif
@@ -14,9 +14,6 @@ set(FILES
CryCommon.cpp
Allocator.h
FinalizingSpline.h
Gem.h
I3DEngine.h
I3DEngine_info.h
IAudioInterfacesCommonData.h
IAudioSystem.h
IChunkFile.h
@@ -86,7 +83,6 @@ set(FILES
ITexture.h
IThreadManager.h
IThreadTask.h
ITimeOfDay.h
ITimer.h
IValidator.h
IVideoRenderer.h
@@ -143,7 +139,6 @@ set(FILES
CryAssert.h
CryCrc32.h
CryCustomTypes.h
CryEngineDecalInfo.h
CryFile.h
CryFixedArray.h
CryFixedString.h
@@ -292,7 +287,6 @@ set(FILES
platform_impl.cpp
Win32specific.h
Win64specific.h
WindowsUtils.h
CryExtension/CryCreateClassInstance.h
CryExtension/CryGUID.h
CryExtension/CryTypeID.h
@@ -317,7 +311,6 @@ set(FILES
CryPool/STLWrapper.h
CryPool/ThreadSafe.h
stl/STLAlignedAlloc.h
ILocalMemoryUsage.h
Serialization/Assert.h
Serialization/BitVector.h
Serialization/BitVectorImpl.h
@@ -10,7 +10,6 @@
#
set(FILES
Mocks/I3DEngineMock.h
Mocks/IAudioSystemMock.h
Mocks/IConsoleMock.h
Mocks/ICryPakMock.h
@@ -102,7 +102,6 @@ inline int RoundToClosestMB(size_t memSize)
#include <IRenderer.h>
#include <CryFile.h>
#include <ISystem.h>
#include <I3DEngine.h>
#include <ITimer.h>
#include <IPhysics.h>
#include <IXml.h>
@@ -127,7 +126,6 @@ namespace AZ::IO
struct IArchive;
}
struct ICryFont;
struct I3DEngine;
struct IMovieSystem;
struct IAudioSystem;
struct IPhysicalWorld;
@@ -193,10 +193,6 @@ static void UnloadMap([[maybe_unused]] IConsoleCmdArgs* args)
if (gEnv->pSystem && gEnv->pSystem->GetILevelSystem() && !gEnv->IsEditor())
{
gEnv->pSystem->GetILevelSystem()->UnloadLevel();
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->LoadEmptyLevel();
}
}
}
@@ -674,18 +670,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
pSpamDelay->Set(0.0f);
}
if (gEnv->p3DEngine)
{
bool is3DEngineLoaded = gEnv->IsEditor() ? gEnv->p3DEngine->InitLevelForEditor(pLevelInfo->GetPath(), pLevelInfo->m_defaultGameTypeName.c_str())
: gEnv->p3DEngine->LoadLevel(pLevelInfo->GetPath(), pLevelInfo->m_defaultGameTypeName.c_str());
if (!is3DEngineLoaded)
{
OnLoadingError(levelName, "3DEngine failed to handle loading the level");
return 0;
}
}
// Parse level specific config data.
AZStd::string const sLevelNameOnly(PathUtil::GetFileName(levelName));
@@ -760,14 +744,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
gEnv->pSystem->SetSystemGlobalState(ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PRECACHE);
//////////////////////////////////////////////////////////////////////////
// Notify 3D engine that loading finished
//////////////////////////////////////////////////////////////////////////
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->PostLoadLevel();
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
gEnv->pConsole->SetScrollMax(600 / 2);
@@ -991,18 +967,6 @@ void CLevelSystem::UnloadLevel()
CTimeValue tBegin = gEnv->pTimer->GetAsyncTime();
I3DEngine* p3DEngine = gEnv->p3DEngine;
if (p3DEngine)
{
IDeferredPhysicsEventManager* pPhysEventManager = p3DEngine->GetDeferredPhysicsEventManager();
if (pPhysEventManager)
{
// clear deferred physics queues before renderer, since we could have jobs running
// which access a rendermesh
pPhysEventManager->ClearDeferredEvents();
}
}
//AM: Flush render thread (Flush is not exposed - using EndFrame())
//We are about to delete resources that could be in use
if (gEnv->pRenderer)
@@ -1076,25 +1040,10 @@ void CLevelSystem::UnloadLevel()
SAFE_RELEASE(m_pCurrentLevel);
/*
Force Lua garbage collection before p3DEngine->UnloadLevel() and pRenderer->FreeResources(flags) are called.
p3DEngine->UnloadLevel() will destroy particle emitters even if they're still referenced by Lua objects that are yet to be collected.
(as per comment in 3dEngineLoad.cpp (line 501) - "Force to clean all particles that are left, even if still referenced.").
Then, during the next GC cycle, Lua finally cleans up, the particle emitter smart pointers will be pointing to invalid memory).
Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event), which is too late
(after the render resources have been purged).
This extra GC step takes a few ms more level unload time, which is a small price for fixing nasty crashes.
If, however, we wanted to claim it back, we could potentially get rid of the GC step that is triggered by ESYSTEM_EVENT_LEVEL_POST_UNLOAD to break even.
*/
// Force Lua garbage collection (may no longer be needed now the legacy renderer has been removed).
// Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event).
EBUS_EVENT(AZ::ScriptSystemRequestBus, GarbageCollect);
// Delete engine resources
if (p3DEngine)
{
p3DEngine->UnloadLevel();
}
// Force to clean render resources left after deleting all objects and materials.
IRenderer* pRenderer = gEnv->pRenderer;
if (pRenderer)
@@ -55,10 +55,6 @@ namespace LegacyLevelSystem
if (gEnv->pSystem && gEnv->pSystem->GetILevelSystem() && !gEnv->IsEditor())
{
gEnv->pSystem->GetILevelSystem()->UnloadLevel();
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->LoadEmptyLevel();
}
}
}
@@ -262,22 +258,6 @@ namespace LegacyLevelSystem
pSpamDelay->Set(0.0f);
}
if (gEnv->p3DEngine)
{
AZ::IO::PathView levelPath(levelName);
AZStd::string parentPath(levelPath.ParentPath().Native());
static constexpr const char* defaultGameTypeName = "Mission0";
bool is3DEngineLoaded = gEnv->IsEditor() ? gEnv->p3DEngine->InitLevelForEditor(parentPath.c_str(), defaultGameTypeName)
: gEnv->p3DEngine->LoadLevel(parentPath.c_str(), defaultGameTypeName);
if (!is3DEngineLoaded)
{
OnLoadingError(levelName, "3DEngine failed to handle loading the level");
return 0;
}
}
// Parse level specific config data.
AZStd::string const sLevelNameOnly(PathUtil::GetFileName(levelName));
@@ -340,14 +320,6 @@ namespace LegacyLevelSystem
gEnv->pSystem->SetSystemGlobalState(ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PRECACHE);
//////////////////////////////////////////////////////////////////////////
// Notify 3D engine that loading finished
//////////////////////////////////////////////////////////////////////////
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->PostLoadLevel();
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
gEnv->pConsole->SetScrollMax(600 / 2);
@@ -569,18 +541,6 @@ namespace LegacyLevelSystem
CTimeValue tBegin = gEnv->pTimer->GetAsyncTime();
I3DEngine* p3DEngine = gEnv->p3DEngine;
if (p3DEngine)
{
IDeferredPhysicsEventManager* pPhysEventManager = p3DEngine->GetDeferredPhysicsEventManager();
if (pPhysEventManager)
{
// clear deferred physics queues before renderer, since we could have jobs running
// which access a rendermesh
pPhysEventManager->ClearDeferredEvents();
}
}
// AM: Flush render thread (Flush is not exposed - using EndFrame())
// We are about to delete resources that could be in use
if (gEnv->pRenderer)
@@ -644,25 +604,10 @@ namespace LegacyLevelSystem
GetISystem()->GetIResourceManager()->UnloadLevel();
/*
Force Lua garbage collection before p3DEngine->UnloadLevel() and pRenderer->FreeResources(flags) are called.
p3DEngine->UnloadLevel() will destroy particle emitters even if they're still referenced by Lua objects that are yet to be
collected. (as per comment in 3dEngineLoad.cpp (line 501) - "Force to clean all particles that are left, even if still referenced.").
Then, during the next GC cycle, Lua finally cleans up, the particle emitter smart pointers will be pointing to invalid memory).
Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event), which is too late
(after the render resources have been purged).
This extra GC step takes a few ms more level unload time, which is a small price for fixing nasty crashes.
If, however, we wanted to claim it back, we could potentially get rid of the GC step that is triggered by
ESYSTEM_EVENT_LEVEL_POST_UNLOAD to break even.
*/
// Force Lua garbage collection (may no longer be needed now the legacy renderer has been removed).
// Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event).
EBUS_EVENT(AZ::ScriptSystemRequestBus, GarbageCollect);
// Delete engine resources
if (p3DEngine)
{
p3DEngine->UnloadLevel();
}
// Force to clean render resources left after deleting all objects and materials.
IRenderer* pRenderer = gEnv->pRenderer;
if (pRenderer)
-55
View File
@@ -22,7 +22,6 @@
#include "MiniGUI/MiniMenu.h"
#include "MiniGUI/MiniTable.h"
#include <IConsole.h>
#include <I3DEngine.h>
#include <ITimer.h>
#include "System.h"
@@ -853,21 +852,6 @@ void CPerfHUD::SaveStatsCallback([[maybe_unused]] void* data, [[maybe_unused]] b
// RENDER CALLBACKS
//////////////////////////////////////////////////////////////////////////
/*
void CPerfHUD::DisplayRenderInfoCallback(const Rect& rect)
{
IMiniGUIPtr pGUI;
if (CryCreateClassInstanceForInterface( cryiidof<IMiniGUI>(),pGUI ))
{
//right aligned display
float x = rect.right;
float y = rect.top;
float step = 13.f;
gEnv->p3DEngine->DisplayInfo(x, y, step, true);
}
}*/
void CPerfHUD::EnableWidget(ICryPerfHUDWidget::EWidgetID id, int mode)
{
const int nWidgets = m_widgets.size();
@@ -1530,26 +1514,6 @@ void CRenderStatsWidget::Update()
m_runtimeData.nFwdLights = 0;
m_runtimeData.nFwdShadowLights = 0;
//////////////////////////////////////////////////////////////////////////
if (gEnv->p3DEngine)
{
I3DEngine::SObjectsStreamingStatus objStats;
gEnv->p3DEngine->GetObjectsStreamingStatus(objStats);
float fMeshRequiredMB = (float)(objStats.nMemRequired) / (1024 * 1024);
sprintf_s(entryBuffer, "Mesh Required: %.2f (%dMB)", fMeshRequiredMB, azlossy_cast<int>(objStats.nMeshPoolSize));
if (fMeshRequiredMB < objStats.nMeshPoolSize)
{
m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_NORM, CPerfHUD::TEXT_SIZE_NORM);
}
else
{
m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_ERROR, CPerfHUD::TEXT_SIZE_NORM);
CryPerfHUDWarning(1.f, "Too Many Geometry: %.2fMB", fMeshRequiredMB);
}
}
//////////////////////////////////////////////////////////////////////////
if (gEnv->pRenderer)
{
@@ -1727,25 +1691,6 @@ CStreamingStatsWidget::CStreamingStatsWidget(IMiniCtrl* pParentMenu, ICryPerfHUD
//////////////////////////////////////////////////////////////////////////
void CStreamingStatsWidget::Update()
{
char entryBuffer[CMiniInfoBox::MAX_TEXT_LENGTH] = {0};
//Clear old entries
m_pInfoBox->ClearEntries();
I3DEngine::SObjectsStreamingStatus objStats;
gEnv->p3DEngine->GetObjectsStreamingStatus(objStats);
float fMeshRequiredMB = (float)(objStats.nMemRequired) / (1024 * 1024);
sprintf_s(entryBuffer, "Mesh Required: %.2f (%dMB)", fMeshRequiredMB, objStats.nMeshPoolSize);
if (fMeshRequiredMB < objStats.nMeshPoolSize)
{
m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_NORM, CPerfHUD::TEXT_SIZE_NORM);
}
else
{
m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_ERROR, CPerfHUD::TEXT_SIZE_NORM);
CryPerfHUDWarning(1.f, "Too Many Geometry: %.2fMB", fMeshRequiredMB);
}
}
//////////////////////////////////////////////////////////////////////////
File diff suppressed because it is too large Load Diff
@@ -1,245 +0,0 @@
/*
* 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.
// Description : Visual helper for checking a local memory usage on maps
#ifndef CRYINCLUDE_CRYSYSTEM_STATISTICS_LOCALMEMORYUSAGE_H
#define CRYINCLUDE_CRYSYSTEM_STATISTICS_LOCALMEMORYUSAGE_H
#pragma once
#include "../CryCommon/Cry_Geo.h"
#include "ILocalMemoryUsage.h"
#include "TimeValue.h"
#define LOCALMEMORY_SECTOR_SIZE 32.f //Size of one sector
#define LOCALMEMORY_SECTOR_NR_X 128 //4096 / LOCALMEMORY_SECTOR_SIZE Sector number of the world (x)
#define LOCALMEMORY_SECTOR_NR_Y 128 //4096 / LOCALMEMORY_SECTOR_SIZE Sector number of the world (y)
#define LOCALMEMORY_SECTOR_PER_PASS 128 //4096 / 32 Sector nr for one calculation pass. Now it is the whole world;
//Sector number must be = LOCALMEMORY_SECTOR_PER_PASS * n
#define LOCALMEMORY_COLOR_OK 0, 255, 0
#define LOCALMEMORY_COLOR_WARNING 255, 255, 0
#define LOCALMEMORY_COLOR_ERROR 255, 0, 0
#define LOCALMEMORY_COLOR_TEXTURE 0, 0, 255
#define LOCALMEMORY_COLOR_GEOMETRY 0, 0, 0
#define LOCALMEMORY_COLOR_BLACK 0, 0, 0, 192
#define LOCALMEMORY_FCOLOR_OK 0, 1, 0
#define LOCALMEMORY_FCOLOR_WARNING 1, 1, 0
#define LOCALMEMORY_FCOLOR_ERROR 1, 0, 0
#define LOCALMEMORY_FCOLOR_OTHER 0, 0, 1
struct IMaterial;
struct IStatObj;
struct IRenderMesh;
struct IRenderNode;
struct CRenderChunk;
class CCamera;
#include <VectorMap.h>
struct CLocalMemoryUsage
: public ILocalMemoryUsage
{
private:
struct STextureInfo;
struct SMaterialInfo;
struct SStatObjInfo;
typedef std__hash_map<INT_PTR, STextureInfo > TTextureMap; // Type: hash map of textures
typedef std__hash_map<INT_PTR, SMaterialInfo> TMaterialMap; // Type: hash map of materials
typedef std__hash_map<INT_PTR, SStatObjInfo > TStatObjMap; // Type: hash map of stat objects
//*******************
struct SResource
{
CLocalMemoryUsage* m_pLocalMemoryUsage; // Inner pointer to the singleton (we can use gEnv->pLocalMemoryUsage with type cast instead this)
float m_arrMipFactor[LOCALMEMORY_SECTOR_PER_PASS * LOCALMEMORY_SECTOR_PER_PASS]; // Mipmap factor based on minimum distance of the resource from the sector (bounding box distance)
bool m_arrRowDirty[LOCALMEMORY_SECTOR_PER_PASS]; // Dirty flag for m_arrMipFactor rows
bool m_used;
static int m_arrMemoryUsage[LOCALMEMORY_SECTOR_PER_PASS]; // Memory usage of the resource in sectors (last row)
static int m_arrPieces[LOCALMEMORY_SECTOR_PER_PASS]; // Pieces nr of the resource in sectors (last row)
virtual void StartChecking(); // Called every frame first
void CheckOnAllSectorsP1(const AABB& bounding, float maxViewDist, float viewDistMultiplierForLOD, float mipFactor); // Calculates the minimum of sector bounding vs renderobject bounding distances
SResource();
virtual void Init(CLocalMemoryUsage* pLocalMemoryUsage);
//If we will needed a destructor, it must be virtual!
};
//*******************
struct STextureInfo
: public SResource
{
ITexture* m_pTexture; // Texture pointer
//int m_size; // For later use - Used memory
//int m_xSize; // For later use - Texture x size
//int m_ySize; // For later use - Texture y size
//int m_numMips; // For later use - Number of mip maps
void CheckOnAllSectorsP2(); // Calculate memory usage using distances
STextureInfo();
~STextureInfo();
};
//*******************
struct STextureInfoAndTilingFactor
{
STextureInfo* m_pTextureInfo;
float m_tilingFactor;
};
typedef std::vector<STextureInfoAndTilingFactor> TTextureVector; // Type: vector of textures
struct SMaterialInfo
: public SResource
{
//_smart_ptr<IMaterial> m_pMaterial; // For later use
TTextureVector m_textures; // Used textures
SMaterialInfo();
void AddTextureInfo(STextureInfoAndTilingFactor texture);// Add a new texture (unique)
void CheckOnAllSectorsP2(); // Forward distance informations to textures
};
//*******************
struct SStatObjInfo
: public SResource
{
int m_streamableContentMemoryUsage; // Total streamable memory usage
//IStatObj *m_pStatObj; //TODO kiszedni
string m_filePath; // The original file name and path of the StatObj
bool m_bSubObject; // Is the original StatObj a subobject?
/*
int m_lodNr; // For later use
int m_vertices;
int m_meshSize;
int m_physProxySize;
int m_physPrimitives;
int m_indices;
int m_indicesPerLod[MAX_LODS];
*/
SStatObjInfo();
void CheckOnAllSectorsP2(); // Calculate memory usage using distances
};
//*******************
struct SSector
{
SSector();
void StartChecking(); // Called every frame first
int m_memoryUsage_Textures; // Sum of texture memory usage
int m_memoryUsage_Geometry; // Sum of geometry memory usage
};
//*******************
PREFAST_SUPPRESS_WARNING(6262);
TTextureMap m_globalTextures; // Hash map of resources: textures
PREFAST_SUPPRESS_WARNING(6262);
TMaterialMap m_globalMaterials; // Hash map of resources: materials
PREFAST_SUPPRESS_WARNING(6262);
TStatObjMap m_globalStatObjs; // Hash map of resources: stat objects
ICVar* m_pStreamCgfPredicitionDistance; // Config: additional object distance for streaming
ICVar* m_pDebugDraw; // Config: debug draw mode
int sys_LocalMemoryTextureLimit; // Config: texture limit for streaming
int sys_LocalMemoryGeometryLimit; // Config: stat object geometry limit for streaming
int sys_LocalMemoryTextureStreamingSpeedLimit; // Config: texture streaming speed limit (approx)
int sys_LocalMemoryGeometryStreamingSpeedLimit; // Config: stat object geometry streaming speed limit (approx)
float sys_LocalMemoryWarningRatio; // Config: Warning ratio for streaming
float sys_LocalMemoryOuterViewDistance; // Config: View distance for debug draw
float sys_LocalMemoryInnerViewDistance; // Config: View distance for detailed debug draw
float sys_LocalMemoryObjectWidth; // Config: Width of the debug object
float sys_LocalMemoryObjectHeight; // Config: Height of the debug object
int sys_LocalMemoryObjectAlpha; // Config: Color alpha of the debug object
float sys_LocalMemoryStreamingSpeedObjectLength; // Config: Length of the streaming speed debug object
float sys_LocalMemoryStreamingSpeedObjectWidth; // Config: Width of the streaming speed debug object
float sys_LocalMemoryDiagramWidth; // Config: Width of the diagram
float sys_LocalMemoryDiagramRadius; // Config: Radius of the diagram
float sys_LocalMemoryDiagramDistance; // Config: Distance of the diagram from the main debug object
float sys_LocalMemoryDiagramStreamingSpeedRadius; // Config: Radius of the streaming speed diagram
float sys_LocalMemoryDiagramStreamingSpeedDistance; // Config: Distance of the streaming speed diagram from the streaming speed debug line
int sys_LocalMemoryDiagramAlpha; // Config: Color alpha of the diagram
int sys_LocalMemoryDrawText; // Config: If != 0, it will draw the numeric values
int sys_LocalMemoryLogText; // Config: If != 0, it will log the numeric values
int sys_LocalMemoryOptimalMSecPerSec; // Config: Optimal calculation time (MSec) per secundum
int sys_LocalMemoryMaxMSecBetweenCalls; // Config: Maximal time difference (MSec) between calls
RectI m_actProcessedSectors; // Processed sectors (now it is the whole world)
RectI m_actDrawedSectors; // Processed sectors (now it is the whole world)
Vec2i m_sectorNr; // Sector x and y number
float m_AverageUpdateTime; // Avarage Update() time (MSec)
CTimeValue m_LastCallTime; // Last call time of Update()
SSector m_arrSectors[LOCALMEMORY_SECTOR_NR_X * LOCALMEMORY_SECTOR_NR_Y]; // Sectors
public:
CLocalMemoryUsage();
~CLocalMemoryUsage();
virtual void OnRender(IRenderer* pRenderer, const CCamera* camera);
virtual void OnUpdate();
virtual void DeleteGlobalData(); // Deletes the m_globalXXX hash maps
private:
void DeleteUnusedResources(); // Delete the non-used resources (especially StatObjs)
void StartChecking(const RectI& actProcessedSectors); // Called every frame first
void CollectGeometryP1(); // Calculates the minimum of sector bounding vs renderobject bounding distances
// Get / create StatObjInfo then run Pass1
SStatObjInfo* CheckStatObjP1(IStatObj* pStatObj, IRenderNode* pRenderNode, AABB bounding, float maxViewDist, float scale);
//void CollectStatObjInfo_Recursive( SStatObjInfo* statObjInfo, IStatObj *pStatObj );
//void CollectGeometryInfo( SStatObjInfo* statObjInfo, IStatObj *pStatObj );
// Get / create MaterialInfo then run Pass1
void CheckMaterialP1(_smart_ptr<IMaterial> pMaterial, AABB bounding, float maxViewDist, float scale, float mipFactor);
void CheckChunkMaterialP1(_smart_ptr<IMaterial> pMaterial, AABB bounding, float maxViewDist, float scale, CRenderChunk* pRenderChunk);
void CheckMeshMaterialP1(IRenderMesh* pRenderMesh, _smart_ptr<IMaterial> pMaterial, AABB bounding, float maxViewDist, float scale);
void CheckStatObjMaterialP1(IStatObj* pStatObj, _smart_ptr<IMaterial> pMaterial, AABB bounding, float maxViewDist, float scale);
// Collects textures used by the material
void CollectMaterialInfo_Recursive(SMaterialInfo* materialInfo, _smart_ptr<IMaterial> pMaterial);
// Get / create TextureInfo
STextureInfo* GetTextureInfo(ITexture* pTexture);
};
#undef MAX_LODS
#endif // CRYINCLUDE_CRYSYSTEM_STATISTICS_LOCALMEMORYUSAGE_H
+3 -100
View File
@@ -119,8 +119,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#include AZ_RESTRICTED_FILE(System_cpp)
#endif
#include <I3DEngine.h>
#include <IRenderer.h>
#include <IMovieSystem.h>
#include <ServiceNetwork.h>
@@ -131,7 +129,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#include <ISoftCodeMgr.h>
#include "VisRegTest.h"
#include <LyShine/ILyShine.h>
#include <ITimeOfDay.h>
#include <LoadScreenBus.h>
@@ -154,7 +151,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#include "Serialization/ArchiveHost.h"
#include "SystemEventDispatcher.h"
#include "ServerThrottle.h"
#include "ILocalMemoryUsage.h"
#include "ResourceManager.h"
#include "HMDBus.h"
#include "OverloadSceneManager/OverloadSceneManager.h"
@@ -682,15 +678,6 @@ void CSystem::ShutDown()
// Shutdown any running VR devices.
EBUS_EVENT(AZ::VR::HMDInitRequestBus, Shutdown);
//////////////////////////////////////////////////////////////////////////
// Clear 3D Engine resources.
if (m_env.p3DEngine)
{
m_env.p3DEngine->UnloadLevel();
}
//////////////////////////////////////////////////////////////////////////
// Shutdown resource manager.
m_pResourceManager->Shutdown();
@@ -706,7 +693,6 @@ void CSystem::ShutDown()
SAFE_DELETE(m_env.pServiceNetwork);
SAFE_RELEASE(m_env.pLyShine);
SAFE_RELEASE(m_env.pCryFont);
SAFE_RELEASE(m_env.p3DEngine); // depends on EntitySystem
if (m_env.pConsole)
{
((CXConsole*)m_env.pConsole)->FreeRenderResources();
@@ -1231,8 +1217,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
return false;
}
RenderBegin();
#ifndef EXCLUDE_UPDATE_ON_CONSOLE
// do the dedicated sleep earlier than the frame profiler to avoid having it counted
if (gEnv->IsDedicated())
@@ -1295,11 +1279,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
GetIRemoteConsole()->Update();
#endif
if (gEnv->pLocalMemoryUsage != NULL)
{
gEnv->pLocalMemoryUsage->OnUpdate();
}
if (!gEnv->IsEditor() && gEnv->pRenderer)
{
// If the dimensions of the render target change,
@@ -1490,11 +1469,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
//update time subsystem
m_Time.UpdateOnFrameStart();
if (m_env.p3DEngine)
{
m_env.p3DEngine->OnFrameStart();
}
//////////////////////////////////////////////////////////////////////
// update rate limiter for dedicated server
if (m_pServerThrottle.get())
@@ -1651,7 +1625,7 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
}
//////////////////////////////////////////////////////////////////////
bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode)
bool CSystem::UpdatePostTickBus(int updateFlags, int /*nPauseMode*/)
{
CTimeValue updateStart = gEnv->pTimer->GetAsyncTime();
@@ -1663,44 +1637,6 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode)
UpdateMovieSystem(updateFlags, fMovieFrameTime, false);
}
//////////////////////////////////////////////////////////////////////
//update process (3D engine)
if (!(updateFlags & ESYSUPDATE_EDITOR) && !m_bNoUpdate && m_env.p3DEngine)
{
FRAME_PROFILER("SysUpdate:Update3DEngine", this, PROFILE_SYSTEM);
if (ITimeOfDay* pTOD = m_env.p3DEngine->GetTimeOfDay())
{
pTOD->Tick();
}
if (m_env.p3DEngine)
{
m_env.p3DEngine->Tick(); // clear per frame temp data
}
if (m_pProcess && (m_pProcess->GetFlags() & PROC_3DENGINE))
{
if ((nPauseMode != 1))
{
if (!IsEquivalent(m_ViewCamera.GetPosition(), Vec3(0, 0, 0), VEC_EPSILON))
{
if (m_env.p3DEngine)
{
// m_env.p3DEngine->SetCamera(m_ViewCamera);
m_pProcess->Update();
}
}
}
}
else
{
if (m_pProcess)
{
m_pProcess->Update();
}
}
}
//////////////////////////////////////////////////////////////////////
//update sound system part 2
if (!g_cvars.sys_deferAudioUpdateOptim && !m_bNoUpdate)
@@ -1748,41 +1684,8 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode)
gEnv->pCryPak->DisableRuntimeFileAccess(true);
}
// If it's in editing mode (in editor) the render is done in RenderViewport so we skip rendering here.
if (!gEnv->IsEditing() && gEnv->pRenderer && gEnv->p3DEngine)
{
if (GetIViewSystem())
{
GetIViewSystem()->Update(min(gEnv->pTimer->GetFrameTime(), 0.1f));
}
// Begin occlusion job after setting the correct camera.
gEnv->p3DEngine->PrepareOcclusion(GetViewCamera());
CrySystemNotificationBus::Broadcast(&CrySystemNotifications::OnPreRender);
// Also broadcast for anyone else that needs to draw global debug to do so now
AzFramework::DebugDisplayEventBus::Broadcast(&AzFramework::DebugDisplayEvents::DrawGlobalDebugInfo);
Render();
gEnv->p3DEngine->EndOcclusion();
CrySystemNotificationBus::Broadcast(&CrySystemNotifications::OnPostRender);
RenderEnd();
gEnv->p3DEngine->SyncProcessStreamingUpdate();
if (NeedDoWorkDuringOcclusionChecks())
{
DoWorkDuringOcclusionChecks();
}
// Sync the work that must be done in the main thread by the end of frame.
gEnv->pRenderer->GetGenerateShadowRendItemJobExecutor()->WaitForCompletion();
gEnv->pRenderer->GetGenerateRendItemJobExecutor()->WaitForCompletion();
}
// Also broadcast for anyone else that needs to draw global debug to do so now
AzFramework::DebugDisplayEventBus::Broadcast(&AzFramework::DebugDisplayEvents::DrawGlobalDebugInfo);
return !IsQuitting();
}
-16
View File
@@ -408,13 +408,6 @@ public:
virtual void DoWorkDuringOcclusionChecks();
virtual bool NeedDoWorkDuringOcclusionChecks() { return m_bNeedDoWorkDuringOcclusionChecks; }
//! Begin rendering frame.
void RenderBegin();
//! Render subsystems.
void Render();
//! End rendering frame and swap back buffer.
void RenderEnd(bool bRenderStats = true, bool bMainWindow = true);
//Called when the renderer finishes rendering the scene
void OnScene3DEnd() override;
@@ -429,11 +422,6 @@ public:
//! Update screen and call some important tick functions during loading.
void SynchronousLoadingTick(const char* pFunc, int line);
//! Renders the statistics; this is called from RenderEnd, but if the
//! Host application (Editor) doesn't employ the Render cycle in ISystem,
//! it may call this method to render the essential statistics
void RenderStatistics() override;
uint32 GetUsedMemory();
virtual void DumpMemoryUsageStatistics(bool bUseKB);
@@ -469,7 +457,6 @@ public:
AZ::IO::IArchive* GetIPak() { return m_env.pCryPak; };
IConsole* GetIConsole() { return m_env.pConsole; };
IRemoteConsole* GetIRemoteConsole();
I3DEngine* GetI3DEngine(){ return m_env.p3DEngine; }
IMovieSystem* GetIMovieSystem() { return m_env.pMovieSystem; };
IMemoryManager* GetIMemoryManager(){ return m_pMemoryManager; }
IThreadManager* GetIThreadManager() override {return m_env.pThreadManager; }
@@ -696,9 +683,6 @@ private:
void CreateRendererVars(const SSystemInitParams& startupParams);
void CreateSystemVars();
void CreateAudioVars();
void RenderStats();
void RenderOverscanBorders();
void RenderMemStats();
AZStd::unique_ptr<AZ::DynamicModuleHandle> LoadDLL(const char* dllName);
-13
View File
@@ -86,7 +86,6 @@
#endif //WIN32
#include <I3DEngine.h>
#include <IRenderer.h>
#include <AzCore/IO/FileIO.h>
#include <IMovieSystem.h>
@@ -107,7 +106,6 @@
#include "PhysRenderer.h"
#include "LocalizedStringManager.h"
#include "SystemEventDispatcher.h"
#include "Statistics/LocalMemoryUsage.h"
#include "ThreadConfigManager.h"
#include "Validator.h"
#include "ServerThrottle.h"
@@ -768,11 +766,6 @@ static void LoadDetectedSpec(ICVar* pVar)
GetISystem()->SetConfigSpec(static_cast<ESystemConfigSpec>(spec), platform, false);
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetMaterialManager()->RefreshMaterialRuntime();
}
no_recursive = false;
}
@@ -2788,12 +2781,6 @@ AZ_POP_DISABLE_WARNING
m_env.pRenderer->TryFlush();
}
#if !defined(RELEASE)
m_env.pLocalMemoryUsage = new CLocalMemoryUsage();
#else
m_env.pLocalMemoryUsage = nullptr;
#endif
if (g_cvars.sys_float_exceptions > 0)
{
if (g_cvars.sys_float_exceptions == 3 && gEnv->IsEditor()) // Turn off float exceptions in editor if sys_float_exceptions = 3
-315
View File
@@ -31,7 +31,6 @@
#include <IProcess.h>
#include "Log.h"
#include "XConsole.h"
#include <I3DEngine.h>
#include <CryLibrary.h>
#include "PhysRenderer.h"
#include <IMovieSystem.h>
@@ -222,92 +221,6 @@ void CSystem::CreateRendererVars(const SSystemInitParams& startupParams)
"Usage: r_OverscanBordersDrawDebugView [0=off/1=show]");
}
//////////////////////////////////////////////////////////////////////////
void CSystem::RenderBegin()
{
FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled);
if (m_bIgnoreUpdates)
{
return;
}
bool rndAvail = m_env.pRenderer != 0;
//////////////////////////////////////////////////////////////////////
//start the rendering pipeline
if (rndAvail)
{
m_env.pRenderer->BeginFrame();
}
gEnv->nMainFrameID = (rndAvail) ? m_env.pRenderer->GetFrameID(false) : 0;
}
//////////////////////////////////////////////////////////////////////////
void CSystem::RenderEnd([[maybe_unused]] bool bRenderStats, bool bMainWindow)
{
{
FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled);
if (m_bIgnoreUpdates)
{
return;
}
if (!m_env.pRenderer)
{
return;
}
if (bMainWindow) // we don't do this in UI Editor window for example
{
#if !defined (_RELEASE)
// Flush render data and swap buffers.
m_env.pRenderer->RenderDebug(bRenderStats);
#endif
#if defined(USE_PERFHUD)
if (m_pPerfHUD)
{
m_pPerfHUD->Draw();
}
if (m_pMiniGUI)
{
m_pMiniGUI->Draw();
}
#endif
if (!gEnv->pSystem->GetILevelSystem() || !gEnv->pSystem->GetILevelSystem()->IsLevelLoaded())
{
IConsole* console = GetIConsole();
//Same goes for the console. When no level is loaded, it's okay to render it outside of the renderer
//so that users can load maps or change settings.
if (console != nullptr)
{
console->Draw();
}
}
}
m_env.pRenderer->ForceGC(); // XXX Rename this
m_env.pRenderer->EndFrame();
if (IConsole* pConsole = GetIConsole())
{
// if we have pending cvar calculation, execute it here
// since we know cvars will be correct here after ->EndFrame().
if (!pConsole->IsHashCalculated())
{
pConsole->CalcCheatVarHash();
}
}
}
}
void CSystem::OnScene3DEnd()
{
//Render Console
@@ -391,231 +304,3 @@ void CSystem::DisplayErrorMessage(const char* acMessage,
#endif
m_ErrorMessages.push_back(message);
}
//! Renders the statistics; this is called from RenderEnd, but if the
//! Host application (Editor) doesn't employ the Render cycle in ISystem,
//! it may call this method to render the essential statistics
//////////////////////////////////////////////////////////////////////////
void CSystem::RenderStatistics()
{
RenderStats();
}
//////////////////////////////////////////////////////////////////////
void CSystem::Render()
{
if (m_bIgnoreUpdates)
{
return;
}
//check what is the current process
if (!m_pProcess)
{
return; //should never happen
}
//check if the game is in pause or
//in menu mode
//bool bPause=false;
//if (m_pProcess->GetFlags() & PROC_MENU)
// bPause=true;
FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled);
//////////////////////////////////////////////////////////////////////
//draw
m_env.p3DEngine->PreWorldStreamUpdate(m_ViewCamera);
if (m_pProcess)
{
if (m_pProcess->GetFlags() & PROC_3DENGINE)
{
if (!gEnv->IsEditing()) // Editor calls it's own rendering update
{
if (m_env.p3DEngine && !m_env.IsFMVPlaying())
{
if (!IsEquivalent(m_ViewCamera.GetPosition(), Vec3(0, 0, 0), VEC_EPSILON) || // never pass undefined camera to p3DEngine->RenderWorld()
gEnv->IsDedicated() || (gEnv->pRenderer && gEnv->pRenderer->IsPost3DRendererEnabled()))
{
GetIRenderer()->SetViewport(0, 0, GetIRenderer()->GetWidth(), GetIRenderer()->GetHeight());
m_env.p3DEngine->RenderWorld(SHDF_ALLOW_WATER | SHDF_ALLOWPOSTPROCESS | SHDF_ALLOWHDR | SHDF_ZPASS | SHDF_ALLOW_AO, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_ViewCamera), __FUNCTION__);
}
else
{
if (gEnv->pRenderer)
{
// force rendering of black screen to be sure we don't only render the clear color (which is the fog color by default)
gEnv->pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST);
gEnv->pRenderer->Draw2dImage(0, 0, 800, 600, -1, 0.0f, 0.0f, 1.0f, 1.0f, 0.f,
0.0f, 0.0f, 0.0f, 1.0f, 0.f);
}
}
}
#if !defined(_RELEASE)
if (m_pVisRegTest)
{
m_pVisRegTest->AfterRender();
}
#endif
if (m_env.pMovieSystem)
{
m_env.pMovieSystem->Render();
}
}
}
else
{
GetIRenderer()->SetViewport(0, 0, GetIRenderer()->GetWidth(), GetIRenderer()->GetHeight());
m_pProcess->RenderWorld(SHDF_ALLOW_WATER | SHDF_ALLOWPOSTPROCESS | SHDF_ALLOWHDR | SHDF_ZPASS | SHDF_ALLOW_AO, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_ViewCamera), __FUNCTION__);
}
}
m_env.p3DEngine->WorldStreamUpdate();
gEnv->pRenderer->SwitchToNativeResolutionBackbuffer();
}
//////////////////////////////////////////////////////////////////////////
void CSystem::RenderStats()
{
#if defined(ENABLE_PROFILING_CODE)
#ifndef _RELEASE
// if we rendered an error message on screen during the last frame, then sleep now
// to force hard stall for 3sec
if (m_bHasRenderedErrorMessage && !gEnv->IsEditor() && !IsLoading())
{
// DO NOT REMOVE OR COMMENT THIS OUT!
// If you hit this, then you most likely have invalid (synchronous) file accesses
// which must be fixed in order to not stall the entire game.
Sleep(3000);
m_bHasRenderedErrorMessage = false;
}
#endif
// render info messages on screen
float fTextPosX = 5.0f;
float fTextPosY = -10;
float fTextStepY = 13;
float fFrameTime = gEnv->pTimer->GetRealFrameTime();
TErrorMessages::iterator itnext;
for (TErrorMessages::iterator it = m_ErrorMessages.begin(); it != m_ErrorMessages.end(); it = itnext)
{
itnext = it;
++itnext;
SErrorMessage& message = *it;
SDrawTextInfo ti;
ti.flags = eDrawText_FixedSize | eDrawText_2D | eDrawText_Monospace;
memcpy(ti.color, message.m_Color, 4 * sizeof(float));
ti.xscale = ti.yscale = 1.4f;
m_env.pRenderer->DrawTextQueued(Vec3(fTextPosX, fTextPosY += fTextStepY, 1.0f), ti, message.m_Message.c_str());
if (!IsLoading())
{
message.m_fTimeToShow -= fFrameTime;
}
if (message.m_HardFailure)
{
m_bHasRenderedErrorMessage = true;
}
if (message.m_fTimeToShow < 0.0f)
{
m_ErrorMessages.erase(it);
}
}
#endif
if (!m_env.pConsole)
{
return;
}
#ifndef _RELEASE
if (m_rOverscanBordersDrawDebugView)
{
RenderOverscanBorders();
}
#endif
int iDisplayInfo = m_rDisplayInfo->GetIVal();
if (iDisplayInfo == 0)
{
return;
}
// Draw engine stats
if (m_env.p3DEngine)
{
// Draw 3dengine stats and get last text cursor position
float nTextPosX = 101 - 20, nTextPosY = -2, nTextStepY = 3;
m_env.p3DEngine->DisplayInfo(nTextPosX, nTextPosY, nTextStepY, iDisplayInfo != 1);
// Dump Open 3D Engine CPU and GPU memory statistics to screen
m_env.p3DEngine->DisplayMemoryStatistics();
#if defined(ENABLE_LW_PROFILERS)
if (m_rDisplayInfo->GetIVal() == 2)
{
m_env.pRenderer->TextToScreen(nTextPosX, nTextPosY += nTextStepY, "SysMem %.1f mb",
float(DumpMMStats(false)) / 1024.f);
}
#endif
#if 0
for (int i = 0; i < NUM_POOLS; ++i)
{
int used = (g_pPakHeap->m_iBigPoolUsed[i] ? (int)g_pPakHeap->m_iBigPoolSize[i] : 0);
int size = (int)g_pPakHeap->m_iBigPoolSize[i];
float fC1[4] = {1, 1, 0, 1};
m_env.pRenderer->Draw2dLabel(10, 100.0f + i * 16, 2.1f, fC1, false, "BigPool %d: %d bytes of %d bytes used", i, used, size);
}
#endif
}
}
void CSystem::RenderOverscanBorders()
{
#ifndef _RELEASE
if (m_env.pRenderer && m_rOverscanBordersDrawDebugView)
{
int iOverscanBordersDrawDebugView = m_rOverscanBordersDrawDebugView->GetIVal();
if (iOverscanBordersDrawDebugView)
{
const int texId = -1;
const float uv = 0.0f;
const float rot = 0.0f;
const int whiteTextureId = m_env.pRenderer->GetWhiteTextureId();
const float r = 1.0f;
const float g = 1.0f;
const float b = 1.0f;
const float a = 0.2f;
Vec2 overscanBorders = Vec2(0.0f, 0.0f);
m_env.pRenderer->EF_Query(EFQ_OverscanBorders, overscanBorders);
const float overscanBorderWidth = overscanBorders.x * VIRTUAL_SCREEN_WIDTH;
const float overscanBorderHeight = overscanBorders.y * VIRTUAL_SCREEN_HEIGHT;
const float xPos = overscanBorderWidth;
const float yPos = overscanBorderHeight;
const float width = VIRTUAL_SCREEN_WIDTH - (2.0f * overscanBorderWidth);
const float height = VIRTUAL_SCREEN_HEIGHT - (2.0f * overscanBorderHeight);
m_env.pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST);
m_env.pRenderer->Draw2dImage(xPos, yPos,
width, height,
whiteTextureId,
uv, uv, uv, uv,
rot,
r, g, b, a);
}
}
#endif
}
-18
View File
@@ -15,7 +15,6 @@
#include "System.h"
#include <time.h>
#include <I3DEngine.h>
#include <IRenderer.h>
#include <IMovieSystem.h>
#include <ILog.h>
@@ -302,23 +301,6 @@ void CSystem::CollectMemStats (ICrySizer* pSizer, MemStatsPurposeEnum nPurpose,
}
}
if (m_env.p3DEngine)
{
SIZER_COMPONENT_NAME(pSizer, "Cry3DEngine");
{
m_env.p3DEngine->GetMemoryUsage (pSizer);
{
SIZER_COMPONENT_NAME (pSizer, "$Allocations waste");
const SmallModuleInfo* info = FindModuleInfo(stats, "Cry3DEngine.dll");
if (info)
{
pSizer->AddObject(info, info->memInfo.allocated - info->memInfo.requested);
}
}
}
}
if (m_env.pRenderer)
{
SIZER_COMPONENT_NAME(pSizer, "CryRenderer");
+1 -1
View File
@@ -98,7 +98,7 @@ void CView::Update(float frameTime, bool isActive)
//see if the view have to use a custom near clipping plane
const float nearPlane = (m_viewParams.nearplane >= CAMERA_MIN_NEAR) ? (m_viewParams.nearplane) : fNearZ;
const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : gEnv->p3DEngine->GetMaxViewDistance();
const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : DEFAULT_FAR;
float fov = (m_viewParams.fov < 0.001f) ? DEFAULT_FOV : m_viewParams.fov;
// [VR] specific
@@ -533,11 +533,6 @@ void CViewSystem::BeginCutScene(IAnimSequence* pSeq, [[maybe_unused]] unsigned l
{
m_cutsceneCount++;
if (m_cutsceneCount == 1)
{
gEnv->p3DEngine->ResetPostEffects();
}
VS_CALL_LISTENERS(OnBeginCutScene(pSeq, bResetFX));
}
@@ -546,11 +541,6 @@ void CViewSystem::EndCutScene(IAnimSequence* pSeq, [[maybe_unused]] unsigned lon
{
m_cutsceneCount -= (m_cutsceneCount > 0);
if (m_cutsceneCount == 0)
{
gEnv->p3DEngine->ResetPostEffects();
}
ClearCutsceneViews();
VS_CALL_LISTENERS(OnEndCutScene(pSeq));
-1
View File
@@ -18,7 +18,6 @@
#include "VisRegTest.h"
#include "ISystem.h"
#include "I3DEngine.h"
#include "IRenderer.h"
#include "IConsole.h"
#include "ITimer.h"
@@ -57,7 +57,6 @@ set(FILES
UnixConsole.h
SystemInit.h
Serialization/MemoryReader.h
Statistics/LocalMemoryUsage.h
MemoryFragmentationProfiler.h
XML/ReadWriteXMLSink.h
Serialization/ArchiveHost.h
@@ -151,7 +150,6 @@ set(FILES
MiniGUI/MiniInfoBox.h
MiniGUI/MiniMenu.h
MiniGUI/MiniTable.h
Statistics/LocalMemoryUsage.cpp
ZLibCompressor.cpp
ZLibCompressor.h
SoftCode/SoftCodeMgr.cpp
@@ -74,7 +74,7 @@ namespace AZ
"Unable to retrieve the correct container information for AZStd::array instance.");
}
Flags flags = Flags::None;
ContinuationFlags flags = ContinuationFlags::None;
Uuid elementTypeId = Uuid::CreateNull();
auto typeEnumCallback = [&elementTypeId, &flags](const Uuid&, const SerializeContext::ClassElement* genericClassElement)
{
@@ -82,7 +82,7 @@ namespace AZ
elementTypeId = genericClassElement->m_typeId;
if (genericClassElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER)
{
flags = Flags::ResolvePointer;
flags = ContinuationFlags::ResolvePointer;
}
return false;
};
@@ -161,7 +161,7 @@ namespace AZ
"Not enough entries in JSON array to load an AZStd::array from.");
}
Flags flags = Flags::None;
ContinuationFlags flags = ContinuationFlags::None;
Uuid elementTypeId = Uuid::CreateNull();
auto typeEnumCallback = [&elementTypeId, &flags](const Uuid&, const SerializeContext::ClassElement* genericClassElement)
{
@@ -169,7 +169,7 @@ namespace AZ
elementTypeId = genericClassElement->m_typeId;
if (genericClassElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER)
{
flags = Flags::ResolvePointer;
flags = ContinuationFlags::ResolvePointer;
}
return false;
};
@@ -208,22 +208,28 @@ namespace AZ
// BaseJsonSerializer
//
JsonSerializationResult::ResultCode BaseJsonSerializer::ContinueLoading(void* object, const Uuid& typeId, const rapidjson::Value& value,
JsonDeserializerContext& context, Flags flags)
BaseJsonSerializer::OperationFlags BaseJsonSerializer::GetOperationsFlags() const
{
return flags & Flags::ResolvePointer ?
JsonDeserializer::LoadToPointer(object, typeId, value, context) :
JsonDeserializer::Load(object, typeId, value, context);
return OperationFlags::None;
}
JsonSerializationResult::ResultCode BaseJsonSerializer::ContinueStoring(rapidjson::Value& output, const void* object,
const void* defaultObject, const Uuid& typeId, JsonSerializerContext& context, Flags flags)
JsonSerializationResult::ResultCode BaseJsonSerializer::ContinueLoading(
void* object, const Uuid& typeId, const rapidjson::Value& value, JsonDeserializerContext& context, ContinuationFlags flags)
{
return (flags & ContinuationFlags::ResolvePointer) == ContinuationFlags::ResolvePointer
? JsonDeserializer::LoadToPointer(object, typeId, value, context)
: JsonDeserializer::Load(object, typeId, value, context);
}
JsonSerializationResult::ResultCode BaseJsonSerializer::ContinueStoring(
rapidjson::Value& output, const void* object, const void* defaultObject, const Uuid& typeId, JsonSerializerContext& context,
ContinuationFlags flags)
{
using namespace JsonSerializationResult;
if (flags & Flags::ReplaceDefault && !context.ShouldKeepDefaults())
if ((flags & ContinuationFlags::ReplaceDefault) == ContinuationFlags::ReplaceDefault && !context.ShouldKeepDefaults())
{
if (flags & Flags::ResolvePointer)
if ((flags & ContinuationFlags::ResolvePointer) == ContinuationFlags::ResolvePointer)
{
return JsonSerializer::StoreFromPointer(output, object, nullptr, typeId, context);
}
@@ -248,7 +254,7 @@ namespace AZ
}
}
return flags & Flags::ResolvePointer ?
return (flags & ContinuationFlags::ResolvePointer) == ContinuationFlags::ResolvePointer ?
JsonSerializer::StoreFromPointer(output, object, defaultObject, typeId, context) :
JsonSerializer::Store(output, object, defaultObject, typeId, context);
}
@@ -265,8 +271,9 @@ namespace AZ
return JsonSerializer::StoreTypeName(output, typeId, context);
}
JsonSerializationResult::ResultCode BaseJsonSerializer::ContinueLoadingFromJsonObjectField(void* object, const Uuid& typeId, const rapidjson::Value& value,
rapidjson::Value::StringRefType memberName, JsonDeserializerContext& context, Flags flags)
JsonSerializationResult::ResultCode BaseJsonSerializer::ContinueLoadingFromJsonObjectField(
void* object, const Uuid& typeId, const rapidjson::Value& value, rapidjson::Value::StringRefType memberName,
JsonDeserializerContext& context, ContinuationFlags flags)
{
using namespace JsonSerializationResult;
@@ -291,7 +298,7 @@ namespace AZ
JsonSerializationResult::ResultCode BaseJsonSerializer::ContinueStoringToJsonObjectField(rapidjson::Value& output,
rapidjson::Value::StringRefType newMemberName, const void* object, const void* defaultObject,
const Uuid& typeId, JsonSerializerContext& context, Flags flags)
const Uuid& typeId, JsonSerializerContext& context, ContinuationFlags flags)
{
using namespace JsonSerializationResult;
@@ -161,13 +161,19 @@ namespace AZ
public:
AZ_RTTI(BaseJsonSerializer, "{7291FFDC-D339-40B5-BB26-EA067A327B21}");
enum Flags
enum class ContinuationFlags
{
None = 0, //! No extra flags.
None = 0, //! No extra flags.
ResolvePointer = 1 << 0, //! The pointer passed in contains a pointer. The (de)serializer will attempt to resolve to an instance.
ReplaceDefault = 1 << 1 //! The default value provided for storing will be replaced with a newly created one.
};
enum class OperationFlags
{
None = 0, //! No flags that control how the custom json serializer is used.
ManualDefault = 1 << 0 //! Even if an (explicit) default is found the custom json serializer will still be called.
};
virtual ~BaseJsonSerializer() = default;
//! Transforms the data from the rapidjson Value to outputValue, if the conversion is possible and supported.
@@ -180,6 +186,9 @@ namespace AZ
virtual JsonSerializationResult::Result Store(rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue,
const Uuid& valueTypeId, JsonSerializerContext& context) = 0;
//! Returns the operation flags which tells the Json Serialization how this custom json serializer can be used.
virtual OperationFlags GetOperationsFlags() const;
protected:
//! Continues loading of a (sub)value. Use this function to load member variables for instance. This is more optimal than
//! directly calling the json serialization.
@@ -187,8 +196,9 @@ namespace AZ
//! @param typeId Type id of the object passed in.
//! @param value The value in the JSON document where the deserializer will start reading data from.
//! @param context The context used during deserialization. Use the value passed in from Load.
JsonSerializationResult::ResultCode ContinueLoading(void* object, const Uuid& typeId, const rapidjson::Value& value,
JsonDeserializerContext& context, Flags flags = Flags::None);
JsonSerializationResult::ResultCode ContinueLoading(
void* object, const Uuid& typeId, const rapidjson::Value& value, JsonDeserializerContext& context,
ContinuationFlags flags = ContinuationFlags::None);
//! Continues storing of a (sub)value. Use this function to store member variables for instance. This is more optimal than
//! directly calling the json serialization.
@@ -200,8 +210,9 @@ namespace AZ
//! the settings.
//! @param typeId The type id of the object and default object.
//! @param context The context used during serialization. Use the value passed in from Store.
JsonSerializationResult::ResultCode ContinueStoring(rapidjson::Value& output, const void* object, const void* defaultObject,
const Uuid& typeId, JsonSerializerContext& context, Flags flags = Flags::None);
JsonSerializationResult::ResultCode ContinueStoring(
rapidjson::Value& output, const void* object, const void* defaultObject, const Uuid& typeId, JsonSerializerContext& context,
ContinuationFlags flags = ContinuationFlags::None);
//! Retrieves the type id from a json object or json string.
//! @param typeId The retrieved type id.
@@ -222,12 +233,14 @@ namespace AZ
const Uuid& typeId, JsonSerializerContext& context);
//! Helper function similar to ContinueLoading, but loads the data as a member of 'value' rather than 'value' itself, if it exists.
JsonSerializationResult::ResultCode ContinueLoadingFromJsonObjectField(void* object, const Uuid& typeId, const rapidjson::Value& value,
rapidjson::Value::StringRefType memberName, JsonDeserializerContext& context, Flags flags = Flags::None);
JsonSerializationResult::ResultCode ContinueLoadingFromJsonObjectField(
void* object, const Uuid& typeId, const rapidjson::Value& value, rapidjson::Value::StringRefType memberName,
JsonDeserializerContext& context, ContinuationFlags flags = ContinuationFlags::None);
//! Helper function similar to ContinueStoring, but stores the data as a member of 'output' rather than overwriting 'output'.
JsonSerializationResult::ResultCode ContinueStoringToJsonObjectField(rapidjson::Value& output, rapidjson::Value::StringRefType newMemberName,
const void* object, const void* defaultObject, const Uuid& typeId, JsonSerializerContext& context, Flags flags = Flags::None);
JsonSerializationResult::ResultCode ContinueStoringToJsonObjectField(
rapidjson::Value& output, rapidjson::Value::StringRefType newMemberName, const void* object, const void* defaultObject,
const Uuid& typeId, JsonSerializerContext& context, ContinuationFlags flags = ContinuationFlags::None);
//! Checks if a value is an explicit default. This useful for containers where not storing anything as a default would mean
//! a slot wouldn't be used so something has to be added to represent the fully default target.
@@ -238,6 +251,7 @@ namespace AZ
rapidjson::Value GetExplicitDefault();
};
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::BaseJsonSerializer::Flags)
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::BaseJsonSerializer::ContinuationFlags)
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::BaseJsonSerializer::OperationFlags)
} // namespace AZ
@@ -75,9 +75,10 @@ namespace AZ
auto elementCallback = [this, &array, &retVal, &index, &context]
(void* elementPtr, const Uuid& elementId, const SerializeContext::ClassData*, const SerializeContext::ClassElement* classElement)
{
Flags flags = classElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER ?
Flags::ResolvePointer : Flags::None;
flags |= Flags::ReplaceDefault;
ContinuationFlags flags = classElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER
? ContinuationFlags::ResolvePointer
: ContinuationFlags::None;
flags |= ContinuationFlags::ReplaceDefault;
ScopedContextPath subPath(context, index);
index++;
@@ -161,8 +162,9 @@ namespace AZ
container->EnumTypes(typeEnumCallback);
AZ_Assert(classElement, "No class element found for the type in the basic container.");
Flags flags = classElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER ?
Flags::ResolvePointer : Flags::None;
ContinuationFlags flags = classElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER
? ContinuationFlags::ResolvePointer
: ContinuationFlags::None;
const size_t capacity = container->IsFixedCapacity() ? container->Capacity(outputValue) : std::numeric_limits<size_t>::max();
@@ -22,6 +22,19 @@
namespace AZ
{
JsonSerializationResult::ResultCode JsonDeserializer::DeserializerDefaultCheck(BaseJsonSerializer* serializer, void* object,
const Uuid& typeId, const rapidjson::Value& value, JsonDeserializerContext& context)
{
using namespace AZ::JsonSerializationResult;
bool isExplicitDefault = IsExplicitDefault(value);
bool manuallyDefaults = (serializer->GetOperationsFlags() & BaseJsonSerializer::OperationFlags::ManualDefault) ==
BaseJsonSerializer::OperationFlags::ManualDefault;
return !isExplicitDefault || (isExplicitDefault && manuallyDefaults)
? serializer->Load(object, typeId, value, context)
: context.Report(Tasks::ReadField, Outcomes::DefaultsUsed, "Value has an explicit default.");
}
JsonSerializationResult::ResultCode JsonDeserializer::Load(void* object, const Uuid& typeId, const rapidjson::Value& value,
JsonDeserializerContext& context)
{
@@ -33,17 +46,12 @@ namespace AZ
"Target object for Json Serialization is pointing to nothing during loading.");
}
if (IsExplicitDefault(value))
{
return context.Report(Tasks::ReadField, Outcomes::DefaultsUsed, "Value has an explicit default.");
}
BaseJsonSerializer* serializer = context.GetRegistrationContext()->GetSerializerForType(typeId);
if (serializer)
{
return serializer->Load(object, typeId, value, context);
return DeserializerDefaultCheck(serializer, object, typeId, value, context);
}
const SerializeContext::ClassData* classData = context.GetSerializeContext()->FindClassData(typeId);
if (!classData)
{
@@ -56,9 +64,14 @@ namespace AZ
serializer = context.GetRegistrationContext()->GetSerializerForType(classData->m_azRtti->GetGenericTypeId());
if (serializer)
{
return serializer->Load(object, typeId, value, context);
return DeserializerDefaultCheck(serializer, object, typeId, value, context);
}
}
if (IsExplicitDefault(value))
{
return context.Report(Tasks::ReadField, Outcomes::DefaultsUsed, "Value has an explicit default.");
}
if (classData->m_azRtti && (classData->m_azRtti->GetTypeTraits() & AZ::TypeTraits::is_enum) == AZ::TypeTraits::is_enum)
{
@@ -113,5 +113,13 @@ namespace AZ
//! Checks if a value is an explicit default. This means the value is an object with no members.
static bool IsExplicitDefault(const rapidjson::Value& value);
private:
static JsonSerializationResult::ResultCode DeserializerDefaultCheck(
BaseJsonSerializer* serializer,
void* object,
const Uuid& typeId,
const rapidjson::Value& value,
JsonDeserializerContext& context);
};
} // namespace AZ
@@ -215,10 +215,10 @@ namespace AZ
// Load key
void* keyAddress = pairContainer->GetElementByIndex(address, pairElement, 0);
AZ_Assert(keyAddress, "Element reserved for associative container, but unable to retrieve address of the key.");
Flags keyLoadFlags = Flags::None;
ContinuationFlags keyLoadFlags = ContinuationFlags::None;
if (keyElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER)
{
keyLoadFlags = Flags::ResolvePointer;
keyLoadFlags = ContinuationFlags::ResolvePointer;
*reinterpret_cast<void**>(keyAddress) = nullptr;
}
JSR::ResultCode keyResult = ContinueLoading(keyAddress, keyElement->m_typeId, key, context, keyLoadFlags);
@@ -231,10 +231,10 @@ namespace AZ
// Load value
void* valueAddress = pairContainer->GetElementByIndex(address, pairElement, 1);
AZ_Assert(valueAddress, "Element reserved for associative container, but unable to retrieve address of the value.");
Flags valueLoadFlags = Flags::None;
ContinuationFlags valueLoadFlags = ContinuationFlags::None;
if (valueElement->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER)
{
valueLoadFlags = Flags::ResolvePointer;
valueLoadFlags = ContinuationFlags::ResolvePointer;
*reinterpret_cast<void**>(valueAddress) = nullptr;
}
JSR::ResultCode valueResult = ContinueLoading(valueAddress, valueElement->m_typeId, value, context, valueLoadFlags);
@@ -82,7 +82,7 @@ namespace AZ
{
// If the target type is the same as the type already stored in the smart pointer than no new
// instance is created and the existing instance will be updated with the data in the json document.
result = ContinueLoading(instance, elementClassId, inputValue, context, Flags::ResolvePointer);
result = ContinueLoading(instance, elementClassId, inputValue, context, ContinuationFlags::ResolvePointer);
return false;
}
}
@@ -93,7 +93,7 @@ namespace AZ
// the wrong address. In these cases explicitly reset the smart pointer. This will erase the existing
// data but that's fine as it's not being used.
void* element = nullptr;
result = ContinueLoading(&element, elementClassId, inputValue, context, Flags::ResolvePointer);
result = ContinueLoading(&element, elementClassId, inputValue, context, ContinuationFlags::ResolvePointer);
if (result.GetProcessing() != JSR::Processing::Halted && result.GetProcessing() != JSR::Processing::Altered)
{
void* elementPtr = container->ReserveElement(instance, nullptr);
@@ -155,8 +155,14 @@ namespace AZ
container->EnumElements(const_cast<void*>(defaultValue), defaultInputCallback);
}
JSR::ResultCode result = ContinueStoring(outputValue, inputValue, defaultValue, inputPtrType, context, Flags::ResolvePointer);
JSR::ResultCode result =
ContinueStoring(outputValue, inputValue, defaultValue, inputPtrType, context, ContinuationFlags::ResolvePointer);
return context.Report(result, result.GetProcessing() != JSR::Processing::Halted ?
"Successfully processed smart pointer." : "A problem occurred while processing a smart pointer.");
}
BaseJsonSerializer::OperationFlags JsonSmartPointerSerializer::GetOperationsFlags() const
{
return OperationFlags::ManualDefault;
}
} // namespace AZ
@@ -28,5 +28,7 @@ namespace AZ
JsonDeserializerContext& context) override;
JsonSerializationResult::Result Store(rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue,
const Uuid& valueTypeId, JsonSerializerContext& context) override;
OperationFlags GetOperationsFlags() const override;
};
} // namespace AZ
@@ -99,8 +99,9 @@ namespace AZ
ScopedContextPath subPath(context, i);
Flags flags = classElements[i]->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER ?
Flags::ResolvePointer : Flags::None;
ContinuationFlags flags = classElements[i]->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER
? ContinuationFlags::ResolvePointer
: ContinuationFlags::None;
JSR::ResultCode result = ContinueStoring(elementValues[i], elementAddress, defaultElementAddress,
classElements[i]->m_typeId, context, flags);
@@ -179,8 +180,9 @@ namespace AZ
void* elementAddress = container->GetElementByIndex(outputValue, nullptr, i);
AZ_Assert(elementAddress, "Address of AZStd::pair or AZStd::tuple element %zu could not be retrieved.", i);
Flags flags = classElements[i]->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER ?
Flags::ResolvePointer : Flags::None;
ContinuationFlags flags = classElements[i]->m_flags & SerializeContext::ClassElement::Flags::FLG_POINTER
? ContinuationFlags::ResolvePointer
: ContinuationFlags::None;
while (arrayIndex < inputValue.Size())
{
@@ -104,6 +104,11 @@ namespace JsonSerializationTests
AZ::AllocatorInstance<AZ::PoolAllocator>::Destroy();
}
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Asset>();
}
AZStd::shared_ptr<AZ::BaseJsonSerializer> CreateSerializer() override
{
return AZStd::make_shared<AZ::Data::AssetJsonSerializer>();
@@ -119,7 +119,8 @@ namespace JsonSerializationTests
int value = 0;
int* ptrValue = &value;
ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);
ResultCode result =
ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
ASSERT_NE(nullptr, ptrValue);
@@ -134,7 +135,8 @@ namespace JsonSerializationTests
json.Set(42);
int* ptrValue = nullptr;
ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);
ResultCode result =
ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
ASSERT_NE(nullptr, ptrValue);
@@ -150,7 +152,8 @@ namespace JsonSerializationTests
rapidjson::Value json(rapidjson::kObjectType);
int* ptrValue = nullptr;
ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);
ResultCode result =
ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
ASSERT_NE(nullptr, ptrValue);
@@ -165,7 +168,8 @@ namespace JsonSerializationTests
rapidjson::Value json(rapidjson::kNullType);
int* ptrValue = reinterpret_cast<int*>(azmalloc(sizeof(int), alignof(int), AZ::SystemAllocator));
ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);
ResultCode result =
ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
ASSERT_EQ(nullptr, ptrValue);
@@ -194,8 +198,8 @@ namespace JsonSerializationTests
int value = 42;
int* ptrValue = &value;
ResultCode result = ContinueStoring(*m_jsonDocument, &ptrValue, nullptr, azrtti_typeid<int>(), *m_jsonSerializationContext,
Flags::ResolvePointer);
ResultCode result = ContinueStoring(
*m_jsonDocument, &ptrValue, nullptr, azrtti_typeid<int>(), *m_jsonSerializationContext, ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
Expect_DocStrEq("42");
@@ -210,8 +214,9 @@ namespace JsonSerializationTests
int value2 = 42;
int* defaultPtrValue = &value2;
ResultCode result =
ContinueStoring(*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid<int>(), *m_jsonSerializationContext, Flags::ResolvePointer);
ResultCode result = ContinueStoring(
*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid<int>(), *m_jsonSerializationContext,
ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
Expect_DocStrEq("{}");
@@ -224,7 +229,7 @@ namespace JsonSerializationTests
int* ptrValue = nullptr;
ResultCode result = ContinueStoring(
*m_jsonDocument, &ptrValue, nullptr, azrtti_typeid<int>(), *m_jsonSerializationContext, Flags::ResolvePointer);
*m_jsonDocument, &ptrValue, nullptr, azrtti_typeid<int>(), *m_jsonSerializationContext, ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
Expect_DocStrEq("null");
@@ -238,8 +243,9 @@ namespace JsonSerializationTests
int value2 = 42;
int* defaultPtrValue = &value2;
ResultCode result =
ContinueStoring(*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid<int>(), *m_jsonSerializationContext, Flags::ResolvePointer);
ResultCode result = ContinueStoring(
*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid<int>(), *m_jsonSerializationContext,
ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
Expect_DocStrEq("null");
@@ -252,8 +258,9 @@ namespace JsonSerializationTests
int* ptrValue = nullptr;
int* defaultPtrValue = nullptr;
ResultCode result =
ContinueStoring(*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid<int>(), *m_jsonSerializationContext, Flags::ResolvePointer);
ResultCode result = ContinueStoring(
*m_jsonDocument, &ptrValue, &defaultPtrValue, azrtti_typeid<int>(), *m_jsonSerializationContext,
ContinuationFlags::ResolvePointer);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
Expect_DocStrEq("null");
@@ -265,8 +272,8 @@ namespace JsonSerializationTests
int value = 42;
ResultCode result = ContinueStoring(*m_jsonDocument, &value, nullptr, azrtti_typeid<int>(), *m_jsonSerializationContext,
Flags::ReplaceDefault);
ResultCode result = ContinueStoring(
*m_jsonDocument, &value, nullptr, azrtti_typeid<int>(), *m_jsonSerializationContext, ContinuationFlags::ReplaceDefault);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
Expect_DocStrEq("42");
@@ -280,7 +287,7 @@ namespace JsonSerializationTests
int* ptrValue = &value;
ResultCode result = ContinueStoring(*m_jsonDocument, &ptrValue, nullptr, azrtti_typeid<int>(), *m_jsonSerializationContext,
Flags::ResolvePointer | Flags::ReplaceDefault);
ContinuationFlags::ResolvePointer | ContinuationFlags::ReplaceDefault);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
Expect_DocStrEq("42");
@@ -293,8 +300,8 @@ namespace JsonSerializationTests
int value = 42;
AZ::Uuid unknownType("{09AE3CEC-EBFC-41EC-A7F6-949721521716}");
ResultCode result = ContinueStoring(*m_jsonDocument, &value, nullptr, unknownType, *m_jsonSerializationContext,
Flags::ReplaceDefault);
ResultCode result =
ContinueStoring(*m_jsonDocument, &value, nullptr, unknownType, *m_jsonSerializationContext, ContinuationFlags::ReplaceDefault);
EXPECT_EQ(Processing::Halted, result.GetProcessing());
}
@@ -90,9 +90,14 @@ namespace JsonSerializationTests
virtual ~JsonSerializerConformityTestDescriptor() = default;
virtual AZStd::shared_ptr<AZ::BaseJsonSerializer> CreateSerializer() = 0;
//! Create an instance of the target type with all values set to default.
virtual AZStd::shared_ptr<T> CreateDefaultInstance() = 0;
//! Create an instance of the target type that constructed with default constructor.
//! This will be the same instance that Json Serialization creates for dynamic types. Typically it's the same
//! as from CreateDefaultInstance(), except of types, such as pointers, that need to do minimal (de)serialization
//! to initialize an object.
virtual AZStd::shared_ptr<T> CreateDefaultConstructedInstance() { return CreateDefaultInstance(); }
//! Create an instance of the target type with some values set and some kept on defaults.
//! If the target type doesn't support partial specialization this can be ignored and
//! tests for partial support will be skipped.
@@ -316,10 +321,10 @@ namespace JsonSerializationTests
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto original = this->m_description.CreateDefaultInstance();
ResultCode result = serializer->Load(instance.get(), azrtti_typeid(*original),
ResultCode result = serializer->Load(instance.get(), azrtti_typeid(*instance),
*this->m_jsonDocument, *this->m_jsonDeserializationContext);
if (this->m_features.m_mandatoryFields.empty())
@@ -339,6 +344,42 @@ namespace JsonSerializationTests
}
}
TYPED_TEST_P(JsonSerializerConformityTests, Load_DeserializeEmptyObjectThroughMainLoad_SucceedsAndObjectMatchesDefaults)
{
using namespace AZ::JsonSerializationResult;
if (this->m_features.SupportsJsonType(rapidjson::kObjectType))
{
this->m_jsonDocument->Parse("{}");
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto original = this->m_description.CreateDefaultInstance();
AZ::JsonDeserializerSettings settings;
settings.m_serializeContext = this->m_jsonDeserializationContext->GetSerializeContext();
settings.m_registrationContext = this->m_jsonDeserializationContext->GetRegistrationContext();
ResultCode result = AZ::JsonSerialization::Load(
instance.get(), azrtti_typeid(*instance), *this->m_jsonDocument, settings);
if (this->m_features.m_mandatoryFields.empty())
{
EXPECT_EQ(Outcomes::DefaultsUsed, result.GetOutcome());
EXPECT_EQ(Processing::Completed, result.GetProcessing());
}
else
{
EXPECT_EQ(Outcomes::Unsupported, result.GetOutcome());
bool validProcessing =
result.GetProcessing() == Processing::Altered ||
result.GetProcessing() == Processing::PartialAlter;
EXPECT_TRUE(validProcessing);
}
EXPECT_TRUE(this->m_description.AreEqual(*original, *instance));
}
}
TYPED_TEST_P(JsonSerializerConformityTests, Load_DeserializeEmptyArray_SucceedsAndObjectMatchesDefaults)
{
using namespace AZ::JsonSerializationResult;
@@ -349,7 +390,7 @@ namespace JsonSerializationTests
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto original = this->m_description.CreateDefaultInstance();
this->m_deserializationSettings->m_clearContainers = false;
@@ -384,7 +425,7 @@ namespace JsonSerializationTests
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto original = this->m_description.CreateDefaultInstance();
this->m_deserializationSettings->m_clearContainers = true;
@@ -488,7 +529,7 @@ namespace JsonSerializationTests
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto compare = this->m_description.CreateFullySetInstance();
ResultCode result = serializer->Load(instance.get(), azrtti_typeid(*instance),
@@ -499,6 +540,28 @@ namespace JsonSerializationTests
EXPECT_TRUE(this->m_description.AreEqual(*instance, *compare));
}
TYPED_TEST_P(JsonSerializerConformityTests, Load_DeserializeFullySetInstanceThroughMainLoad_SucceedsAndObjectMatchesFullySetInstance)
{
using namespace AZ::JsonSerializationResult;
AZStd::string_view json = this->m_description.GetJsonFor_Load_DeserializeFullySetInstance();
this->m_jsonDocument->Parse(json.data());
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto compare = this->m_description.CreateFullySetInstance();
AZ::JsonDeserializerSettings settings;
settings.m_serializeContext = this->m_jsonDeserializationContext->GetSerializeContext();
settings.m_registrationContext = this->m_jsonDeserializationContext->GetRegistrationContext();
ResultCode result = AZ::JsonSerialization::Load(instance.get(), azrtti_typeid(*instance), *this->m_jsonDocument, settings);
EXPECT_EQ(Outcomes::Success, result.GetOutcome());
EXPECT_EQ(Processing::Completed, result.GetProcessing());
EXPECT_TRUE(this->m_description.AreEqual(*instance, *compare));
}
TYPED_TEST_P(JsonSerializerConformityTests, Load_DeserializeWithMissingMandatoryField_LoadFailedAndUnsupportedReported)
{
using namespace AZ::JsonSerializationResult;
@@ -518,7 +581,7 @@ namespace JsonSerializationTests
ASSERT_NE(this->m_jsonDocument->MemberEnd(), memberToErase);
this->m_jsonDocument->RemoveMember(memberToErase);
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
ResultCode result = serializer->Load(instance.get(), azrtti_typeid(*instance),
*this->m_jsonDocument, *this->m_jsonDeserializationContext);
@@ -546,7 +609,7 @@ namespace JsonSerializationTests
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto compare = this->m_description.CreatePartialDefaultInstance();
ASSERT_NE(nullptr, compare);
@@ -567,7 +630,7 @@ namespace JsonSerializationTests
ASSERT_FALSE(this->m_jsonDocument->HasParseError());
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
AZ::ScopedContextReporter reporter(*this->m_jsonDeserializationContext,
[](AZStd::string_view message, ResultCode result, AZStd::string_view path) -> ResultCode
@@ -604,7 +667,7 @@ namespace JsonSerializationTests
}
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
auto compare = this->m_description.CreateFullySetInstance();
ResultCode result = serializer->Load(instance.get(), azrtti_typeid(*instance),
@@ -635,7 +698,7 @@ namespace JsonSerializationTests
}
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
auto instance = this->m_description.CreateDefaultConstructedInstance();
ResultCode result = serializer->Load(instance.get(), azrtti_typeid(*instance),
*this->m_jsonDocument, *this->m_jsonDeserializationContext);
@@ -693,6 +756,36 @@ namespace JsonSerializationTests
}
}
TYPED_TEST_P(JsonSerializerConformityTests, Store_SerializeDefaultInstanceThroughMainStore_EmptyJsonReturned)
{
using namespace AZ::JsonSerializationResult;
auto serializer = this->m_description.CreateSerializer();
auto instance = this->m_description.CreateDefaultInstance();
rapidjson::Value convertedValue = this->CreateExplicitDefault();
AZ::JsonSerializerSettings settings;
settings.m_serializeContext = this->m_jsonDeserializationContext->GetSerializeContext();
settings.m_registrationContext = this->m_jsonDeserializationContext->GetRegistrationContext();
ResultCode result = AZ::JsonSerialization::Store(
convertedValue, this->m_jsonDocument->GetAllocator(), instance.get(), instance.get(), azrtti_typeid(*instance), settings);
EXPECT_EQ(Processing::Completed, result.GetProcessing());
if (convertedValue.IsObject() && !this->m_features.m_mandatoryFields.empty())
{
ASSERT_EQ(convertedValue.MemberCount(), this->m_features.m_mandatoryFields.size());
for (const AZStd::string& mandatoryField : this->m_features.m_mandatoryFields)
{
EXPECT_NE(convertedValue.MemberEnd(), convertedValue.FindMember(mandatoryField.c_str()));
}
}
else
{
EXPECT_EQ(Outcomes::DefaultsUsed, result.GetOutcome());
this->Expect_ExplicitDefault(convertedValue);
}
}
TYPED_TEST_P(JsonSerializerConformityTests, Store_SerializeWithDefaultsKept_FullyWrittenJson)
{
using namespace AZ::JsonSerializationResult;
@@ -924,6 +1017,20 @@ namespace JsonSerializationTests
}
}
TYPED_TEST_P(JsonSerializerConformityTests, GetOperationsFlags_ManualDefaultSetIfNeeded_ManualDefaultOperationSetIfMandatoryFieldsAreDeclared)
{
if (this->m_features.SupportsJsonType(rapidjson::kObjectType))
{
if (!this->m_features.m_mandatoryFields.empty())
{
auto serializer = this->m_description.CreateSerializer();
bool manuallyHandlesDefaults = (serializer->GetOperationsFlags() & AZ::BaseJsonSerializer::OperationFlags::ManualDefault) ==
AZ::BaseJsonSerializer::OperationFlags::ManualDefault;
EXPECT_TRUE(manuallyHandlesDefaults);
}
}
}
REGISTER_TYPED_TEST_CASE_P(JsonSerializerConformityTests,
Registration_SerializerIsRegisteredWithContext_SerializerFound,
@@ -934,14 +1041,16 @@ namespace JsonSerializationTests
Load_InvalidTypeOfArrayType_ReturnsUnsupported,
Load_InvalidTypeOfStringType_ReturnsUnsupported,
Load_InvalidTypeOfNumberType_ReturnsUnsupported,
Load_DeserializeUnreflectedType_ReturnsUnsupported,
Load_DeserializeEmptyObject_SucceedsAndObjectMatchesDefaults,
Load_DeserializeEmptyObjectThroughMainLoad_SucceedsAndObjectMatchesDefaults,
Load_DeserializeEmptyArray_SucceedsAndObjectMatchesDefaults,
Load_DeserializeEmptyArrayWithClearEnabled_SucceedsAndObjectMatchesDefaults,
Load_DeserializeEmptyArrayWithClearedTarget_SucceedsAndObjectMatchesDefaults,
Load_InterruptClearingTarget_ContainerIsNotCleared,
Load_DeserializeFullySetInstance_SucceedsAndObjectMatchesFullySetInstance,
Load_DeserializeFullySetInstanceThroughMainLoad_SucceedsAndObjectMatchesFullySetInstance,
Load_DeserializePartialInstance_SucceedsAndObjectMatchesParialInstance,
Load_DeserializeWithMissingMandatoryField_LoadFailedAndUnsupportedReported,
Load_InsertAdditionalData_SucceedsAndObjectMatchesFullySetInstance,
@@ -950,6 +1059,7 @@ namespace JsonSerializationTests
Store_SerializeUnreflectedType_ReturnsUnsupported,
Store_SerializeDefaultInstance_EmptyJsonReturned,
Store_SerializeDefaultInstanceThroughMainStore_EmptyJsonReturned,
Store_SerializeWithDefaultsKept_FullyWrittenJson,
Store_SerializeFullySetInstance_StoredSuccessfullyAndJsonMatches,
Store_SerializeWithoutDefault_StoredSuccessfullyAndJsonMatches,
@@ -957,10 +1067,12 @@ namespace JsonSerializationTests
Store_SerializePartialInstance_StoredSuccessfullyAndJsonMatches,
Store_SerializeEmptyArray_StoredSuccessfullyAndJsonMatches,
Store_HaltedThroughCallback_StoreFailsAndHaltReported,
StoreLoad_RoundTripWithPartialDefault_IdenticalInstances,
StoreLoad_RoundTripWithFullSet_IdenticalInstances,
StoreLoad_RoundTripWithDefaultsKept_IdenticalInstances);
StoreLoad_RoundTripWithDefaultsKept_IdenticalInstances,
GetOperationsFlags_ManualDefaultSetIfNeeded_ManualDefaultOperationSetIfMandatoryFieldsAreDeclared);
} // namespace JsonSerializationTests
namespace AZ
@@ -32,6 +32,11 @@ namespace JsonSerializationTests
return AZStd::make_shared<AZ::JsonSmartPointerSerializer>();
}
AZStd::shared_ptr<SmartPointer> CreateDefaultConstructedInstance() override
{
return AZStd::make_shared<SmartPointer>();
}
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<SmartPointer>();
@@ -228,13 +233,19 @@ namespace JsonSerializationTests
public:
using SmartPointer = typename SmartPointerSimpleDerivedClassTestDescription<T>::SmartPointer;
AZStd::shared_ptr<SmartPointer> CreateDefaultInstance() override
// This test is specific for derived classes being used as a default value.
AZStd::shared_ptr<SmartPointer> CreateDefaultConstructedInstance() override
{
auto result = AZStd::make_shared<SmartPointer>();
*result = SmartPointer(aznew SimpleInheritence());
return result;
}
AZStd::shared_ptr<SmartPointer> CreateDefaultInstance() override
{
return CreateDefaultConstructedInstance();
}
AZStd::string_view GetJsonForPartialDefaultInstance() override
{
return R"(
@@ -386,13 +397,19 @@ namespace JsonSerializationTests
public:
using SmartPointer = typename SmartPointerComplexDerivedClassTestDescription<T>::SmartPointer;
AZStd::shared_ptr<SmartPointer> CreateDefaultInstance() override
// This test is specific for derived classes being used as a default value.
AZStd::shared_ptr<SmartPointer> CreateDefaultConstructedInstance() override
{
auto result = AZStd::make_shared<SmartPointer>();
*result = SmartPointer(aznew MultipleInheritence());
return result;
}
AZStd::shared_ptr<SmartPointer> CreateDefaultInstance() override
{
return CreateDefaultConstructedInstance();
}
AZStd::string_view GetJsonForPartialDefaultInstance() override
{
return R"(
@@ -34,6 +34,8 @@ class ITexture;
namespace AzFramework
{
inline constexpr AZ::s32 g_defaultSceneEntityDebugDisplayId = AZ_CRC_CE("MainViewportEntityDebugDisplayId"); // default id to draw to all viewports in the default scene
/// DebugDisplayRequests provides a debug draw api to be used by components and viewport features.
class DebugDisplayRequests
: public AZ::EBusTraits
@@ -19,44 +19,29 @@
namespace AzPhysics
{
struct SimulatedBody;
}
namespace Physics
{
//! Requests for generic physical world bodies
class WorldBodyRequests
//! Requests for physics simulated body components.
class SimulatedBodyComponentRequests
: public AZ::ComponentBus
{
public:
using MutexType = AZStd::recursive_mutex;
//! Enable physics for this body
//! Enable physics for this body.
virtual void EnablePhysics() = 0;
//! Disable physics for this body
//! Disable physics for this body.
virtual void DisablePhysics() = 0;
//! Retrieve whether physics is enabled for this body
//! Retrieve whether physics is enabled for this body.
virtual bool IsPhysicsEnabled() const = 0;
//! Retrieves the AABB(aligned-axis bounding box) for this body
//! Retrieves the AABB(aligned-axis bounding box) for this body.
virtual AZ::Aabb GetAabb() const = 0;
//! Retrieves current WorldBody* for this body. Note: Do not hold a reference to AzPhysics::SimulatedBody* as could be deleted
virtual AzPhysics::SimulatedBody* GetWorldBody() = 0;
//! Perform a single-object raycast against this body
//! Get the Simulated Body Handle for this body.
virtual AzPhysics::SimulatedBodyHandle GetSimulatedBodyHandle() const = 0;
//! Retrieves current WorldBody* for this body.
//! @note Do not hold a reference to AzPhysics::SimulatedBody* as it could be deleted or moved.
virtual AzPhysics::SimulatedBody* GetSimulatedBody() = 0;
//! Perform a single-object raycast against this body.
virtual AzPhysics::SceneQueryHit RayCast(const AzPhysics::RayCastRequest& request) = 0;
};
using WorldBodyRequestBus = AZ::EBus<WorldBodyRequests>;
//! Notifications for generic physical world bodies
class WorldBodyNotifications
: public AZ::ComponentBus
{
public:
//! Notification for physics enabled
virtual void OnPhysicsEnabled() = 0;
//! Notification for physics disabled
virtual void OnPhysicsDisabled() = 0;
};
using WorldBodyNotificationBus = AZ::EBus<WorldBodyNotifications>;
using SimulatedBodyComponentRequestsBus = AZ::EBus<SimulatedBodyComponentRequests>;
}
@@ -48,6 +48,9 @@ namespace Physics
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext
->RegisterGenericType<AZStd::shared_ptr<SphereShapeConfiguration>>();
serializeContext->Class<SphereShapeConfiguration, ShapeConfiguration>()
->Version(1)
->Field("Radius", &SphereShapeConfiguration::m_radius)
@@ -76,6 +79,9 @@ namespace Physics
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext
->RegisterGenericType<AZStd::shared_ptr<BoxShapeConfiguration>>();
serializeContext->Class<BoxShapeConfiguration, ShapeConfiguration>()
->Version(1)
->Field("Configuration", &BoxShapeConfiguration::m_dimensions)
@@ -104,6 +110,9 @@ namespace Physics
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext
->RegisterGenericType<AZStd::shared_ptr<CapsuleShapeConfiguration>>();
serializeContext->Class<CapsuleShapeConfiguration, ShapeConfiguration>()
->Version(1)
->Field("Height", &CapsuleShapeConfiguration::m_height)
@@ -153,6 +162,9 @@ namespace Physics
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext
->RegisterGenericType<AZStd::shared_ptr<PhysicsAssetShapeConfiguration>>();
serializeContext->Class<PhysicsAssetShapeConfiguration, ShapeConfiguration>()
->Version(1)
->Field("PhysicsAsset", &PhysicsAssetShapeConfiguration::m_asset)
@@ -185,6 +197,9 @@ namespace Physics
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext
->RegisterGenericType<AZStd::shared_ptr<NativeShapeConfiguration>>();
serializeContext->Class<NativeShapeConfiguration, ShapeConfiguration>()
->Version(1)
->Field("Scale", &NativeShapeConfiguration::m_nativeShapeScale)
@@ -208,6 +223,9 @@ namespace Physics
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext
->RegisterGenericType<AZStd::shared_ptr<CookedMeshShapeConfiguration>>();
serializeContext->Class<CookedMeshShapeConfiguration, ShapeConfiguration>()
->Version(1)
->Field("CookedData", &CookedMeshShapeConfiguration::m_cookedData)
@@ -21,7 +21,7 @@
#include <AzFramework/Physics/ShapeConfiguration.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzFramework/Physics/CollisionBus.h>
#include <AzFramework/Physics/WorldBodyBus.h>
#include <AzFramework/Physics/Components/SimulatedBodyComponentBus.h>
#include <AzFramework/Physics/WindBus.h>
#include <AzFramework/Physics/PhysicsSystem.h>
#include <AzFramework/Physics/Collision/CollisionEvents.h>
@@ -39,19 +39,19 @@ namespace Physics
{
namespace ReflectionUtils
{
void ReflectWorldBodyBus(AZ::ReflectContext* context)
void ReflectSimulatedBodyComponentRequestsBus(AZ::ReflectContext* context)
{
if (auto* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<Physics::WorldBodyRequestBus>("WorldBodyRequestBus")
behaviorContext->EBus<AzPhysics::SimulatedBodyComponentRequestsBus>("SimulatedBodyComponentRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "physics")
->Attribute(AZ::Script::Attributes::Category, "PhysX")
->Event("EnablePhysics", &WorldBodyRequests::EnablePhysics)
->Event("DisablePhysics", &WorldBodyRequests::DisablePhysics)
->Event("IsPhysicsEnabled", &WorldBodyRequests::IsPhysicsEnabled)
->Event("GetAabb", &WorldBodyRequests::GetAabb)
->Event("RayCast", &WorldBodyRequests::RayCast)
->Event("EnablePhysics", &AzPhysics::SimulatedBodyComponentRequests::EnablePhysics)
->Event("DisablePhysics", &AzPhysics::SimulatedBodyComponentRequests::DisablePhysics)
->Event("IsPhysicsEnabled", &AzPhysics::SimulatedBodyComponentRequests::IsPhysicsEnabled)
->Event("GetAabb", &AzPhysics::SimulatedBodyComponentRequests::GetAabb)
->Event("RayCast", &AzPhysics::SimulatedBodyComponentRequests::RayCast)
;
}
}
@@ -131,7 +131,7 @@ namespace Physics
AnimationConfiguration::Reflect(context);
CharacterConfiguration::Reflect(context);
AzPhysics::SimulatedBody::Reflect(context);
ReflectWorldBodyBus(context);
ReflectSimulatedBodyComponentRequestsBus(context);
CollisionFilteringRequests::Reflect(context);
AzPhysics::SceneQuery::ReflectSceneQueryObjects(context);
ReflectWindBus(context);
@@ -148,6 +148,12 @@ namespace AzFramework
//! Blocks until all operations made on the provided ticket before the barrier call have completed.
virtual void Barrier(EntitySpawnTicket& ticket, BarrierCallback completionCallback) = 0;
//! Register a handler for OnSpawned events.
virtual void AddOnSpawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) = 0;
//! Register a handler for OnDespawned events.
virtual void AddOnDespawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) = 0;
protected:
[[nodiscard]] virtual void* CreateTicket(AZ::Data::Asset<Spawnable>&& spawnable) = 0;
virtual void DestroyTicket(void* ticket) = 0;
@@ -114,6 +114,16 @@ namespace AzFramework
}
}
void SpawnableEntitiesManager::AddOnSpawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler)
{
handler.Connect(m_onSpawnedEvent);
}
void SpawnableEntitiesManager::AddOnDespawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler)
{
handler.Connect(m_onDespawnedEvent);
}
auto SpawnableEntitiesManager::ProcessQueue() -> CommandQueueStatus
{
AZStd::queue<Requests> pendingRequestQueue;
@@ -223,6 +233,8 @@ namespace AzFramework
ticket.m_spawnedEntities.begin() + spawnedEntitiesCount, ticket.m_spawnedEntities.end()));
}
m_onSpawnedEvent.Signal(ticket.m_spawnable);
ticket.m_currentTicketId++;
return true;
}
@@ -257,6 +269,8 @@ namespace AzFramework
ticket.m_spawnedEntities.begin() + spawnedEntitiesCount, ticket.m_spawnedEntities.end()));
}
m_onSpawnedEvent.Signal(ticket.m_spawnable);
ticket.m_currentTicketId++;
return true;
}
@@ -289,6 +303,8 @@ namespace AzFramework
request.m_completionCallback(*request.m_ticket);
}
m_onDespawnedEvent.Signal(ticket.m_spawnable);
ticket.m_currentTicketId++;
return true;
}
@@ -315,6 +331,8 @@ namespace AzFramework
&GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendants, entity->GetId());
}
}
m_onDespawnedEvent.Signal(ticket.m_spawnable);
// Rebuild the list of entities.
ticket.m_spawnedEntities.clear();
@@ -350,6 +368,9 @@ namespace AzFramework
}
ticket.m_currentTicketId++;
m_onSpawnedEvent.Signal(ticket.m_spawnable);
return true;
}
else
@@ -60,6 +60,9 @@ namespace AzFramework
void Barrier(EntitySpawnTicket& spawnInfo, BarrierCallback completionCallback) override;
void AddOnSpawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) override;
void AddOnDespawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) override;
//
// The following function is thread safe but intended to be run from the main thread.
//
@@ -156,5 +159,8 @@ namespace AzFramework
AZStd::deque<Requests> m_delayedQueue; //!< Requests that were processed before, but couldn't be completed.
AZStd::queue<Requests> m_pendingRequestQueue;
AZStd::mutex m_pendingRequestQueueMutex;
AZ::Event<AZ::Data::Asset<Spawnable>> m_onSpawnedEvent;
AZ::Event<AZ::Data::Asset<Spawnable>> m_onDespawnedEvent;
};
} // namespace AzFramework
@@ -213,6 +213,12 @@ set(FILES
StreamingInstall/StreamingInstall.cpp
StreamingInstall/StreamingInstallRequests.h
StreamingInstall/StreamingInstallNotifications.h
Physics/Collision/CollisionEvents.h
Physics/Collision/CollisionEvents.cpp
Physics/Collision/CollisionLayers.h
Physics/Collision/CollisionLayers.cpp
Physics/Collision/CollisionGroups.h
Physics/Collision/CollisionGroups.cpp
Physics/Common/PhysicsSceneQueries.h
Physics/Common/PhysicsSceneQueries.cpp
Physics/Common/PhysicsEvents.h
@@ -223,12 +229,7 @@ set(FILES
Physics/Common/PhysicsSimulatedBodyEvents.h
Physics/Common/PhysicsSimulatedBodyEvents.cpp
Physics/Common/PhysicsTypes.h
Physics/Collision/CollisionEvents.h
Physics/Collision/CollisionEvents.cpp
Physics/Collision/CollisionLayers.h
Physics/Collision/CollisionLayers.cpp
Physics/Collision/CollisionGroups.h
Physics/Collision/CollisionGroups.cpp
Physics/Components/SimulatedBodyComponentBus.h
Physics/Configuration/CollisionConfiguration.h
Physics/Configuration/CollisionConfiguration.cpp
Physics/Configuration/RigidBodyConfiguration.h
@@ -265,7 +266,6 @@ set(FILES
Physics/ShapeConfiguration.h
Physics/ShapeConfiguration.cpp
Physics/SystemBus.h
Physics/WorldBodyBus.h
Physics/ColliderComponentBus.h
Physics/RagdollPhysicsBus.h
Physics/CharacterPhysicsDataBus.h
@@ -117,8 +117,6 @@ namespace AzToolsFramework
{
EditorEntityModel::EditorEntityModel()
{
AzFramework::ApplicationRequests::Bus::BroadcastResult(m_isPrefabEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
EntityCompositionNotificationBus::Handler::BusConnect();
EditorOnlyEntityComponentNotificationBus::Handler::BusConnect();
EditorEntityRuntimeActivationChangeNotificationBus::Handler::BusConnect();
@@ -565,7 +563,7 @@ namespace AzToolsFramework
{
//retrieve or add an entity entry to the table
//the entry must exist, even if not connected, so children and other data can be assigned
[[maybe_unused]] auto [it, inserted] = m_entityInfoTable.try_emplace(entityId, m_isPrefabEnabled);
[[maybe_unused]] auto [it, inserted] = m_entityInfoTable.try_emplace(entityId);
auto& entityInfo = it->second;
//the entity id defaults to invalid and must be set to match the requested id
@@ -882,11 +880,6 @@ namespace AzToolsFramework
}
}
EditorEntityModel::EditorEntityModelEntry::EditorEntityModelEntry(bool isPrefabEnabled)
: m_isPrefabEnabled(isPrefabEnabled)
{
}
EditorEntityModel::EditorEntityModelEntry::~EditorEntityModelEntry()
{
Disconnect();
@@ -1213,29 +1206,15 @@ namespace AzToolsFramework
auto childItr = m_childIndexCache.find(childId);
if (childItr != m_childIndexCache.end())
{
if (m_isPrefabEnabled)
{
// Take the last entry and move it into the removed spot instead of deleting the entry and having to move all
// following entries one step down.
AZ::EntityId backEntity = m_children.back();
m_children[childItr->second] = backEntity;
// Update cached index for the moved id to the new index.
m_childIndexCache[backEntity] = childItr->second;
// Now remove the deleted id from the children and cache.
m_childIndexCache.erase(childId);
m_children.erase(m_children.end() - 1);
}
else
{
m_children.erase(m_children.begin() + childItr->second);
// rebuild index cache for faster lookup
m_childIndexCache.clear();
for (auto childIdToCache : m_children)
{
m_childIndexCache[childIdToCache] = static_cast<AZ::u64>(m_childIndexCache.size());
}
}
// Take the last entry and move it into the removed spot instead of deleting the entry and having to move all
// following entries one step down.
AZ::EntityId backEntity = m_children.back();
m_children[childItr->second] = backEntity;
// Update cached index for the moved id to the new index.
m_childIndexCache[backEntity] = childItr->second;
// Now remove the deleted id from the children and cache.
m_childIndexCache.erase(childId);
m_children.erase(m_children.end() - 1);
}
}
@@ -171,7 +171,6 @@ namespace AzToolsFramework
, public PropertyEditorEntityChangeNotificationBus::Handler
{
public:
explicit EditorEntityModelEntry(bool isPrefabEnabled);
~EditorEntityModelEntry();
// Separately connect to EditorEntityInfoRequestBus and refresh Entity
@@ -336,7 +335,6 @@ namespace AzToolsFramework
bool m_visible = true;
bool m_locked = false;
bool m_connected = false;
bool m_isPrefabEnabled = false;
AZStd::string m_name;
AZStd::string m_sliceAssetName;
AZStd::unordered_map<AZ::EntityId, AZ::u64> m_childIndexCache;
@@ -375,6 +373,5 @@ namespace AzToolsFramework
AZ::EntityId m_postInstantiateBeforeEntity;
AZ::EntityId m_postInstantiateSliceParent;
bool m_gotInstantiateSliceDetails = false;
bool m_isPrefabEnabled = false;
};
}
@@ -244,6 +244,8 @@ namespace AzToolsFramework
/// from ViewportCursorScreenPosition. This method will always return the correct position to generate a mouse
/// position delta.
virtual AZStd::optional<AzFramework::ScreenPoint> PreviousViewportCursorScreenPosition() = 0;
/// Is mouse over viewport.
virtual bool IsMouseOver() const = 0;
protected:
~ViewportMouseCursorRequests() = default;
@@ -19,8 +19,6 @@ namespace AzToolsFramework
{
namespace ViewportInteraction
{
const AZ::s32 g_mainViewportEntityDebugDisplayId = AZ_CRC("MainViewportEntityDebugDisplayId", 0x58ae7fe8);
void ViewportInteractionReflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
@@ -256,9 +256,5 @@ namespace AzToolsFramework
/// Reflect all viewport related types.
void ViewportInteractionReflect(AZ::ReflectContext* context);
/// The Id the main DebugDisplayRequestBus will be connected on.
extern const AZ::s32 g_mainViewportEntityDebugDisplayId;
} // namespace ViewportInteraction
} // namespace AzToolsFramework
@@ -78,7 +78,7 @@ namespace Benchmark
}
BENCHMARK_REGISTER_F(BM_PrefabUpdateInstances, UpdateInstances_SingeEntityInstances)
->RangeMultiplier(10)
->Range(100, 1000)
->Range(100, 10000)
->Unit(benchmark::kMillisecond)
->Complexity();
-108
View File
@@ -650,114 +650,6 @@ void Q2DViewport::OnDestroy()
//////////////////////////////////////////////////////////////////////////
void Q2DViewport::Render()
{
if (GetIEditor()->IsInGameMode())
{
return;
}
if (!m_renderer)
{
return;
}
if (!isVisible())
{
return;
}
if (!GetIEditor()->GetDocument()->IsDocumentReady())
{
return;
}
if (m_renderer->IsStereoEnabled())
{
return;
}
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
QRect rc = rect();
if (rc.isEmpty())
{
return;
}
CalculateViewTM();
// Render
WIN_HWND priorContext = m_renderer->GetCurrentContextHWND();
m_renderer->SetCurrentContext(renderOverlayHWND());
m_renderer->BeginFrame();
m_renderer->ChangeViewport(0, 0, rc.right(), rc.bottom(), true);
CScopedWireFrameMode scopedWireFrame(m_renderer, R_SOLID_MODE);
auto colorf = Rgb2ColorF(m_colorBackground);
m_renderer->ClearTargetsLater(FRT_CLEAR, colorf);
//////////////////////////////////////////////////////////////////////////
// 2D Mode.
//////////////////////////////////////////////////////////////////////////
if (rc.right() != 0 && rc.bottom() != 0)
{
TransformationMatrices backupSceneMatrices;
m_renderer->Set2DMode(rc.right(), rc.bottom(), backupSceneMatrices);
//////////////////////////////////////////////////////////////////////////
// Draw viewport elements here.
//////////////////////////////////////////////////////////////////////////
// Calc world bounding box for objects rendering.
m_displayBounds = GetWorldBounds(QPoint(0, 0), QPoint(rc.width(), rc.height()));
// Draw all objects.
DisplayContext& dc = m_displayContext;
dc.settings = GetIEditor()->GetDisplaySettings();
dc.view = this;
dc.renderer = m_renderer;
dc.engine = GetIEditor()->Get3DEngine();
dc.flags = DISPLAY_2D;
dc.box = m_displayBounds;
dc.camera = &GetIEditor()->GetSystem()->GetViewCamera();
if (!dc.settings->IsDisplayLabels() || !dc.settings->IsDisplayHelpers())
{
dc.flags |= DISPLAY_HIDENAMES;
}
if (dc.settings->IsDisplayLinks() && dc.settings->IsDisplayHelpers())
{
dc.flags |= DISPLAY_LINKS;
}
if (m_bDegradateQuality)
{
dc.flags |= DISPLAY_DEGRADATED;
}
SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(GetIEditor()->GetSystem()->GetViewCamera());
m_renderer->BeginSpawningGeneratingRendItemJobs(passInfo.ThreadID());
m_renderer->BeginSpawningShadowGeneratingRendItemJobs(passInfo.ThreadID());
m_renderer->EF_StartEf(passInfo);
dc.SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOff | e_DepthTestOn);
Draw(dc);
m_renderer->EF_EndEf3D(SHDF_STREAM_SYNC, -1, -1, passInfo);
m_renderer->EF_RenderTextMessages();
// Return back from 2D mode.
m_renderer->Unset2DMode(backupSceneMatrices);
m_renderer->RenderDebug(false);
ProcessRenderLisneters(m_displayContext);
m_renderer->EndFrame();
}
GetIEditor()->GetRenderer()->SetCurrentContext(priorContext);
}
//////////////////////////////////////////////////////////////////////////
@@ -50,8 +50,6 @@
#include "Include/IObjectManager.h"
#include "CryEditDoc.h"
#include "QtViewPaneManager.h"
#include "AzAssetBrowser/Preview/LegacyPreviewerFactory.h"
namespace AzAssetBrowserRequestHandlerPrivate
{
@@ -230,18 +228,15 @@ namespace AzAssetBrowserRequestHandlerPrivate
}
AzAssetBrowserRequestHandler::AzAssetBrowserRequestHandler()
: m_previewerFactory(aznew LegacyPreviewerFactory)
{
using namespace AzToolsFramework::AssetBrowser;
AssetBrowserInteractionNotificationBus::Handler::BusConnect();
AzQtComponents::DragAndDropEventsBus::Handler::BusConnect(AzQtComponents::DragAndDropContexts::EditorViewport);
AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusConnect();
}
AzAssetBrowserRequestHandler::~AzAssetBrowserRequestHandler()
{
AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusDisconnect();
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
AzQtComponents::DragAndDropEventsBus::Handler::BusDisconnect();
}
@@ -527,15 +522,6 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA
}
}
const AzToolsFramework::AssetBrowser::PreviewerFactory* AzAssetBrowserRequestHandler::GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
{
if (m_previewerFactory->IsEntrySupported(entry))
{
return m_previewerFactory.get();
}
return nullptr;
}
void AzAssetBrowserRequestHandler::AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers)
{
using namespace AzToolsFramework;
@@ -37,12 +37,9 @@ namespace AzToolsFramework
}
}
class LegacyPreviewerFactory;
class AzAssetBrowserRequestHandler
: protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
, protected AzQtComponents::DragAndDropEventsBus::Handler
, protected AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler
{
public:
AzAssetBrowserRequestHandler();
@@ -66,16 +63,8 @@ protected:
void DragLeave(QDragLeaveEvent* event) override;
void Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
//////////////////////////////////////////////////////////////////////////
// PreviewerRequestBus::Handler
//////////////////////////////////////////////////////////////////////////
const AzToolsFramework::AssetBrowser::PreviewerFactory* GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
bool CanAcceptDragAndDropEvent(
QDropEvent* event, AzQtComponents::DragAndDropContextBase& context,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry*>*> outSources = AZStd::nullopt,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry*>*> outProducts = AZStd::nullopt) const;
private:
AZStd::unique_ptr<const LegacyPreviewerFactory> m_previewerFactory;
};
@@ -1,409 +0,0 @@
/*
* 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.
*
*/
#include "EditorDefs.h"
#include "LegacyPreviewer.h"
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
#include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h>
// Editor
#include "Util/Image.h"
#include "Util/ImageUtil.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <AzAssetBrowser/Preview/ui_LegacyPreviewer.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
static const int s_CharWidth = 6;
const QString LegacyPreviewer::Name{ QStringLiteral("LegacyPreviewer") };
LegacyPreviewer::LegacyPreviewer(QWidget* parent)
: Previewer(parent)
, m_ui(new Ui::LegacyPreviewerClass())
, m_textureType(TextureType::RGB)
{
m_ui->setupUi(this);
m_ui->m_comboBoxRGB->addItems(QStringList() << "RGB" << "RGBA" << "Alpha");
m_ui->m_previewCtrl->SetAspectRatio(4.0f / 3.0f);
connect(m_ui->m_comboBoxRGB, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), this,
[=](int index)
{
m_textureType = static_cast<TextureType>(index);
UpdateTextureType();
});
Clear();
}
LegacyPreviewer::~LegacyPreviewer()
{
}
void LegacyPreviewer::Clear() const
{
m_ui->m_previewCtrl->ReleaseObject();
m_ui->m_modelPreviewWidget->hide();
m_ui->m_texturePreviewWidget->hide();
m_ui->m_fileInfoCtrl->hide();
}
void LegacyPreviewer::Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry)
{
using namespace AzToolsFramework::AssetBrowser;
if (!entry)
{
Clear();
return;
}
switch (entry->GetEntryType())
{
case AssetBrowserEntry::AssetEntryType::Source:
{
const SourceAssetBrowserEntry* sourceEntry = azrtti_cast<const SourceAssetBrowserEntry*>(entry);
DisplaySource(sourceEntry);
break;
}
case AssetBrowserEntry::AssetEntryType::Product:
DisplayProduct(static_cast<const ProductAssetBrowserEntry*>(entry));
break;
default:
Clear();
}
}
const QString& LegacyPreviewer::GetName() const
{
return Name;
}
void LegacyPreviewer::resizeEvent(QResizeEvent* /*event*/)
{
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
}
bool LegacyPreviewer::DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product)
{
m_ui->m_fileInfoCtrl->show();
m_fileinfo = QString::fromUtf8(product->GetName().c_str());
m_fileinfo += GetFileSize(product->GetRelativePath().c_str());
EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh");
AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
QString filename(product->GetRelativePath().c_str());
// Find item.
if (product->GetAssetType() == meshAssetTypeResult.GetAssetType())
{
m_ui->m_modelPreviewWidget->show();
m_ui->m_texturePreviewWidget->hide();
m_ui->m_previewCtrl->LoadFile(filename);
int nVertexCount = m_ui->m_previewCtrl->GetVertexCount();
int nFaceCount = m_ui->m_previewCtrl->GetFaceCount();
int nMaxLod = m_ui->m_previewCtrl->GetMaxLod();
int nMtls = m_ui->m_previewCtrl->GetMtlCount();
if (nFaceCount > 0)
{
m_fileinfo += tr("\r\n%1 Faces\r\n%2 Verts\r\n%3 MaxLod\r\n%4 Materials").arg(nFaceCount).arg(nVertexCount).arg(nMaxLod).arg(nMtls);
}
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
updateGeometry();
return true;
}
EBusFindAssetTypeByName textureAssetTypeResult("Texture");
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
if (product->GetAssetType() == textureAssetTypeResult.GetAssetType())
{
// Get full product file path
const char* assetCachePath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@assets@");
AZStd::string productFullPath;
AzFramework::StringFunc::Path::Join(assetCachePath, product->GetRelativePath().c_str(), productFullPath);
if (AZ::IO::FileIOBase::GetInstance()->Exists(productFullPath.c_str()))
{
// Try to display it in modern dds image loader, if no one exists, use the legacy image loader
bool foundPixmap = DisplayTextureProductModern(productFullPath.c_str());
return foundPixmap ? foundPixmap : DisplayTextureLegacy(productFullPath.c_str());
}
else
{
// If we cannot find the product file, means it's not treated as an asset, display its source
return DisplayTextureLegacy(product->GetFullPath().c_str());
}
}
Clear();
return false;
}
void LegacyPreviewer::DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source)
{
using namespace AzToolsFramework::AssetBrowser;
EBusFindAssetTypeByName textureAssetType("Texture");
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetType, &AZ::AssetTypeInfo::GetAssetType);
if (source->GetPrimaryAssetType() == textureAssetType.GetAssetType())
{
m_ui->m_fileInfoCtrl->show();
m_fileinfo = QString::fromUtf8(source->GetName().c_str());
m_fileinfo += GetFileSize(source->GetFullPath().c_str());
const char* fullSourcePath = source->GetFullPath().c_str();
// If it's a source dds file, try to display it using modern way
if (AzFramework::StringFunc::Path::IsExtension(fullSourcePath, "dds", false))
{
if (DisplayTextureProductModern(fullSourcePath))
{
return;
}
}
DisplayTextureLegacy(source->GetFullPath().c_str());
}
else
{
AZStd::vector<const ProductAssetBrowserEntry*> products;
source->GetChildrenRecursively<ProductAssetBrowserEntry>(products);
if (products.empty())
{
Clear();
}
else
{
for (auto* product : products)
{
if (DisplayProduct(product))
{
break;
}
}
}
}
}
QString LegacyPreviewer::GetFileSize(const char* path)
{
QString fileSizeStr;
AZ::u64 fileSizeResult = 0;
if (AZ::IO::FileIOBase::GetInstance()->Size(path, fileSizeResult))
{
static double kb = 1024.0f;
static double mb = kb * 1024.0;
static double gb = mb * 1024.0;
static QString byteStr = "B";
static QString kbStr = "KB";
static QString mbStr = "MB";
static QString gbStr = "GB";
#if AZ_TRAIT_OS_PLATFORM_APPLE
kb = 1000.0;
mb = kb * 1000.0;
gb = mb * 1000.0;
kbStr = "kB";
mbStr = "mB";
gbStr = "gB";
#endif // AZ_TRAIT_OS_PLATFORM_APPLE
if (fileSizeResult < kb)
{
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(fileSizeResult), byteStr);
}
else if (fileSizeResult < mb)
{
double size = fileSizeResult / kb;
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), kbStr);
}
else if (fileSizeResult < gb)
{
double size = fileSizeResult / mb;
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), mbStr);
}
else
{
double size = fileSizeResult / gb;
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), gbStr);
}
}
return fileSizeStr;
}
bool LegacyPreviewer::DisplayTextureLegacy(const char* fullImagePath)
{
m_ui->m_modelPreviewWidget->hide();
m_ui->m_texturePreviewWidget->show();
bool foundPixmap = false;
if (!AZ::IO::FileIOBase::GetInstance()->IsDirectory(fullImagePath))
{
QString strLoadFilename = QString(fullImagePath);
if (CImageUtil::LoadImage(strLoadFilename, m_previewImageSource))
{
m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3")
.arg(m_previewImageSource.GetWidth())
.arg(m_previewImageSource.GetHeight())
.arg(m_previewImageSource.GetFormatDescription());
m_fileinfoAlphaTexture = m_fileinfo;
UpdateTextureType();
foundPixmap = true;
}
}
if (!foundPixmap)
{
m_ui->m_previewImageCtrl->setPixmap(QPixmap());
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
}
updateGeometry();
return foundPixmap;
}
bool LegacyPreviewer::DisplayTextureProductModern(const char* fullProductImagePath)
{
m_ui->m_modelPreviewWidget->hide();
m_ui->m_texturePreviewWidget->show();
bool foundPixmap = false;
QImage previewImage;
AZStd::string productInfo;
AZStd::string productAlphaInfo;
AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequestsBus::BroadcastResult(foundPixmap, &AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequests::GetProductTexturePreview, fullProductImagePath, previewImage, productInfo, productAlphaInfo);
if (foundPixmap)
{
QPixmap pix = QPixmap::fromImage(previewImage);
m_ui->m_previewImageCtrl->setPixmap(pix);
m_ui->m_previewImageCtrl->updateGeometry();
CImageUtil::QImageToImage(previewImage, m_previewImageSource);
m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3")
.arg(m_previewImageSource.GetWidth())
.arg(m_previewImageSource.GetHeight())
.arg(m_previewImageSource.GetFormatDescription());
m_fileinfoAlphaTexture = m_fileinfo;
m_fileinfo += QString(productInfo.c_str());
if (productAlphaInfo.empty())
{
// If there is no separate info for alpha, use the image info
m_fileinfoAlphaTexture += QString(productInfo.c_str());
}
else
{
m_fileinfoAlphaTexture += QString(productAlphaInfo.c_str());
}
UpdateTextureType();
}
else
{
m_ui->m_previewImageCtrl->setPixmap(QPixmap());
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
}
updateGeometry();
return foundPixmap;
}
void LegacyPreviewer::UpdateTextureType()
{
m_previewImageUpdated.Copy(m_previewImageSource);
switch (m_textureType)
{
case TextureType::RGB:
{
m_previewImageUpdated.SwapRedAndBlue();
m_previewImageUpdated.FillAlpha();
break;
}
case TextureType::RGBA:
{
m_previewImageUpdated.SwapRedAndBlue();
break;
}
case TextureType::Alpha:
{
for (int h = 0; h < m_previewImageUpdated.GetHeight(); h++)
{
for (int w = 0; w < m_previewImageUpdated.GetWidth(); w++)
{
int a = m_previewImageUpdated.ValueAt(w, h) >> 24;
m_previewImageUpdated.ValueAt(w, h) = RGB(a, a, a) | 0xFF000000;
}
}
break;
}
}
// note that Qt will not deep copy the data, so WE MUST KEEP THE IMAGE DATA AROUND!
QPixmap qtPixmap = QPixmap::fromImage(
QImage(reinterpret_cast<uchar*>(m_previewImageUpdated.GetData()), m_previewImageUpdated.GetWidth(), m_previewImageUpdated.GetHeight(), QImage::Format_ARGB32));
m_ui->m_previewImageCtrl->setPixmap(qtPixmap);
m_ui->m_fileInfoCtrl->setText(WordWrap(m_textureType == TextureType::Alpha? m_fileinfoAlphaTexture: m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
m_ui->m_previewImageCtrl->updateGeometry();
}
bool LegacyPreviewer::FileInfoCompare(const FileInfo& f1, const FileInfo& f2)
{
if ((f1.attrib & _A_SUBDIR) && !(f2.attrib & _A_SUBDIR))
{
return true;
}
if (!(f1.attrib & _A_SUBDIR) && (f2.attrib & _A_SUBDIR))
{
return false;
}
return QString::compare(f1.filename, f2.filename, Qt::CaseInsensitive) < 0;
}
QString LegacyPreviewer::WordWrap(const QString& string, int maxLength)
{
QString result;
int length = 0;
for (auto c : string)
{
if (c == '\n')
{
length = 0;
}
else if (length > maxLength)
{
result.append('\n');
length = 0;
}
else
{
length++;
}
result.append(c);
}
return result;
}
#include <AzAssetBrowser/Preview/moc_LegacyPreviewer.cpp>
@@ -1,100 +0,0 @@
/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <Editor/Util/Image.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/AssetBrowser/Previewer/Previewer.h>
#include <QWidget>
#include <QScopedPointer>
#endif
namespace Ui
{
class LegacyPreviewerClass;
}
namespace AzToolsFramework
{
namespace AssetBrowser
{
class ProductAssetBrowserEntry;
class SourceAssetBrowserEntry;
class AssetBrowserEntry;
}
}
class QResizeEvent;
class LegacyPreviewer
: public AzToolsFramework::AssetBrowser::Previewer
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(LegacyPreviewer, AZ::SystemAllocator, 0);
explicit LegacyPreviewer(QWidget* parent = nullptr);
~LegacyPreviewer();
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::AssetBrowser::Previewer
//////////////////////////////////////////////////////////////////////////
void Clear() const override;
void Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) override;
const QString& GetName() const override;
static const QString Name;
protected:
void resizeEvent(QResizeEvent * event) override;
private:
struct FileInfo
{
QString filename;
unsigned attrib;
time_t time_create; /* -1 for FAT file systems */
time_t time_access; /* -1 for FAT file systems */
time_t time_write;
_fsize_t size;
};
enum class TextureType
{
RGB,
RGBA,
Alpha
};
QScopedPointer<Ui::LegacyPreviewerClass> m_ui;
CImageEx m_previewImageSource;
CImageEx m_previewImageUpdated;
TextureType m_textureType;
QString m_fileinfo;
QString m_fileinfoAlphaTexture;
bool DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product);
void DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source);
QString GetFileSize(const char* path);
bool DisplayTextureLegacy(const char* fullImagePath);
bool DisplayTextureProductModern(const char* fullProductImagePath);
void UpdateTextureType();
static bool FileInfoCompare(const FileInfo& f1, const FileInfo& f2);
//! QLabel word wrap does not break long words such as filenames, so manual word wrap needed
static QString WordWrap(const QString& string, int maxLength);
};
@@ -1,176 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LegacyPreviewerClass</class>
<widget class="QWidget" name="LegacyPreviewerClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>148</width>
<height>282</height>
</rect>
</property>
<property name="windowTitle">
<string>Preview</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="m_texturePreviewWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="m_horizontalLayout">
<item>
<spacer name="m_horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="m_comboBoxRGB">
<property name="currentText">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="AzToolsFramework::AspectRatioAwarePixmapWidget" name="m_previewImageCtrl" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_modelPreviewWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="CPreviewModelCtrl" name="m_previewCtrl" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="m_fileInfoCtrl">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="m_verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CPreviewModelCtrl</class>
<extends>QWidget</extends>
<header>Controls/PreviewModelCtrl.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>AzToolsFramework::AspectRatioAwarePixmapWidget</class>
<extends>QWidget</extends>
<header>AzToolsFramework/UI/UICore/AspectRatioAwarePixmapWidget.hxx</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
@@ -1,71 +0,0 @@
/*
* 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.
*
*/
#include "EditorDefs.h"
#include "LegacyPreviewerFactory.h"
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h> // for AssetBrowserEntry::AssetEntryType
#include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h> // for EBusFindAssetTypeByName
// Editor
#include "LegacyPreviewer.h"
AzToolsFramework::AssetBrowser::Previewer* LegacyPreviewerFactory::CreatePreviewer(QWidget* parent) const
{
return new LegacyPreviewer(parent);
}
bool LegacyPreviewerFactory::IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
{
using namespace AzToolsFramework::AssetBrowser;
EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh");
AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
EBusFindAssetTypeByName textureAssetTypeResult("Texture");
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
switch (entry->GetEntryType())
{
case AssetBrowserEntry::AssetEntryType::Source:
{
const auto* source = azrtti_cast < const SourceAssetBrowserEntry * > (entry);
if (source->GetPrimaryAssetType() == textureAssetTypeResult.GetAssetType())
{
return true;
}
AZStd::vector < const ProductAssetBrowserEntry * > products;
source->GetChildrenRecursively < ProductAssetBrowserEntry > (products);
for (auto* product : products)
{
if (product->GetAssetType() == textureAssetTypeResult.GetAssetType() ||
product->GetAssetType() == meshAssetTypeResult.GetAssetType())
{
return true;
}
}
break;
}
case AssetBrowserEntry::AssetEntryType::Product:
const auto* product = azrtti_cast < const ProductAssetBrowserEntry * > (entry);
return product->GetAssetType() == textureAssetTypeResult.GetAssetType() ||
product->GetAssetType() == meshAssetTypeResult.GetAssetType();
}
return false;
}
const QString& LegacyPreviewerFactory::GetName() const
{
return LegacyPreviewer::Name;
}
@@ -1,34 +0,0 @@
/*
* 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.
*
*/
#pragma once
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/AssetBrowser/Previewer/PreviewerFactory.h>
class QString;
class LegacyPreviewerFactory final
: public AzToolsFramework::AssetBrowser::PreviewerFactory
{
public:
AZ_CLASS_ALLOCATOR(LegacyPreviewerFactory, AZ::SystemAllocator, 0);
LegacyPreviewerFactory() = default;
~LegacyPreviewerFactory() = default;
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::AssetBrowser::PreviewerFactory
//////////////////////////////////////////////////////////////////////////
AzToolsFramework::AssetBrowser::Previewer* CreatePreviewer(QWidget* parent = nullptr) const override;
bool IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
const QString& GetName() const override;
};
@@ -826,9 +826,6 @@ void CBaseLibraryManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
SetSelectedItem(0);
ClearAll();
break;
case eNotify_OnMissionChange:
SetSelectedItem(0);
break;
case eNotify_OnCloseScene:
SetSelectedItem(0);
ClearAll();
File diff suppressed because it is too large Load Diff
@@ -1,198 +0,0 @@
/*
* 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.
#ifndef CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QString>
#include <QPoint>
#include <QWidget>
#include <IStatObj.h>
#endif
struct IRenderNode;
class CImageEx;
class CPreviewModelCtrl
: public QWidget
, public IEditorNotifyListener
{
Q_OBJECT
public:
explicit CPreviewModelCtrl(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
QSize minimumSizeHint() const override;
public:
void LoadFile(const QString& modelFile, bool changeCamera = true);
Vec3 GetSize() const { return m_size; };
QString GetLoadedFile() const { return m_loadedFile; }
void SetEntity(IRenderNode* entity);
void SetObject(IStatObj* pObject);
IStatObj* GetObject() { return m_pObj; }
void SetCameraLookAt(float fRadiusScale, const Vec3& dir = Vec3(0, 1, 0));
void SetCameraRadius(float fRadius);
CCamera& GetCamera();
void SetGrid(bool bEnable) { m_bGrid = bEnable; }
void SetAxis(bool bEnable, bool forParticleEditor = false) { m_bAxis = bEnable; m_bAxisParticleEditor = forParticleEditor; }
void SetRotation(bool bEnable);
void SetClearColor(const ColorF& color);
void SetBackgroundTexture(const QString& textureFilename);
void UseBackLight(bool bEnable);
bool UseBackLight() const { return m_bUseBacklight; }
void SetShowNormals(bool bShow) { m_bShowNormals = bShow; }
void SetShowPhysics(bool bShow) { m_bShowPhysics = bShow; }
void SetShowRenderInfo(bool bShow) { m_bShowRenderInfo = bShow; }
void EnableUpdate(bool bEnable);
bool IsUpdateEnabled() const { return m_bUpdate; }
void Update(bool bForceUpdate = false);
void ProcessKeys();
// this turns on and off aspect-ratio-maintaining. Use it when the widget is free to resize itself.
void SetAspectRatio(float newAspectRatio);
int heightForWidth(int w) const override;
bool hasHeightForWidth() const override;
void GetImageOffscreen(CImageEx& image, const QSize& customSize = QSize(0, 0));
void GetCameraTM(Matrix34& cameraTM);
void SetCameraTM(const Matrix34& cameraTM);
// Place camera so that whole object fits on screen.
void FitToScreen();
// Get information about the preview model.
int GetFaceCount();
int GetVertexCount();
int GetMaxLod();
int GetMtlCount();
void SetShowObject(bool bShowObject) {m_bShowObject = bShowObject; }
bool GetShowObject() {return m_bShowObject; }
void SetAmbient(ColorF amb) { m_ambientColor = amb; }
void SetAmbientMultiplier(f32 multiplier) { m_ambientMultiplier = multiplier; }
typedef void (* CameraChangeCallback)(void* m_userData, CPreviewModelCtrl* m_currentCamera);
void SetCameraChangeCallback(CameraChangeCallback callback, void* userData) { m_cameraChangeCallback = callback, m_pCameraChangeUserData = userData; }
void EnableMaterialPrecaching(bool bPrecacheMaterial) { m_bPrecacheMaterial = bPrecacheMaterial; }
void EnableWireframeRendering(bool bDrawWireframe) { m_bDrawWireFrame = bDrawWireframe; }
public:
~CPreviewModelCtrl();
bool CreateContext();
void ReleaseObject();
void DeleteRenderContex();
protected:
void OnCreate();
void OnDestroy();
void OnLButtonDown(QPoint point);
void OnLButtonUp(QPoint point);
void OnMButtonDown(QPoint point);
void OnMButtonUp(QPoint point);
void OnRButtonUp(QPoint point);
void OnRButtonDown(QPoint point);
QPaintEngine* paintEngine() const override;
void showEvent(QShowEvent* event) override;
void paintEvent(QPaintEvent* event) override;
void timerEvent(QTimerEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
protected:
virtual bool Render();
virtual void SetCamera(CCamera& cam);
virtual void RenderObject(_smart_ptr<IMaterial> pMaterial, SRenderingPassInfo& passInfo);
HWND m_hWnd;
CCamera m_camera;
float m_fov;
struct SPreviousContext;
std::vector<SPreviousContext> m_previousContexts;
void SetOrbitAngles(const Ang3& ang);
void DrawGrid();
void DrawBackground();
_smart_ptr<IMaterial> GetCurrentMaterial();
_smart_ptr<IStatObj> m_pObj;
IRenderer* m_pRenderer;
bool m_bContextCreated;
Vec3 m_size;
Vec3 m_pos;
int m_nTimer;
bool m_useAspectRatio = false;
float m_aspectRatio = 1.0f;
QString m_loadedFile;
std::vector<CDLight> m_lights;
AABB m_aabb;
Vec3 m_cameraTarget;
float m_cameraRadius;
Vec3 m_cameraAngles;
bool m_bInRotateMode;
bool m_bInMoveMode;
bool m_bInPanMode;
QPoint m_mousePosition;
QPoint m_previousMousePosition;
IRenderNode* m_pEntity;
bool m_bHaveAnythingToRender;
bool m_bGrid;
bool m_bAxis;
bool m_bAxisParticleEditor;
bool m_bUpdate;
bool m_bRotate;
float m_rotateAngle;
ColorF m_clearColor;
ColorF m_ambientColor;
f32 m_ambientMultiplier;
bool m_bUseBacklight;
bool m_bShowObject;
bool m_bPrecacheMaterial;
bool m_bDrawWireFrame;
bool m_bShowNormals;
bool m_bShowPhysics;
bool m_bShowRenderInfo;
int m_backgroundTextureId;
float m_tileX;
float m_tileY;
float m_tileSizeX;
float m_tileSizeY;
CameraChangeCallback m_cameraChangeCallback;
void* m_pCameraChangeUserData;
protected:
void StorePreviousContext();
void SetCurrentContext();
void RestorePreviousContext();
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
@@ -1,26 +0,0 @@
/*
* 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.
// Description : implementation file
#include "EditorDefs.h"
#include "TimeOfDaySlider.h"
QString TimeOfDaySlider::hoverValueText(int sliderValue) const
{
return QString::fromLatin1("%1:%2").arg(static_cast<int>(sliderValue / 60)).arg(sliderValue % 60, 2, 10, QLatin1Char('0'));
}
#include <Controls/moc_TimeOfDaySlider.cpp>
@@ -1,34 +0,0 @@
/*
* 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.
#ifndef CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
#define CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzQtComponents/Components/Widgets/Slider.h>
#endif
class TimeOfDaySlider
: public AzQtComponents::SliderInt
{
Q_OBJECT
public:
using AzQtComponents::SliderInt::SliderInt;
protected:
QString hoverValueText(int sliderValue) const override;
};
#endif // CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
+1 -181
View File
@@ -78,7 +78,6 @@ AZ_POP_DISABLE_WARNING
#include <AzQtComponents/Utilities/QtPluginPaths.h>
// CryCommon
#include <CryCommon/I3DEngine.h>
#include <CryCommon/ITimer.h>
#include <CryCommon/IPhysics.h>
#include <CryCommon/ILevelSystem.h>
@@ -99,7 +98,6 @@ AZ_POP_DISABLE_WARNING
#include "GridSettingsDialog.h"
#include "LayoutConfigDialog.h"
#include "ViewManager.h"
#include "ModelViewport.h"
#include "FileTypeUtils.h"
#include "PluginManager.h"
@@ -109,14 +107,12 @@ AZ_POP_DISABLE_WARNING
#include "GameEngine.h"
#include "StartupTraceHandler.h"
#include "ThumbnailGenerator.h"
#include "ToolsConfigPage.h"
#include "Objects/SelectionGroup.h"
#include "Include/IObjectManager.h"
#include "WaitProgress.h"
#include "ToolBox.h"
#include "Geometry/EdMesh.h"
#include "LevelInfo.h"
#include "EditorPreferencesDialog.h"
#include "GraphicsSettingsDialog.h"
@@ -392,7 +388,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_FILE_RESAVESLICES, OnFileResaveSlices)
ON_COMMAND(ID_FILE_EDITEDITORINI, OnFileEditEditorini)
ON_COMMAND(ID_PREFERENCES, OnPreferences)
ON_COMMAND(ID_RELOAD_GEOMETRY, OnReloadGeometry)
ON_COMMAND(ID_REDO, OnRedo)
ON_COMMAND(ID_TOOLBAR_WIDGET_REDO, OnRedo)
ON_COMMAND(ID_RELOAD_TEXTURES, OnReloadTextures)
@@ -401,7 +396,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_FILE_NEW_SLICE, OnCreateSlice)
ON_COMMAND(ID_FILE_OPEN_SLICE, OnOpenSlice)
#endif
ON_COMMAND(ID_RESOURCES_GENERATECGFTHUMBNAILS, OnGenerateCgfThumbnails)
ON_COMMAND(ID_SWITCH_PHYSICS, OnSwitchPhysics)
ON_COMMAND(ID_GAME_SYNCPLAYER, OnSyncPlayer)
ON_COMMAND(ID_RESOURCES_REDUCEWORKINGSET, OnResourcesReduceworkingset)
@@ -457,7 +451,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_FILE_SAVELEVELRESOURCES, OnFileSavelevelresources)
ON_COMMAND(ID_CLEAR_REGISTRY, OnClearRegistryData)
ON_COMMAND(ID_VALIDATELEVEL, OnValidatelevel)
ON_COMMAND(ID_TOOLS_VALIDATEOBJECTPOSITIONS, OnValidateObjectPositions)
ON_COMMAND(ID_TOOLS_PREFERENCES, OnToolsPreferences)
ON_COMMAND(ID_GRAPHICS_SETTINGS, OnGraphicsSettings)
ON_COMMAND(ID_SWITCHCAMERA_DEFAULTCAMERA, OnSwitchToDefaultCamera)
@@ -471,8 +464,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_DISPLAY_SHOWHELPERS, OnShowHelpers)
ON_COMMAND(ID_OPEN_TRACKVIEW, OnOpenTrackView)
ON_COMMAND(ID_OPEN_UICANVASEDITOR, OnOpenUICanvasEditor)
ON_COMMAND(ID_TERRAIN_TIMEOFDAY, OnTimeOfDay)
ON_COMMAND(ID_TERRAIN_TIMEOFDAYBUTTON, OnTimeOfDay)
ON_COMMAND_RANGE(ID_GAME_PC_ENABLELOWSPEC, ID_GAME_PC_ENABLEVERYHIGHSPEC, OnChangeGameSpec)
@@ -1912,11 +1903,6 @@ void CCryEditApp::LoadFile(QString fileName)
{
return;
}
CViewport* vp = GetIEditor()->GetViewManager()->GetView(0);
if (CModelViewport* mvp = viewport_cast<CModelViewport*>(vp))
{
mvp->LoadObject(fileName, 1);
}
LoadTagLocations();
@@ -2952,43 +2938,6 @@ void CCryEditApp::OnReloadTextures()
GetIEditor()->GetRenderer()->EF_ReloadTextures();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnReloadGeometry()
{
CErrorsRecorder errRecorder(GetIEditor());
CWaitProgress wait("Reloading static geometry");
CLogFile::WriteLine("Reloading Static objects geometries.");
CEdMesh::ReloadAllGeometries();
GetIEditor()->GetObjectManager()->SendEvent(EVENT_UNLOAD_GEOM);
GetIEditor()->GetObjectManager()->SendEvent(EVENT_RELOAD_GEOM);
GetIEditor()->Notify(eNotify_OnReloadTrackView);
// Rephysicalize viewport meshes
for (int i = 0; i < GetIEditor()->GetViewManager()->GetViewCount(); ++i)
{
CViewport* vp = GetIEditor()->GetViewManager()->GetView(i);
if (CModelViewport* mvp = viewport_cast<CModelViewport*>(vp))
{
mvp->RePhysicalize();
}
}
IRenderNode** plist = new IRenderNode*[
gEnv->p3DEngine->GetObjectsByType(eERType_StaticMeshRenderComponent,0)
];
for (const EERType type : AZStd::array<EERType, 3>{eERType_Dummy_10, eERType_StaticMeshRenderComponent})
{
for (int j = gEnv->p3DEngine->GetObjectsByType(type, plist) - 1; j >= 0; j--)
{
plist[j]->Physicalize(true);
}
}
delete[] plist;
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUndo()
{
@@ -3153,15 +3102,6 @@ void CCryEditApp::OnSyncPlayerUpdate(QAction* action)
action->setChecked(!GetIEditor()->GetGameEngine()->IsSyncPlayerPosition());
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnGenerateCgfThumbnails()
{
qApp->setOverrideCursor(Qt::BusyCursor);
CThumbnailGenerator gen;
gen.GenerateForDirectory("Objects\\");
qApp->restoreOverrideCursor();
}
void CCryEditApp::OnUpdateNonGameMode(QAction* action)
{
action->setEnabled(!GetIEditor()->IsInGameMode());
@@ -3260,10 +3200,9 @@ CCryEditApp::ECreateLevelResult CCryEditApp::CreateLevel(const QString& levelNam
m_bIsExportingLegacyData = false;
}
GetIEditor()->GetGameEngine()->LoadLevel(GetIEditor()->GetGameEngine()->GetMissionName(), true, true);
GetIEditor()->GetGameEngine()->LoadLevel(true, true);
GetIEditor()->GetSystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_PRECACHE_START, 0, 0);
GetIEditor()->GetGameEngine()->ReloadEnvironment();
GetIEditor()->GetSystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_PRECACHE_END, 0, 0);
}
@@ -3882,119 +3821,6 @@ void CCryEditApp::OnValidatelevel()
levelInfo.Validate();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnValidateObjectPositions()
{
IObjectManager* objMan = GetIEditor()->GetObjectManager();
if (!objMan)
{
return;
}
CErrorReport errorReport;
errorReport.SetCurrentFile("");
errorReport.SetImmediateMode(false);
int objCount = objMan->GetObjectCount();
AABB bbox1;
AABB bbox2;
int bugNo = 0;
QString statTxt("");
std::vector<CBaseObject*> objects;
objMan->GetObjects(objects);
std::vector<CBaseObject*> foundObjects;
std::vector<GUID> objIDs;
for (int i1 = 0; i1 < objCount; ++i1)
{
CBaseObject* pObj1 = objects[i1];
if (!pObj1)
{
continue;
}
// Object must have geometry
if (!pObj1->GetGeometry())
{
continue;
}
pObj1->GetBoundBox(bbox1);
// Check if object has other objects inside its bbox
foundObjects.clear();
objMan->FindObjectsInAABB(bbox1, foundObjects);
for (int i2 = 0; i2 < foundObjects.size(); ++i2)
{
CBaseObject* pObj2 = objects[i2];
if (!pObj2)
{
continue;
}
if (pObj2->GetId() == pObj1->GetId())
{
continue;
}
if (pObj2->GetParent())
{
continue;
}
if (stl::find(objIDs, pObj2->GetId()))
{
continue;
}
if (!pObj2->GetGeometry())
{
continue;
}
pObj2->GetBoundBox(bbox2);
if (!bbox1.IsContainPoint(bbox2.max))
{
continue;
}
if (!bbox1.IsContainPoint(bbox2.min))
{
continue;
}
objIDs.push_back(pObj2->GetId());
CErrorRecord error;
error.pObject = pObj2;
error.count = bugNo;
error.error = tr("%1 inside %2 object").arg(pObj2->GetName(), pObj1->GetName());
error.description = "Object left inside other object";
errorReport.ReportError(error);
++bugNo;
}
statTxt = tr("%1/%2 [Reported Objects: %3]").arg(i1).arg(objCount).arg(bugNo);
GetIEditor()->SetStatusText(statTxt);
}
if (errorReport.GetErrorCount() == 0)
{
QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QString(), QObject::tr("No Errors Found"));
}
else
{
errorReport.Display();
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnToolsPreferences()
{
@@ -4143,12 +3969,6 @@ void CCryEditApp::OnOpenUICanvasEditor()
QtViewPaneManager::instance()->OpenPane(LyViewPane::UiEditor);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnTimeOfDay()
{
GetIEditor()->OpenView("Time Of Day");
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable)
{
-4
View File
@@ -230,11 +230,9 @@ public:
void OnFileEditEditorini();
void OnPreferences();
void OnReloadTextures();
void OnReloadGeometry();
void OnRedo();
void OnUpdateRedo(QAction* action);
void OnUpdateUndo(QAction* action);
void OnGenerateCgfThumbnails();
void OnSwitchPhysics();
void OnSwitchPhysicsUpdate(QAction* action);
void OnSyncPlayer();
@@ -419,7 +417,6 @@ private:
void OnFileSavelevelresources();
void OnClearRegistryData();
void OnValidatelevel();
void OnValidateObjectPositions();
void OnToolsPreferences();
void OnGraphicsSettings();
void OnSwitchToDefaultCamera();
@@ -434,7 +431,6 @@ private:
void OnOpenTrackView();
void OnOpenAudioControlsEditor();
void OnOpenUICanvasEditor();
void OnTimeOfDay();
void OnChangeGameSpec(UINT nID);
void SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable);
void OnUpdateGameSpec(QAction* action);
+1 -271
View File
@@ -42,7 +42,6 @@
#include "Settings.h"
#include "PluginManager.h"
#include "Mission.h"
#include "ViewManager.h"
#include "DisplaySettings.h"
#include "GameEngine.h"
@@ -57,7 +56,6 @@
#include "CheckOutDialog.h"
#include "GameExporter.h"
#include "MainWindow.h"
#include "ITimeOfDay.h"
#include "LevelFileDialog.h"
#include "StatObjBus.h"
@@ -123,7 +121,6 @@ CCryEditDoc::CCryEditDoc()
// The right way would require us to save to the level folder the export status of the
// level.
, m_boLevelExported(true)
, m_mission(NULL)
, m_modified(false)
, m_envProbeHeight(200.0f)
, m_envProbeSliceRelativePath("EngineAssets/Slices/DefaultLevelSetup.slice")
@@ -158,7 +155,6 @@ CCryEditDoc::CCryEditDoc()
CCryEditDoc::~CCryEditDoc()
{
GetIEditor()->SetDocument(nullptr);
ClearMissions();
delete m_pLevelShaderCache;
@@ -255,17 +251,6 @@ bool CCryEditDoc::Save()
return OnSaveDocument(GetActivePathName());
}
void CCryEditDoc::ChangeMission()
{
GetIEditor()->Notify(eNotify_OnMissionChange);
// Notify listeners.
for (std::list<IDocListener*>::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
{
(*it)->OnMissionChange();
}
}
void CCryEditDoc::DeleteContents()
{
m_hasErrors = false;
@@ -295,10 +280,6 @@ void CCryEditDoc::DeleteContents()
// Delete all objects from Object Manager.
GetIEditor()->GetObjectManager()->DeleteAllObjects();
ClearMissions();
GetIEditor()->GetGameEngine()->ResetResources();
// Load scripts data
SetModifiedFlag(FALSE);
SetModifiedModules(eModifiedNothing);
@@ -341,7 +322,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
if (!isPrefabEnabled)
{
CAutoDocNotReady autoDocNotReady;
QString currentMissionName;
if (arrXmlAr[DMAS_GENERAL] != NULL)
{
@@ -356,8 +336,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
// Fog settings ///////////////////////////////////////////////////////
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
// Serialize Missions //////////////////////////////////////////////////
SerializeMissions(arrXmlAr, currentMissionName, false);
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
@@ -404,7 +382,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
HEAP_CHECK
CLogFile::FormatLine("Loading from %s...", szFilename.toUtf8().data());
QString currentMissionName;
QString szLevelPath = Path::GetPath(szFilename);
{
@@ -482,27 +459,9 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
}
HEAP_CHECK
if (!isPrefabEnabled)
{
// multiple missions are no longer supported, only load the current mission (last used)
SerializeMissions(arrXmlAr, currentMissionName, false);
}
HEAP_CHECK
if (GetIEditor()->Get3DEngine())
{
if (!isPrefabEnabled)
{
GetIEditor()->Get3DEngine()->LoadCompiledOctreeForEditor();
}
}
{
CAutoLogTime logtime("Game Engine level load");
GetIEditor()->GetGameEngine()->LoadLevel(currentMissionName, true, true);
GetIEditor()->GetGameEngine()->LoadLevel(true, true);
}
if (!isPrefabEnabled)
@@ -523,27 +482,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
}
{
QByteArray str;
str = tr("Activating Mission %1").arg(currentMissionName).toUtf8();
CAutoLogTime logtime(str.data());
// Select current mission.
m_mission = FindMission(currentMissionName);
if (m_mission)
{
SyncCurrentMissionContent(true);
}
else
{
GetCurrentMission();
}
}
ForceSkyUpdate();
if (!isPrefabEnabled)
{
// Serialize Shader Cache.
@@ -730,94 +668,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr)
}
}
void CCryEditDoc::SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMissionName, bool bPartsInXml)
{
bool bLoading = IsLoadingXmlArArray(arrXmlAr);
if (bLoading)
{
// Loading
CLogFile::WriteLine("Loading missions...");
// Clear old layers
ClearMissions();
// Load shared objects and layers.
XmlNodeRef objectsNode = arrXmlAr[DMAS_GENERAL]->root->findChild("Objects");
XmlNodeRef objectLayersNode = arrXmlAr[DMAS_GENERAL]->root->findChild("ObjectLayers");
// Load the layer count
XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->findChild("Missions");
if (!node)
{
return;
}
QString current;
node->getAttr("Current", current);
currentMissionName = current;
// Read all node
for (int i = 0; i < node->getChildCount(); i++)
{
CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]);
ar.root = node->getChild(i);
CMission* mission = new CMission(this);
mission->Serialize(ar);
if (bPartsInXml)
{
mission->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]);
mission->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]);
}
else
{
mission->LoadParts();
}
// Timur[9/11/2002] For backward compatibility with shared objects
if (objectsNode)
{
mission->AddObjectsNode(objectsNode);
}
if (objectLayersNode)
{
mission->SetLayersNode(objectLayersNode);
}
AddMission(mission);
}
}
else
{
// Storing
CLogFile::WriteLine("Storing missions...");
// Save contents of current mission.
SyncCurrentMissionContent(false);
XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->newChild("Missions");
//! Store current mission name.
currentMissionName = GetCurrentMission()->GetName();
node->setAttr("Current", currentMissionName.toUtf8().data());
// Write all surface types.
for (int i = 0; i < m_missions.size(); i++)
{
CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]);
ar.root = node->newChild("Mission");
m_missions[i]->Serialize(ar, false);
if (bPartsInXml)
{
m_missions[i]->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]);
m_missions[i]->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]);
}
else
{
m_missions[i]->SaveParts();
}
}
CLogFile::WriteString("Done");
}
}
void CCryEditDoc::SerializeShaderCache(CXmlArchive& xmlAr)
{
if (xmlAr.bLoading)
@@ -2089,58 +1939,6 @@ void CCryEditDoc::SaveAutoBackup(bool bForce)
isInProgress = false;
}
CMission* CCryEditDoc::GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent /* = false */)
{
if (m_mission)
{
return m_mission;
}
if (!m_missions.empty())
{
// Choose first available mission.
SetCurrentMission(m_missions[0]);
return m_mission;
}
// Create initial mission.
m_mission = new CMission(this);
m_mission->SetName("Mission0");
AddMission(m_mission);
m_mission->SyncContent(true, false, bSkipLoadingAIWhenSyncingContent);
return m_mission;
}
void CCryEditDoc::SetCurrentMission(CMission* mission)
{
if (mission != m_mission)
{
QWaitCursor wait;
if (m_mission)
{
m_mission->SyncContent(false, false);
}
m_mission = mission;
m_mission->SyncContent(true, false);
GetIEditor()->GetGameEngine()->LoadMission(m_mission->GetName());
}
}
void CCryEditDoc::ClearMissions()
{
for (int i = 0; i < m_missions.size(); i++)
{
delete m_missions[i];
}
m_missions.clear();
m_mission = 0;
}
bool CCryEditDoc::IsLevelExported() const
{
return m_boLevelExported;
@@ -2151,37 +1949,6 @@ void CCryEditDoc::SetLevelExported(bool boExported)
m_boLevelExported = boExported;
}
CMission* CCryEditDoc::FindMission(const QString& name) const
{
for (int i = 0; i < m_missions.size(); i++)
{
if (QString::compare(name, m_missions[i]->GetName(), Qt::CaseInsensitive) == 0)
{
return m_missions[i];
}
}
return 0;
}
void CCryEditDoc::AddMission(CMission* mission)
{
assert(std::find(m_missions.begin(), m_missions.end(), mission) == m_missions.end());
m_missions.push_back(mission);
GetIEditor()->Notify(eNotify_OnInvalidateControls);
}
void CCryEditDoc::RemoveMission(CMission* mission)
{
// if deleting current mission.
if (mission == m_mission)
{
m_mission = 0;
}
m_missions.erase(std::find(m_missions.begin(), m_missions.end(), mission));
GetIEditor()->Notify(eNotify_OnInvalidateControls);
}
void CCryEditDoc::RegisterListener(IDocListener* listener)
{
if (listener == nullptr)
@@ -2287,19 +2054,6 @@ void CCryEditDoc::OnStartLevelResourceList()
gEnv->pCryPak->GetResourceList(AZ::IO::IArchive::RFOM_Level)->Clear();
}
void CCryEditDoc::ForceSkyUpdate()
{
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
CMission* pCurMission = GetIEditor()->GetDocument()->GetCurrentMission();
if (pTimeOfDay && pCurMission)
{
pTimeOfDay->SetTime(pCurMission->GetTime(), gSettings.bForceSkyUpdate);
pCurMission->SetTime(pCurMission->GetTime());
GetIEditor()->Notify(eNotify_OnTimeOfDayChange);
}
}
BOOL CCryEditDoc::DoFileSave()
{
if (GetEditMode() == CCryEditDoc::DocumentEditingMode::LevelEdit)
@@ -2361,27 +2115,11 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
//////////////////////////////////////////////////////////////////////////
if (!GetIEditor()->IsInPreviewMode())
{
// Make new mission.
GetIEditor()->ReloadTemplates();
m_environmentTemplate = GetIEditor()->FindTemplate("Environment");
GetCurrentMission(true); // true = skip loading the AI in case the content needs to get synchronized (otherwise it would attempt to load AI stuff from the previously loaded level (!) which might give confusing warnings)
GetIEditor()->GetGameEngine()->SetMissionName(GetCurrentMission()->GetName());
GetIEditor()->GetGameEngine()->SetLevelCreated(true);
GetIEditor()->GetGameEngine()->ReloadEnvironment();
GetIEditor()->GetGameEngine()->SetLevelCreated(false);
// Default time of day.
auto defaultTimeOfDayPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Assets" / "Editor" / "default_time_of_day.xml";
XmlNodeRef root = GetISystem()->LoadXmlFromFile(defaultTimeOfDayPath.c_str());
if (root)
{
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
if (pTimeOfDay)
{
pTimeOfDay->Serialize(root, true);
}
}
}
{
@@ -2469,8 +2207,6 @@ void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
pVar->Get(value);
childNode->setAttr("value", value.toUtf8().data());
}
GetIEditor()->GetGameEngine()->ReloadEnvironment();
}
QString CCryEditDoc::GetCryIndexPath(const LPCTSTR levelFilePath)
@@ -2523,12 +2259,6 @@ void CCryEditDoc::ReleaseXmlArchiveArray(TDocMultiArchive& arrXmlAr)
SAFE_DELETE(arrXmlAr[0]);
}
void CCryEditDoc::SyncCurrentMissionContent(bool bRetrieve)
{
GetCurrentMission()->SyncContent(bRetrieve, false);
}
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorEntityContextNotificationBus interface implementation
void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& /*ticket*/)
-24
View File
@@ -22,7 +22,6 @@
#include <TimeValue.h>
#endif
class CMission;
class CLevelShaderCache;
class CClouds;
struct LightingSettings;
@@ -124,18 +123,6 @@ public: // Create from serialization only
const char* GetTemporaryLevelName() const;
void DeleteTemporaryLevel();
void ChangeMission();
//! Return currently active Mission.
CMission* GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent = false);
//! Get number of missions on Map.
int GetMissionCount() const { return m_missions.size(); }
//! Get Mission by index.
CMission* GetMission(int index) const { return m_missions[index]; }
//! Find Mission by name.
CMission* FindMission(const QString& name) const;
//! Makes specified mission current.
void SetCurrentMission(CMission* mission);
CLevelShaderCache* GetShaderCache() { return m_pLevelShaderCache; }
CClouds* GetClouds() { return m_pClouds; }
void SetWaterColor(const QColor& col) { m_waterColor = col; }
@@ -167,7 +154,6 @@ protected:
virtual void Load(TDocMultiArchive& arrXmlAr, const QString& szFilename);
virtual void StartStreamingLoad(){}
virtual void SyncCurrentMissionContent(bool bRetrieve);
void Save(CXmlArchive& xmlAr);
void Load(CXmlArchive& xmlAr, const QString& szFilename);
@@ -179,14 +165,8 @@ protected:
bool LoadEntitiesFromSlice(const QString& sliceFile);
void SerializeFogSettings(CXmlArchive& xmlAr);
virtual void SerializeViewSettings(CXmlArchive& xmlAr);
void SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMission, bool bPartsInXml);
void SerializeShaderCache(CXmlArchive& xmlAr);
void SerializeNameSelection(CXmlArchive& xmlAr);
void ForceSkyUpdate();
//! Add new mission to map.
void AddMission(CMission* mission);
//! Remove existing mission from map.
void RemoveMission(CMission* mission);
void LogLoadTime(int time);
struct TSaveDocContext
@@ -200,10 +180,8 @@ protected:
virtual bool OnSaveDocument(const QString& lpszPathName);
virtual void OnFileSaveAs();
void LoadTemplates();
//! called immediately after saving the level.
void AfterSave();
void ClearMissions();
void RegisterConsoleVariables();
void OnStartLevelResourceList();
static void OnValidateSurfaceTypesChanged(ICVar*);
@@ -220,9 +198,7 @@ protected:
QColor m_waterColor;
XmlNodeRef m_fogTemplate;
XmlNodeRef m_environmentTemplate;
CMission* m_mission;
CClouds* m_pClouds;
std::vector<CMission*> m_missions;
std::list<IDocListener*> m_listeners;
bool m_bDocumentReady;
CLevelShaderCache* m_pLevelShaderCache;
-5
View File
@@ -86,11 +86,6 @@ void CDisplaySettings::PostInitApply()
void CDisplaySettings::SetRenderFlags(int flags)
{
m_renderFlags = flags;
if (!GetIEditor()->Get3DEngine())
{
return;
}
}
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -132,7 +132,6 @@
#include <IRenderer.h>
#include <CryFile.h>
#include <ISystem.h>
#include <I3DEngine.h>
#include <IIndexedMesh.h>
#include <ITimer.h>
#include <IXml.h>
+14 -38
View File
@@ -54,7 +54,6 @@
#include <AtomToolsFramework/Viewport/RenderViewportWidget.h>
// CryCommon
#include <CryCommon/I3DEngine.h>
#include <CryCommon/HMDBus.h>
// AzFramework
@@ -97,6 +96,10 @@
#include <QtGui/private/qhighdpiscaling_p.h>
#include <IEntityRenderState.h>
#include <IPhysics.h>
#include <IStatObj.h>
AZ_CVAR(
bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null,
"Output the timing of the new IVisibilitySystem query");
@@ -250,11 +253,6 @@ void EditorViewportWidget::resizeEvent(QResizeEvent* event)
gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, width(), height());
if (gEnv->pRenderer)
{
gEnv->pRenderer->EF_DisableTemporalEffects();
}
// We queue the window resize event because the render overlay may be hidden.
// If the render overlay is not visible, the native window that is backing it will
// also be hidden, and it will not resize until it becomes visible.
@@ -520,9 +518,6 @@ void EditorViewportWidget::Update()
// Render
{
// TODO: Move out this logic to a controller and refactor to work with Atom
// m_renderer->SetClearColor(Vec3(0.4f, 0.4f, 0.4f));
// 3D engine stats
GetIEditor()->GetSystem()->RenderBegin();
OnRender();
@@ -547,8 +542,6 @@ void EditorViewportWidget::Update()
}
}
GetIEditor()->GetSystem()->RenderEnd(m_bRenderStats);
gEnv->pSystem->SetViewCamera(CurCamera);
}
@@ -1305,26 +1298,8 @@ namespace AZ::ViewportHelpers
//////////////////////////////////////////////////////////////////////////
void EditorViewportWidget::OnTitleMenu(QMenu* menu)
{
const int nWireframe = gEnv->pConsole->GetCVar("r_wireframe")->GetIVal();
QAction* action = menu->addAction(tr("Wireframe"));
connect(action, &QAction::triggered, action, []()
{
ICVar* piVar(gEnv->pConsole->GetCVar("r_wireframe"));
int nRenderMode = piVar->GetIVal();
if (nRenderMode != R_WIREFRAME_MODE)
{
piVar->Set(R_WIREFRAME_MODE);
}
else
{
piVar->Set(R_SOLID_MODE);
}
});
action->setCheckable(true);
action->setChecked(nWireframe == R_WIREFRAME_MODE);
const bool bDisplayLabels = GetIEditor()->GetDisplaySettings()->IsDisplayLabels();
action = menu->addAction(tr("Labels"));
QAction* action = menu->addAction(tr("Labels"));
connect(action, &QAction::triggered, this, [bDisplayLabels] {GetIEditor()->GetDisplaySettings()->DisplayLabels(!bDisplayLabels);
});
action->setCheckable(true);
@@ -1556,7 +1531,6 @@ void EditorViewportWidget::ToggleCameraObject()
{
if (m_viewSourceType == ViewSourceType::SequenceCamera)
{
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
ResetToViewSourceType(ViewSourceType::LegacyCamera);
}
else
@@ -2136,17 +2110,23 @@ bool EditorViewportWidget::AdjustObjectPosition(const ray_hit& hit, Vec3& outNor
//////////////////////////////////////////////////////////////////////////
bool EditorViewportWidget::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const
{
SRayHitInfo hitInfo;
AZ_UNUSED(pRenderMesh);
AZ_UNUSED(vInPos);
AZ_UNUSED(vInDir);
AZ_UNUSED(vOutPos);
AZ_UNUSED(vOutNormal);
return false;
/*SRayHitInfo hitInfo;
hitInfo.bUseCache = false;
hitInfo.bInFirstHit = false;
hitInfo.inRay.origin = vInPos;
hitInfo.inRay.direction = vInDir.GetNormalized();
hitInfo.inReferencePoint = vInPos;
hitInfo.fMaxHitDistance = 0;
bool bRes = GetIEditor()->Get3DEngine()->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr);
bool bRes = ???->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr);
vOutPos = hitInfo.vHitPos;
vOutNormal = hitInfo.vHitNormal;
return bRes;
return bRes;*/
}
void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const
@@ -2417,10 +2397,6 @@ void EditorViewportWidget::SetDefaultCamera()
return;
}
ResetToViewSourceType(ViewSourceType::None);
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
}
GetViewManager()->SetCameraObjectId(m_cameraObjectId);
SetName(m_defaultViewName);
SetViewTM(m_defaultViewTM);
@@ -481,10 +481,6 @@ protected:
OBB m_GroundOBB;
Vec3 m_GroundOBBPos;
//-------------------------------------------
// Render options.
bool m_bRenderStats = true;
// Index of camera objects.
mutable GUID m_cameraObjectId;
mutable AZ::EntityId m_viewEntityId;
-53
View File
@@ -1,53 +0,0 @@
/*
* 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.
#include "EditorDefs.h"
#include "EnvironmentPanel.h"
// Editor
#include "GameEngine.h"
#include "CryEditDoc.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_EnvironmentPanel.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
/////////////////////////////////////////////////////////////////////////////
// CEnvironmentPanel dialog
CEnvironmentPanel::CEnvironmentPanel(QWidget* pParent /*=nullptr*/)
: QWidget(pParent)
, ui(new Ui::CEnvironmentPanel)
{
XmlNodeRef node = GetIEditor()->GetDocument()->GetEnvironmentTemplate();
m_onSetCallback = AZStd::bind(&CCryEditDoc::OnEnvironmentPropertyChanged, GetIEditor()->GetDocument(), AZStd::placeholders::_1);
ui->setupUi(this);
ui->m_wndProps->Setup();
ui->m_wndProps->CreateItems(node, m_varBlock, &m_onSetCallback, true);
ui->m_wndProps->RebuildCtrl(false);
ui->m_wndProps->ExpandAll();
connect(ui->APPLYBTN, &QPushButton::clicked, this, &CEnvironmentPanel::OnBnClickedApply);
}
CEnvironmentPanel::~CEnvironmentPanel()
{
}
//////////////////////////////////////////////////////////////////////////
void CEnvironmentPanel::OnBnClickedApply()
{
GetIEditor()->GetGameEngine()->ReloadEnvironment();
}
-53
View File
@@ -1,53 +0,0 @@
/*
* 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.
#ifndef CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
#define CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
#pragma once
// EnvironmentPanel.h : header file
//
#include "Util/Variable.h"
#include <QWidget>
#include <QScopedPointer>
/////////////////////////////////////////////////////////////////////////////
// CEnvironmentPanel dialog
namespace Ui {
class CEnvironmentPanel;
}
class CEnvironmentPanel
: public QWidget
{
// Construction
public:
CEnvironmentPanel(QWidget* pParent = nullptr); // standard constructor
~CEnvironmentPanel();
// Implementation
protected:
CVarBlockPtr m_varBlock;
public:
void OnBnClickedApply();
private:
QScopedPointer<Ui::CEnvironmentPanel> ui;
IVariable::OnSetCallback m_onSetCallback;
};
#endif // CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
-56
View File
@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CEnvironmentPanel</class>
<widget class="QWidget" name="CEnvironmentPanel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<height>259</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="ReflectedPropertyControl" name="m_wndProps" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="APPLYBTN">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>162</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ReflectedPropertyControl</class>
<extends>QWidget</extends>
<header>Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+4 -55
View File
@@ -22,7 +22,6 @@
#include <Maestro/Types/AnimParamType.h>
// Editor
#include "Geometry/EdGeometry.h"
#include "ViewManager.h"
#include "OBJExporter.h"
#include "OCMExporter.h"
@@ -41,6 +40,9 @@
#include "Resource.h"
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
#include <IEntityRenderState.h>
#include <IStatObj.h>
namespace
{
void SetTexture(Export::TPath& outName, IRenderShaderResources* pRes, int nSlot)
@@ -494,53 +496,6 @@ bool CExportManager::AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matri
bool CExportManager::AddMeshes(Export::CObject* pObj)
{
CEdGeometry* pEdGeom = m_pBaseObj->GetGeometry();
IIndexedMesh* pIndMesh = 0;
if (pEdGeom)
{
size_t idx = 0;
size_t nextIdx = 0;
do
{
pIndMesh = 0;
if (m_isOccluder)
{
if (pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(2))
{
pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(2)->GetIndexedMesh(true);
}
if (!pIndMesh && pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(1))
{
pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(1)->GetIndexedMesh(true);
}
}
if (!pIndMesh)
{
pIndMesh = pEdGeom->GetIndexedMesh(idx);
nextIdx++;
}
if (!pIndMesh)
{
break;
}
Matrix34 tm;
pEdGeom->GetTM(&tm, idx);
Matrix34A objTM = tm;
AddMesh(pObj, pIndMesh, &objTM);
idx = nextIdx;
}
while (pIndMesh && idx);
if (idx > 0)
{
return true;
}
}
if (m_pBaseObj->GetType() == OBJTYPE_AZENTITY)
{
CEntityObject* pEntityObject = (CEntityObject*)m_pBaseObj;
@@ -548,11 +503,7 @@ bool CExportManager::AddMeshes(Export::CObject* pObj)
if (pEngineNode)
{
if (m_isPrecaching)
{
GetIEditor()->Get3DEngine()->PrecacheRenderNode(pEngineNode, 0);
}
else
if (!m_isPrecaching)
{
for (int i = 0; i < pEngineNode->GetSlotCount(); ++i)
{
@@ -1115,8 +1066,6 @@ bool CExportManager::AddSelectedRegionObjects()
AddObject(objects[i]);
}
GetIEditor()->Get3DEngine()->ProposeContentPrecache();
// Repeat pipeline to collect geometry
m_isPrecaching = false;
for (size_t i = 0; i < numObjects; ++i)
+1 -193
View File
@@ -34,15 +34,11 @@
// Editor
#include "IEditorImpl.h"
#include "CryEditDoc.h"
#include "Geometry/EdMesh.h"
#include "Mission.h"
#include "Settings.h"
// CryCommon
#include <CryCommon/I3DEngine.h>
#include <CryCommon/INavigationSystem.h>
#include <CryCommon/IDeferredCollisionEvent.h>
#include <CryCommon/ITimeOfDay.h>
#include <CryCommon/LyShine/ILyShine.h>
#include <CryCommon/MainThreadRenderRequestBus.h>
@@ -283,7 +279,6 @@ AZ_POP_DISABLE_WARNING
AZ::Interface<IEditorCameraController>::Unregister(this);
GetIEditor()->UnregisterNotifyListener(this);
m_pISystem->GetIMovieSystem()->SetCallback(NULL);
CEdMesh::ReleaseAll();
if (m_gameDll)
{
@@ -493,13 +488,6 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
SetEditorCoreEnvironment(gEnv);
if (gEnv
&& gEnv->p3DEngine
&& gEnv->p3DEngine->GetTimeOfDay())
{
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
}
if (gEnv && gEnv->pMovieSystem)
{
gEnv->pMovieSystem->EnablePhysicsEvents(m_bSimulationMode);
@@ -549,26 +537,14 @@ void CGameEngine::SetLevelPath(const QString& path)
{
m_levelExtension = defaultExtension;
}
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->SetLevelPath(m_levelPath.toUtf8().data());
}
}
void CGameEngine::SetMissionName(const QString& mission)
{
m_missionName = mission;
}
bool CGameEngine::LoadLevel(
const QString& mission,
[[maybe_unused]] bool bDeleteAIGraph,
bool bReleaseResources)
{
LOADING_TIME_PROFILE_SECTION(GetIEditor()->GetSystem());
m_bLevelLoaded = false;
m_missionName = mission;
CLogFile::FormatLine("Loading map '%s' into engine...", m_levelPath.toUtf8().data());
// Switch the current directory back to the Primary CD folder first.
// The engine might have trouble to find some files when the current
@@ -607,30 +583,17 @@ bool CGameEngine::LoadLevel(
}
// Load level in 3d engine.
if (gEnv->p3DEngine && !gEnv->p3DEngine->InitLevelForEditor(m_levelPath.toUtf8().data(), m_missionName.toUtf8().data()))
{
CLogFile::WriteLine("ERROR: Can't load level !");
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("ERROR: Can't load level !"));
return false;
}
// Audio: notify audio of level loading start?
GetIEditor()->GetObjectManager()->SendEvent(EVENT_REFRESH);
m_bLevelLoaded = true;
if (!bReleaseResources)
{
ReloadEnvironment();
}
return true;
}
bool CGameEngine::ReloadLevel()
{
if (!LoadLevel(GetMissionName(), false, false))
if (!LoadLevel(false, false))
{
return false;
}
@@ -638,61 +601,8 @@ bool CGameEngine::ReloadLevel()
return true;
}
bool CGameEngine::LoadMission(const QString& mission)
{
if (!IsLevelLoaded())
{
return false;
}
if (mission != m_missionName)
{
m_missionName = mission;
gEnv->p3DEngine->LoadMissionDataFromXMLNode(m_missionName.toUtf8().data());
}
return true;
}
bool CGameEngine::ReloadEnvironment()
{
if (!gEnv->p3DEngine)
{
return false;
}
if (!IsLevelLoaded() && !m_bJustCreated)
{
return false;
}
if (!GetIEditor()->GetDocument())
{
return false;
}
XmlNodeRef env = XmlHelpers::CreateXmlNode("Environment");
CXmlTemplate::SetValues(GetIEditor()->GetDocument()->GetEnvironmentTemplate(), env);
// Notify mission that environment may be changed.
GetIEditor()->GetDocument()->GetCurrentMission()->OnEnvironmentChange();
QString xmlStr = QString::fromLatin1(env->getXML());
// Reload level data in engine.
gEnv->p3DEngine->LoadEnvironmentSettingsFromXML(env);
return true;
}
void CGameEngine::SwitchToInGame()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->DisablePostEffects();
gEnv->p3DEngine->ResetPostEffects();
}
auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get();
if (streamer)
{
@@ -707,11 +617,6 @@ void CGameEngine::SwitchToInGame()
m_pISystem->SetThreadState(ESubsys_Physics, false);
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->ResetParticlesAndDecals();
}
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(true);
m_bInGameMode = true;
@@ -721,10 +626,6 @@ void CGameEngine::SwitchToInGame()
pRuler->SetActive(false);
}
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetTimeOfDay()->EndEditMode();
}
gEnv->pSystem->GetViewCamera().SetMatrix(m_playerViewTM);
// Disable accelerators.
@@ -760,24 +661,9 @@ void CGameEngine::SwitchToInEditor()
m_pISystem->SetThreadState(ESubsys_Physics, false);
if (gEnv->p3DEngine)
{
// Reset 3d engine effects
gEnv->p3DEngine->DisablePostEffects();
gEnv->p3DEngine->ResetPostEffects();
gEnv->p3DEngine->ResetParticlesAndDecals();
}
CViewport* pGameViewport = GetIEditor()->GetViewManager()->GetGameViewport();
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(m_bSimulationMode);
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
// this has to be done before the RemoveSink() call, or else some entities may not be removed
gEnv->p3DEngine->GetDeferredPhysicsEventManager()->ClearDeferredEvents();
}
// Enable accelerators.
GetIEditor()->EnableAcceleratos(true);
@@ -865,7 +751,6 @@ void CGameEngine::SetGameMode(bool bInGame)
// Ignore updates while changing in and out of game mode
m_bIgnoreUpdates = true;
LockResources();
// Switching modes will destroy the current AzFramework::EntityConext which may contain
// data the queued events hold on to, so execute all queued events before switching.
@@ -891,7 +776,6 @@ void CGameEngine::SetGameMode(bool bInGame)
GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED, bInGame, 0);
UnlockResources();
m_bIgnoreUpdates = false;
GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_GAME_MODE_SWITCH_END, bInGame, 0);
@@ -906,11 +790,6 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(enabled);
if (!bOnlyPhysics)
{
LockResources();
}
if (enabled)
{
CRuler* pRuler = GetIEditor()->GetRuler();
@@ -935,35 +814,12 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
if (m_bSimulationMode)
{
if (!bOnlyPhysics)
{
if (m_pISystem->GetI3DEngine())
{
m_pISystem->GetI3DEngine()->ResetPostEffects();
}
GetIEditor()->SetConsoleVar("ai_ignoreplayer", 1);
//GetIEditor()->SetConsoleVar( "ai_soundperception",0 );
}
// [Anton] the order of the next 3 calls changed, since, EVENT_INGAME loads physics state (if any),
// and Reset should be called before it
GetIEditor()->GetObjectManager()->SendEvent(EVENT_INGAME);
}
else
{
if (!bOnlyPhysics)
{
GetIEditor()->SetConsoleVar("ai_ignoreplayer", 0);
//GetIEditor()->SetConsoleVar( "ai_soundperception",1 );
if (m_pISystem->GetI3DEngine())
{
m_pISystem->GetI3DEngine()->ResetPostEffects();
}
}
GetIEditor()->GetObjectManager()->SendEvent(EVENT_OUTOFGAME);
}
@@ -983,23 +839,9 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequestBus::Events::StartPlayInEditor);
}
if (!bOnlyPhysics)
{
UnlockResources();
}
AzFramework::InputChannelRequestBus::Broadcast(&AzFramework::InputChannelRequests::ResetState);
}
void CGameEngine::ResetResources()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->UnloadLevel();
}
}
void CGameEngine::SetPlayerViewMatrix(const Matrix34& tm, [[maybe_unused]] bool bEyePos)
{
m_playerViewTM = tm;
@@ -1107,24 +949,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
{
case eNotify_OnBeginNewScene:
case eNotify_OnBeginSceneOpen:
{
ResetResources();
}
break;
case eNotify_OnEndSceneOpen:
case eNotify_OnEndTerrainRebuild:
{
}
case eNotify_OnEndNewScene: // intentional fall-through?
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->PostLoadLevel();
}
}
break;
case eNotify_OnSplashScreenDestroyed:
{
if (m_pSystemUserCallback != NULL)
@@ -1136,22 +960,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event)
}
}
void CGameEngine::LockResources()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->LockCGFResources();
}
}
void CGameEngine::UnlockResources()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->UnlockCGFResources();
}
}
void CGameEngine::OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain)
{
INavigationSystem* pNavigationSystem = nullptr; // INavigationSystem will be converted to an AZInterface (LY-111343)
-13
View File
@@ -89,15 +89,10 @@ public:
//! Load new terrain level into 3d engine.
//! Also load AI triangulation for this level.
bool LoadLevel(
const QString& mission,
bool bDeleteAIGraph,
bool bReleaseResources);
//!* Reload level if it was already loaded.
bool ReloadLevel();
//! Load new mission.
bool LoadMission(const QString& mission);
//! Reload environment settings in currently loaded level.
bool ReloadEnvironment();
//! Request to switch In/Out of game mode on next update.
//! The switch will happen when no sub systems are currently being updated.
//! @param inGame When true editor switch to game mode.
@@ -111,14 +106,10 @@ public:
bool IsLevelLoaded() const { return m_bLevelLoaded; };
//! Assign new level path name.
void SetLevelPath(const QString& path);
//! Assign new current mission name.
void SetMissionName(const QString& mission);
//! Return name of currently loaded level.
const QString& GetLevelName() const { return m_levelName; };
//! Return extension of currently loaded level.
const QString& GetLevelExtension() const { return m_levelExtension; };
//! Return name of currently active mission.
const QString& GetMissionName() const { return m_missionName; };
//! Get fully specified level path.
const QString& GetLevelPath() const { return m_levelPath; };
//! Query if engine is in game mode.
@@ -142,9 +133,6 @@ public:
//! Called every frame.
void Update();
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
void LockResources();
void UnlockResources();
void ResetResources();
void OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain);
void OnAreaModified(const AABB& modifiedArea);
@@ -179,7 +167,6 @@ private:
CLogFile m_logFile;
QString m_levelName;
QString m_levelExtension;
QString m_missionName;
QString m_levelPath;
QString m_MOD;
bool m_bLevelLoaded;
+1 -174
View File
@@ -24,7 +24,6 @@
#include "GameExporter.h"
#include "GameEngine.h"
#include "CryEditDoc.h"
#include "Mission.h"
#include "ShaderCache.h"
#include "UsedResources.h"
#include "WaitProgress.h"
@@ -131,13 +130,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
m_levelPath = Path::RemoveBackslash(sLevelPath);
QString rootLevelPath = Path::AddSlash(pGameEngine->GetLevelPath());
// Make sure we unload any unused CGFs before exporting so that they don't end up in
// the level data.
if (pEditor->Get3DEngine())
{
pEditor->Get3DEngine()->FreeUnusedCGFResources();
}
CCryEditDoc* pDocument = pEditor->GetDocument();
if (flags & eExp_Fast)
@@ -191,8 +183,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
////////////////////////////////////////////////////////////////////////
if (exportSuccessful)
{
ExportVisAreas(sLevelPath.toUtf8().data(), eExportEndian);
////////////////////////////////////////////////////////////////////////
// Exporting map setttings
////////////////////////////////////////////////////////////////////////
@@ -254,47 +244,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
return exportSuccessful;
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndian)
{
char szFileOutputPath[_MAX_PATH];
// export visareas
IEditor* pEditor = GetIEditor();
// remove old files
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
m_levelPak.m_pakFile.RemoveFile(szFileOutputPath);
SHotUpdateInfo exportInfo;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
if (p3DEngine && (eExportEndian == GetPlatformEndian())) // skip second export, this data is common for PC and consoles
{
std::vector<struct IStatObj*>* pTempBrushTable = NULL;
std::vector<_smart_ptr<IMaterial>>* pTempMatsTable = NULL;
std::vector<struct IStatInstGroup*>* pTempVegGroupTable = NULL;
// export visareas
CLogFile::WriteLine("Exporting indoors...");
pEditor->SetStatusText("Exporting indoors...");
if (IVisAreaManager* pVisAreaManager = p3DEngine->GetIVisAreaManager())
{
if (int nSize = pVisAreaManager->GetCompiledDataSize())
{ // get visareas data from 3dengine and save it into file
uint8* pData = new uint8[nSize];
pVisAreaManager->GetCompiledData(pData, nSize, &pTempBrushTable, &pTempMatsTable, &pTempVegGroupTable, eExportEndian);
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
CCryMemFile visareasCompiledFile;
visareasCompiledFile.Write(pData, nSize);
m_levelPak.m_pakFile.UpdateFile(szFileOutputPath, visareasCompiledFile);
delete[] pData;
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
{
@@ -319,7 +268,7 @@ void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
void CGameExporter::ExportLevelData(const QString& path, bool /*bExportMission*/)
{
IEditor* pEditor = GetIEditor();
pEditor->SetStatusText(QObject::tr("Exporting LevelData.xml..."));
@@ -332,49 +281,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
XmlNodeRef rootAction = XmlHelpers::CreateXmlNode("LevelDataAction");
rootAction->setAttr("SandboxVersion", versionString);
ExportMapInfo(root);
CCryEditDoc* pDocument = pEditor->GetDocument();
CMission* pCurrentMission = 0;
if (bExportMission)
{
pCurrentMission = pDocument->GetCurrentMission();
// Save contents of current mission.
}
//////////////////////////////////////////////////////////////////////////
// Export missions tag.
//////////////////////////////////////////////////////////////////////////
XmlNodeRef missionsNode = rootAction->newChild("Missions");
QString missionFileName;
QString currentMissionFileName;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
if (p3DEngine)
{
for (int i = 0; i < pDocument->GetMissionCount(); i++)
{
CMission* pMission = pDocument->GetMission(i);
QString name = pMission->GetName();
name.replace(' ', '_');
missionFileName = QStringLiteral("Mission_%1.xml").arg(name);
XmlNodeRef missionDescNode = missionsNode->newChild("Mission");
missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data());
missionDescNode->setAttr("File", missionFileName.toUtf8().data());
missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount();
missionDescNode->setAttr("ProgressBarRange", nProgressBarRange);
if (pMission == pCurrentMission)
{
currentMissionFileName = missionFileName;
}
}
}
//////////////////////////////////////////////////////////////////////////
// Save Level Data XML
//////////////////////////////////////////////////////////////////////////
@@ -389,41 +295,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
CCryMemFile fileAction;
fileAction.Write(xmlDataAction.c_str(), xmlDataAction.length());
m_levelPak.m_pakFile.UpdateFile(levelDataActionFile.toUtf8().data(), fileAction);
if (bExportMission)
{
XmlNodeRef objectsNode = NULL;
//////////////////////////////////////////////////////////////////////////
// Export current mission file.
//////////////////////////////////////////////////////////////////////////
XmlNodeRef missionNode = rootAction->createNode("Mission");
pCurrentMission->Export(missionNode, objectsNode);
if (p3DEngine)
{
missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
}
//if (!CFileUtil::OverwriteFile( path+currentMissionFileName ))
// return;
AZStd::vector<char> entitySaveBuffer;
AZ::IO::ByteContainerStream<AZStd::vector<char> > entitySaveStream(&entitySaveBuffer);
bool savedEntities = false;
EBUS_EVENT_RESULT(savedEntities, AzToolsFramework::EditorEntityContextRequestBus, SaveToStreamForGame, entitySaveStream, AZ::DataStream::ST_BINARY);
if (savedEntities)
{
QString entitiesFile;
entitiesFile = QStringLiteral("%1%2.entities_xml").arg(path, pCurrentMission ? pCurrentMission->GetName() : "");
m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), entitySaveBuffer.size());
}
_smart_ptr<IXmlStringData> pXmlStrData = missionNode->getXMLData(5000000);
CCryMemFile fileMission;
fileMission.Write(pXmlStrData->GetString(), pXmlStrData->GetStringLength());
m_levelPak.m_pakFile.UpdateFile((path + currentMissionFileName).toUtf8().data(), fileMission);
}
}
//////////////////////////////////////////////////////////////////////////
@@ -446,18 +317,6 @@ void CGameExporter::ExportLevelInfo(const QString& path)
const int compiledHeightmapSize = static_cast<int>(terrainAabb.GetXExtent() / terrainGridResolution.GetX());
root->setAttr("HeightmapSize", compiledHeightmapSize);
// Save all missions in this level.
XmlNodeRef missionsNode = root->newChild("Missions");
int numMissions = pEditor->GetDocument()->GetMissionCount();
for (int i = 0; i < numMissions; i++)
{
CMission* pMission = pEditor->GetDocument()->GetMission(i);
XmlNodeRef missionNode = missionsNode->newChild("Mission");
missionNode->setAttr("Name", pMission->GetName().toUtf8().data());
missionNode->setAttr("Description", pMission->GetDescription().toUtf8().data());
}
//////////////////////////////////////////////////////////////////////////
// Save LevelInfo file.
//////////////////////////////////////////////////////////////////////////
@@ -469,38 +328,6 @@ void CGameExporter::ExportLevelInfo(const QString& path)
m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file);
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportMapInfo(XmlNodeRef& node)
{
if (!GetIEditor()->Get3DEngine())
{
return;
}
XmlNodeRef info = node->newChild("LevelInfo");
IEditor* pEditor = GetIEditor();
info->setAttr("Name", QFileInfo(pEditor->GetDocument()->GetTitle()).completeBaseName());
auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
const AZ::Aabb terrainAabb = terrain ? terrain->GetTerrainAabb() : AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero());
const AZ::Vector2 terrainGridResolution = terrain ? terrain->GetTerrainGridResolution() : AZ::Vector2::CreateOne();
const int terrainSizeInMeters = static_cast<int>(terrainAabb.GetXExtent());
const int terrainUnitSizeInMeters = static_cast<int>(terrainGridResolution.GetX());
info->setAttr("HeightmapSize", terrainSizeInMeters / terrainUnitSizeInMeters);
info->setAttr("HeightmapUnitSize", terrainUnitSizeInMeters);
//! Default Max Height value.
constexpr int HEIGHTMAP_MAX_HEIGHT = 150; //This is the default max height in CHeightmap
info->setAttr("HeightmapMaxHeight", HEIGHTMAP_MAX_HEIGHT);
info->setAttr("WaterLevel", pEditor->Get3DEngine()->GetWaterLevel());
// Serialize surface types.
CXmlArchive xmlAr;
xmlAr.bLoading = false;
xmlAr.root = node;
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportLevelResourceList(const QString& path)
{
-2
View File
@@ -91,9 +91,7 @@ private:
void ExportLevelData(const QString& path, bool bExportMission = true);
void ExportLevelInfo(const QString& path);
void ExportVisAreas(const char* pszGamePath, EEndian eExportEndian);
void ExportOcclusionMesh(const char* pszGamePath);
void ExportMapInfo(XmlNodeRef& node);
void ExportLevelResourceList(const QString& path);
void ExportLevelUsedResourceList(const QString& path);
@@ -1,16 +0,0 @@
/*
* 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.
#include "EditorDefs.h"
#include "EdGeometry.h"
-84
View File
@@ -1,84 +0,0 @@
/*
* 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.
#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
#define CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
#pragma once
struct IIndexedMesh;
struct DisplayContext;
struct HitContext;
struct SSubObjSelectionModifyContext;
class CObjectArchive;
// Basic supported geometry types.
enum EEdGeometryType
{
GEOM_TYPE_MESH = 0, // Mesh geometry.
GEOM_TYPE_BRUSH, // Solid brush geometry.
GEOM_TYPE_PATCH, // Bezier patch surface geometry.
GEOM_TYPE_NURB, // Nurbs surface geometry.
};
//////////////////////////////////////////////////////////////////////////
// Description:
// CEdGeometry is a base class for all supported editable geometries.
//////////////////////////////////////////////////////////////////////////
class CRYEDIT_API CEdGeometry
: public CRefCountBase
{
public:
CEdGeometry() {};
// Query the type of the geometry mesh.
virtual EEdGeometryType GetType() const = 0;
// Serialize geometry.
virtual void Serialize(CObjectArchive& ar) = 0;
// Return geometry axis aligned bounding box.
virtual void GetBounds(AABB& box) = 0;
// Clones Geometry, returns exact copy of the original geometry.
virtual CEdGeometry* Clone() = 0;
// Access to the indexed mesh.
// Return false if geometry can not be represented by an indexed mesh.
virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0) = 0;
virtual IStatObj* GetIStatObj() const = 0;
virtual void GetTM(Matrix34* pTM, size_t idx = 0) = 0;
//////////////////////////////////////////////////////////////////////////
// Advanced geometry interface for SubObject selection and modification.
//////////////////////////////////////////////////////////////////////////
virtual void SetModified(bool bModified = true) = 0;
virtual bool IsModified() const = 0;
virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags) = 0;
virtual void EndSubObjSelection() = 0;
// Display geometry for sub object selection.
virtual void Display(DisplayContext& dc) = 0;
// Sub geometry hit testing and selection.
virtual bool HitTest(HitContext& hit) = 0;
//////////////////////////////////////////////////////////////////////////
virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true) = 0;
// Called when selection modification is accepted.
virtual void AcceptModifySelection() = 0;
protected:
~CEdGeometry() {};
};
#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
File diff suppressed because it is too large Load Diff
-194
View File
@@ -1,194 +0,0 @@
/*
* 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.
// Description : Editor structure that wraps access to IStatObj
#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
#define CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
#pragma once
#include "EdGeometry.h"
#include "Objects/SubObjSelection.h"
#include "TriMesh.h"
// Flags that can be set on CEdMesh.
enum CEdMeshFlags
{
};
//////////////////////////////////////////////////////////////////////////
// Description:
// CEdMesh is a Geometry kind representing simple mesh.
// Holds IStatObj interface from the 3D Engine.
//////////////////////////////////////////////////////////////////////////
class CRYEDIT_API CEdMesh
: public CEdGeometry
{
public:
//////////////////////////////////////////////////////////////////////////
// CEdGeometry implementation.
//////////////////////////////////////////////////////////////////////////
virtual EEdGeometryType GetType() const { return GEOM_TYPE_MESH; };
virtual void Serialize(CObjectArchive& ar);
virtual void GetBounds(AABB& box);
virtual CEdGeometry* Clone();
virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0);
virtual void GetTM(Matrix34* pTM, size_t idx = 0);
virtual void SetModified(bool bModified = true);
virtual bool IsModified() const { return m_bModified; };
virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags);
virtual void EndSubObjSelection();
virtual void Display(DisplayContext& dc);
virtual bool HitTest(HitContext& hit);
bool GetSelectionReferenceFrame(Matrix34& refFrame);
virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true);
virtual void AcceptModifySelection();
//////////////////////////////////////////////////////////////////////////
~CEdMesh();
// Return filename of mesh.
const QString& GetFilename() const { return m_filename; };
void SetFilename(const QString& filename);
//! Reload geometry of mesh.
void ReloadGeometry();
void AddUser();
void RemoveUser();
int GetUserCount() const { return m_nUserCount; };
//////////////////////////////////////////////////////////////////////////
void SetFlags(int nFlags) { m_nFlags = nFlags; };
int GetFlags() { return m_nFlags; }
//////////////////////////////////////////////////////////////////////////
//! Access stored IStatObj.
IStatObj* GetIStatObj() const { return m_pStatObj; }
//! Returns true if filename and geomname refer to the same object as this one.
bool IsSameObject(const char* filename);
//! RenderMesh.
void Render(SRendParams& rp, const SRenderingPassInfo& passInfo);
//! Make new CEdMesh, if same IStatObj loaded, and CEdMesh for this IStatObj is allocated.
//! This instance of CEdMesh will be returned.
static CEdMesh* LoadMesh(const char* filename);
// Creates a new mesh not from a file.
// Create a new StatObj and IndexedMesh.
static CEdMesh* CreateMesh(const char* name);
//! Reload all geometries.
static void ReloadAllGeometries();
static void ReleaseAll();
//! Check if default object was loaded.
bool IsDefaultObject();
//////////////////////////////////////////////////////////////////////////
// Copy EdMesh data to the specified mesh.
void CopyToMesh(CTriMesh& toMesh, int nCopyFlags);
// Copy EdMesh data from the specified mesh.
void CopyFromMesh(CTriMesh& fromMesh, int nCopyFlags, bool bUndo);
// Retrieve mesh class.
CTriMesh* GetMesh();
//////////////////////////////////////////////////////////////////////////
void InvalidateMesh();
void SetWorldTM(const Matrix34& worldTM);
// Save mesh into the file.
// Optionally can provide pointer to the pak file where to save files into.
void SaveToCGF(const char* sFilename, CPakFile* pPakFile = NULL, _smart_ptr<IMaterial> pMaterial = NULL);
// Draw debug representation of this mesh.
void DebugDraw(const SGeometryDebugDrawInfo& info, float fExtrdueScale = 0.01f);
private:
//////////////////////////////////////////////////////////////////////////
CEdMesh(IStatObj* pGeom);
CEdMesh();
void UpdateSubObjCache();
void UpdateIndexedMeshFromCache(bool bFast);
void OnSelectionChange();
//////////////////////////////////////////////////////////////////////////
struct SSubObjHitTestEnvironment
{
Vec3 vWSCameraPos;
Vec3 vWSCameraVector;
Vec3 vOSCameraVector;
bool bHitTestNearest;
bool bHitTestSelected;
bool bSelectOnHit;
bool bAdd;
bool bRemove;
bool bSelectValue;
bool bHighlightOnly;
bool bIgnoreBackfacing;
};
struct SSubObjHitTestResult
{
CTriMesh::EStream stream; // To What stream of the TriMesh this result apply.
MeshElementsArray elems; // List of hit elements.
float minDistance; // Minimal distance to the hit.
SSubObjHitTestResult() { minDistance = FLT_MAX; }
};
bool HitTestVertex(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
bool HitTestEdge(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
bool HitTestFace(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
// Return`s true if selection changed.
bool SelectSubObjElements(SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
bool IsHitTestResultSelected(SSubObjHitTestResult& result);
//////////////////////////////////////////////////////////////////////////
//! CGF filename.
QString m_filename;
IStatObj* m_pStatObj;
int m_nUserCount;
int m_nFlags;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
typedef std::map<QString, CEdMesh*, stl::less_stricmp<QString> > MeshMap;
static MeshMap m_meshMap;
// This cache is created when sub object selection is needed.
struct SubObjCache
{
// Cache of data in geometry.
// World space mesh.
CTriMesh* pTriMesh;
Matrix34 worldTM;
Matrix34 invWorldTM;
CBitArray m_tempBitArray;
bool bNoDisplay;
SubObjCache()
: pTriMesh(0)
, bNoDisplay(false) {};
};
SubObjCache* m_pSubObjCache;
bool m_bModified;
std::vector<IIndexedMesh*> m_tempIndexedMeshes;
std::vector<Matrix34> m_tempMatrices;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
-9
View File
@@ -85,7 +85,6 @@ namespace WinWidget
}
struct ISystem;
struct I3DEngine;
struct IRenderer;
struct AABB;
struct IEventLoopHook;
@@ -137,7 +136,6 @@ enum EEditorNotifyEvent
eNotify_OnEndLayerExport, // Sent after a layer have been exported.
eNotify_OnCloseScene, // Send when the document is about to close.
eNotify_OnSceneClosed, // Send when the document is closed.
eNotify_OnMissionChange, // Send when the current mission changes.
eNotify_OnBeginLoad, // Sent when the document is start to load.
eNotify_OnEndLoad, // Sent when the document loading is finished
@@ -180,8 +178,6 @@ enum EEditorNotifyEvent
eNotify_OnDisplayRenderUpdate, // Sent when editor finish terrain texture generation.
eNotify_OnTimeOfDayChange, // Time of day parameters where modified.
eNotify_OnDataBaseUpdate, // DataBase Library was modified.
eNotify_OnLayerImportBegin, //layer import was started
@@ -241,8 +237,6 @@ struct IDocListener
virtual void OnLoadDocument() = 0;
//! Called when document is being closed.
virtual void OnCloseDocument() = 0;
//! Called when mission changes.
virtual void OnMissionChange() = 0;
};
//! Derive from this class if you want to register for getting global editor notifications.
@@ -431,7 +425,6 @@ struct IEditor
virtual void DeleteThis() = 0;
//! Access to Editor ISystem interface.
virtual ISystem* GetSystem() = 0;
virtual I3DEngine* Get3DEngine() = 0;
virtual IRenderer* GetRenderer() = 0;
//! Access to class factory.
virtual IEditorClassFactory* GetClassFactory() = 0;
@@ -739,8 +732,6 @@ struct IEditor
typedef AZStd::function<void(QMenu*, const CBaseObject*)> TContextMenuExtensionFunc;
virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) = 0;
virtual void SetCurrentMissionTime(float time) = 0;
virtual SSystemGlobalEnvironment* GetEnv() = 0;
virtual IImageUtil* GetImageUtil() = 0; // Vladimir@conffx
virtual SEditorSettings* GetEditorSettings() = 0;
-17
View File
@@ -71,7 +71,6 @@ AZ_POP_DISABLE_WARNING
#include "BackgroundTaskManager.h"
#include "BackgroundScheduleManager.h"
#include "EditorFileMonitor.h"
#include "Mission.h"
#include "MainStatusBar.h"
#include "SettingsBlock.h"
@@ -441,15 +440,6 @@ ISystem* CEditorImpl::GetSystem()
return m_pSystem;
}
I3DEngine* CEditorImpl::Get3DEngine()
{
if (gEnv)
{
return gEnv->p3DEngine;
}
return nullptr;
}
IRenderer* CEditorImpl::GetRenderer()
{
if (gEnv)
@@ -1716,13 +1706,6 @@ void CEditorImpl::RegisterObjectContextMenuExtension(TContextMenuExtensionFunc f
m_objectContextMenuExtensions.push_back(func);
}
void CEditorImpl::SetCurrentMissionTime(float time)
{
if (CMission* pMission = GetIEditor()->GetDocument()->GetCurrentMission())
{
pMission->SetTime(time);
}
}
// Vladimir@Conffx
SSystemGlobalEnvironment* CEditorImpl::GetEnv()
{
-2
View File
@@ -116,7 +116,6 @@ public:
bool IsInitialized() const{ return m_bInitialized; }
bool SaveDocument();
ISystem* GetSystem();
I3DEngine* Get3DEngine();
IRenderer* GetRenderer();
void WriteToConsole(const char* string) { CLogFile::WriteLine(string); };
void WriteToConsole(const QString& string) { CLogFile::WriteLine(string); };
@@ -321,7 +320,6 @@ public:
void OnObjectContextMenuOpened(QMenu* pMenu, const CBaseObject* pObject);
virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) override;
virtual void SetCurrentMissionTime(float time);
virtual SSystemGlobalEnvironment* GetEnv() override;
virtual IBaseLibraryManager* GetMaterialManagerLibrary() override; // Vladimir@Conffx
virtual IEditorMaterialManager* GetIEditorMaterialManager() override; // Vladimir@Conffx
+4 -33
View File
@@ -25,6 +25,7 @@
#include "Util/Image.h"
#include "Util/ImageUtil.h"
#include <IStatObj.h>
#define HELPER_MATERIAL "Objects/Helper"
@@ -76,12 +77,11 @@ void CIconManager::Done()
//////////////////////////////////////////////////////////////////////////
void CIconManager::Reset()
{
I3DEngine* pEngine = GetIEditor()->Get3DEngine();
// Do not unload objects. but clears them.
int i;
for (i = 0; i < sizeof(m_objects) / sizeof(m_objects[0]); i++)
{
if (m_objects[i] && pEngine)
if (m_objects[i])
{
m_objects[i]->Release();
}
@@ -130,39 +130,10 @@ int CIconManager::GetIconTexture(EIcon icon)
return m_icons[icon];
}
//////////////////////////////////////////////////////////////////////////
_smart_ptr<IMaterial> CIconManager::GetHelperMaterial()
IStatObj* CIconManager::GetObject(EStatObject)
{
if (!m_pHelperMtl)
{
m_pHelperMtl = GetIEditor()->Get3DEngine()->GetMaterialManager()->LoadMaterial(HELPER_MATERIAL);
}
return m_pHelperMtl;
};
//////////////////////////////////////////////////////////////////////////
IStatObj* CIconManager::GetObject(EStatObject object)
{
assert(object >= 0 && object < eStatObject_COUNT);
if (m_objects[object])
{
return m_objects[object];
}
// Try to load this object.
m_objects[object] = GetIEditor()->Get3DEngine()->LoadStatObjUnsafeManualRef(g_ObjectNames[object], NULL, NULL, false);
if (!m_objects[object])
{
CLogFile::FormatLine("Error: Load Failed: %s", g_ObjectNames[object]);
}
m_objects[object]->AddRef();
if (GetHelperMaterial())
{
m_objects[object]->SetMaterial(GetHelperMaterial());
}
return m_objects[object];
return nullptr;
}
//////////////////////////////////////////////////////////////////////////
-4
View File
@@ -51,7 +51,6 @@ public:
virtual IStatObj* GetObject(EStatObject object);
virtual int GetIconTexture(const char* iconName);
virtual _smart_ptr<IMaterial> GetHelperMaterial();
//////////////////////////////////////////////////////////////////////////
// Icon bitmaps.
@@ -64,14 +63,11 @@ public:
virtual void OnNewDocument() { Reset(); };
virtual void OnLoadDocument() { Reset(); };
virtual void OnCloseDocument() { Reset(); };
virtual void OnMissionChange() { Reset(); };
//////////////////////////////////////////////////////////////////////////
private:
StdMap<QString, int> m_textures;
_smart_ptr<IMaterial> m_pHelperMtl;
IStatObj* m_objects[eStatObject_COUNT];
int m_icons[eIcon_COUNT];
@@ -61,7 +61,6 @@ struct IIconManager
virtual IStatObj* GetObject(EStatObject object) = 0;
virtual int GetIconTexture(EIcon icon) = 0;
virtual int GetIconTexture(const char* iconName) = 0;
virtual _smart_ptr<IMaterial> GetHelperMaterial() = 0;
virtual QImage* GetIconBitmap(const char* filename, bool& haveAlpha, uint32 effects = 0) = 0;
// Register an Icon for the specific command
virtual void RegisterCommandIcon([[maybe_unused]] const char* filename, [[maybe_unused]] int nCommandId) {}

Some files were not shown because too many files have changed in this diff Show More