MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SetInstanceTransform

Method SetInstanceTransform

Source/Engine/Foliage/Foliage.cpp:755–785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753}
754
755void Foliage::SetInstanceTransform(int32 index, const Transform& value)
756{
757 auto& instance = Instances[index];
758 auto type = &FoliageTypes[instance.Type];
759
760 // Change transform
761 instance.Transform = value;
762
763 // Update bounds
764 instance.Bounds = BoundingSphere::Empty;
765 if (!type->IsReady())
766 return;
767 Vector3 corners[8];
768 auto& meshes = type->Model->LODs[0].Meshes;
769 const Transform transform = _transform.LocalToWorld(instance.Transform);
770 for (int32 j = 0; j < meshes.Count(); j++)
771 {
772 meshes[j].GetBox().GetCorners(corners);
773
774 for (int32 k = 0; k < 8; k++)
775 {
776 Vector3::Transform(corners[k], transform, corners[k]);
777 }
778 BoundingSphere meshBounds;
779 BoundingSphere::FromPoints(corners, 8, meshBounds);
780 ASSERT(meshBounds.Radius > ZeroTolerance);
781
782 BoundingSphere::Merge(instance.Bounds, meshBounds, instance.Bounds);
783 }
784 instance.Bounds.Radius += ZeroTolerance;
785}
786
787void Foliage::OnFoliageTypeModelLoaded(int32 index)
788{

Callers 5

FoliageInstanceNodeClass · 0.80
OnApplyTransformationMethod · 0.80
SetOptionsMethod · 0.80
DoMethod · 0.80
UndoMethod · 0.80

Calls 7

TransformClass · 0.50
MergeFunction · 0.50
IsReadyMethod · 0.45
LocalToWorldMethod · 0.45
CountMethod · 0.45
GetCornersMethod · 0.45
GetBoxMethod · 0.45

Tested by

no test coverage detected