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(editor)
|
||||
|
||||
|
||||
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) {
|
||||
// Reset velocity
|
||||
if (property != "Velocity")
|
||||
velocity = Vector3::ZERO;
|
||||
bool reset = property == "Position" || property == "Rotation" || property == "CFrame" || property == "Size" || property == "Shape";
|
||||
|
||||
if (workspace())
|
||||
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
|
||||
if (property != "Anchored")
|
||||
if (reset)
|
||||
BreakJoints();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,9 @@ void PartAssembly::SetCollisionsEnabled(bool enabled) {
|
|||
void PartAssembly::SetOrigin(CFrame newOrigin) {
|
||||
for (auto part : parts) {
|
||||
part->cframe = newOrigin * (_assemblyOrigin.Inverse() * part->cframe);
|
||||
part->velocity = 0; // Reset velocity
|
||||
part->UpdateProperty("CFrame");
|
||||
part->UpdateProperty("Velocity");
|
||||
// sendPropertyUpdatedSignal(part, "CFrame", Variant(part->cframe));
|
||||
}
|
||||
|
||||
|
@ -78,12 +80,15 @@ void PartAssembly::SetOrigin(CFrame newOrigin) {
|
|||
void PartAssembly::TransformBy(CFrame transform) {
|
||||
for (auto part : parts) {
|
||||
part->cframe = transform * part->cframe;
|
||||
part->velocity = 0; // Reset velocity
|
||||
part->UpdateProperty("CFrame");
|
||||
part->UpdateProperty("Position");
|
||||
part->UpdateProperty("Rotation");
|
||||
part->UpdateProperty("Velocity");
|
||||
sendPropertyUpdatedSignal(part, "CFrame", Variant(part->cframe));
|
||||
sendPropertyUpdatedSignal(part, "Position", Variant(part->cframe));
|
||||
sendPropertyUpdatedSignal(part, "Rotation", Variant(part->cframe));
|
||||
sendPropertyUpdatedSignal(part, "Velocity", Variant(part->cframe));
|
||||
}
|
||||
|
||||
_assemblyOrigin = transform * _assemblyOrigin;
|
||||
|
@ -127,6 +132,7 @@ std::vector<PartTransformState> PartAssembly::GetCurrentTransforms() {
|
|||
t.part = part;
|
||||
t.cframe = part->cframe;
|
||||
t.size = part->size;
|
||||
t.velocity = part->velocity;
|
||||
transforms.push_back(t);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ class Selection;
|
|||
struct PartTransformState {
|
||||
std::shared_ptr<BasePart> part;
|
||||
Vector3 size;
|
||||
Vector3 velocity;
|
||||
CFrame cframe;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Multimedia LinguistTools)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Multimedia LinguistTools)
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Multimedia LinguistTools OpenGL OpenGLWidgets)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia LinguistTools OpenGL OpenGLWidgets)
|
||||
find_package(QScintilla REQUIRED)
|
||||
|
||||
set(TS_FILES editor_en_US.ts)
|
||||
|
@ -52,43 +52,14 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|||
MANUAL_FINALIZATION
|
||||
${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})
|
||||
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()
|
||||
|
||||
target_include_directories(editor PUBLIC "../core/src" "../include" ${QSCINTILLA_INCLUDE_DIR})
|
||||
target_link_libraries(editor PRIVATE openblocks Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia ${QSCINTILLA_LIBRARY})
|
||||
target_include_directories(editor PUBLIC "../core/src" "../include" ${QSCINTILLA_INCLUDE_DIR} Qt6::OpenGL Qt6::OpenGLWidgets)
|
||||
target_link_libraries(editor PRIVATE openblocks Qt6::Widgets Qt6::Multimedia ${QSCINTILLA_LIBRARY} Qt6::OpenGL Qt6::OpenGLWidgets)
|
||||
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
|
||||
add_custom_command(
|
||||
TARGET editor POST_BUILD
|
||||
|
@ -123,17 +94,7 @@ if (WIN32)
|
|||
)
|
||||
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
|
||||
${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
|
||||
)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "./ui_mainwindow.h"
|
||||
#include "mainglwidget.h"
|
||||
#include "datatypes/vector.h"
|
||||
#include "enum/surface.h"
|
||||
#include "handles.h"
|
||||
#include "logger.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))))
|
||||
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.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;
|
||||
NormalId face = faceFromNormal(localNormal);
|
||||
SurfaceType surface = SurfaceType(mainWindow()->selectedTool - TOOL_SMOOTH);
|
||||
std::string surfacePropertyName = EnumType::NormalId.FromValue(face)->Name() + "Surface";
|
||||
|
||||
switch (face) {
|
||||
case Right: part->rightSurface = surface; break;
|
||||
case Top: part->topSurface = surface; break;
|
||||
case Back: part->backSurface = surface; break;
|
||||
case Left: part->leftSurface = surface; break;
|
||||
case Bottom: part->bottomSurface = surface; break;
|
||||
case Front: part->frontSurface = surface; break;
|
||||
default: return;
|
||||
}
|
||||
// Get old surface and set new surface
|
||||
EnumItem newSurface = EnumType::SurfaceType.FromValue((int)surface).value();
|
||||
EnumItem oldSurface = part->GetProperty(surfacePropertyName).expect().get<EnumItem>();
|
||||
part->SetProperty(surfacePropertyName, newSurface).expect();
|
||||
|
||||
M_mainWindow->undoManager.PushState({UndoStatePropertyChanged { part, surfacePropertyName, oldSurface, newSurface }});
|
||||
|
||||
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/electronicpingshort.wav"))
|
||||
playSound("./assets/excluded/electronicpingshort.wav");
|
||||
|
@ -471,6 +471,7 @@ void MainGLWidget::mouseReleaseEvent(QMouseEvent* evt) {
|
|||
for (auto t : initialTransforms) {
|
||||
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, "Velocity", t.velocity, t.part->velocity });
|
||||
}
|
||||
|
||||
M_mainWindow->undoManager.PushState(historyState);
|
||||
|
|
Loading…
Add table
Reference in a new issue