update according to review
This commit is contained in:
parent
91fae0376d
commit
11acbfc710
5 changed files with 48 additions and 119 deletions
|
@ -1,82 +1,43 @@
|
|||
#include "gameview.h"
|
||||
|
||||
#include "ui_gameview.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "editor/editor_client.h"
|
||||
|
||||
#include "graphics/pipeline.h"
|
||||
|
||||
|
||||
|
||||
GameView::GameView(QWidget* parent) :
|
||||
|
||||
QDockWidget(parent),
|
||||
|
||||
m_ui(new Ui::GameView)
|
||||
|
||||
{
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_pipeline = NULL;
|
||||
|
||||
m_client = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
GameView::~GameView()
|
||||
|
||||
{
|
||||
|
||||
delete m_ui;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QWidget* GameView::getContentWidget() const
|
||||
|
||||
{
|
||||
|
||||
return m_ui->viewFrame;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GameView::resizeEvent(QResizeEvent* event)
|
||||
|
||||
{
|
||||
|
||||
int w = event->size().width();
|
||||
|
||||
int h = event->size().height();
|
||||
|
||||
if (m_pipeline)
|
||||
|
||||
{
|
||||
|
||||
m_pipeline->resize(w, h);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GameView::on_playButton_clicked()
|
||||
|
||||
{
|
||||
|
||||
m_client->toggleGameMode();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,62 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
|
||||
|
||||
namespace Ui
|
||||
|
||||
{
|
||||
|
||||
class LogWidget;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class LogWidget : public QDockWidget
|
||||
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
explicit LogWidget(QWidget* parent = NULL);
|
||||
|
||||
~LogWidget();
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
void infoReceived(const QString& system, const QString& message);
|
||||
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
void on_clearButton_clicked();
|
||||
|
||||
void onInfoReceived(const QString& system, const QString& message);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void onInfo(const char* system, const char* message);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Ui::LogWidget* m_ui;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -197,8 +197,8 @@ namespace Lumix
|
|||
{
|
||||
uint8_t data[12];
|
||||
*(float*)data = forward;
|
||||
*(float*)(data+4) = right;
|
||||
*(float*)(data+8) = speed;
|
||||
*(float*)(data + 4) = right;
|
||||
*(float*)(data + 8) = speed;
|
||||
m_impl->sendMessage(ClientMessageType::MOVE_CAMERA, data, 12);
|
||||
}
|
||||
|
||||
|
|
|
@ -550,19 +550,18 @@ struct PipelineInstanceImpl : public PipelineInstance
|
|||
{
|
||||
if (m_active_camera.isValid())
|
||||
{
|
||||
static Array<TerrainInfo> terrain_infos;
|
||||
terrain_infos.clear();
|
||||
m_scene->getTerrainInfos(terrain_infos, layer_mask);
|
||||
m_terrain_infos.clear();
|
||||
m_scene->getTerrainInfos(m_terrain_infos, layer_mask);
|
||||
Vec3 camera_position = m_active_camera.entity.getPosition();
|
||||
for (int i = 0; i < terrain_infos.size(); ++i)
|
||||
for (int i = 0; i < m_terrain_infos.size(); ++i)
|
||||
{
|
||||
if (terrain_infos[i].m_material)
|
||||
if (m_terrain_infos[i].m_material)
|
||||
{
|
||||
if (terrain_infos[i].m_material->getShader())
|
||||
if (m_terrain_infos[i].m_material->getShader())
|
||||
{
|
||||
Matrix world_matrix;
|
||||
terrain_infos[i].m_entity.getMatrix(world_matrix);
|
||||
Shader* shader = terrain_infos[i].m_material->getShader();
|
||||
m_terrain_infos[i].m_entity.getMatrix(world_matrix);
|
||||
Shader* shader = m_terrain_infos[i].m_material->getShader();
|
||||
shader->setUniform("world_matrix", world_matrix);
|
||||
shader->setUniform("shadowmap_matrix0", m_shadow_modelviewprojection[0]);
|
||||
shader->setUniform("shadowmap_matrix1", m_shadow_modelviewprojection[1]);
|
||||
|
@ -571,11 +570,11 @@ struct PipelineInstanceImpl : public PipelineInstance
|
|||
shader->setUniform("light_dir", m_light_dir);
|
||||
|
||||
Vec3 scale;
|
||||
scale.x = terrain_infos[i].m_xz_scale;
|
||||
scale.y = terrain_infos[i].m_y_scale;
|
||||
scale.x = m_terrain_infos[i].m_xz_scale;
|
||||
scale.y = m_terrain_infos[i].m_y_scale;
|
||||
scale.z = scale.x;
|
||||
terrain_infos[i].m_material->getShader()->setUniform("terrain_scale", scale);
|
||||
m_scene->renderTerrain(terrain_infos[i], *m_renderer, *this, camera_position);
|
||||
m_terrain_infos[i].m_material->getShader()->setUniform("terrain_scale", scale);
|
||||
m_scene->renderTerrain(m_terrain_infos[i], *m_renderer, *this, camera_position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -676,6 +675,7 @@ struct PipelineInstanceImpl : public PipelineInstance
|
|||
int m_height;
|
||||
Map<uint32_t, CustomCommandHandler> m_custom_commands_handlers;
|
||||
Component m_active_camera;
|
||||
Array<TerrainInfo> m_terrain_infos;
|
||||
|
||||
private:
|
||||
void operator=(const PipelineInstanceImpl&);
|
||||
|
|
|
@ -147,7 +147,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
Component createHeightfield(Entity entity)
|
||||
virtual Component createHeightfield(Entity entity) override
|
||||
{
|
||||
Terrain* terrain = LUMIX_NEW(Terrain);
|
||||
m_terrains.push(terrain);
|
||||
|
@ -161,7 +161,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
Component createController(Entity entity)
|
||||
virtual Component createController(Entity entity) override
|
||||
{
|
||||
physx::PxCapsuleControllerDesc cDesc;
|
||||
cDesc.material = m_default_material;
|
||||
|
@ -186,7 +186,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
Component createBoxRigidActor(Entity entity)
|
||||
virtual Component createBoxRigidActor(Entity entity) override
|
||||
{
|
||||
RigidActor* actor = LUMIX_NEW(RigidActor);
|
||||
m_actors.push(actor);
|
||||
|
@ -214,7 +214,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
Component createMeshRigidActor(Entity entity)
|
||||
virtual Component createMeshRigidActor(Entity entity) override
|
||||
{
|
||||
RigidActor* actor = LUMIX_NEW(RigidActor);
|
||||
m_actors.push(actor);
|
||||
|
@ -227,19 +227,19 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void getHeightmap(Component cmp, string& str)
|
||||
virtual void getHeightmap(Component cmp, string& str) override
|
||||
{
|
||||
str = m_terrains[cmp.index]->m_heightmap ? m_terrains[cmp.index]->m_heightmap->getPath().c_str() : "";
|
||||
}
|
||||
|
||||
|
||||
void getHeightmapXZScale(Component cmp, float& scale)
|
||||
virtual void getHeightmapXZScale(Component cmp, float& scale) override
|
||||
{
|
||||
scale = m_terrains[cmp.index]->m_xz_scale;
|
||||
}
|
||||
|
||||
|
||||
void setHeightmapXZScale(Component cmp, const float& scale)
|
||||
virtual void setHeightmapXZScale(Component cmp, const float& scale) override
|
||||
{
|
||||
if (scale != m_terrains[cmp.index]->m_xz_scale)
|
||||
{
|
||||
|
@ -249,13 +249,13 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void getHeightmapYScale(Component cmp, float& scale)
|
||||
virtual void getHeightmapYScale(Component cmp, float& scale) override
|
||||
{
|
||||
scale = m_terrains[cmp.index]->m_y_scale;
|
||||
}
|
||||
|
||||
|
||||
void setHeightmapYScale(Component cmp, const float& scale)
|
||||
virtual void setHeightmapYScale(Component cmp, const float& scale) override
|
||||
{
|
||||
if (scale != m_terrains[cmp.index]->m_y_scale)
|
||||
{
|
||||
|
@ -268,7 +268,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void setHeightmap(Component cmp, const string& str)
|
||||
virtual void setHeightmap(Component cmp, const string& str) override
|
||||
{
|
||||
if (m_terrains[cmp.index]->m_heightmap)
|
||||
{
|
||||
|
@ -285,13 +285,13 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void getShapeSource(Component cmp, string& str)
|
||||
virtual void getShapeSource(Component cmp, string& str) override
|
||||
{
|
||||
str = m_actors[cmp.index]->m_source;
|
||||
}
|
||||
|
||||
|
||||
void setShapeSource(Component cmp, const string& str)
|
||||
virtual void setShapeSource(Component cmp, const string& str) override
|
||||
{
|
||||
bool is_dynamic = false;
|
||||
getIsDynamic(cmp, is_dynamic);
|
||||
|
@ -417,18 +417,18 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void render()
|
||||
virtual void render() override
|
||||
{
|
||||
m_scene->getNbActors(physx::PxActorTypeSelectionFlag::eRIGID_STATIC);
|
||||
const physx::PxRenderBuffer& rb = m_scene->getRenderBuffer();
|
||||
const physx::PxU32 numLines = rb.getNbLines();
|
||||
const physx::PxU32 numPoints = rb.getNbPoints();
|
||||
const physx::PxU32 numTri = rb.getNbTriangles();
|
||||
if (numLines)
|
||||
const physx::PxU32 num_lines = rb.getNbLines();
|
||||
const physx::PxU32 num_points = rb.getNbPoints();
|
||||
const physx::PxU32 num_tri = rb.getNbTriangles();
|
||||
if (num_lines)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
const physx::PxDebugLine* PX_RESTRICT lines = rb.getLines();
|
||||
for (physx::PxU32 i = 0; i<numLines; i++)
|
||||
for (physx::PxU32 i = 0; i < num_lines; ++i)
|
||||
{
|
||||
const physx::PxDebugLine& line = lines[i];
|
||||
GLubyte bytes[3];
|
||||
|
@ -444,7 +444,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void update(float time_delta)
|
||||
virtual void update(float time_delta) override
|
||||
{
|
||||
time_delta = 0.01f;
|
||||
m_scene->simulate(time_delta);
|
||||
|
@ -466,13 +466,13 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void moveController(Component cmp, const Vec3& v, float dt)
|
||||
virtual void moveController(Component cmp, const Vec3& v, float dt) override
|
||||
{
|
||||
m_controllers[cmp.index].m_controller->move(physx::PxVec3(v.x, v.y, v.z), 0.001f, dt, physx::PxControllerFilters());
|
||||
}
|
||||
|
||||
|
||||
bool raycast(const Vec3& origin, const Vec3& dir, float distance, RaycastHit& result)
|
||||
virtual bool raycast(const Vec3& origin, const Vec3& dir, float distance, RaycastHit& result) override
|
||||
{
|
||||
physx::PxVec3 physx_origin(origin.x, origin.y, origin.z);
|
||||
physx::PxVec3 unit_dir(dir.x, dir.y, dir.z);
|
||||
|
@ -516,14 +516,12 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
{
|
||||
m_actors[cmps[i].index]->m_physx_actor->setGlobalPose(trans, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (cmps[i].type == CONTROLLER_HASH)
|
||||
{
|
||||
Vec3 pos = entity.getPosition();
|
||||
physx::PxExtendedVec3 pvec(pos.x, pos.y, pos.z);
|
||||
m_controllers[cmps[i].index].m_controller->setPosition(pvec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -569,7 +567,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
}
|
||||
|
||||
terrain->m_heightmap->removeDataReference();
|
||||
//terrain->m_heightmap->removeDataReference();
|
||||
|
||||
physx::PxHeightFieldDesc hfDesc;
|
||||
hfDesc.format = physx::PxHeightFieldFormat::eS16_TM;
|
||||
|
@ -625,13 +623,13 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void getIsDynamic(Component cmp, bool& is)
|
||||
virtual void getIsDynamic(Component cmp, bool& is) override
|
||||
{
|
||||
is = isDynamic(cmp.index);
|
||||
}
|
||||
|
||||
|
||||
void getHalfExtents(Component cmp, Vec3& size)
|
||||
virtual void getHalfExtents(Component cmp, Vec3& size) override
|
||||
{
|
||||
physx::PxRigidActor* actor = m_actors[cmp.index]->m_physx_actor;
|
||||
physx::PxShape* shapes;
|
||||
|
@ -645,7 +643,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void setHalfExtents(Component cmp, const Vec3& size)
|
||||
virtual void setHalfExtents(Component cmp, const Vec3& size) override
|
||||
{
|
||||
physx::PxRigidActor* actor = m_actors[cmp.index]->m_physx_actor;
|
||||
physx::PxShape* shapes;
|
||||
|
@ -663,7 +661,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void setIsDynamic(Component cmp, const bool& is)
|
||||
virtual void setIsDynamic(Component cmp, const bool& new_value) override
|
||||
{
|
||||
int dynamic_index = -1;
|
||||
RigidActor* actor = m_actors[cmp.index];
|
||||
|
@ -676,9 +674,9 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
}
|
||||
bool is_dynamic = dynamic_index != -1;
|
||||
if (is_dynamic != is)
|
||||
if (is_dynamic != new_value)
|
||||
{
|
||||
if (is)
|
||||
if (new_value)
|
||||
{
|
||||
m_dynamic_actors.push(actor);
|
||||
}
|
||||
|
@ -695,7 +693,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
matrix2Transform(cmp.entity.getMatrix(), transform);
|
||||
|
||||
physx::PxRigidActor* actor;
|
||||
if (is)
|
||||
if (new_value)
|
||||
{
|
||||
actor = PxCreateDynamic(*m_system->m_impl->m_physics, transform, geom.any(), *m_default_material, 1.0f);
|
||||
}
|
||||
|
@ -703,6 +701,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
{
|
||||
actor = PxCreateStatic(*m_system->m_impl->m_physics, transform, geom.any(), *m_default_material);
|
||||
}
|
||||
ASSERT(actor);
|
||||
m_scene->removeActor(*m_actors[cmp.index]->m_physx_actor);
|
||||
m_actors[cmp.index]->m_physx_actor->release();
|
||||
m_scene->addActor(*actor);
|
||||
|
@ -782,7 +781,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void serialize(ISerializer& serializer)
|
||||
virtual void serialize(ISerializer& serializer) override
|
||||
{
|
||||
serializer.serialize("count", m_actors.size());
|
||||
serializer.beginArray("actors");
|
||||
|
@ -916,7 +915,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void deserialize(ISerializer& serializer)
|
||||
virtual void deserialize(ISerializer& serializer) override
|
||||
{
|
||||
deserializeActors(serializer);
|
||||
deserializeControllers(serializer);
|
||||
|
@ -924,7 +923,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
PhysicsSystem& getSystem() const
|
||||
virtual PhysicsSystem& getSystem() const override
|
||||
{
|
||||
return *m_system;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue