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;
}