diff --git a/opennurbs_archivable_dictionary.cpp b/opennurbs_archivable_dictionary.cpp index a6a319fc..9e13bf8b 100644 --- a/opennurbs_archivable_dictionary.cpp +++ b/opennurbs_archivable_dictionary.cpp @@ -342,13 +342,18 @@ bool ON_ArchivableDictionary::Read(ON_BinaryArchive& binary_archive) auto rc = binary_archive.BeginReadDictionaryEntry(&item_type, item_name); if (rc == 1) { - auto value = DictionaryEntry::CreateInstance((DictionaryEntryType) item_type); - if (value != nullptr) + std::unique_ptr value(DictionaryEntry::CreateInstance((DictionaryEntryType)item_type)); + if (value) { if (!value->ReadDictionaryEntry(binary_archive)) return false; - m_private->m_map[item_name].reset(value); + m_private->m_map[item_name] = std::move(value); + } + else + { + // We skip unknown item types + ON_WarningEx(__FILE__, __LINE__, OPENNURBS__FUNCTION__, "Uknown ArchivableDictionary item type %d.", item_type); } } else if (rc == 2) break; diff --git a/opennurbs_evaluate_nurbs.cpp b/opennurbs_evaluate_nurbs.cpp index 19595cbb..f0f8a7be 100644 --- a/opennurbs_evaluate_nurbs.cpp +++ b/opennurbs_evaluate_nurbs.cpp @@ -1087,6 +1087,8 @@ bool ON_EvaluateNurbsSurfaceSpan( sizeof_buffer = ((i + j) << 3) + Pcount*Psize; N_0 = (sizeof_buffer <= sizeof(stack_buffer)) ? stack_buffer : (double*)(heap_buffer=onmalloc(sizeof_buffer)); + if ( nullptr == N_0) + return false; N_1 = N_0 + i; P0 = N_1 + j; memset( P0, 0, Pcount*Psize ); diff --git a/opennurbs_material.cpp b/opennurbs_material.cpp index 7a2fdbd3..009281a0 100644 --- a/opennurbs_material.cpp +++ b/opennurbs_material.cpp @@ -1426,7 +1426,7 @@ int ON_Material::CompareColorAttributes( const ON_Material& a, const ON_Material rc = CompareDouble(a_pbr->SubsurfaceScatteringRadius(), b_pbr->SubsurfaceScatteringRadius()); if (0 != rc) return rc; - + rc = CompareDouble(a_pbr->Metallic(), b_pbr->Metallic()); if (0 != rc) return rc; @@ -1533,7 +1533,7 @@ int ON_Material::CompareReflectionAttributes(const ON_Material& a, const ON_Mate if (0 != rc) return rc; rc = CompareDouble(a_pbr->ClearcoatRoughness(), b_pbr->ClearcoatRoughness()); - + return rc; } @@ -2185,7 +2185,7 @@ bool ON_Texture::Write( if ( minor_version <= 1 ) break; - + // version 1.2 added m_bTreatAsLinear rc = binary_archive.WriteBool(m_bTreatAsLinear); if (!rc) break; @@ -3917,7 +3917,7 @@ public: m_info = src.m_info; return *this; } - + #if defined(ON_COMPILER_CLANG) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" @@ -3999,7 +3999,7 @@ public: #if defined(ON_COMPILER_CLANG) #pragma clang diagnostic pop #endif - + void SetInfo(const ON_MappingMeshInfo& info) { m_info = info; @@ -5349,7 +5349,7 @@ public: return true; } } - + return false; } @@ -8429,7 +8429,7 @@ bool ON_TextureMapping::SetOcsMapping( { const ON_Interval interval(0.0, 1.0); const auto rc = SetPlaneMapping(plane, interval, interval, interval); - m_type = ON_TextureMapping::TYPE::plane_mapping; + m_type = ON_TextureMapping::TYPE::ocs_mapping; return rc; } @@ -8620,7 +8620,7 @@ private: #if defined(ON_COMPILER_CLANG) #pragma clang diagnostic pop #endif - + public: ON_PhysicallyBasedMaterialUserData() { @@ -8741,13 +8741,13 @@ public: { if (!binary_archive.WriteDouble(alpha)) return false; } - + return true; } bool Read(ON_BinaryArchive& binary_archive, int version) { - if (!binary_archive.ReadColor(base_color)) return false; + if (!binary_archive.ReadColor(base_color)) return false; if (!binary_archive.ReadInt((int*)&brdf)) return false; if (!binary_archive.ReadDouble(&subsurface)) return false; if (!binary_archive.ReadColor(subsurface_scattering_color)) return false; @@ -8771,7 +8771,7 @@ public: { if (!binary_archive.ReadDouble(&alpha)) return false; } - + return true; } #endif @@ -9163,7 +9163,7 @@ bool ON_Material::IsPhysicallyBased(void) const //https://mcneel.myjetbrains.com/youtrack/issue/RH-68577 return pUD->m_parameters.base_color.IsValid(); - + //return nullptr != PhysicallyBased(); } diff --git a/opennurbs_public_version.h b/opennurbs_public_version.h index e107d9de..71139d8e 100644 --- a/opennurbs_public_version.h +++ b/opennurbs_public_version.h @@ -6,7 +6,7 @@ // To update version numbers, edit ..\build\build_dates.msbuild #define RMA_VERSION_MAJOR 8 -#define RMA_VERSION_MINOR 13 +#define RMA_VERSION_MINOR 14 //////////////////////////////////////////////////////////////// // @@ -14,9 +14,9 @@ // first step in each build. // #define RMA_VERSION_YEAR 2024 -#define RMA_VERSION_MONTH 11 -#define RMA_VERSION_DATE 12 -#define RMA_VERSION_HOUR 13 +#define RMA_VERSION_MONTH 12 +#define RMA_VERSION_DATE 10 +#define RMA_VERSION_HOUR 15 #define RMA_VERSION_MINUTE 0 //////////////////////////////////////////////////////////////// @@ -35,8 +35,8 @@ // 3 = build system release build #define RMA_VERSION_BRANCH 0 -#define VERSION_WITH_COMMAS 8,13,24317,13000 -#define VERSION_WITH_PERIODS 8.13.24317.13000 +#define VERSION_WITH_COMMAS 8,14,24345,15000 +#define VERSION_WITH_PERIODS 8.14.24345.15000 #define COPYRIGHT "Copyright (C) 1993-2024, Robert McNeel & Associates. All Rights Reserved." #define SPECIAL_BUILD_DESCRIPTION "Public OpenNURBS C++ 3dm file IO library." @@ -44,11 +44,11 @@ #define RMA_VERSION_NUMBER_MAJOR_WSTRING L"8" #define RMA_PREVIOUS_VERSION_NUMBER_MAJOR_WSTRING L"7" -#define RMA_VERSION_NUMBER_SR_STRING "SR13" -#define RMA_VERSION_NUMBER_SR_WSTRING L"SR13" +#define RMA_VERSION_NUMBER_SR_STRING "SR14" +#define RMA_VERSION_NUMBER_SR_WSTRING L"SR14" -#define RMA_VERSION_WITH_PERIODS_STRING "8.13.24317.13000" -#define RMA_VERSION_WITH_PERIODS_WSTRING L"8.13.24317.13000" +#define RMA_VERSION_WITH_PERIODS_STRING "8.14.24345.15000" +#define RMA_VERSION_WITH_PERIODS_WSTRING L"8.14.24345.15000" diff --git a/opennurbs_text.cpp b/opennurbs_text.cpp index f3a862d9..95cc7a33 100644 --- a/opennurbs_text.cpp +++ b/opennurbs_text.cpp @@ -1747,10 +1747,10 @@ bool ON_TextContent::CreateStackedText(ON_TextRun* run, int cpcount, const ON__U ON_2dVector V(0.0, 0.0); V.x = stack_width + separator_size; run->SetAdvance(V); - V.x = (stack_width - top_width) / 2.0; + V.x = (stack_width - top_width) / 2.0 - top_run->BoundingBox().m_min.x; V.y = top_dy; top_run->SetOffset(V); - V.x = (stack_width - bottom_width) / 2.0; + V.x = (stack_width - bottom_width) / 2.0 - bottom_run->BoundingBox().m_min.x; V.y = bottom_dy; bottom_run->SetOffset(V); diff --git a/opennurbs_viewport.cpp b/opennurbs_viewport.cpp index 2784a098..c4fe5424 100644 --- a/opennurbs_viewport.cpp +++ b/opennurbs_viewport.cpp @@ -1491,6 +1491,7 @@ bool ON_Viewport::ChangeToParallelProjection( bool bSymmetricFrustum ) ) { // no changes are required + if (rc) rc = SetViewScale(1.0, 1.0, 1.0); return rc; } @@ -1544,7 +1545,7 @@ bool ON_Viewport::ChangeToParallelProjection( bool bSymmetricFrustum ) if ( m_target_point.IsValid() ) UpdateTargetPointHelper(*this,target_distance); } - + if (rc) rc = SetViewScale(1.0, 1.0, 1.0); return rc; } @@ -1632,6 +1633,7 @@ bool ON_Viewport::ChangeToPerspectiveProjection( SetCamera35mmLensLength(lens_length); } // no other changes are required + if (rc) rc = SetViewScale(1.0, 1.0, 1.0); return rc; } @@ -1654,6 +1656,7 @@ bool ON_Viewport::ChangeToPerspectiveProjection( if ( rc && m_target_point.IsValid() ) UpdateTargetPointHelper(*this,target_distance); + if (rc) rc = SetViewScale(1.0, 1.0, 1.0); return rc; } @@ -1724,6 +1727,18 @@ bool GetTwoPointPerspectiveUpAndDirHelper( const ON_3dVector& up, return false; } +/* +Description: + When a viewport is set to Parallel Reflected projection, the geometry on the ceiling is shown as if it is mirrored to the floor below. +*/ +bool ON_Viewport::ChangeToParallelReflectedProjection() +{ + bool rc = false; + if (!IsParallelProjection()) + rc = ChangeToParallelProjection(true); + if (rc) rc = SetViewScale(1.0, 1.0, -1.0); + return rc; +} bool ON_Viewport::ChangeToTwoPointPerspectiveProjection( double target_distance, ON_3dVector up, @@ -1745,6 +1760,7 @@ bool ON_Viewport::ChangeToTwoPointPerspectiveProjection( { SetCamera35mmLensLength(lens_length); } + if (rc) rc = SetViewScale(1.0, 1.0, 1.0); // no other changes are required return rc; } @@ -1807,7 +1823,7 @@ bool ON_Viewport::ChangeToTwoPointPerspectiveProjection( } } - + if (rc) rc = SetViewScale(1.0, 1.0, 1.0); return rc; } diff --git a/opennurbs_viewport.h b/opennurbs_viewport.h index 22a2a21b..dbc55956 100644 --- a/opennurbs_viewport.h +++ b/opennurbs_viewport.h @@ -230,6 +230,18 @@ public: */ bool ChangeToParallelProjection( bool bSymmetricFrustum ); + /* + Description: + When a viewport is set to a standard Parallel projection, the + geometry that is on the ceiling plane is occluded by the geometry + above. When a viewport is set to Parallel Reflected projection, + the geometry on the ceiling is shown as if it is mirrored to the + floor below. + Remarks: + Calls ChangeToParallelProjection and sets the viewscale to (1, 1, -1) + */ + bool ChangeToParallelReflectedProjection(); + /* Description: Use this function to change projections of valid viewports diff --git a/opennurbs_xml.cpp b/opennurbs_xml.cpp index 3652c23d..6ae27d91 100644 --- a/opennurbs_xml.cpp +++ b/opennurbs_xml.cpp @@ -1822,7 +1822,7 @@ public: bool GetPropertiesFromTag(const ON_wString& sTag); bool IsClosingTag(const ON_wString& sTag) const; ON_XMLNode* GetNodeAtPath(const wchar_t* wszPath, bool bCreate); - ON_XMLProperty* AddProperty(const ON_XMLProperty& prop); + ON_XMLProperty* AddProperty(const ON_XMLProperty& prop, bool add_to_end = false); void AddEmptyDefaultProperty(void); ON_XMLProperty* AttachProperty(ON_XMLProperty* pProp); bool RemoveProperty(const wchar_t* name); @@ -2219,14 +2219,34 @@ bool ON_XMLNodePrivate::RecurseChildren(ON_XMLRecurseChildrenCallback callback, return true; } -ON_XMLProperty* ON_XMLNodePrivate::AddProperty(const ON_XMLProperty& prop) +ON_XMLProperty* ON_XMLNodePrivate::AddProperty(const ON_XMLProperty& prop, bool add_to_end) { std::lock_guard lg(m_mutex); auto* prop_copy = new ON_XMLProperty(prop); prop_copy->_private->_owner = &m_node; - prop_copy->_private->_next = m_first_property; - m_first_property = prop_copy; + + if (!add_to_end || nullptr == m_first_property) + { + prop_copy->_private->_next = m_first_property; + m_first_property = prop_copy; + } + else + { + auto last = m_first_property; + prop_copy->_private->_next = nullptr; + + //Spin to the end. + while (auto n = last->Next()) + { + last = n; + } + + ON_ASSERT(nullptr != last); + ON_ASSERT(nullptr == last->Next()); + + last->_private->_next = prop_copy; + } return prop_copy; } @@ -2610,7 +2630,7 @@ const ON_XMLNode& ON_XMLNode::operator = (const ON_XMLNode& src) auto pi = src.GetPropertyIterator(); while (nullptr != (pProperty = pi.GetNextProperty())) { - _private->AddProperty(*pProperty); + _private->AddProperty(*pProperty, true); //Add it to the end so that the order stays the same. } // Copy in the children.