update according to code review
This commit is contained in:
parent
f45f563906
commit
f2c5e68415
10 changed files with 40 additions and 27 deletions
|
@ -25,6 +25,7 @@ namespace Lux
|
|||
operator string() const { return string(m_path); }
|
||||
|
||||
const char* c_str() const { return m_path; }
|
||||
int length() const { return strlen(m_path); }
|
||||
|
||||
bool operator == (const Path& rhs) const { return m_id == rhs.m_id; }
|
||||
bool operator == (const char* rhs) const { Path path(rhs); return m_id == path.m_id; }
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Lux
|
|||
uint32_t i = 0;
|
||||
while (*path != '\0' && i < max_size)
|
||||
{
|
||||
*out = *path == '/' ? '\\' : *path;
|
||||
*out = *path == '\\' ? '/' : *path;
|
||||
*out = *path >= 'A' && *path <= 'Z' ? *path - 'A' + 'a' : *out;
|
||||
|
||||
path++;
|
||||
|
|
|
@ -146,7 +146,7 @@ class PODArray
|
|||
}
|
||||
}
|
||||
|
||||
const T& operator[] (int index) const { ASSERT(index < m_size); return m_data[index]; }
|
||||
const T& operator[] (int index) const { ASSERT(index >= 0 && index < m_size); return m_data[index]; }
|
||||
T& operator[](int index) { ASSERT(index >= 0 && index < m_size); return m_data[index]; }
|
||||
int size() const { return m_size; }
|
||||
int capacity() const { return m_capacity; }
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "core/array.h"
|
||||
#include "core/free_list.h"
|
||||
#include "core/os_file.h"
|
||||
#include "core/path.h"
|
||||
#include "core/static_array.h"
|
||||
#include "core/string.h"
|
||||
#include "core/tcp_file_device.h"
|
||||
|
@ -50,7 +51,7 @@ namespace Lux
|
|||
string path;
|
||||
if (strncmp(m_buffer.data(), m_base_path.c_str(), m_base_path.length()) != 0)
|
||||
{
|
||||
path = m_base_path;
|
||||
path = m_base_path.c_str();
|
||||
path += m_buffer.data();
|
||||
}
|
||||
else
|
||||
|
@ -168,11 +169,12 @@ namespace Lux
|
|||
void stop() {} // TODO: implement stop
|
||||
void setBasePath(const char* base_path)
|
||||
{
|
||||
m_base_path = base_path;
|
||||
if (m_base_path[m_base_path.length() - 1] != '/')
|
||||
string base_path_str(base_path);
|
||||
if (base_path_str[base_path_str.length() - 1] != '/')
|
||||
{
|
||||
m_base_path += "/";
|
||||
base_path_str += "/";
|
||||
}
|
||||
m_base_path = base_path_str;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -180,7 +182,7 @@ namespace Lux
|
|||
StaticArray<char, 0x50000> m_buffer;
|
||||
StaticArray<OsFile*, 0x50000> m_files;
|
||||
FreeList<int32_t, 0x50000> m_ids;
|
||||
string m_base_path;
|
||||
Path m_base_path;
|
||||
};
|
||||
|
||||
struct TCPFileServerImpl
|
||||
|
|
|
@ -57,7 +57,9 @@ void EditorIcon::render(Renderer* renderer, IRenderDevice& render_device)
|
|||
Component camera = render_device.getPipeline().getCamera(0);
|
||||
Lux::Matrix mtx = camera.entity.getMatrix();
|
||||
|
||||
float scale = /*renderer->getHalfFovTan()*/ 0.0333f * (m_entity.getPosition() - mtx.getTranslation()).length() * 2;
|
||||
float fov;
|
||||
renderer->getCameraFov(camera, fov);
|
||||
float scale = tan(fov * 0.5f) * (m_entity.getPosition() - mtx.getTranslation()).length() * 2;
|
||||
|
||||
mtx.setTranslation(m_entity.getPosition());
|
||||
Matrix scale_mtx = Matrix::IDENTITY;
|
||||
|
@ -67,10 +69,10 @@ void EditorIcon::render(Renderer* renderer, IRenderDevice& render_device)
|
|||
glPushMatrix();
|
||||
glMultMatrixf(&mtx.m11);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(0, 0, 0);
|
||||
glVertex3f(0, 1, 0);
|
||||
glVertex3f(1, 1, 0);
|
||||
glVertex3f(1, 0, 0);
|
||||
glVertex3f(-0.015f, -0.015f, 0);
|
||||
glVertex3f(-0.015f, 0.015f, 0);
|
||||
glVertex3f(0.015f, 0.015f, 0);
|
||||
glVertex3f(0.015f, -0.015f, 0);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -867,7 +867,7 @@ void EditorServerImpl::renderScene(IRenderDevice& render_device)
|
|||
m_engine.getRenderer().render(render_device);
|
||||
for(int i = 0, c = m_editor_icons.size(); i < c; ++i)
|
||||
{
|
||||
// m_editor_icons[i]->render(&m_engine.getRenderer(), render_device);
|
||||
m_editor_icons[i]->render(&m_engine.getRenderer(), render_device);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1160,7 +1160,7 @@ void EditorServerImpl::createUniverse(bool create_scene, const char* base_path)
|
|||
m_camera.setRotation(Quat(Vec3(0, 1, 0), -Math::PI));
|
||||
Component cmp = m_engine.getRenderer().createComponent(camera_type, m_camera);
|
||||
|
||||
Entity light = m_engine.getUniverse()->createEntity();
|
||||
/*Entity light = m_engine.getUniverse()->createEntity();
|
||||
Matrix mtx = Matrix::IDENTITY;
|
||||
mtx.setXVector(Vec3(1, 0, 0));
|
||||
mtx.setYVector(Vec3(0, -1, 1).normalized());
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <cstdio>
|
||||
#include <Windows.h>
|
||||
#include "core/crc32.h"
|
||||
#include "core/path_utils.h"
|
||||
#include "editor/editor_client.h"
|
||||
#include "editor/server_message_types.h"
|
||||
#include "editor_native/main_frame.h"
|
||||
|
@ -69,16 +70,7 @@ void RenderableUI::browseSource(Lux::UI::Block& block, void*)
|
|||
strcpy_s(buf, buf + s.length());
|
||||
}
|
||||
}
|
||||
/// TODO make this function
|
||||
char* c = buf;
|
||||
while(*c)
|
||||
{
|
||||
if(*c == '\\')
|
||||
{
|
||||
*c = '/';
|
||||
}
|
||||
++c;
|
||||
}
|
||||
Lux::PathUtils::normalize(buf, buf, MAX_PATH);
|
||||
m_source_box->getChild(0)->setBlockText(buf);
|
||||
m_source_box->getChild(0)->emitEvent("text_accepted");
|
||||
}
|
||||
|
|
|
@ -318,10 +318,14 @@ struct PipelineImpl : public Pipeline
|
|||
|
||||
void renderShadowmap()
|
||||
{
|
||||
Component light_cmp = m_renderer.getLight(0);
|
||||
if (!light_cmp.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
glEnable(GL_CULL_FACE);
|
||||
m_shadowmap_framebuffer->bind();
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
Component light_cmp = m_renderer.getLight(0);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
@ -503,8 +507,9 @@ void UnbindFramebufferCommand::execute(PipelineImpl& pipeline)
|
|||
|
||||
void DrawFullscreenQuadCommand::deserialize(PipelineImpl& pipeline, ISerializer& serializer)
|
||||
{
|
||||
char material[100];
|
||||
serializer.deserializeArrayItem(material, 100);
|
||||
const int MATERIAL_NAME_MAX_LENGTH = 100;
|
||||
char material[MATERIAL_NAME_MAX_LENGTH];
|
||||
serializer.deserializeArrayItem(material, MATERIAL_NAME_MAX_LENGTH);
|
||||
char material_path[MAX_PATH];
|
||||
strcpy(material_path, "materials/");
|
||||
strcat(material_path, material);
|
||||
|
|
|
@ -203,6 +203,12 @@ struct RendererImpl : public Renderer
|
|||
}
|
||||
|
||||
|
||||
virtual void getCameraFov(Component cmp, float& fov) LUX_OVERRIDE
|
||||
{
|
||||
fov = m_cameras[cmp.index]->m_fov;
|
||||
}
|
||||
|
||||
|
||||
virtual void getRenderablePath(Component cmp, string& path) LUX_OVERRIDE
|
||||
{
|
||||
if(m_renderables[cmp.index].m_model)
|
||||
|
@ -266,6 +272,10 @@ struct RendererImpl : public Renderer
|
|||
|
||||
virtual Component getLight(int index) LUX_OVERRIDE
|
||||
{
|
||||
if (index >= m_lights.size())
|
||||
{
|
||||
return Component::INVALID;
|
||||
}
|
||||
return Component(m_lights[index].m_entity, crc32("light"), this, index);
|
||||
};
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ class LUX_ENGINE_API Renderer : public IPlugin
|
|||
virtual void setRenderablePath(Component cmp, const string& path) = 0;
|
||||
virtual void getRenderablePath(Component cmp, string& path) = 0;
|
||||
virtual void getRenderableInfos(PODArray<RenderableInfo>& infos) = 0;
|
||||
virtual void getCameraFov(Component cmp, float& fov) = 0;
|
||||
virtual Pipeline* loadPipeline(const char* path) = 0;
|
||||
virtual Engine& getEngine() = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue