# April improvements: physics upgrade, sphere casting, layers filtering, easy factory, iOS fixes, image improvements, and more

**URL:** https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885
**Category:** News
**Created:** [May 1, 2025, 7:25pm UTC](https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885 "2025-05-01T19:25:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [May 1, 2025, 7:25pm UTC](https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885/1 "2025-05-01T19:25:37Z")

</div>

| [![&quot;Mars One&quot; environment from Sketchfab https://sketchfab.com/3d-models/mars-one-mission-base-83ced347037f47aba8473147d65df074 by Admone](https://forum.castle-engine.io/uploads/default/original/2X/0/0d0fd5aca41fe110cb28c06d7c9aeeb72f73f50a.png)](https://castle-engine.io/wp/wp-content/uploads/2025/05/Zrzut-ekranu-z-2025-05-01-21-20-41.png "&quot;Mars One&quot; environment from Sketchfab https://sketchfab.com/3d-models/mars-one-mission-base-83ced347037f47aba8473147d65df074 by Admone") |

We have a number of improvements to announce, so welcome to another _“bag of improvements all around the engine”_ news post! Take a look around, see if you find something you like 🙂 As usual, all the announced improvements are already part of the [latest downloads](https://castle-engine.io/download).

1. `TCastleComponentFactory` is now a non-visual component registered in the editor, so it’s easier to use it. You can just add the factory instance to your [view](https://castle-engine.io/views), point it using `TCastleComponentFactory.Url` to the design that you want to spawn multiple times, and then from code use `TCastleComponentFactory.ComponentLoad` to spawn multiple instances of the same thing.

For examples using `TCastleComponentFactory` like this, see [examples/audio/game\_3d\_sound](https://github.com/castle-engine/castle-engine/tree/master/examples/audio/game_3d_sound) (the `TntFactory: TCastleComponentFactory`) or [simple\_3d\_scanning\_fun from conference-pascal-cafe-2025](https://github.com/castle-engine/conference-pascal-cafe-2025/tree/master/simple_3d_scanning_fun) (the `FactoryGamepads: TCastleComponentFactory`).

There are more examples in the engine using `TCastleComponentFactory`, though some create `TCastleComponentFactory` by code. Like [examples/space\_shooter](https://github.com/castle-engine/castle-engine/blob/physics_third_person_navigation/examples/space_shooter/code/gameexplosionsmanager.pas). This approach is also of course fine (it is always OK to create in code what can be done in the editor), it depends on what is more comfortable in given case.

2. We have upgraded [Kraft, our physics engine](https://github.com/BeRo1985/kraft) to follow the latest developments done by _Benjamin “BeRo” Rosseaux_. This brings new optimizations and features (see below).

3. Following the _Kraft_ upgrade, we expose a new method in _Castle Game Engine_: casting a sphere using physics. See `TCastleAbstractRootTransform.PhysicsSphereCast`, `TCastleRigidBody.PhysicsSphereCast`. This is similar to casting a ray, but now you move an imagined sphere in a certain direction.

4. More physics improvements? Sure 🙂 Our `TCastleAbstractRootTransform.PhysicsRayCast`, `TCastleRigidBody.PhysicsRayCast` methods have been extended to support [layers](https://castle-engine.io/physics#_layers). They just get an additional parameter `CollisionLayers: TPhysicsLayers`, by default `AllLayers`. Customize it to test for collisions only with a subset of your bodies.

5. Thanks to [Vlad (phomm)](https://github.com/phomm) you can now disable compiling-in support for some formats that you don’t need, to reduce the exe size of your applications. See [how to use the `CASTLE_xxx_SUPPORT_DISABLE` symbols](https://github.com/castle-engine/castle-engine/blob/8a24e14d30e1eeb95bf526bee33b59eda75744f1/src/common_includes/castleconf.inc#L640).

6. We fixed [iOS building](https://castle-engine.io/ios) and [TestFairy integration](https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/data/ios/services/test_fairy/README.adoc). Ups! Without oversight of the CI/CD such mistakes can happen. I added to TODO to make automatic test of iOS building through [GitHub Actions](https://castle-engine.io/github_actions) soon.

7. Our [build tool `unused-data` analysis can now optionally remove some unused files](https://castle-engine.io/build_tool#_unused_data).

8. We have improved some functionality around images:

9. Finally, we have made `UrlEncode` and `UrlDecode` public. Useful to construct URLs to arbitrary files, see `TCastleZip.Files` for example.

10. BTW, Delphi users, [Delphi 12.3 is available](https://blogs.embarcadero.com/rad-studio-12-3-april-patch-available/) and of course our engine was tested and works flawlessly with it. Don’t hesitate to upgrade 🙂

OK, and this is _not everything_. We still have a number of [web](https://castle-engine.io/web) and [IFC](https://castle-engine.io/ifc) improvements to announce in upcoming dedicated posts. And a new release of our Android apps are in-review. Stay tuned for more!

And if you like what we do, please consider [supporting us on Patreon](https://www.patreon.com/castleengine). We count on your support to keep the engine development active. Thank you!

P.S. As I didn’t have a perfect image for this news post, I typed “improvements” into [Sketchfab](https://castle-engine.io/sketchfab) and run with it 🙂 The screenshot shows [“Mars One” Mission 3D environment](https://sketchfab.com/3d-models/mars-one-mission-base-83ced347037f47aba8473147d65df074) modeled by [Admone](https://sketchfab.com/admone) and displayed using our [Castle Model Viewer](https://castle-engine.io/castle-model-viewer).

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [May 1, 2025, 7:26pm UTC](https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885/2 "2025-05-01T19:26:24Z")

</div>



---

<div class="post-metadata">

### Author: ![DiggiDoggi](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/d/6a8cbe/32.png) [@DiggiDoggi](https://forum.castle-engine.io/u/DiggiDoggi)
#### Post date: [May 1, 2025, 10:12pm UTC](https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885/3 "2025-05-01T22:12:26Z")

</div>

The sphere cast is something that immediately got my attention. Typically, in a 3d game players can interact with stuff - from opening the doors to picking some herbs. Thanks to the sphere instead of a single ray it’s now possible to select things that are in a general direction of where the player is looking, without the need to look directly at the item (or casting multiple rays if nothing’s hit). Also shooting from a weapon or casting a fire ball can be less tedious now, so this update made me happy.

Also the TDrawableImage is a nice & easy solution for situations where a texture is dynamically created or changed. For example, a sign on a shop with player’s custom text / image. Maybe even someone make a game for artists - like painting Monalisa on a virtual canvas.

Plus, you didn’t forget about Delphi users! I don’t need oxygen or H2O as much as I need Delphi to live.

Thanks a lot for all these little big things 🙂

---

<div class="post-metadata">

### Author: ![edj](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/edj/32/1701_2.png) [@edj](https://forum.castle-engine.io/u/edj)
#### Post date: [May 2, 2025, 2:08pm UTC](https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885/4 "2025-05-02T14:08:14Z")

</div>

> [@michalis](#):
>
> CASTLE\_xxx\_SUPPORT\_DISABLE

How much size is saved by disabling all of these? I don’t have a problem with my current exe size (around 10meg for the client and 10meg for the server), but my prior prototype was well over 100megs, though I am not sure why since it didn’t do that much more. I won’t need much from external content as I want to build most everything in the game parametrically.

Is there a gofundme to clone you?

---

<div class="post-metadata">

### Author: ![phomm](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/phomm/32/2827_2.png) [@phomm](https://forum.castle-engine.io/u/phomm)
#### Post date: [May 2, 2025, 5:27pm UTC](https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885/5 "2025-05-02T17:27:38Z")

</div>

@edj Hi, I described the size gain here [User defined Disable of media formats, allows to shrink binary file by phomm · Pull Request #670 · castle-engine/castle-engine · GitHub](https://github.com/castle-engine/castle-engine/pull/670)  
when I enabled only gltf and spritesheets (which I need for my game) I gained 2. 5 mb in release exe

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [May 4, 2025, 3:03pm UTC](https://forum.castle-engine.io/t/april-improvements-physics-upgrade-sphere-casting-layers-filtering-easy-factory-ios-fixes-image-improvements-and-more/1885/6 "2025-05-04T15:03:46Z")

</div>

> [@edj](#):
>
> How much size is saved by disabling all of these? I don’t have a problem with my current exe size (around 10meg for the client and 10meg for the server), but my prior prototype was well over 100megs, though I am not sure why since it didn’t do that much more. I won’t need much from external content as I want to build most everything in the game parametrically.

I see @phomm already answered the main question, about possible gain.

As for 100 MB, be sure to compare the same platform and only “release” builds. Debug builds can be much larger.

> [@edj](#):
>
> Is there a gofundme to clone you?

We’re working on it 🙂
