| 2635 | } |
| 2636 | |
| 2637 | int CScriptObjectEntity::BreakEntity(IFunctionHandler *pH) |
| 2638 | { |
| 2639 | //CHECK_PARAMETERS(2); |
| 2640 | |
| 2641 | Vec3 vDir(0,0,1); |
| 2642 | CScriptObjectVector oVec(m_pScriptSystem,true); |
| 2643 | if (pH->GetParam(1,*oVec)) |
| 2644 | { |
| 2645 | vDir = oVec.Get(); |
| 2646 | } |
| 2647 | float explosionForce = 0.01f; // small small force. |
| 2648 | pH->GetParam(2,explosionForce); |
| 2649 | |
| 2650 | float fDensity = 10; |
| 2651 | float fLifeTime = 20; |
| 2652 | bool bRigidBody = false; |
| 2653 | pH->GetParam(3,bRigidBody); |
| 2654 | pH->GetParam(4,fLifeTime); |
| 2655 | pH->GetParam(5,fDensity); |
| 2656 | |
| 2657 | if (m_pEntity) |
| 2658 | for(int n=2; n<m_pEntity->GetNumObjects(); n++) |
| 2659 | { |
| 2660 | CEntityObject obj; |
| 2661 | if(!m_pEntity->GetEntityObject(n,obj)) |
| 2662 | continue; |
| 2663 | |
| 2664 | Vec3 vOffSet = (obj.object->GetBoxMin()+obj.object->GetBoxMax())*0.5f; |
| 2665 | Vec3 vSize = obj.object->GetBoxMax()-obj.object->GetBoxMin(); |
| 2666 | |
| 2667 | // get entity matrix |
| 2668 | //Matrix44 EntityMatrix; |
| 2669 | //EntityMatrix.Identity(); |
| 2670 | //EntityMatrix = GetTranslationMat(m_pEntity->GetPos())*EntityMatrix; |
| 2671 | //EntityMatrix = GetRotationZYX44(-gf_DEGTORAD*m_pEntity->GetAngles())*EntityMatrix; |
| 2672 | //EntityMatrix = GetScale33( Vec3(m_pEntity->GetScale(),m_pEntity->GetScale(),m_pEntity->GetScale()) )*EntityMatrix; |
| 2673 | |
| 2674 | //OPTIMISED_BY_IVO |
| 2675 | Matrix33diag diag = Vec3(m_pEntity->GetScale(),m_pEntity->GetScale(),m_pEntity->GetScale()); //use diag-matrix for scaling |
| 2676 | Matrix34 rt34 = Matrix34::CreateRotationXYZ( Deg2Rad(m_pEntity->GetAngles()), m_pEntity->GetPos() ); //set rotation and translation in one function call |
| 2677 | Matrix44 EntityMatrix = rt34*diag; //optimised concatenation: m34*diag |
| 2678 | |
| 2679 | EntityMatrix = GetTransposed44(EntityMatrix); //TODO: remove this after E3 and use Matrix34 instead of Matrix44 |
| 2680 | |
| 2681 | |
| 2682 | |
| 2683 | vOffSet = EntityMatrix.TransformVectorOLD(vOffSet); |
| 2684 | |
| 2685 | ParticleParams SpawnParticleParams; |
| 2686 | SpawnParticleParams.vPosition = m_pEntity->GetPos()+vOffSet; |
| 2687 | SpawnParticleParams.vDirection = vDir + vOffSet;//Vec3 (0,0,0); |
| 2688 | SpawnParticleParams.fFocus = 30.f; |
| 2689 | SpawnParticleParams.vColorStart = Vec3 (0,1,1); |
| 2690 | SpawnParticleParams.vColorEnd = Vec3 (1,1,0); |
| 2691 | // SpawnParticleParams.fSpeed = 1.0f; |
| 2692 | SpawnParticleParams.fSpeed = explosionForce*0.7f;//0.25f; |
| 2693 | SpawnParticleParams.fSpeed.variation = 0.25f; |
| 2694 | SpawnParticleParams.nCount = 1; |
nothing calls this directly
no test coverage detected