Compare commits
3 commits
d79d4e3b4a
...
5e36709dc8
Author | SHA1 | Date | |
---|---|---|---|
5e36709dc8 | |||
6d95cc8e1a | |||
6e387a72d2 |
6 changed files with 23 additions and 57 deletions
|
@ -23,5 +23,4 @@ add_subdirectory(core)
|
||||||
add_subdirectory(client)
|
add_subdirectory(client)
|
||||||
add_subdirectory(editor)
|
add_subdirectory(editor)
|
||||||
|
|
||||||
|
|
||||||
install(FILES $<TARGET_RUNTIME_DLLS:editor> TYPE BIN)
|
install(FILES $<TARGET_RUNTIME_DLLS:editor> TYPE BIN)
|
|
@ -58,15 +58,13 @@ void BasePart::OnWorkspaceRemoved(std::shared_ptr<Workspace> oldWorkspace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePart::onUpdated(std::string property) {
|
void BasePart::onUpdated(std::string property) {
|
||||||
// Reset velocity
|
bool reset = property == "Position" || property == "Rotation" || property == "CFrame" || property == "Size" || property == "Shape";
|
||||||
if (property != "Velocity")
|
|
||||||
velocity = Vector3::ZERO;
|
|
||||||
|
|
||||||
if (workspace())
|
if (workspace())
|
||||||
workspace().value()->SyncPartPhysics(std::dynamic_pointer_cast<BasePart>(this->shared_from_this()));
|
workspace().value()->SyncPartPhysics(std::dynamic_pointer_cast<BasePart>(this->shared_from_this()));
|
||||||
|
|
||||||
// When position/rotation/size is manually edited, break all joints, they don't apply anymore
|
// When position/rotation/size is manually edited, break all joints, they don't apply anymore
|
||||||
if (property != "Anchored")
|
if (reset)
|
||||||
BreakJoints();
|
BreakJoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,9 @@ void PartAssembly::SetCollisionsEnabled(bool enabled) {
|
||||||
void PartAssembly::SetOrigin(CFrame newOrigin) {
|
void PartAssembly::SetOrigin(CFrame newOrigin) {
|
||||||
for (auto part : parts) {
|
for (auto part : parts) {
|
||||||
part->cframe = newOrigin * (_assemblyOrigin.Inverse() * part->cframe);
|
part->cframe = newOrigin * (_assemblyOrigin.Inverse() * part->cframe);
|
||||||
|
part->velocity = 0; // Reset velocity
|
||||||
part->UpdateProperty("CFrame");
|
part->UpdateProperty("CFrame");
|
||||||
|
part->UpdateProperty("Velocity");
|
||||||
// sendPropertyUpdatedSignal(part, "CFrame", Variant(part->cframe));
|
// sendPropertyUpdatedSignal(part, "CFrame", Variant(part->cframe));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,12 +80,15 @@ void PartAssembly::SetOrigin(CFrame newOrigin) {
|
||||||
void PartAssembly::TransformBy(CFrame transform) {
|
void PartAssembly::TransformBy(CFrame transform) {
|
||||||
for (auto part : parts) {
|
for (auto part : parts) {
|
||||||
part->cframe = transform * part->cframe;
|
part->cframe = transform * part->cframe;
|
||||||
|
part->velocity = 0; // Reset velocity
|
||||||
part->UpdateProperty("CFrame");
|
part->UpdateProperty("CFrame");
|
||||||
part->UpdateProperty("Position");
|
part->UpdateProperty("Position");
|
||||||
part->UpdateProperty("Rotation");
|
part->UpdateProperty("Rotation");
|
||||||
|
part->UpdateProperty("Velocity");
|
||||||
sendPropertyUpdatedSignal(part, "CFrame", Variant(part->cframe));
|
sendPropertyUpdatedSignal(part, "CFrame", Variant(part->cframe));
|
||||||
sendPropertyUpdatedSignal(part, "Position", Variant(part->cframe));
|
sendPropertyUpdatedSignal(part, "Position", Variant(part->cframe));
|
||||||
sendPropertyUpdatedSignal(part, "Rotation", Variant(part->cframe));
|
sendPropertyUpdatedSignal(part, "Rotation", Variant(part->cframe));
|
||||||
|
sendPropertyUpdatedSignal(part, "Velocity", Variant(part->cframe));
|
||||||
}
|
}
|
||||||
|
|
||||||
_assemblyOrigin = transform * _assemblyOrigin;
|
_assemblyOrigin = transform * _assemblyOrigin;
|
||||||
|
@ -127,6 +132,7 @@ std::vector<PartTransformState> PartAssembly::GetCurrentTransforms() {
|
||||||
t.part = part;
|
t.part = part;
|
||||||
t.cframe = part->cframe;
|
t.cframe = part->cframe;
|
||||||
t.size = part->size;
|
t.size = part->size;
|
||||||
|
t.velocity = part->velocity;
|
||||||
transforms.push_back(t);
|
transforms.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ class Selection;
|
||||||
struct PartTransformState {
|
struct PartTransformState {
|
||||||
std::shared_ptr<BasePart> part;
|
std::shared_ptr<BasePart> part;
|
||||||
Vector3 size;
|
Vector3 size;
|
||||||
|
Vector3 velocity;
|
||||||
CFrame cframe;
|
CFrame cframe;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Multimedia LinguistTools)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Multimedia LinguistTools OpenGL OpenGLWidgets)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Multimedia LinguistTools)
|
find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia LinguistTools OpenGL OpenGLWidgets)
|
||||||
find_package(QScintilla REQUIRED)
|
find_package(QScintilla REQUIRED)
|
||||||
|
|
||||||
set(TS_FILES editor_en_US.ts)
|
set(TS_FILES editor_en_US.ts)
|
||||||
|
@ -52,43 +52,14 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
MANUAL_FINALIZATION
|
MANUAL_FINALIZATION
|
||||||
${PROJECT_SOURCES}
|
${PROJECT_SOURCES}
|
||||||
)
|
)
|
||||||
# Define target properties for Android with Qt 6 as:
|
|
||||||
# set_property(TARGET editor APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
|
|
||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
|
|
||||||
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
|
|
||||||
|
|
||||||
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
||||||
else()
|
|
||||||
if(ANDROID)
|
|
||||||
add_library(editor SHARED
|
|
||||||
${PROJECT_SOURCES}
|
|
||||||
)
|
|
||||||
# Define properties for Android with Qt 5 after find_package() calls as:
|
|
||||||
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
|
|
||||||
else()
|
|
||||||
add_executable(editor
|
|
||||||
${PROJECT_SOURCES}
|
|
||||||
mainglwidget.h mainglwidget.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(editor PUBLIC "../core/src" "../include" ${QSCINTILLA_INCLUDE_DIR})
|
target_include_directories(editor PUBLIC "../core/src" "../include" ${QSCINTILLA_INCLUDE_DIR} Qt6::OpenGL Qt6::OpenGLWidgets)
|
||||||
target_link_libraries(editor PRIVATE openblocks Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia ${QSCINTILLA_LIBRARY})
|
target_link_libraries(editor PRIVATE openblocks Qt6::Widgets Qt6::Multimedia ${QSCINTILLA_LIBRARY} Qt6::OpenGL Qt6::OpenGLWidgets)
|
||||||
add_dependencies(editor openblocks)
|
add_dependencies(editor openblocks)
|
||||||
|
|
||||||
# Qt6 does not include QOpenGLWidgets as part of Widgets base anymore, so
|
|
||||||
# we have to include it manually
|
|
||||||
if (${QT_VERSION} GREATER_EQUAL 6)
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS OpenGL OpenGLWidgets)
|
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGL OpenGLWidgets)
|
|
||||||
|
|
||||||
target_include_directories(editor PUBLIC Qt6::OpenGL Qt6::OpenGLWidgets)
|
|
||||||
target_link_libraries(editor PRIVATE Qt6::OpenGL Qt6::OpenGLWidgets)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Copy assets
|
# Copy assets
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET editor POST_BUILD
|
TARGET editor POST_BUILD
|
||||||
|
@ -123,17 +94,7 @@ if (WIN32)
|
||||||
)
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
|
||||||
# If you are developing for iOS or macOS you should consider setting an
|
|
||||||
# explicit, fixed bundle identifier manually though.
|
|
||||||
if(${QT_VERSION} VERSION_LESS 6.1.0)
|
|
||||||
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.qtbasic)
|
|
||||||
endif()
|
|
||||||
set_target_properties(editor PROPERTIES
|
set_target_properties(editor PROPERTIES
|
||||||
${BUNDLE_ID_OPTION}
|
|
||||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
|
||||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
|
||||||
MACOSX_BUNDLE TRUE
|
|
||||||
WIN32_EXECUTABLE TRUE
|
WIN32_EXECUTABLE TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
#include "mainglwidget.h"
|
#include "mainglwidget.h"
|
||||||
#include "datatypes/vector.h"
|
#include "datatypes/vector.h"
|
||||||
|
#include "enum/surface.h"
|
||||||
#include "handles.h"
|
#include "handles.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -238,6 +239,7 @@ void MainGLWidget::handleLinearTransform(QMouseEvent* evt) {
|
||||||
if (glm::any(glm::lessThan(glm::vec3(selectionAssembly.size() + abs(draggingHandle->normal) * diff), glm::vec3(0.001f))))
|
if (glm::any(glm::lessThan(glm::vec3(selectionAssembly.size() + abs(draggingHandle->normal) * diff), glm::vec3(0.001f))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// This causes the velocity to be reset even though it shouldn't, but it's not a huge deal, so whatevs.
|
||||||
selectionAssembly.TransformBy(CFrame() + absDiff * 0.5f);
|
selectionAssembly.TransformBy(CFrame() + absDiff * 0.5f);
|
||||||
selectionAssembly.Scale(selectionAssembly.size() + abs(draggingHandle->normal) * diff, diff > 0);
|
selectionAssembly.Scale(selectionAssembly.size() + abs(draggingHandle->normal) * diff, diff > 0);
|
||||||
}
|
}
|
||||||
|
@ -419,16 +421,14 @@ void MainGLWidget::mousePressEvent(QMouseEvent* evt) {
|
||||||
Vector3 localNormal = part->cframe.Inverse().Rotation() * rayHit->worldNormal;
|
Vector3 localNormal = part->cframe.Inverse().Rotation() * rayHit->worldNormal;
|
||||||
NormalId face = faceFromNormal(localNormal);
|
NormalId face = faceFromNormal(localNormal);
|
||||||
SurfaceType surface = SurfaceType(mainWindow()->selectedTool - TOOL_SMOOTH);
|
SurfaceType surface = SurfaceType(mainWindow()->selectedTool - TOOL_SMOOTH);
|
||||||
|
std::string surfacePropertyName = EnumType::NormalId.FromValue(face)->Name() + "Surface";
|
||||||
|
|
||||||
switch (face) {
|
// Get old surface and set new surface
|
||||||
case Right: part->rightSurface = surface; break;
|
EnumItem newSurface = EnumType::SurfaceType.FromValue((int)surface).value();
|
||||||
case Top: part->topSurface = surface; break;
|
EnumItem oldSurface = part->GetProperty(surfacePropertyName).expect().get<EnumItem>();
|
||||||
case Back: part->backSurface = surface; break;
|
part->SetProperty(surfacePropertyName, newSurface).expect();
|
||||||
case Left: part->leftSurface = surface; break;
|
|
||||||
case Bottom: part->bottomSurface = surface; break;
|
M_mainWindow->undoManager.PushState({UndoStatePropertyChanged { part, surfacePropertyName, oldSurface, newSurface }});
|
||||||
case Front: part->frontSurface = surface; break;
|
|
||||||
default: return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/electronicpingshort.wav"))
|
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/electronicpingshort.wav"))
|
||||||
playSound("./assets/excluded/electronicpingshort.wav");
|
playSound("./assets/excluded/electronicpingshort.wav");
|
||||||
|
@ -471,6 +471,7 @@ void MainGLWidget::mouseReleaseEvent(QMouseEvent* evt) {
|
||||||
for (auto t : initialTransforms) {
|
for (auto t : initialTransforms) {
|
||||||
historyState.push_back(UndoStatePropertyChanged { t.part, "CFrame", t.cframe, t.part->cframe });
|
historyState.push_back(UndoStatePropertyChanged { t.part, "CFrame", t.cframe, t.part->cframe });
|
||||||
historyState.push_back(UndoStatePropertyChanged { t.part, "Size", t.size, t.part->size });
|
historyState.push_back(UndoStatePropertyChanged { t.part, "Size", t.size, t.part->size });
|
||||||
|
historyState.push_back(UndoStatePropertyChanged { t.part, "Velocity", t.velocity, t.part->velocity });
|
||||||
}
|
}
|
||||||
|
|
||||||
M_mainWindow->undoManager.PushState(historyState);
|
M_mainWindow->undoManager.PushState(historyState);
|
||||||
|
|
Loading…
Add table
Reference in a new issue