SnapCore - No Inclusion List?
-
On 28/02/2016 at 14:32, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R16+
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;---------
The SnapCore snapping system support is working very well in my plugin (within a SceneHookData). Only problem is that the point selection should be limited to an object and its children (determined by the object in a linkbox on my plugin as active object).SnapCore::Init() has an AtomArray exclusion list which means that I would need to add every object in the document but that limited set. Is that the only possibility?
ETA: Even with that said and done, points can still be shown and selected on exclusionary objects. The list of objects added to the AtomArray is correct. What is missing in this code? Do I actually need to check the AtomArray against the 'target' returned in SnapResult?
//*---------------------------------------------------------------------------* Bool V4DHook::GetSnapIntersection(BaseDocument* pDoc, BaseDraw* pBaseDraw) //*---------------------------------------------------------------------------* { // Get 3D coordinates on Object for grow point (using snap interface) // - Allocate SnapCore AutoAlloc<SnapCore> _snap; if (!_snap) return false; AutoAlloc<AtomArray> excludeList; if (!excludeList) return false; if (!GetV4DObject(pDoc)) return false; GeData data; m_pV4DObject->GetParameter(DescID(V4DOBJECT_HOST_OBJECT), data, DESCFLAGS_GET_0); BaseObject* hostObj = static_cast<BaseObject*>(data.GetLink(pDoc)); if (!hostObj) return false; // - Get List of objects not part of the Host set GetExcludeList(pDoc->GetFirstObject(), hostObj, excludeList); BaseObject* obj = nullptr; for (Int32 i = 0; i != excludeList->GetCount(); ++i) { obj = static_cast<BaseObject*>(excludeList->GetIndex(i)); GePrint("Excluded: "+obj->GetName()); } // - Initialize Snap if (!_snap->Init(pDoc, pBaseDraw, excludeList)) return false; // - Just use snap in get GetCursorInfo if you need realtime snap drawing Vector startPos = pBaseDraw->SW(Vector(m_fX, m_fY, 500)); SnapResult snapResul = SnapResult(); // - Get Snap Hit if (!_snap->Snap(startPos, snapResul, SNAPFLAGS_0)) return false; m_HitPosition = startPos + snapResul.delta; return true; }
-
On 29/02/2016 at 12:28, xxxxxxxx wrote:
I have never worked with the snap library but according to the docs your code should work just fine and I don't see anything wrong (assuming the list is indeed correct).
Maybe it's broken (due to the old AtomArray?). You could try not to pass an AtomArray (but nullptr) and then use SetCustomExcludeList(), which uses newer data structures, before the snap call. This may fit your task as well according to the description in the docs.
Not sure if and when you need to call Update(). Wouldn't make much sense logically but well, it doesn't hurt trying. : )
-
On 01/03/2016 at 00:46, xxxxxxxx wrote:
Hello,
indeed there is only the possibility to exclude elements and no way to define a "include" list. I can only guess that this approach was never anticipated.
It seems that the "exclude" argument of SnapCore::Init() is currently not handled correctly. A bug report was filed.
Best wishes,
Sebastian -
On 01/03/2016 at 05:48, xxxxxxxx wrote:
Thanks, Katachi and Sebastian.
-
On 01/03/2016 at 10:54, xxxxxxxx wrote:
Robert, I would be very interested to know if using snap->SetCustomExcludeList() works for you instead?
Cheers