Link: Fix mirror twice color issue (#28071)

This commit is contained in:
PaddleStroke
2026-03-09 22:12:34 +01:00
committed by GitHub
parent ee27de857a
commit a0af0d2b85
+24 -13
View File
@@ -88,6 +88,16 @@ FC_LOG_LEVEL_INIT("App::Link", true, true)
using namespace Gui;
using namespace Base;
namespace
{
void updateWindingOrder(Gui::LinkView* linkView, App::LinkBaseExtension* ext)
{
Base::Matrix4D mat = ext->getTransform(false);
ext->getTrueLinkedObject(true, &mat, 0, false);
linkView->renderDoubleSide(mat.determinant3() < 0.0);
}
} // namespace
using CharRange = boost::iterator_range<const char*>;
////////////////////////////////////////////////////////////////////////////
@@ -1161,18 +1171,18 @@ void LinkView::setDrawStyle(int style, double lineWidth, double pointSize)
void LinkView::renderDoubleSide(bool enable)
{
if (!pcShapeHints) {
pcShapeHints = new SoShapeHints;
pcShapeHints->shapeType = SoShapeHints::SOLID;
pcLinkRoot->insertChild(pcShapeHints, 0);
}
if (enable) {
if (!pcShapeHints) {
pcShapeHints = new SoShapeHints;
pcShapeHints->vertexOrdering = SoShapeHints::CLOCKWISE;
pcShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
pcLinkRoot->insertChild(pcShapeHints, 0);
}
pcShapeHints->setOverride(true);
pcShapeHints->vertexOrdering = SoShapeHints::CLOCKWISE;
}
else if (pcShapeHints) {
pcShapeHints->setOverride(false);
else {
pcShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
}
pcShapeHints->setOverride(true);
}
void LinkView::setMaterial(int index, const App::Material* material)
@@ -2192,6 +2202,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension* ext, const App:
}
applyColors();
checkIcon(ext);
updateWindingOrder(linkView, ext);
}
else if (prop == ext->getColoredElementsProperty()) {
if (!prop->testStatus(App::Property::User3)) {
@@ -2204,8 +2215,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension* ext, const App:
if (canScale(v)) {
pcTransform->scaleFactor.setValue(v.x, v.y, v.z);
}
SbMatrix matrix = convert(ext->getTransform(false));
linkView->renderDoubleSide(matrix.det3() < 1e-7);
updateWindingOrder(linkView, ext);
}
}
else if (prop == ext->getPlacementProperty() || prop == ext->getLinkPlacementProperty()) {
@@ -2215,8 +2225,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension* ext, const App:
if (canScale(v)) {
pcTransform->scaleFactor.setValue(v.x, v.y, v.z);
}
SbMatrix matrix = convert(ext->getTransform(false));
linkView->renderDoubleSide(matrix.det3() < 1e-7);
updateWindingOrder(linkView, ext);
}
}
else if (prop == ext->getLinkCopyOnChangeGroupProperty()) {
@@ -2267,6 +2276,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension* ext, const App:
// applyColors();
signalChangeIcon();
updateWindingOrder(linkView, ext);
}
}
else if (prop == ext->getLinkTransformProperty()) {
@@ -2531,6 +2541,7 @@ void ViewProviderLink::finishRestoring()
updateDataPrivate(ext, ext->_getElementListProperty());
applyMaterial();
applyColors();
updateWindingOrder(linkView, ext);
// TODO: notify the tree. This is ugly, any other way?
getDocument()->signalChangedObject(*this, ext->_LinkTouched);