| 1 |
{ ---------------------------------------------------------------------------- |
| 2 |
|
| 3 |
Define the CONSERVE_TRIANGLE_MEMORY symbol to decrease memory consumed |
| 4 |
by the triangles (in spatial structures created when you set |
| 5 |
"TCastleScene.Spatial"). |
| 6 |
Defining this symbol removes some (seldom used) per-triangle information: |
| 7 |
|
| 8 |
- Per-vertex texture coordinates and per-vertex normal vectors at triangles |
| 9 |
(see TTriangle.TexCoord and TTriangle.Normal). |
| 10 |
|
| 11 |
Not having this information, we cannot implement the X3D events |
| 12 |
ProximitySensor.hitTexCoord_changed and |
| 13 |
ProximitySensor.hitNormal_changed (they will never be generated). |
| 14 |
|
| 15 |
We also cannot generate textures or produce smooth normal vectors |
| 16 |
in ray-tracer. |
| 17 |
|
| 18 |
- Face indexes stored at triangles. |
| 19 |
|
| 20 |
Not having this information, we cannot implement the feature |
| 21 |
"Edit -> Remove face" in castle-model-viewer. |
| 22 |
|
| 23 |
- Defining this also disables the "mailbox" speed optimization for triangles. |
| 24 |
|
| 25 |
This may cause a little worse collision speed, but it should not be |
| 26 |
noticeable at all in interactive simulations (like FPS walking). |
| 27 |
The slowdown is only noticeable when you use ray-tracing, |
| 28 |
and even then the slowdown is small and depends on the scene. |
| 29 |
|
| 30 |
See the TRIANGLE_OCTREE_USE_MAILBOX symbol below, |
| 31 |
and see the TTriangle.Mailbox* fields. |
| 32 |
} |
| 33 |
{ $define CONSERVE_TRIANGLE_MEMORY} |
| 34 |
|
| 35 |
{ ---------------------------------------------------------------------------- |
| 36 |
|
| 37 |
Define CONSERVE_TRIANGLE_MEMORY_MORE to conserve even more triangle memory, |
| 38 |
but at the cost of speed. Some useful triangle values will not |
| 39 |
be precalculated in the memory, but will be recalculated every time they |
| 40 |
are needed. |
| 41 |
|
| 42 |
Note that defining CONSERVE_TRIANGLE_MEMORY and CONSERVE_TRIANGLE_MEMORY_MORE |
| 43 |
is independent, you can define any combination of them. |
| 44 |
For now, we advice first trying with CONSERVE_TRIANGLE_MEMORY, |
| 45 |
and eventually adding CONSERVE_TRIANGLE_MEMORY_MORE if you really must. |
| 46 |
|
| 47 |
This will affect collision detection speed. The difference in normal |
| 48 |
FPS games is probably not noticeable, but if you do something intensive, |
| 49 |
like ray-tracing, it will be noticeable. The slowdown is about 1.1-1.23. |
| 50 |
|
| 51 |
$ ./rayhunter classic 3 1000 1000 ../demo-models/lights_materials/raytracer/area_light_test_final.wrl /tmp/a.png |
| 52 |
Undefined: |
| 53 |
Rendering done in 3.90 seconds. |
| 54 |
Defined: |
| 55 |
Rendering done in 4.30 seconds. |
| 56 |
|
| 57 |
./rayhunter path 2 2 2000 1000 ../demo-models/lights_materials/raytracer/area_light_test_final.wrl /tmp/a.png |
| 58 |
Undefined: |
| 59 |
Rendering done in 67.00 seconds. |
| 60 |
Defined: |
| 61 |
Rendering done in 82.83 seconds. |
| 62 |
} |
| 63 |
{ $define CONSERVE_TRIANGLE_MEMORY_MORE} |
| 64 |
|
| 65 |
{ ---------------------------------------------------------------------------- |
| 66 |
|
| 67 |
Define TRIANGLE_OCTREE_USE_MAILBOX to use "mailboxes" optimization |
| 68 |
for the triangle octree. |
| 69 |
|
| 70 |
This way we avoid checking multiple times collision of the same ray |
| 71 |
with the same triangle. Otherwise, it could be checked many times, |
| 72 |
because a triangle may be duplicated in many octree leaves. |
| 73 |
|
| 74 |
How much the triangle mailbox actually helps depends greatly on |
| 75 |
the kind of the scene, |
| 76 |
and generally in my tests is a noticeable but not terrible advantage. |
| 77 |
For average octree with max-depth = 10 and leaf-capacity = 20 the |
| 78 |
speedup is 1.09 (that is, old time / new time = 1.09). |
| 79 |
} |
| 80 |
{$ifndef CONSERVE_TRIANGLE_MEMORY} |
| 81 |
{$define TRIANGLE_OCTREE_USE_MAILBOX} |
| 82 |
{$endif} |
| 83 |
|
| 84 |
{ ---------------------------------------------------------------------------- |
| 85 |
|
| 86 |
Define SHAPE_OCTREE_USE_MAILBOX to use "mailboxes" optimization |
| 87 |
for the shape octree. |
| 88 |
This helps for octrees with a lot of shapes duplicated in leaves. |
| 89 |
|
| 90 |
E.g. caste's gate_final.wrl speed --- more than 2 times speedup |
| 91 |
with rayhunter using OctreeDynamicCollisions! (from 12.87 to 5.20). |
| 92 |
Tests show that this helps for any model where shapes are duplicated > 1. |
| 93 |
|
| 94 |
For models where shapes are not duplicated (like alien_mirror.wrl), |
| 95 |
this makes a slight slowdown (from to 1.38 to 1.49), but I think that's |
| 96 |
acceptable. Trivial models are fast enough anyway. And note that ray-tracers |
| 97 |
are free to use OctreeVisibleTriangles, not based on shapes, |
| 98 |
since the scene is static there. This is really only for interactive usage |
| 99 |
with OctreeDynamicCollisions and such. |
| 100 |
} |
| 101 |
{$define SHAPE_OCTREE_USE_MAILBOX} |