mcneel / rhinocommon

RhinoCommon is the .NET SDK for Rhino5 / Grasshopper
http://wiki.mcneel.com/developer/rhinocommon
242 stars 93 forks source link

User defined PickContext objects don't work #131

Closed tmakin closed 11 years ago

tmakin commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 https://github.com/mcneel/rhinocommon/issues/131#issuecomment-14508722 .Das Bild wurde vom Absender entfernt.

dalefugier commented 11 years ago

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 commented 11 years ago

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 https://github.com/mcneel/rhinocommon/issues/131#issuecomment-14513222 .Das Bild wurde vom Absender entfernt.