| 947 | //---------------------------------------------------------------------------- |
| 948 | |
| 949 | void Projectile::emitParticles(const Point3F& from, const Point3F& to, const Point3F& vel, const U32 ms) |
| 950 | { |
| 951 | if ( mHasExploded ) |
| 952 | return; |
| 953 | |
| 954 | Point3F axis = -vel; |
| 955 | |
| 956 | if( axis.isZero() ) |
| 957 | axis.set( 0.0, 0.0, 1.0 ); |
| 958 | else |
| 959 | axis.normalize(); |
| 960 | |
| 961 | bool fromWater = pointInWater(from); |
| 962 | bool toWater = pointInWater(to); |
| 963 | |
| 964 | if (!fromWater && !toWater && bool(mParticleEmitter)) // not in water |
| 965 | mParticleEmitter->emitParticles(from, to, axis, vel, ms); |
| 966 | else if (fromWater && toWater && bool(mParticleWaterEmitter)) // in water |
| 967 | mParticleWaterEmitter->emitParticles(from, to, axis, vel, ms); |
| 968 | else if (!fromWater && toWater && mDataBlock->splash) // entering water |
| 969 | { |
| 970 | // cast the ray to get the surface point of the water |
| 971 | RayInfo rInfo; |
| 972 | if (gClientContainer.castRay(from, to, WaterObjectType, &rInfo)) |
| 973 | { |
| 974 | MatrixF trans = getTransform(); |
| 975 | trans.setPosition(rInfo.point); |
| 976 | |
| 977 | Splash *splash = new Splash(); |
| 978 | splash->onNewDataBlock(mDataBlock->splash, false); |
| 979 | splash->setTransform(trans); |
| 980 | splash->setInitialState(trans.getPosition(), Point3F(0.0, 0.0, 1.0)); |
| 981 | if (!splash->registerObject()) |
| 982 | { |
| 983 | delete splash; |
| 984 | splash = NULL; |
| 985 | } |
| 986 | |
| 987 | // create an emitter for the particles out of water and the particles in water |
| 988 | if (mParticleEmitter) |
| 989 | mParticleEmitter->emitParticles(from, rInfo.point, axis, vel, ms); |
| 990 | |
| 991 | if (mParticleWaterEmitter) |
| 992 | mParticleWaterEmitter->emitParticles(rInfo.point, to, axis, vel, ms); |
| 993 | } |
| 994 | } |
| 995 | else if (fromWater && !toWater && mDataBlock->splash) // leaving water |
| 996 | { |
| 997 | // cast the ray in the opposite direction since that point is out of the water, otherwise |
| 998 | // we hit water immediately and wont get the appropriate surface point |
| 999 | RayInfo rInfo; |
| 1000 | if (gClientContainer.castRay(to, from, WaterObjectType, &rInfo)) |
| 1001 | { |
| 1002 | MatrixF trans = getTransform(); |
| 1003 | trans.setPosition(rInfo.point); |
| 1004 | |
| 1005 | Splash *splash = new Splash(); |
| 1006 | splash->onNewDataBlock(mDataBlock->splash,false); |
no test coverage detected