VOXEDIT: use the frame from scene mgr
parent
a260bf81f7
commit
832fe46019
|
@ -84,7 +84,7 @@ void SceneGraphRenderer::clear() {
|
|||
}
|
||||
}
|
||||
|
||||
void SceneGraphRenderer::prepare(voxelformat::SceneGraph &sceneGraph, bool hideInactive, bool grayInactive) {
|
||||
void SceneGraphRenderer::prepare(voxelformat::SceneGraph &sceneGraph, int frame, bool hideInactive, bool grayInactive) {
|
||||
// remove those volumes that are no longer part of the scene graph
|
||||
for (int i = 0; i < RawVolumeRenderer::MAX_VOLUMES; ++i) {
|
||||
if (!sceneGraph.hasNode(i)) {
|
||||
|
@ -100,7 +100,8 @@ void SceneGraphRenderer::prepare(voxelformat::SceneGraph &sceneGraph, bool hideI
|
|||
_renderer.extractRegion(node.id(), node.region());
|
||||
}
|
||||
if (_sceneMode) {
|
||||
const voxelformat::SceneGraphTransform &transform = node.transform(0);
|
||||
// TODO ik solver
|
||||
const voxelformat::SceneGraphTransform &transform = node.transformForFrame(frame);
|
||||
const glm::vec3 pivot = transform.pivot() * glm::vec3(node.region().getDimensionsInVoxels());
|
||||
_renderer.setModelMatrix(node.id(), transform.matrix(), pivot);
|
||||
} else {
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
void translate(voxelformat::SceneGraphNode &node, const glm::ivec3 &v);
|
||||
bool toMesh(voxelformat::SceneGraphNode &node, voxel::Mesh* mesh);
|
||||
bool empty(voxelformat::SceneGraphNode &node);
|
||||
void prepare(voxelformat::SceneGraph &sceneGraph, bool hideInactive = false, bool grayInactive = false);
|
||||
void prepare(voxelformat::SceneGraph &sceneGraph, int frame = 0, bool hideInactive = false, bool grayInactive = false);
|
||||
/**
|
||||
* @param waitPending Wait for pending extractions and update the buffers before doing the rendering. If this is false, you have to call @c update() manually!
|
||||
*/
|
||||
|
|
|
@ -216,16 +216,16 @@ void MainWindow::leftWidget() {
|
|||
_toolsPanel.update(TITLE_TOOLS);
|
||||
}
|
||||
|
||||
void MainWindow::mainWidget(int frame) {
|
||||
_scene->update(frame);
|
||||
_sceneTop->update(frame);
|
||||
_sceneLeft->update(frame);
|
||||
_sceneFront->update(frame);
|
||||
_sceneAnimation->update(frame);
|
||||
void MainWindow::mainWidget() {
|
||||
_scene->update();
|
||||
_sceneTop->update();
|
||||
_sceneLeft->update();
|
||||
_sceneFront->update();
|
||||
_sceneAnimation->update();
|
||||
}
|
||||
|
||||
void MainWindow::rightWidget(int frame) {
|
||||
_positionsPanel.update(TITLE_POSITIONS, _lastExecutedCommand, frame);
|
||||
void MainWindow::rightWidget() {
|
||||
_positionsPanel.update(TITLE_POSITIONS, _lastExecutedCommand);
|
||||
_modifierPanel.update(TITLE_MODIFIERS, _lastExecutedCommand);
|
||||
_animationPanel.update(TITLE_ANIMATION_SETTINGS, _lastExecutedCommand);
|
||||
_formatSettingsPanel.update(TITLE_FORMAT_SETTINGS);
|
||||
|
@ -416,10 +416,9 @@ void MainWindow::update() {
|
|||
const ImGuiID dockspaceId = ImGui::GetID("DockSpace");
|
||||
ImGui::DockSpace(dockspaceId);
|
||||
|
||||
int frame = 0; // TODO: select the proper key frame
|
||||
leftWidget();
|
||||
mainWidget(frame);
|
||||
rightWidget(frame);
|
||||
mainWidget();
|
||||
rightWidget();
|
||||
|
||||
registerPopups();
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ private:
|
|||
StatusBar _statusBar;
|
||||
|
||||
void leftWidget();
|
||||
void mainWidget(int frame);
|
||||
void rightWidget(int frame);
|
||||
void mainWidget();
|
||||
void rightWidget();
|
||||
|
||||
void dialog(const char *icon, const char *text);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "ModifierPanel.h"
|
||||
#include "IMGUIApp.h"
|
||||
#include "Util.h"
|
||||
#include "imgui.h"
|
||||
#include "voxedit-util/SceneManager.h"
|
||||
#include "ui/imgui/IMGUIEx.h"
|
||||
#include "ui/imgui/IconsForkAwesome.h"
|
||||
|
|
|
@ -66,13 +66,14 @@ void PositionsPanel::modelView(command::CommandExecutionListener &listener) {
|
|||
}
|
||||
}
|
||||
|
||||
void PositionsPanel::sceneView(command::CommandExecutionListener &listener, int frame) {
|
||||
void PositionsPanel::sceneView(command::CommandExecutionListener &listener) {
|
||||
if (ImGui::CollapsingHeader(ICON_FA_ARROWS_ALT " Transform", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
const voxelformat::SceneGraph &sceneGraph = sceneMgr().sceneGraph();
|
||||
const int activeNode = sceneGraph.activeNode();
|
||||
if (activeNode != -1) {
|
||||
voxelformat::SceneGraphNode &node = sceneGraph.node(activeNode);
|
||||
voxelformat::SceneGraphTransform &transform = node.transform(frame);
|
||||
const int frame = sceneMgr().currentFrame();
|
||||
voxelformat::SceneGraphTransform &transform = node.transform(node.keyFrameForFrame(frame));
|
||||
float matrixTranslation[3], matrixRotation[3], matrixScale[3];
|
||||
ImGuizmo::DecomposeMatrixToComponents(glm::value_ptr(transform.matrix()), matrixTranslation, matrixRotation, matrixScale);
|
||||
bool change = false;
|
||||
|
@ -97,10 +98,10 @@ void PositionsPanel::sceneView(command::CommandExecutionListener &listener, int
|
|||
}
|
||||
}
|
||||
|
||||
void PositionsPanel::update(const char *title, command::CommandExecutionListener &listener, int frame) {
|
||||
void PositionsPanel::update(const char *title, command::CommandExecutionListener &listener) {
|
||||
if (ImGui::Begin(title, nullptr, ImGuiWindowFlags_NoDecoration)) {
|
||||
if (sceneMgr().editMode() == EditMode::Scene) {
|
||||
sceneView(listener, frame);
|
||||
sceneView(listener);
|
||||
} else {
|
||||
modelView(listener);
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ namespace voxedit {
|
|||
class PositionsPanel {
|
||||
private:
|
||||
void modelView(command::CommandExecutionListener &listener);
|
||||
void sceneView(command::CommandExecutionListener &listener, int frame);
|
||||
void sceneView(command::CommandExecutionListener &listener);
|
||||
public:
|
||||
void update(const char *title, command::CommandExecutionListener &listener, int frame);
|
||||
void update(const char *title, command::CommandExecutionListener &listener);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ bool Viewport::init(ViewportController::RenderMode renderMode) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Viewport::update(int frame) {
|
||||
void Viewport::update() {
|
||||
static const char *polygonModes[] = {"Points", "Lines", "Solid"};
|
||||
static_assert(lengthof(polygonModes) == (int)video::PolygonMode::Max, "Array size doesn't match enum values");
|
||||
|
||||
|
@ -92,7 +92,7 @@ void Viewport::update(int frame) {
|
|||
const glm::vec2 uvc(uv.z, uv.w);
|
||||
const video::TexturePtr &texture = _frameBuffer.texture(video::FrameBufferAttachment::Color0);
|
||||
ImGui::Image(texture->handle(), contentSize, uva, uvc);
|
||||
renderGizmo(_controller.camera(), headerSize, contentSize, frame);
|
||||
renderGizmo(_controller.camera(), headerSize, contentSize);
|
||||
|
||||
if (sceneMgr().isLoading()) {
|
||||
ImGui::LoadingIndicatorCircle("Loading", 150, core::Color::White, core::Color::Gray);
|
||||
|
@ -212,7 +212,7 @@ bool Viewport::setupFrameBuffer(const glm::ivec2 &frameBufferSize) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Viewport::renderGizmo(video::Camera &camera, const float headerSize, const ImVec2 &size, int frame) {
|
||||
void Viewport::renderGizmo(video::Camera &camera, const float headerSize, const ImVec2 &size) {
|
||||
if (!_showAxisVar->boolVal()) {
|
||||
return;
|
||||
}
|
||||
|
@ -253,16 +253,17 @@ void Viewport::renderGizmo(video::Camera &camera, const float headerSize, const
|
|||
ImGuizmo::SetOrthographic(camera.mode() == video::CameraMode::Orthogonal);
|
||||
const float step = (float)core::Var::getSafe(cfg::VoxEditGridsize)->intVal();
|
||||
const float snap[]{step, step, step};
|
||||
const voxelformat::SceneGraphTransform &transform = node.transform(frame);
|
||||
const int keyFrame = node.keyFrameForFrame(sceneMgr().currentFrame());
|
||||
const voxelformat::SceneGraphTransform &transform = node.transform(keyFrame);
|
||||
glm::mat4 transformMatrix = transform.matrix();
|
||||
glm::mat4 viewMatrix = camera.viewMatrix();
|
||||
const float *projMatrix = glm::value_ptr(camera.projectionMatrix());
|
||||
ImGuizmo::Manipulate(glm::value_ptr(viewMatrix), projMatrix, (ImGuizmo::OPERATION)operation, mode, glm::value_ptr(transformMatrix), nullptr, _guizmoSnap->boolVal() ? snap: nullptr);
|
||||
if (ImGuizmo::IsUsing()) {
|
||||
_guizmoActivated = true;
|
||||
sceneMgr().nodeUpdateTransform(activeNode, transformMatrix, frame, false);
|
||||
sceneMgr().nodeUpdateTransform(activeNode, transformMatrix, keyFrame, false);
|
||||
} else if (_guizmoActivated) {
|
||||
sceneMgr().nodeUpdateTransform(activeNode, transformMatrix, frame, true);
|
||||
sceneMgr().nodeUpdateTransform(activeNode, transformMatrix, keyFrame, true);
|
||||
_guizmoActivated = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ private:
|
|||
|
||||
void renderToFrameBuffer();
|
||||
bool setupFrameBuffer(const glm::ivec2& frameBufferSize);
|
||||
void renderGizmo(video::Camera &camera, const float headerSize, const ImVec2 &size, int frame);
|
||||
void renderGizmo(video::Camera &camera, const float headerSize, const ImVec2 &size);
|
||||
|
||||
public:
|
||||
Viewport(const core::String& id);
|
||||
~Viewport();
|
||||
|
||||
bool isHovered() const;
|
||||
void update(int frame);
|
||||
void update();
|
||||
bool init(ViewportController::RenderMode renderMode = ViewportController::RenderMode::Editor);
|
||||
void shutdown();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "math/Axis.h"
|
||||
#include "math/Random.h"
|
||||
#include "math/Ray.h"
|
||||
#include "video/Renderer.h"
|
||||
#include "video/ScopedBlendMode.h"
|
||||
#include "video/ScopedLineWidth.h"
|
||||
#include "video/ScopedPolygonMode.h"
|
||||
|
@ -972,7 +973,7 @@ void SceneManager::updateAABBMesh() {
|
|||
} else {
|
||||
_shapeBuilder.setColor(core::Color::Gray);
|
||||
}
|
||||
_shapeBuilder.aabb(toAABB(region, node.transform()));
|
||||
_shapeBuilder.aabb(toAABB(region, node.transformForFrame(_currentFrame)));
|
||||
}
|
||||
_shapeRenderer.createOrUpdate(_aabbMeshIndex, _shapeBuilder);
|
||||
}
|
||||
|
@ -985,13 +986,13 @@ void SceneManager::render(const video::Camera& camera, uint8_t renderMask) {
|
|||
if (_editMode == EditMode::Scene) {
|
||||
_shapeRenderer.render(_aabbMeshIndex, camera);
|
||||
} else if (const int nodeId = activeNode()) {
|
||||
const voxelformat::SceneGraphNode *n = sceneGraphNode(nodeId);
|
||||
voxelformat::SceneGraphNode *n = sceneGraphNode(nodeId);
|
||||
const voxel::Region& region = n->volume()->region();
|
||||
_gridRenderer.render(camera, toAABB(region, n->transform()));
|
||||
_gridRenderer.render(camera, toAABB(region, n->transformForFrame(_currentFrame)));
|
||||
}
|
||||
}
|
||||
if (renderScene) {
|
||||
_volumeRenderer.prepare(_sceneGraph, _hideInactive->boolVal(), _grayInactive->boolVal());
|
||||
_volumeRenderer.prepare(_sceneGraph, _currentFrame, _hideInactive->boolVal(), _grayInactive->boolVal());
|
||||
_volumeRenderer.render(camera, _renderShadow, false);
|
||||
extractVolume();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue