SnapCore and Intersect

  • Hi all,
    I tried the code described in this thread:
    This code inside the liquitool example work as expected.
    But if i try to use SnapCore::Intersect instead SnapCore::Snap, to get the normal at point, this code don't work.

    This is the line that I changed to:
    if (snap->Intersect(pos, norm, false, res)) instead if (snap->Snap(pos, res))

    Seem that the intersection don't work anymore.

    Any help?
    Thanks in advance
    Renato T.

    Real mx = msg.GetReal(BFM_INPUT_X);
    Real my = msg.GetReal(BFM_INPUT_Y);
    LONG button;
    switch (msg.GetLong(BFM_INPUT_CHANNEL))
        case BFM_INPUT_MOUSELEFT : button=KEY_MLEFT; break;
        case BFM_INPUT_MOUSERIGHT: button=KEY_MRIGHT; break;
        default: return TRUE;
    AutoAlloc<SnapCore> snap;  // Allocate snap
    if (!snap) return FALSE;
    snap->Init(doc, bd);
    Real dx, dy;
    BaseContainer bc;
    BaseContainer device;
    Vector pos;
    SnapResult res;
    BaseObject *active = doc->GetActiveObject();
    while (win->MouseDrag(&dx,&dy,&device)==MOUSEDRAGRESULT_CONTINUE) // Start drag
        // Increment mouse position during drag
        mx += dx;
        my += dy;
        pos = bd->SW(Vector(mx, my, 500)); // Update pos
        if (snap->Snap(pos, res)) // If point snap anywhere 
            pos +=; // Pos will be updated with snapped delta
        if (active)
            active->SetAbsPos(pos); // Set the object position to the new one!
    win->MouseDragEnd(); // Reset viewport status

  • Seem that the normal is returned by SnapCore::Snap in SnapResult::mat.v2. I'm verifying

  • Hi @RenatoT, I don't think there is an issue,

    just in case Intersect is supposed to work only for guide and spline see Modeling Settings - Intersection Snap. So maybe you are looking for GeRayCollider::Interesct.


  • Hi Maxime. Thanks for reply. At last I used the BVHTree for that.

Log in to reply