| 903 | } |
| 904 | |
| 905 | bool Projectile::pointInWater(const Point3F &point) |
| 906 | { |
| 907 | // This is pretty much a hack so we can use the existing ContainerQueryInfo |
| 908 | // and findObject router. |
| 909 | |
| 910 | // We only care if we intersect with water at all |
| 911 | // so build a box at the point that has only 1 z extent. |
| 912 | // And test if water coverage is anything other than zero. |
| 913 | |
| 914 | Box3F boundsBox( point, point ); |
| 915 | boundsBox.maxExtents.z += 1.0f; |
| 916 | |
| 917 | ContainerQueryInfo info; |
| 918 | info.box = boundsBox; |
| 919 | info.mass = 0.0f; |
| 920 | |
| 921 | // Find and retreive physics info from intersecting WaterObject(s) |
| 922 | if(mContainer != NULL) |
| 923 | { |
| 924 | mContainer->findObjects( boundsBox, WaterObjectType, findRouter, &info ); |
| 925 | } |
| 926 | else |
| 927 | { |
| 928 | // Handle special case where the projectile has exploded prior to having |
| 929 | // called onAdd() on the client. This occurs when the projectile on the |
| 930 | // server is created and then explodes in the same network update tick. |
| 931 | // On the client end in NetConnection::ghostReadPacket() the ghost is |
| 932 | // created and then Projectile::unpackUpdate() is called prior to the |
| 933 | // projectile being registered. Within unpackUpdate() the explosion |
| 934 | // is triggered, but without being registered onAdd() isn't called and |
| 935 | // the container is not set. As all we're doing is checking if the |
| 936 | // given explosion point is within water, we should be able to use the |
| 937 | // global container here. We could likely always get away with this, |
| 938 | // but using the actual defined container when possible is the right |
| 939 | // thing to do. DAW |
| 940 | AssertFatal(isClientObject(), "Server projectile has not been properly added"); |
| 941 | gClientContainer.findObjects( boundsBox, WaterObjectType, findRouter, &info ); |
| 942 | } |
| 943 | |
| 944 | return ( info.waterCoverage > 0.0f ); |
| 945 | } |
| 946 | |
| 947 | //---------------------------------------------------------------------------- |
| 948 |
nothing calls this directly
no test coverage detected