Skip to content
This repository has been archived by the owner on Dec 23, 2020. It is now read-only.

User defined PickContext objects don't work #131

Closed
tmakin opened this issue Mar 6, 2013 · 4 comments
Closed

User defined PickContext objects don't work #131

tmakin opened this issue Mar 6, 2013 · 4 comments

Comments

@tmakin
Copy link

tmakin commented Mar 6, 2013

Below is an example of the output from a test using a custom curve object to investigate the behaviour of the PickContext class. I can't get my custom pick context objects to return anything sensible even if I initialise it with the exact same params as the context object passed to the OnPick function. Is this a problem with RhinoCommon or the underlying native Rhino code?

class MyCurve : Rhino.DocObjects.Custom.CustomCurveObject
        {
            public MyCurve()
                : base()
            {
            }

            protected override IEnumerable<Rhino.DocObjects.ObjRef> OnPick(Rhino.Input.Custom.PickContext context)
            {
                var objects = base.OnPick(context);

                if (objects == null)
                {
                    return null;
                }

                //create a custom pickContext using identical parameters to the orginal
                Rhino.Input.Custom.PickContext myContext = new Rhino.Input.Custom.PickContext()
                {
                    PickLine = context.PickLine,
                    View = context.View,
                    PickStyle = context.PickStyle,
                    PickMode = context.PickMode,
                    PickGroupsEnabled = context.PickGroupsEnabled
                };

                var curve = this.CurveGeometry.ToNurbsCurve();

                //first perform the test with the object supplied in the onPick argument
                double t1, depth1, dist1;
                var result1 = context.PickFrustumTest(curve, out t1, out depth1, out dist1); //t1, depth1 and dist1 all have sensible values

                //now try the custom PickContext
                double t2, depth2, dist2;
                var result2 = myContext.PickFrustumTest(curve, out t2, out depth2, out dist2); //t2, depth2 and dist2 are all zero

                return objects;
            }
        }
@dalefugier
Copy link
Member

Hi Tom,

An object does not use a pick context to do the actual picking. Rather, it uses the information provided by the pick context do decide how to pick. The logic for the picking is inside of the object's Pick() member, not in the pick context. With that, your code does not make a whole lot of sense.

Pick is, well, hard. And it not easy writing a generic sample. If you can provide me some details as to what you are doing (or what you want to do), then I can probably work up some kind of sample.

Feel free to email me directly if that is easier.

Thanks,

Dale Fugier
Rhinoceros Development
Robert McNeel & Associates
dale@mcneel.com

@uto
Copy link

uto commented Mar 6, 2013

Hi Dale,

I think this email is not for me ;)

It seems tobe for Tom Makin

Best

Thomas

Von: Dale Fugier [mailto:notifications@github.com]
Gesendet: Wednesday, March 06, 2013 5:26 PM
An: mcneel/rhinocommon
Betreff: Re: [rhinocommon] User defined PickContext objects don't work (#131)

Hi Tom,

An object does not use a pick context to do the actual picking. Rather, it uses the information provided by the pick context do decide how to pick. The logic for the picking is inside of the object's Pick() member, not in the pick context. With that, your code does not make a whole lot of sense.

Pick is, well, hard. And it not easy writing a generic sample. If you can provide me some details as to what you are doing (or what you want to do), then I can probably work up some kind of sample.

Feel free to email me directly if that is easier.

Thanks,

Dale Fugier
Rhinoceros Development
Robert McNeel & Associates
dale@mcneel.com


Reply to this email directly or view it on GitHub #131 (comment) .Das Bild wurde vom Absender entfernt.

@dalefugier
Copy link
Member

Hi Thomas,

You got the email (post) because you've subscribed to the RhinoCommon repository on GitHub. If you don't want to receive these notifications, then change your GitHub settings.

Thanks,

-- Dale

@uto
Copy link

uto commented Mar 8, 2013

Hi Dale,

Thx it just irritated me because it was written down Thomas in the email :D

Sorry for that

Greetings from Austria

Best

Thomas

Von: Dale Fugier [mailto:notifications@github.com]
Gesendet: Wednesday, March 06, 2013 6:16 PM
An: mcneel/rhinocommon
Cc: Ursula Frick & Thomas Grabner
Betreff: Re: [rhinocommon] User defined PickContext objects don't work (#131)

Hi Thomas,

You got the email (post) because you've subscribed to the RhinoCommon repository on GitHub. If you don't want to receive these notifications, then change your GitHub settings.

Thanks,

-- Dale


Reply to this email directly or view it on GitHub #131 (comment) .Das Bild wurde vom Absender entfernt.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants