RESOLVED Projectile Collision on Forest Editor
by Steve Acaster · in Torque 3D Professional · 02/11/2010 (12:52 pm) · 2 replies
Just reiterating an issue from the alpha.
Projectiles collide with any part of a Forest Editor placed object, rather than the object's own collision mesh.
Original alpha bug thread
moved to new forum
RESOLVED IN 1.1BETA2
Projectiles collide with any part of a Forest Editor placed object, rather than the object's own collision mesh.
Original alpha bug thread
moved to new forum
RESOLVED IN 1.1BETA2
About the author
One Bloke ... In His Bedroom ... Making Indie Games ...
Associate James Ford
Sickhead Games
Small changes in these two methods ( in different files ).
bool ForestItem::castRay( const Point3F &start, const Point3F &end, RayInfo *outInfo, bool rendered ) const { if ( !mWorldBox.collideLine( start, end ) ) return false; Point3F s, e; MatrixF mat = getTransform(); mat.scale( Point3F(mScale) ); mat.inverse(); mat.mulP( start, &s ); mat.mulP( end, &e ); TSForestItemData *data = (TSForestItemData*)mDataBlock; TSShapeInstance *si = data->getShapeInstance(); if ( !si ) return false; if ( rendered ) { // Always raycast against detail level zero // because it makes lots of things easier. if ( !si->castRayRendered( s, e, outInfo, 0 ) ) return false; if ( outInfo->userData != NULL ) *(ForestItem*)(outInfo->userData) = *this; return true; } RayInfo shortest; shortest.t = 1e8; bool gotMatch = false; for (U32 i = 0; i < data->mLOSDetails.size(); i++) { if (data->mLOSDetails[i] != -1) { //si->animate(data->mLOSDetails[i]); if ( si->castRayOpcode( data->mLOSDetails[i], s, e, outInfo ) ) { if (outInfo->t < shortest.t) { gotMatch = true; shortest = *outInfo; } } } } if ( !gotMatch ) return false; // Copy out the shortest time... *outInfo = shortest; if ( outInfo->userData != NULL ) *(ForestItem*)(outInfo->userData) = *this; return true; }TSShapeInstance* TSForestItemData::_getShapeInstance() const { // Create the shape instance if we haven't already. if ( !mShapeInstance && mShape ) { // Create the instance. mShapeInstance = new TSShapeInstance( mShape, true ); // So we can make OpCode collision calls. mShapeInstance->prepCollision(); // Get the material features adding the wind effect if // we have a positive wind scale and have vertex color // data which is used for the weighting. FeatureSet features = MATMGR->getDefaultFeatures(); if ( mWindScale > 0.0f && mShape->getVertexFormat()->hasColor() ) { // We create our own cloned material list to // enable the wind effects. features.addFeature( MFT_WindEffect ); mShapeInstance->cloneMaterialList( &features ); } } return mShapeInstance; }