Use impl Into<Color> for gizmos.primitive_3d(...) (#12915)
				
					
				
			# Objective - All gizmos APIs besides `gizmos.primitive_3d` use `impl Into<Color>` as their type for `color`. ## Solution - This PR changes `primitive_3d()` to use `impl Into<Color>` aswell.
This commit is contained in:
		
							parent
							
								
									ab7cbfa8fc
								
							
						
					
					
						commit
						2f0b5b9c5a
					
				| @ -29,7 +29,7 @@ pub trait GizmoPrimitive3d<P: Primitive3d> { | |||||||
|         primitive: P, |         primitive: P, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_>; |     ) -> Self::Output<'_>; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -43,7 +43,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Dir3> for Gizmos<'w, 's, T> { | |||||||
|         primitive: Dir3, |         primitive: Dir3, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         self.arrow(position, position + (rotation * *primitive), color); |         self.arrow(position, position + (rotation * *primitive), color); | ||||||
|     } |     } | ||||||
| @ -85,14 +85,14 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Sphere> for Gizmos<'w, 's, T> | |||||||
|         primitive: Sphere, |         primitive: Sphere, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         SphereBuilder { |         SphereBuilder { | ||||||
|             gizmos: self, |             gizmos: self, | ||||||
|             radius: primitive.radius, |             radius: primitive.radius, | ||||||
|             position, |             position, | ||||||
|             rotation, |             rotation, | ||||||
|             color, |             color: color.into(), | ||||||
|             segments: DEFAULT_NUMBER_SEGMENTS, |             segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -184,14 +184,14 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Plane3d> for Gizmos<'w, 's, T | |||||||
|         primitive: Plane3d, |         primitive: Plane3d, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         Plane3dBuilder { |         Plane3dBuilder { | ||||||
|             gizmos: self, |             gizmos: self, | ||||||
|             normal: primitive.normal, |             normal: primitive.normal, | ||||||
|             rotation, |             rotation, | ||||||
|             position, |             position, | ||||||
|             color, |             color: color.into(), | ||||||
|             axis_count: 4, |             axis_count: 4, | ||||||
|             segment_count: 3, |             segment_count: 3, | ||||||
|             segment_length: 0.25, |             segment_length: 0.25, | ||||||
| @ -251,12 +251,13 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Line3d> for Gizmos<'w, 's, T> | |||||||
|         primitive: Line3d, |         primitive: Line3d, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         if !self.enabled { |         if !self.enabled { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         let color = color.into(); | ||||||
|         let direction = rotation * *primitive.direction; |         let direction = rotation * *primitive.direction; | ||||||
|         self.arrow(position, position + direction, color); |         self.arrow(position, position + direction, color); | ||||||
| 
 | 
 | ||||||
| @ -278,7 +279,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Segment3d> for Gizmos<'w, 's, | |||||||
|         primitive: Segment3d, |         primitive: Segment3d, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         if !self.enabled { |         if !self.enabled { | ||||||
|             return; |             return; | ||||||
| @ -303,7 +304,7 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive3d<Polyline3d<N> | |||||||
|         primitive: Polyline3d<N>, |         primitive: Polyline3d<N>, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         if !self.enabled { |         if !self.enabled { | ||||||
|             return; |             return; | ||||||
| @ -328,7 +329,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<BoxedPolyline3d> for Gizmos<' | |||||||
|         primitive: BoxedPolyline3d, |         primitive: BoxedPolyline3d, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         if !self.enabled { |         if !self.enabled { | ||||||
|             return; |             return; | ||||||
| @ -355,7 +356,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cuboid> for Gizmos<'w, 's, T> | |||||||
|         primitive: Cuboid, |         primitive: Cuboid, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         if !self.enabled { |         if !self.enabled { | ||||||
|             return; |             return; | ||||||
| @ -390,6 +391,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cuboid> for Gizmos<'w, 's, T> | |||||||
|         // lines connecting upper and lower rectangles of the cuboid
 |         // lines connecting upper and lower rectangles of the cuboid
 | ||||||
|         let connections = vertices.into_iter().zip(vertices.into_iter().skip(4)); |         let connections = vertices.into_iter().zip(vertices.into_iter().skip(4)); | ||||||
| 
 | 
 | ||||||
|  |         let color = color.into(); | ||||||
|         upper |         upper | ||||||
|             .chain(lower) |             .chain(lower) | ||||||
|             .chain(connections) |             .chain(connections) | ||||||
| @ -439,7 +441,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cylinder> for Gizmos<'w, 's, | |||||||
|         primitive: Cylinder, |         primitive: Cylinder, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         Cylinder3dBuilder { |         Cylinder3dBuilder { | ||||||
|             gizmos: self, |             gizmos: self, | ||||||
| @ -447,7 +449,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cylinder> for Gizmos<'w, 's, | |||||||
|             half_height: primitive.half_height, |             half_height: primitive.half_height, | ||||||
|             position, |             position, | ||||||
|             rotation, |             rotation, | ||||||
|             color, |             color: color.into(), | ||||||
|             segments: DEFAULT_NUMBER_SEGMENTS, |             segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -536,7 +538,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Capsule3d> for Gizmos<'w, 's, | |||||||
|         primitive: Capsule3d, |         primitive: Capsule3d, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         Capsule3dBuilder { |         Capsule3dBuilder { | ||||||
|             gizmos: self, |             gizmos: self, | ||||||
| @ -544,7 +546,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Capsule3d> for Gizmos<'w, 's, | |||||||
|             half_length: primitive.half_length, |             half_length: primitive.half_length, | ||||||
|             position, |             position, | ||||||
|             rotation, |             rotation, | ||||||
|             color, |             color: color.into(), | ||||||
|             segments: DEFAULT_NUMBER_SEGMENTS, |             segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -651,7 +653,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cone> for Gizmos<'w, 's, T> { | |||||||
|         primitive: Cone, |         primitive: Cone, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         Cone3dBuilder { |         Cone3dBuilder { | ||||||
|             gizmos: self, |             gizmos: self, | ||||||
| @ -659,7 +661,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cone> for Gizmos<'w, 's, T> { | |||||||
|             height: primitive.height, |             height: primitive.height, | ||||||
|             position, |             position, | ||||||
|             rotation, |             rotation, | ||||||
|             color, |             color: color.into(), | ||||||
|             base_segments: DEFAULT_NUMBER_SEGMENTS, |             base_segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|             height_segments: DEFAULT_NUMBER_SEGMENTS, |             height_segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|         } |         } | ||||||
| @ -749,7 +751,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<ConicalFrustum> for Gizmos<'w | |||||||
|         primitive: ConicalFrustum, |         primitive: ConicalFrustum, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         ConicalFrustum3dBuilder { |         ConicalFrustum3dBuilder { | ||||||
|             gizmos: self, |             gizmos: self, | ||||||
| @ -758,7 +760,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<ConicalFrustum> for Gizmos<'w | |||||||
|             height: primitive.height, |             height: primitive.height, | ||||||
|             position, |             position, | ||||||
|             rotation, |             rotation, | ||||||
|             color, |             color: color.into(), | ||||||
|             segments: DEFAULT_NUMBER_SEGMENTS, |             segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -861,7 +863,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Torus> for Gizmos<'w, 's, T> | |||||||
|         primitive: Torus, |         primitive: Torus, | ||||||
|         position: Vec3, |         position: Vec3, | ||||||
|         rotation: Quat, |         rotation: Quat, | ||||||
|         color: Color, |         color: impl Into<Color>, | ||||||
|     ) -> Self::Output<'_> { |     ) -> Self::Output<'_> { | ||||||
|         Torus3dBuilder { |         Torus3dBuilder { | ||||||
|             gizmos: self, |             gizmos: self, | ||||||
| @ -869,7 +871,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Torus> for Gizmos<'w, 's, T> | |||||||
|             major_radius: primitive.major_radius, |             major_radius: primitive.major_radius, | ||||||
|             position, |             position, | ||||||
|             rotation, |             rotation, | ||||||
|             color, |             color: color.into(), | ||||||
|             minor_segments: DEFAULT_NUMBER_SEGMENTS, |             minor_segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|             major_segments: DEFAULT_NUMBER_SEGMENTS, |             major_segments: DEFAULT_NUMBER_SEGMENTS, | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Lynn
						Lynn