From 2512b3984841e82b89893541674c8f329500710a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 20 May 2017 14:14:33 -0700 Subject: [PATCH] don't dirty motion-type if lock value isn't actually changing --- libraries/entities/src/EntityItem.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 80f992d865..2cfb71df0c 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2764,13 +2764,19 @@ bool EntityItem::getLocked() const { } void EntityItem::setLocked(bool value) { + bool changed { false }; withWriteLock([&] { - _locked = value; + if (_locked != value) { + _locked = value; + changed = true; + } }); - markDirtyFlags(Simulation::DIRTY_MOTION_TYPE); - EntityTreePointer tree = getTree(); - if (tree) { - tree->entityChanged(getThisPointer()); + if (changed) { + markDirtyFlags(Simulation::DIRTY_MOTION_TYPE); + EntityTreePointer tree = getTree(); + if (tree) { + tree->entityChanged(getThisPointer()); + } } }