Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vec3f Sphere3D::GetFarthestVert( const Vec3f& normalized_dir, const Vec3f& origin, const float radius ) {
- Vec3f add( normalized_dir * radius );
- add += origin;
- return add;
- }
- Vec3f Capsule3D::GetFarthestVert( const Vec3f& normalized_dir ) const {
- const Vec3f a( Sphere3D::GetFarthestVert( normalized_dir, origin, radius ) );
- const Vec3f b( Sphere3D::GetFarthestVert( normalized_dir, GetEnd(), radius ) );
- if ( a.Dot( normalized_dir ) > b.Dot( normalized_dir ) )
- return a;
- return b;
- }
- Vec3f Cylinder3D::GetFarthestVert( const Vec3f& normalized_dir ) const {
- const Vec3f spherePoint( Sphere3D::GetFarthestVert( normalized_dir, GetEnd(), radius ) );
- if ( origin.Dot( normalized_dir ) > spherePoint.Dot( normalized_dir ) )
- return origin;
- // ** if the distance of the point is farther than the end of the cylinder, it exists on the sphere and we need to move it
- const float dist = Plane3f::DistanceToPoint( spherePoint, normal, origin );
- if ( dist > length )
- return spherePoint - normal * (dist - length);
- return spherePoint;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement