Fix creating virtual terrain collision of actor that is not in a game
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "Engine/Graphics/RenderView.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Graphics/Textures/GPUTexture.h"
|
||||
#include "Engine/Physics/PhysicsScene.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Renderer/GlobalSignDistanceFieldPass.h"
|
||||
#include "Engine/Renderer/GI/GlobalSurfaceAtlasPass.h"
|
||||
@@ -807,6 +808,15 @@ void Terrain::OnEnable()
|
||||
#if TERRAIN_USE_PHYSICS_DEBUG
|
||||
GetSceneRendering()->AddPhysicsDebug<Terrain, &Terrain::DrawPhysicsDebug>(this);
|
||||
#endif
|
||||
void* scene = GetPhysicsScene()->GetPhysicsScene();
|
||||
for (int32 i = 0; i < _patches.Count(); i++)
|
||||
{
|
||||
auto patch = _patches[i];
|
||||
if (patch->_physicsActor)
|
||||
{
|
||||
PhysicsBackend::AddSceneActor(scene, patch->_physicsActor);
|
||||
}
|
||||
}
|
||||
|
||||
// Base
|
||||
Actor::OnEnable();
|
||||
|
||||
@@ -2126,7 +2126,8 @@ void TerrainPatch::CreateCollision()
|
||||
void* scene = _terrain->GetPhysicsScene()->GetPhysicsScene();
|
||||
_physicsActor = PhysicsBackend::CreateRigidStaticActor(nullptr, terrainTransform.LocalToWorld(_offset), terrainTransform.Orientation, scene);
|
||||
PhysicsBackend::AttachShape(_physicsShape, _physicsActor);
|
||||
PhysicsBackend::AddSceneActor(scene, _physicsActor);
|
||||
if (_terrain->IsDuringPlay())
|
||||
PhysicsBackend::AddSceneActor(scene, _physicsActor);
|
||||
}
|
||||
|
||||
bool TerrainPatch::CreateHeightField()
|
||||
|
||||
Reference in New Issue
Block a user