New TCastleTransformReference class, to efficiently reference another TCastleTransform within the same viewport

Multiple cars

I implemented TCastleTransformReference to reference another TCastleTransform within the same viewport. This is an efficient way to use the same TCastleTransform multiple times, which is great for memory and speed. Consider using this when you need a lot of copies of something, e.g. lots of trees or grass patches.

All the TCastleTransformReference instances share the same state with the original, e.g. they will play the same animation. In practice, you will probably most often use this with static (not animated) models.

The detailed usage documentation is already part of the manual, at the bottom of “Tutorial: Designing a 3D world” page.

Note: from code, you can even just place the same TCastleTransform instance multiple times within the same viewport using code, even without TCastleTransformReference. This is documented too.

2 Likes