From 3b7e6935848af6ceb99a9ee92eb325e7ca5d9ba4 Mon Sep 17 00:00:00 2001 From: Marcus Weber Date: Tue, 20 Jun 2023 11:34:31 +0200 Subject: [PATCH] Release v1.9.1 --- CHANGELOG.md | 6 ++ CMakeLists.txt | 2 +- .../libCore/tests/ProjectMigration_test.cpp | 57 +++++++++++++++++++ .../include/user_types/Material.h | 8 ++- .../include/user_types/UserObjectFactory.h | 3 + .../libUserTypes/src/UserObjectFactory.cpp | 10 +++- 6 files changed, 83 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7df7506..567242ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,12 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h --> +## [1.9.1] Bugfix Release + +### Fixes +* Prevent stencil and scissor options in materials and meshnodes from being reset to their defaults by undo/redo operations. + + ## [1.9.0] Stencil & Scissor support, Linkable instance count, Texture optimization, Misc Bugfixes * **File version number has changed. Files saved with RaCo 1.9.0 cannot be opened by previous versions.** diff --git a/CMakeLists.txt b/CMakeLists.txt index 3022d953..6afe84cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.19) SET(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo") -project(RaCoOS VERSION 1.9.0) +project(RaCoOS VERSION 1.9.1) SET(RACO_RELEASE_DIRECTORY ${CMAKE_BINARY_DIR}/release) diff --git a/datamodel/libCore/tests/ProjectMigration_test.cpp b/datamodel/libCore/tests/ProjectMigration_test.cpp index 45cf5421..f2803e27 100644 --- a/datamodel/libCore/tests/ProjectMigration_test.cpp +++ b/datamodel/libCore/tests/ProjectMigration_test.cpp @@ -1073,3 +1073,60 @@ TEST_F(MigrationTest, check_user_factory_can_create_all_static_properties) { } } } + +void change_property(ValueBase* value) { + switch (value->type()) { + case PrimitiveType::Bool: + *value = !value->asBool(); + break; + case PrimitiveType::Int: + *value = value->asInt() + 1; + break; + case PrimitiveType::Int64: + *value = value->asInt64() + 1; + break; + case PrimitiveType::Double: + *value = value->asDouble() + 1; + break; + case PrimitiveType::String: + *value = value->asString() + "postfix"; + break; + case PrimitiveType::Ref: + // We can't just change the pointer here but would need to create another valid object as pointer target. + // Ignore for now since we don't have Ref properties inside structs yet. + break; + case PrimitiveType::Table: + case PrimitiveType::Struct: { + auto& container = value->getSubstructure(); + for (size_t index = 0; index < container.size(); index++) { + change_property(container.get(index)); + } + } break; + } +} + +TEST_F(MigrationTest, check_struct_copy_operators) { + // Check that the copy constructor and operator= work for all struct types. + // If this fails fix the implementation of the failing struct member function. + + auto& userFactory{UserObjectFactory::getInstance()}; + + for (auto& item : userFactory.getStructTypes()) { + auto name = item.first; + auto property = userFactory.createValue(name); + ASSERT_TRUE(property->type() != PrimitiveType::Ref) << fmt::format("Struct name {}", name); + + change_property(property); + + // clone uses the copy constructor + auto prop_clone = property->clone(nullptr); + ASSERT_TRUE(*property == *prop_clone) << fmt::format("Struct name {}", name); + + // check operator= + auto property_2 = userFactory.createValue(name); + ASSERT_FALSE(*property_2 == *property); + + *property_2 = *property; + ASSERT_TRUE(*property_2 == *property) << fmt::format("Struct name {}", name); + } +} \ No newline at end of file diff --git a/datamodel/libUserTypes/include/user_types/Material.h b/datamodel/libUserTypes/include/user_types/Material.h index 427b72af..6ec091df 100644 --- a/datamodel/libUserTypes/include/user_types/Material.h +++ b/datamodel/libUserTypes/include/user_types/Material.h @@ -192,7 +192,9 @@ class BlendOptions : public StructBase { depthwrite_(other.depthwrite_), depthFunction_(other.depthFunction_), cullmode_(other.cullmode_), - colorWriteMask_(other.colorWriteMask_) { + colorWriteMask_(other.colorWriteMask_), + scissorOptions_(other.scissorOptions_), + stencilOptions_(other.stencilOptions_) { } BlendOptions& operator=(const BlendOptions& other) { @@ -207,6 +209,8 @@ class BlendOptions : public StructBase { depthFunction_ = other.depthFunction_; cullmode_ = other.cullmode_; colorWriteMask_ = other.colorWriteMask_; + scissorOptions_ = other.scissorOptions_; + stencilOptions_ = other.stencilOptions_; return *this; } @@ -222,6 +226,8 @@ class BlendOptions : public StructBase { depthFunction_.copyAnnotationData(other.depthFunction_); cullmode_.copyAnnotationData(other.cullmode_); colorWriteMask_.copyAnnotationData(other.colorWriteMask_); + scissorOptions_.copyAnnotationData(other.scissorOptions_); + stencilOptions_.copyAnnotationData(other.stencilOptions_); } std::vector> getProperties() { diff --git a/datamodel/libUserTypes/include/user_types/UserObjectFactory.h b/datamodel/libUserTypes/include/user_types/UserObjectFactory.h index aad52ec4..b73a5b61 100644 --- a/datamodel/libUserTypes/include/user_types/UserObjectFactory.h +++ b/datamodel/libUserTypes/include/user_types/UserObjectFactory.h @@ -290,6 +290,7 @@ class UserObjectFactory : public raco::core::UserObjectFactoryInterface { struct StructDescriptor { ReflectionInterface::TypeDescriptor description; StructCreationFunction createFunc; + ValueCreationFunction createValueFunc; }; @@ -342,6 +343,8 @@ class UserObjectFactory : public raco::core::UserObjectFactoryInterface { template static std::shared_ptr createStructInternal(); template + static data_storage::ValueBase* createStructValueInternal(); + template static data_storage::ValueBase* createValueInternal() { return new Value>(); } diff --git a/datamodel/libUserTypes/src/UserObjectFactory.cpp b/datamodel/libUserTypes/src/UserObjectFactory.cpp index f6939ad0..25b17049 100644 --- a/datamodel/libUserTypes/src/UserObjectFactory.cpp +++ b/datamodel/libUserTypes/src/UserObjectFactory.cpp @@ -53,6 +53,10 @@ std::shared_ptr UserObjectFactory::createStructIntern return std::make_shared(); } +template +data_storage::ValueBase* UserObjectFactory::createStructValueInternal() { + return new Value(); +} template std::map UserObjectFactory::makeTypeMap() { @@ -79,7 +83,7 @@ std::map UserObjectFactory template std::map UserObjectFactory::makeStructTypeMap() { return std::map{ - {Args::typeDescription.typeName, {Args::typeDescription, createStructInternal}}...}; + {Args::typeDescription.typeName, {Args::typeDescription, createStructInternal, createStructValueInternal}}...}; } UserObjectFactory::UserObjectFactory() { @@ -184,6 +188,10 @@ data_storage::ValueBase* UserObjectFactory::createValue(const std::string& type) return it->second(); } } + if (auto it = structTypes_.find(type); it != structTypes_.end()) { + return it->second.createValueFunc(); + } + return new Value(); }