Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions engine/includes/components/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ class ENGINE_EXPORT Actor : public Object {
)

public:
enum HideFlags {
ENABLE = (1<<0),
SELECTABLE = (1<<1)
enum Flags {
Enable = (1<<0),
Selectable = (1<<1),
NonSerializable = (1<<2),
Static = (1<<3)
};

public:
Expand Down Expand Up @@ -62,8 +64,8 @@ class ENGINE_EXPORT Actor : public Object {
bool isEnabled() const;
void setEnabled(const bool enabled);

int hideFlags() const;
void setHideFlags(int flags);
int flags() const;
void setFlags(int flags);

bool isEnabledInHierarchy() const;

Expand Down Expand Up @@ -120,8 +122,6 @@ class ENGINE_EXPORT Actor : public Object {

bool m_hierarchyEnable;

bool m_static;

bool m_muteUpdates;

};
Expand Down
5 changes: 5 additions & 0 deletions engine/includes/components/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class ENGINE_EXPORT Camera : public Component {
bool orthographic() const;
void setOrthographic(const bool mode);

bool isScreenSpace() const;
void setScreenSpace(bool mode);

static Camera *current();
static void setCurrent(Camera *current);

Expand Down Expand Up @@ -100,6 +103,8 @@ class ENGINE_EXPORT Camera : public Component {

bool m_ortho;

bool m_screen;

};

#endif // CAMERA_H
5 changes: 5 additions & 0 deletions engine/includes/editor/viewport/tasks/gridrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class GridRender : public PipelineTask {
} break;
default: break;
}

if(camera->isScreenSpace()) {
pos += planeScale * 0.5f;
}

} else {
Ray ray = camera->castRay(0.0f, 0.0f);

Expand Down
29 changes: 16 additions & 13 deletions engine/src/components/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ Actor::Actor() :
m_prefab(nullptr),
m_scene(nullptr),
m_layers(CommandBuffer::DEFAULT | CommandBuffer::RAYCAST | CommandBuffer::SHADOWCAST | CommandBuffer::TRANSLUCENT),
m_flags(Actor::ENABLE | Actor::SELECTABLE),
m_hierarchyEnable(m_flags & Actor::ENABLE),
m_static(false),
m_flags(Actor::Enable | Actor::Selectable),
m_hierarchyEnable(m_flags & Actor::Enable),
m_muteUpdates(false) {

}
Expand All @@ -91,7 +90,7 @@ Actor::~Actor() {
*/
bool Actor::isEnabled() const {
PROFILE_FUNCTION();
return m_flags & ENABLE;
return m_flags & Enable;
}
/*!
Marks this Actor as \a enabled or disabled.
Expand All @@ -100,9 +99,9 @@ bool Actor::isEnabled() const {
void Actor::setEnabled(const bool enabled) {
PROFILE_FUNCTION();
if(enabled) {
m_flags |= ENABLE;
m_flags |= Enable;
} else {
m_flags &= ~ENABLE;
m_flags &= ~Enable;
}

setHierarchyEnabled(enabled);
Expand All @@ -112,17 +111,17 @@ void Actor::setEnabled(const bool enabled) {
}
}
/*!
Returns a set of Actor::HideFlags applied to this Actor.
Returns a set of Actor::Flags applied to this Actor.
*/
int Actor::hideFlags() const {
int Actor::flags() const {
PROFILE_FUNCTION();

return m_flags;
}
/*!
Applies a new set of Actor::HideFlags \a flags to this Actor.
Applies a new set of Actor::Flags \a flags to this Actor.
*/
void Actor::setHideFlags(int flags) {
void Actor::setFlags(int flags) {
PROFILE_FUNCTION();

bool old = isEnabled();
Expand Down Expand Up @@ -173,14 +172,18 @@ void Actor::setScene(Scene *scene) {
Returns true if this actor will not be moved during the game; otherwise returns false.
*/
bool Actor::isStatic() const {
return m_static;
return m_flags & Static;
}
/*!
Marks current Actor as static or dynamic (by default).
This \a flag can help to optimize rendering.
*/
void Actor::setStatic(const bool flag) {
m_static = flag;
if(flag) {
m_flags |= Static;
} else {
m_flags &= ~Static;
}
}
/*!
Returns the layers list for the this Actor as a bit mask.
Expand Down Expand Up @@ -283,7 +286,7 @@ Component *Actor::addComponent(const std::string type) {
*/
bool Actor::isSerializable() const {
PROFILE_FUNCTION();
return (clonedFrom() == 0 || isInstance());
return !(m_flags & NonSerializable) && (clonedFrom() == 0 || isInstance());
}
/*!
\internal
Expand Down
33 changes: 26 additions & 7 deletions engine/src/components/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Camera::Camera() :
m_ratio(1.0f),
m_focal(1.0f),
m_orthoSize(1.0f),
m_ortho(false) {
m_ortho(false),
m_screen(false) {

recalcProjection();
}
Expand Down Expand Up @@ -69,11 +70,10 @@ Vector3 Camera::project(const Vector3 &worldSpace) {
Vector3 Camera::unproject(const Vector3 &screenSpace) {
Matrix4 final((m_projection * viewMatrix()).inverse());

Vector4 in;
in.x = (screenSpace.x) * 2.0f - 1.0f;
in.y = (screenSpace.y) * 2.0f - 1.0f;
in.z = 2.0f * screenSpace.z - 1.0f;
in.w = 1.0f;
Vector4 in(2.0f * screenSpace.x - 1.0f,
2.0f * screenSpace.y - 1.0f,
2.0f * screenSpace.z - 1.0f,
1.0f);

Vector4 out(final * in);

Expand Down Expand Up @@ -210,6 +210,21 @@ void Camera::setOrthographic(const bool mode) {
m_ortho = mode;
recalcProjection();
}
/*!
Returns true is this camera in the screen space mode.
Typically used for Editor.
*/
bool Camera::isScreenSpace() const {
return m_screen;
}
/*!
Sets the screen space \a mode for the camera.
Typically used for Editor.
*/
void Camera::setScreenSpace(bool mode) {
m_screen = mode;
recalcProjection();
}
/*!
Returns current active camera.
*/
Expand Down Expand Up @@ -328,7 +343,11 @@ void Camera::drawGizmosSelected() {
void Camera::recalcProjection() {
if(m_ortho) {
float width = m_orthoSize * m_ratio;
m_projection = Matrix4::ortho(-width / 2, width / 2, -m_orthoSize / 2, m_orthoSize / 2, m_near, m_far);
if(m_screen) {
m_projection = Matrix4::ortho(0, width, 0, m_orthoSize, m_near, m_far);
} else {
m_projection = Matrix4::ortho(-width / 2, width / 2, -m_orthoSize / 2, m_orthoSize / 2, m_near, m_far);
}
} else {
m_projection = Matrix4::perspective(m_fov, m_ratio, m_near, m_far);
}
Expand Down
8 changes: 5 additions & 3 deletions engine/src/components/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ Vector3 Transform::position() const {
Changes \a position of the Transform in local space.
*/
void Transform::setPosition(const Vector3 position) {
std::unique_lock<std::mutex> locker(m_mutex);
m_position = position;
setDirty();
if(m_position != position) {
std::unique_lock<std::mutex> locker(m_mutex);
m_position = position;
setDirty();
}
}
/*!
Returns current rotation of the Transform in local space as Euler angles in degrees.
Expand Down
6 changes: 3 additions & 3 deletions engine/src/editor/viewport/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ void Viewport::init() {
m_color = pipelineContext->resultTexture();
m_color->setFlags(m_color->flags() | Texture::Feedback);

m_debugRender = new DebugRender;

if(!m_gameView) {
m_gridRender = new GridRender;
m_gridRender->setController(m_controller);
Expand All @@ -112,14 +114,12 @@ void Viewport::init() {

pipelineContext->insertRenderTask(m_gridRender, m_guiLayer);
pipelineContext->insertRenderTask(m_outlinePass, m_guiLayer);
pipelineContext->insertRenderTask(m_gizmoRender, m_guiLayer);
pipelineContext->insertRenderTask(m_gizmoRender);

Handles::init();
}

m_debugRender = new DebugRender;
pipelineContext->insertRenderTask(m_debugRender, m_guiLayer);

pipelineContext->subscribePost(Viewport::readPixels, this);
}
}
Expand Down
2 changes: 1 addition & 1 deletion engine/src/pipelinecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void PipelineContext::drawRenderers(const RenderList &list, uint32_t layer, uint
if(it) {
Actor *actor = it->actor();

if((flags == 0 || actor->hideFlags() & flags) && actor->layers() & layer) {
if((flags == 0 || actor->flags() & flags) && actor->layers() & layer) {
for(int32_t i = 0; i < it->m_materials.size(); i++) {
MaterialInstance *instance = it->m_materials[i];
if(instance->transform() == nullptr) {
Expand Down
2 changes: 0 additions & 2 deletions modules/uikit/includes/components/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class UIKIT_EXPORT Frame : public Widget {
Vector4 m_bottomColor;
Vector4 m_leftColor;

Vector2 m_meshSize;

Mesh *m_mesh;

MaterialInstance *m_material;
Expand Down
2 changes: 0 additions & 2 deletions modules/uikit/includes/components/uiloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class UIKIT_EXPORT UiLoader : public Widget {

void cleanHierarchy(Widget *widget);

void drawGizmos() override;

private:
std::string m_documentStyle;

Expand Down
2 changes: 0 additions & 2 deletions modules/uikit/includes/components/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class UIKIT_EXPORT Widget : public NativeBehaviour {

void setParent(Object *parent, int32_t position = -1, bool force = false) override;

void drawGizmosSelected() override;

float styleLength(const std::string &key, float value, bool &pixels);
Vector2 styleBlock2Length(const std::string &property, const Vector2 &value, bool &pixels);
Vector4 styleBlock4Length(const std::string &property, const Vector4 &value, bool &pixels);
Expand Down
29 changes: 5 additions & 24 deletions modules/uikit/includes/editor/tools/widgettool.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,13 @@
#include <editor/editortool.h>

class WidgetController;
class Renderable;
class RectTransform;

class WidgetTool : public EditorTool {
public:
struct Select {
bool operator==(const Select &left) {
return (uuid == left.uuid);
}

uint32_t uuid = 0;
Actor *object = nullptr;
Renderable *renderable = nullptr;

Vector3 position;
Vector3 scale;
Vector3 euler;
Quaternion quat;
};

typedef QList<Select> SelectList;

public:
explicit WidgetTool(WidgetController *controller);

Vector3 objectPosition();
AABBox objectBound();

protected:
void update(bool pivot, bool local, bool snap) override;
Expand All @@ -38,22 +19,22 @@ class WidgetTool : public EditorTool {
void endControl() override;
void cancelControl() override;

Vector3 recalcPosition(RectTransform *rect, RectTransform *root) const;

std::string icon() const override;
std::string name() const override;

std::string component() const override;

protected:
WidgetController *m_controller;

AABBox m_savedBox;

AABBox m_box;

Vector3 m_world;
Vector3 m_savedWorld;
Vector3 m_position;

WidgetController *m_controller;

};

#endif // WIDGETTOOL_H
Loading
Loading