Change LOAD_LEGACY_RENDERER_FOR_EDITOR from true -> false (#315)
Change LOAD_LEGACY_RENDERER_FOR_EDITOR from true -> false, and added some null checks to protect against gEnv->pRenderer and gEnv->p3DEngine now being null in the editor as well as the launcher.
This commit is contained in:
@@ -247,7 +247,7 @@ CUNIXConsole* pUnixConsole;
|
||||
|
||||
#define LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME "Libs/Localization/localization.xml"
|
||||
|
||||
#define LOAD_LEGACY_RENDERER_FOR_EDITOR true // If you set this to false you must for now also set 'ed_useAtomNativeViewport' to true (see /Code/Sandbox/Editor/ViewManager.cpp)
|
||||
#define LOAD_LEGACY_RENDERER_FOR_EDITOR false // If you set this to true you must also set 'ed_useAtomNativeViewport' to false (see /Code/Sandbox/Editor/ViewManager.cpp)
|
||||
#define LOAD_LEGACY_RENDERER_FOR_LAUNCHER false
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -232,7 +232,6 @@ int EditorViewportWidget::OnCreate()
|
||||
{
|
||||
m_renderer = GetIEditor()->GetRenderer();
|
||||
m_engine = GetIEditor()->Get3DEngine();
|
||||
assert(m_engine);
|
||||
|
||||
CreateRenderContext();
|
||||
|
||||
@@ -793,8 +792,14 @@ void EditorViewportWidget::OnRender()
|
||||
// This is necessary so that automated editor tests using the null renderer to test systems like dynamic vegetation
|
||||
// are still able to manipulate the current logical camera position, even if nothing is rendered.
|
||||
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
|
||||
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
|
||||
m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
|
||||
if (GetIEditor()->GetRenderer())
|
||||
{
|
||||
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
|
||||
}
|
||||
if (m_engine)
|
||||
{
|
||||
m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -886,7 +891,7 @@ void EditorViewportWidget::OnBeginPrepareRender()
|
||||
fov = 2 * atanf((h * tan(fov / 2)) / maxTargetHeight);
|
||||
}
|
||||
}
|
||||
m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance());
|
||||
m_Camera.SetFrustum(w, h, fov, fNearZ);
|
||||
}
|
||||
|
||||
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
|
||||
@@ -2606,8 +2611,7 @@ bool EditorViewportWidget::GetActiveCameraPosition(AZ::Vector3& cameraPos)
|
||||
{
|
||||
if (GetIEditor()->IsInGameMode())
|
||||
{
|
||||
const Vec3 camPos = m_engine->GetRenderingCamera().GetPosition();
|
||||
cameraPos = LYVec3ToAZVec3(camPos);
|
||||
cameraPos = m_renderViewport->GetViewportContext()->GetCameraTransform().GetTranslation();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -525,6 +525,11 @@ void CMaterialManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CMaterialManager::ReloadDirtyMaterials()
|
||||
{
|
||||
if (!GetIEditor()->Get3DEngine())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IMaterialManager* runtimeMaterialManager = GetIEditor()->Get3DEngine()->GetMaterialManager();
|
||||
|
||||
uint32 mtlCount = 0;
|
||||
@@ -743,12 +748,15 @@ int CMaterialManager::GetHighlightFlags(CMaterial* pMaterial) const
|
||||
result |= eHighlight_NoSurfaceType;
|
||||
}
|
||||
|
||||
if (ISurfaceTypeManager* pSurfaceManager = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetSurfaceTypeManager())
|
||||
if (GetIEditor()->Get3DEngine())
|
||||
{
|
||||
const ISurfaceType* pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(surfaceTypeName.toUtf8().data());
|
||||
if (pSurfaceType && pSurfaceType->GetBreakability() != 0)
|
||||
if (ISurfaceTypeManager* pSurfaceManager = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetSurfaceTypeManager())
|
||||
{
|
||||
result |= eHighlight_Breakable;
|
||||
const ISurfaceType* pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(surfaceTypeName.toUtf8().data());
|
||||
if (pSurfaceType && pSurfaceType->GetBreakability() != 0)
|
||||
{
|
||||
result |= eHighlight_Breakable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -805,7 +805,10 @@ namespace LmbrCentral
|
||||
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
gEnv->p3DEngine->FreeRenderNodeState(&m_cubemapPreview);
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->FreeRenderNodeState(&m_cubemapPreview);
|
||||
}
|
||||
|
||||
m_light.DestroyRenderLight();
|
||||
m_light.SetEntity(AZ::EntityId());
|
||||
@@ -903,6 +906,11 @@ namespace LmbrCentral
|
||||
|
||||
void EditorLightComponent::OnViewCubemapChanged()
|
||||
{
|
||||
if (!gEnv->p3DEngine)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_viewCubemap)
|
||||
{
|
||||
gEnv->p3DEngine->RegisterEntity(&m_cubemapPreview);
|
||||
@@ -1944,6 +1952,11 @@ namespace LmbrCentral
|
||||
AzToolsFramework::EditorRequestBus::BroadcastResult(m_editor, &AzToolsFramework::EditorRequests::GetEditor);
|
||||
}
|
||||
|
||||
if (!m_editor->Get3DEngine())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_materialManager)
|
||||
{
|
||||
m_materialManager = m_editor->Get3DEngine()->GetMaterialManager();
|
||||
|
||||
@@ -136,13 +136,16 @@ namespace
|
||||
const char* texturePath = configuration.m_projectorTexture.GetAssetPath().c_str();
|
||||
const int flags = FT_DONT_STREAM;
|
||||
|
||||
lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture(texturePath, flags);
|
||||
|
||||
if (!lightParams.m_pLightImage || !lightParams.m_pLightImage->IsTextureLoaded())
|
||||
if (gEnv->pRenderer)
|
||||
{
|
||||
GetISystem()->Warning(VALIDATOR_MODULE_RENDERER, VALIDATOR_WARNING, 0, texturePath,
|
||||
"Light projector texture not found: %s", texturePath);
|
||||
lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture("Textures/defaults/red.dds", flags);
|
||||
lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture(texturePath, flags);
|
||||
|
||||
if (!lightParams.m_pLightImage || !lightParams.m_pLightImage->IsTextureLoaded())
|
||||
{
|
||||
GetISystem()->Warning(VALIDATOR_MODULE_RENDERER, VALIDATOR_WARNING, 0, texturePath,
|
||||
"Light projector texture not found: %s", texturePath);
|
||||
lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture("Textures/defaults/red.dds", flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -180,8 +183,11 @@ namespace
|
||||
diffuseMap.insert(dotPos, "_diff");
|
||||
}
|
||||
|
||||
lightParams.SetSpecularCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(specularMap.c_str(), FT_DONT_STREAM));
|
||||
lightParams.SetDiffuseCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(diffuseMap.c_str(), FT_DONT_STREAM));
|
||||
if (gEnv->pRenderer)
|
||||
{
|
||||
lightParams.SetSpecularCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(specularMap.c_str(), FT_DONT_STREAM));
|
||||
lightParams.SetDiffuseCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(diffuseMap.c_str(), FT_DONT_STREAM));
|
||||
}
|
||||
|
||||
if (lightParams.GetDiffuseCubemap() && lightParams.GetSpecularCubemap())
|
||||
{
|
||||
@@ -401,7 +407,7 @@ namespace LmbrCentral
|
||||
template <typename ConfigurationType, typename ConfigToLightParamsFunc>
|
||||
void LightInstance::CreateRenderLightInternal(const ConfigurationType& configuration, ConfigToLightParamsFunc configToLightParams)
|
||||
{
|
||||
if (m_renderLight || !configuration.m_visible)
|
||||
if (m_renderLight || !configuration.m_visible || !gEnv->p3DEngine)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user