Skip to content

Commit

Permalink
Merge pull request #84 from prizrak9/step
Browse files Browse the repository at this point in the history
Step
  • Loading branch information
pryvyd9 authored Dec 20, 2020
2 parents 5e696ea + 6da0e8c commit 64278d8
Show file tree
Hide file tree
Showing 33 changed files with 17,743 additions and 7,912 deletions.
11 changes: 11 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 0.9.0
- switched red and cyan colors;
- updated ImGui to 1.80 docking;
- updated glfw to 3.2.2;
- disabled ImGui arrow navigation;
- added transition, rotation, scale step configuration;
- removed overcomplicated mouse control;
- used ImGui keystatus logic;
- implemented discrete movement;
- average deltatime + framerate;
- reversed Z;
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ A 3d modelling and visualisation solution with stereo output (anaglyph) and mult
![trace object rotation](https://github.com/prizrak9/StereoOriginal/blob/dev/docs/trace.png?raw=true)
![select some of the created clones and move them](https://github.com/prizrak9/StereoOriginal/blob/dev/docs/moveSelectedClones.png?raw=true)
![rotate what is left of traced object and rotate it to create a flower](https://github.com/prizrak9/StereoOriginal/blob/dev/docs/flower.png?raw=true)

## Known Issues
Combinations Shift + any Numpad key isn't working. There's a bug in glfw. https://github.com/glfw/glfw/issues/670
1 change: 1 addition & 0 deletions StereoOriginal.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StereoPlus2", "StereoPlus2\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A6D15D7A-3616-4A59-B36B-7597DFDCBE44}"
ProjectSection(SolutionItems) = preProject
CHANGE_LOG.md = CHANGE_LOG.md
README.md = README.md
EndProjectSection
EndProject
Expand Down
50 changes: 2 additions & 48 deletions StereoPlus2/DomainTypes.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "GLLoader.hpp"
#include "ToolConfiguration.hpp"
#include "Settings.hpp"
#include <stdlib.h>
#include <set>
#include <array>
Expand Down Expand Up @@ -932,7 +932,7 @@ class StereoCamera : public LeafObject
}
public:
glm::vec2* viewSize = nullptr;
glm::vec3 positionModifier = glm::vec3(0, 3, -10);
glm::vec3 positionModifier = glm::vec3(0, 0.5, 10);

float eyeToCenterDistance = 0.5;

Expand Down Expand Up @@ -1008,52 +1008,6 @@ class StereoCamera : public LeafObject
}
};


//class TraceObjectNode : public LeafObject {
// SceneObject* cache = nullptr;
//
// virtual void HandleBeforeUpdate() override {
// if (auto p = GetParent();
// !p || p->GetType() != TraceObjectT || !p->GetParent()) {
//
// if (cache)
// delete cache;
// cache = nullptr;
// return;
// }
//
// if (cache)
// return;
// //delete cache;
//
// cache = GetParent()->GetParent()->Clone();
// cache->children.clear();
// cache->SetParent(nullptr, false, true, false, false);
// cache->SetWorldPosition(GetWorldPosition());
// cache->SetWorldRotation(GetWorldRotation());
// }
//public:
// virtual ObjectType GetType() const override {
// return TraceObjectNodeT;
// }
// virtual void Draw(
// std::function<glm::vec3(glm::vec3)> toLeft,
// std::function<glm::vec3(glm::vec3)> toRight,
// GLuint shaderLeft,
// GLuint shaderRight,
// GLuint stencilMaskLeft,
// GLuint stencilMaskRight) override {
// if (!cache)
// return;
//
// cache->Draw(toLeft, toRight, shaderLeft, shaderRight, stencilMaskLeft, stencilMaskRight);
// }
//
// ~TraceObjectNode() {
// if (cache)
// delete cache;
// }
//};
class TraceObject : public GroupObject {
bool shouldIgnoreParent;
virtual void HandleBeforeUpdate() override {
Expand Down
15 changes: 8 additions & 7 deletions StereoPlus2/GUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class GUI {
}

if (shouldShowFPS) {
ImGui::LabelText("", "FPS: %-12f DeltaTime: %-12f", Time::GetFrameRate(), Time::GetDeltaTime());
ImGui::LabelText("", "FPS: %-12i DeltaTime: %-12f", Time::GetAverageFrameRate(), Time::GetAverageDeltaTime());
}

return true;
Expand Down Expand Up @@ -170,15 +170,12 @@ class GUI {
keyBinding.input = &input;
input.glWindow = glWindow;

if (!input.Init() ||
!keyBinding.Init())
return false;


// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
io = &ImGui::GetIO(); (void)io;
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io = &ImGui::GetIO();
//io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
Expand Down Expand Up @@ -239,6 +236,10 @@ class GUI {
//ImFont* font = io.Fonts->AddFontFromFileTTF("open-sans.ttf", 20);
//IM_ASSERT(font != NULL);

input.io = io;
if (!input.Init() ||
!keyBinding.Init())
return false;

for (auto window : windows)
if (!window->Init())
Expand Down
31 changes: 29 additions & 2 deletions StereoPlus2/InfrastructureTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class Log {
};

class Time {
static const int timeLogSize = 60;

static std::chrono::steady_clock::time_point* GetBegin() {
static std::chrono::steady_clock::time_point instance;
return &instance;
Expand All @@ -164,18 +166,43 @@ class Time {
static size_t instance;
return &instance;
}

static std::vector<size_t>& TimeLog() {
static std::vector<size_t> v(timeLogSize);
return v;
}

static void UpdateTimeLog(size_t v) {
static int i = 0;
TimeLog()[i] = v;
i++;
if (i >= timeLogSize)
i = 0;
}
public:
static void UpdateFrame() {
auto end = std::chrono::steady_clock::now();
*GetDeltaTimeMicroseconds() = std::chrono::duration_cast<std::chrono::microseconds>(end - *GetBegin()).count();
*GetBegin() = end;

UpdateTimeLog(*GetDeltaTimeMicroseconds());
}
static int GetFrameRate() {
return round(1 / GetDeltaTime());
}
static float GetFrameRate() {
return 1 / GetDeltaTime();
static int GetAverageFrameRate() {
return round(1 / GetAverageDeltaTime());
}
static float GetDeltaTime() {
return (float)*GetDeltaTimeMicroseconds() / 1e6;
}
static float GetAverageDeltaTime() {
size_t t = 0;
for (auto a : TimeLog())
t += a;

return (float)t / 1e6 / timeLogSize;
}
static size_t GetTime() {
return std::chrono::time_point_cast<std::chrono::milliseconds>(*GetBegin()).time_since_epoch().count();
}
Expand Down
Loading

0 comments on commit 64278d8

Please sign in to comment.