Closed FredrikNoren closed 2 years ago
@sebcrozet Just for consistency; I'm using Box<dyn RayCast>
in my project and I wanted to be able to dump anything in there that can be ray cast (shared or "simple").
The
Shape
trait already derives fromRayCast
, which means that&*shared_shape.0
implementsRayCast
.I'm using
Box<dyn RayCast>
in my project and I wanted to be able to dump anything in there that can be ray cast (shared or "simple").
Perhaps it would be useful to to implement Deref
with Target = &dyn Shape
? That way all methods implemented on Shape
should be accessible without needing &*shared_shape.0
.
@Demindiro Looks like type Target = dyn Shape;
is already implemented on SharedShape. Not sure if type Target = &dyn Shape;
is different though?
Looks like
type Target = dyn Shape;
is already implemented on SharedShape.
Indeed (I meant dyn Shape
instead of &dyn Shape
). I would expect cast_local_ray
to be already useable then though.
@Demindiro Hm, I tried just doing Box::new(shared_shape.clone())
but I got the trait bound 'SharedShape: RayCast' is not satisfied. required for the cast to the object type 'dyn RayCast'
. Not sure if there's some other way to do that though. Box::new(pick_bounding.clone() as dyn RayCast)
doesn't work either.
Thank you for this PR! Is there a particular reason for adding this trait implementation? The
Shape
trait already derives fromRayCast
, which means that&*shared_shape.0
implementsRayCast
.