05-02-2021, 09:43 AM
(This post was last modified: 05-02-2021, 09:44 AM by josemendez.)
Hi there,
You're casting the constraints to the wrong type, using the "as" operator. This will return null if the casting fails: https://docs.microsoft.com/en-us/dotnet/...g-and-cast
This line:
should be:
Don't forget to change the declaration of pinConstraints to the same type. See: http://obi.virtualmethodstudio.com/tutor...aints.html
The reason for this is that generics covariance doesn't work as you'd expect in C# < 4.0, and even in later versions you need to be more explicit about it in the generic definition. You can't just cast a generic<TDerived> to a generic<TBase>.
You're casting the constraints to the wrong type, using the "as" operator. This will return null if the casting fails: https://docs.microsoft.com/en-us/dotnet/...g-and-cast
This line:
Code:
pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<IObiConstraintsBatch>;
should be:
Quote:pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
Don't forget to change the declaration of pinConstraints to the same type. See: http://obi.virtualmethodstudio.com/tutor...aints.html
The reason for this is that generics covariance doesn't work as you'd expect in C# < 4.0, and even in later versions you need to be more explicit about it in the generic definition. You can't just cast a generic<TDerived> to a generic<TBase>.