diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 3eb5823ca..ef846fd2c 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -57,6 +57,7 @@ using NLMISC::CRefCount; using NLMISC::CSmartPtr; using NLMISC::CRGBA; using NLMISC::CVector; +using NLMISC::CVectorPacked; using NLMISC::CMatrix; using NLMISC::CSynchronized; diff --git a/code/nel/include/nel/3d/particle_system.h b/code/nel/include/nel/3d/particle_system.h index c1139d070..2cc0f9d79 100644 --- a/code/nel/include/nel/3d/particle_system.h +++ b/code/nel/include/nel/3d/particle_system.h @@ -1244,7 +1244,7 @@ public: static std::vector _ParticleToRemove; // used during the update step, contains the indices of the particles to remove static std::vector _ParticleRemoveListIndex; // for each particle, -1 if it hasn't been removed, or else give the insertion number in _ParticleToRemove static std::vector _CollidingParticles; // index of particle that collided - static std::vector _SpawnPos; // spawn position of newly created particles + static std::vector _SpawnPos; // spawn position of newly created particles public: // current sim steps infos static TAnimationTime EllapsedTime; diff --git a/code/nel/include/nel/3d/ps_attrib.h b/code/nel/include/nel/3d/ps_attrib.h index cd691e719..a70fa7921 100644 --- a/code/nel/include/nel/3d/ps_attrib.h +++ b/code/nel/include/nel/3d/ps_attrib.h @@ -563,12 +563,12 @@ void CPSAttrib::swap(CPSAttrib &other) // here we give some definition for common types -typedef CPSAttrib TPSAttribVector; -typedef CPSAttrib TPSAttribRGBA; -typedef CPSAttrib TPSAttribFloat; -typedef CPSAttrib TPSAttribUInt; -typedef CPSAttrib TPSAttribUInt8; -typedef CPSAttrib TPSAttribTime; +typedef CPSAttrib TPSAttribVector; +typedef CPSAttrib TPSAttribRGBA; +typedef CPSAttrib TPSAttribFloat; +typedef CPSAttrib TPSAttribUInt; +typedef CPSAttrib TPSAttribUInt8; +typedef CPSAttrib TPSAttribTime; } // NL3D diff --git a/code/nel/include/nel/3d/ps_attrib_maker_helper.h b/code/nel/include/nel/3d/ps_attrib_maker_helper.h index 147d1ae5d..4ae6e65b1 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_helper.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_helper.h @@ -1190,10 +1190,10 @@ T CPSAttribMakerT::get(CPSLocated *loc, uint32 index) result= getInternal(loc->getInvMass()[index]); break; case CPSInputType::attrSpeed: - result = getInternal(loc->getSpeed()[index].norm()); + result = getInternal(NLMISC::CVector(loc->getSpeed()[index]).norm()); break; case CPSInputType::attrPosition: - result = getInternal(loc->getPos()[index].norm()); + result = getInternal(NLMISC::CVector(loc->getPos()[index]).norm()); break; case CPSInputType::attrUniformRandom: { @@ -1210,7 +1210,7 @@ T CPSAttribMakerT::get(CPSLocated *loc, uint32 index) static NLMISC::CVector lodVect; float lodOffset; loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode()); - float r = fabsf(loc->getPos()[index] * lodVect + lodOffset); + float r = fabsf(NLMISC::CVector(loc->getPos()[index]) * lodVect + lodOffset); r = this->_NbCycles * r > MaxInputValue ? MaxInputValue : r; if (_Clamp) { @@ -1224,7 +1224,7 @@ T CPSAttribMakerT::get(CPSLocated *loc, uint32 index) static NLMISC::CVector lodVect; float lodOffset; loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode()); - float r = loc->getPos()[index] * lodVect + lodOffset; + float r = NLMISC::CVector(loc->getPos()[index]) * lodVect + lodOffset; r = this->_NbCycles * (r > MaxInputValue ? MaxInputValue : r * r); if (_Clamp) @@ -1240,7 +1240,7 @@ T CPSAttribMakerT::get(CPSLocated *loc, uint32 index) float lodOffset; loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode()); - float r = loc->getPos()[index] * lodVect + lodOffset; + float r = NLMISC::CVector(loc->getPos()[index]) * lodVect + lodOffset; if (r < 0) { result = _F(MaxInputValue); @@ -1260,7 +1260,7 @@ T CPSAttribMakerT::get(CPSLocated *loc, uint32 index) float lodOffset; loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode()); - float r = loc->getPos()[index] * lodVect + lodOffset; + float r = NLMISC::CVector(loc->getPos()[index]) * lodVect + lodOffset; if (r < 0) { result = _F(MaxInputValue); diff --git a/code/nel/include/nel/3d/ps_attrib_maker_iterators.h b/code/nel/include/nel/3d/ps_attrib_maker_iterators.h index c2c54d9d8..cbc3231d0 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_iterators.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_iterators.h @@ -48,7 +48,7 @@ namespace NL3D template struct CVectNormIterator : CPSBaseIterator { - GET_INLINE float get() const { return this->Iter.get().norm(); } + GET_INLINE float get() const { return CVector(this->Iter.get()).norm(); } CVectNormIterator(const TBaseIter &it) : CPSBaseIterator(it) {} }; @@ -76,7 +76,7 @@ namespace NL3D template struct CDistIterator : CPSBaseIterator { - NLMISC::CVector V; + NLMISC::CVectorPacked V; float Offset; CDistIterator(const TBaseIter &it) : CPSBaseIterator(it) {} }; @@ -89,7 +89,7 @@ namespace NL3D GET_INLINE float get() const { - const float r = fabsf(this->Iter.get() * this->V + this->Offset); + const float r = fabsf(CVector(this->Iter.get()) * this->V + this->Offset); return r > MaxInputValue ? MaxInputValue : r; } CFDot3AddIterator(const TBaseIter &it) : CDistIterator(it) {} @@ -101,7 +101,7 @@ namespace NL3D { float get() const { - float r = this->Iter.get() * this->V + this->Offset; + float r = CVector(this->Iter.get()) * this->V + this->Offset; r *= r; return r > MaxInputValue ? MaxInputValue : r; } @@ -115,7 +115,7 @@ namespace NL3D GET_INLINE float get() const { - const float r = this->Iter.get() * this->V + this->Offset; + const float r = CVector(this->Iter.get()) * this->V + this->Offset; if (r < 0.f) return MaxInputValue; return r > MaxInputValue ? MaxInputValue : r; } @@ -130,7 +130,7 @@ namespace NL3D GET_INLINE float get() const { - float r = this->Iter.get() * this->V + this->Offset; + float r = CVector(this->Iter.get()) * this->V + this->Offset; if (r < 0) return MaxInputValue; r *= r; return r > MaxInputValue ? MaxInputValue : r; diff --git a/code/nel/include/nel/3d/ps_force.h b/code/nel/include/nel/3d/ps_force.h index 76cf90ee4..1739bfa92 100644 --- a/code/nel/include/nel/3d/ps_force.h +++ b/code/nel/include/nel/3d/ps_force.h @@ -87,9 +87,9 @@ public: * 'accumulate' set to false. * NB : works only with integrable forces */ - virtual void integrate(float /* date */, CPSLocated * /* src */, uint32 /* startIndex */, uint32 /* numObjects */, NLMISC::CVector * /* destPos */ = NULL, NLMISC::CVector * /* destSpeed */ = NULL, + virtual void integrate(float /* date */, CPSLocated * /* src */, uint32 /* startIndex */, uint32 /* numObjects */, NLMISC::CVectorPacked * /* destPos */ = NULL, NLMISC::CVectorPacked * /* destSpeed */ = NULL, bool /* accumulate */ = false, - uint /* posStride */ = sizeof(NLMISC::CVector), uint /* speedStride */ = sizeof(NLMISC::CVector) + uint /* posStride */ = sizeof(NLMISC::CVectorPacked), uint /* speedStride */ = sizeof(NLMISC::CVectorPacked) ) const { nlassert(0); // not an integrable force @@ -325,7 +325,10 @@ template void CIsotropicForceT::computeForces(CPSLocated &target) for (; speedIt != endSpeedIt; ++speedIt, ++posIt, ++invMassIt) { - _F(*posIt, *speedIt, *invMassIt); + const CVector posv = *posIt; + CVector speedv = *speedIt; + _F(posv, speedv, *invMassIt); + *speedIt = speedv; } } } @@ -770,7 +773,7 @@ protected: virtual CPSLocated *getForceIntensityOwner(void) { return _Owner; } // the normal of the vortex - CPSAttrib _Normal; + CPSAttrib _Normal; // radius of the vortex TPSAttribFloat _Radius; diff --git a/code/nel/include/nel/3d/ps_iterator.h b/code/nel/include/nel/3d/ps_iterator.h index 5a02cecda..5f850e393 100644 --- a/code/nel/include/nel/3d/ps_iterator.h +++ b/code/nel/include/nel/3d/ps_iterator.h @@ -134,10 +134,10 @@ namespace NL3D /// Some typedefs typedef CAdvance1Iterator TIteratorFloatStep1; typedef CAdvance1Iterator TIteratorFloatStep1; - typedef CAdvance1Iterator TIteratorVectStep1; + typedef CAdvance1Iterator TIteratorVectStep1; typedef CAdvance1616Iterator TIteratorFloatStep1616; typedef CAdvance1616Iterator TIteratorTimeStep1616; - typedef CAdvance1616Iterator TIteratorVectStep1616; + typedef CAdvance1616Iterator TIteratorVectStep1616; } // NL3D diff --git a/code/nel/include/nel/3d/ps_located.h b/code/nel/include/nel/3d/ps_located.h index ca1c86a7b..2fb210544 100644 --- a/code/nel/include/nel/3d/ps_located.h +++ b/code/nel/include/nel/3d/ps_located.h @@ -220,6 +220,7 @@ public: CScene *getScene(void); /// shortcut to the same method of the owning particle system + void getLODVect(NLMISC::CVectorPacked &v, float &offset, TPSMatrixMode matrixMode); void getLODVect(NLMISC::CVector &v, float &offset, TPSMatrixMode matrixMode); @@ -411,7 +412,7 @@ public: void computeForces(); // compute collisions - void computeCollisions(uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter); + void computeCollisions(uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter); // get a conversion matrix between 2 matrix modes static const NLMISC::CMatrix &getConversionMatrix(const CParticleSystem &ps, TPSMatrixMode to, TPSMatrixMode from); diff --git a/code/nel/include/nel/3d/ps_util.h b/code/nel/include/nel/3d/ps_util.h index 7542b7053..64af8a7fa 100644 --- a/code/nel/include/nel/3d/ps_util.h +++ b/code/nel/include/nel/3d/ps_util.h @@ -28,6 +28,7 @@ namespace NLMISC { class CMatrix; class CVector; + class CVectorPacked; }; namespace NL3D diff --git a/code/nel/include/nel/3d/ps_zone.h b/code/nel/include/nel/3d/ps_zone.h index cf29bc258..72d5a5529 100644 --- a/code/nel/include/nel/3d/ps_zone.h +++ b/code/nel/include/nel/3d/ps_zone.h @@ -106,7 +106,7 @@ public: /** Compute collisions for the given target. This will update the collisions infos. * The caller must provide pointer to arrays positions before and after time step. */ - virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter) = 0; + virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter) = 0; protected: @@ -141,7 +141,7 @@ protected: class CPSZonePlane : public CPSZone, public IPSMover { public: - virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter); + virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter); virtual void show(); @@ -192,7 +192,7 @@ typedef CPSAttrib TPSAttribRadiusPair; class CPSZoneSphere : public CPSZone, public IPSMover { public: - virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter); + virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter); virtual void show(); @@ -236,7 +236,7 @@ class CPSZoneSphere : public CPSZone, public IPSMover class CPSZoneDisc : public CPSZone, public IPSMover { public: - virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter); + virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter); virtual void show(); CPSZoneDisc() @@ -283,7 +283,7 @@ class CPSZoneDisc : public CPSZone, public IPSMover class CPSZoneCylinder : public CPSZone, public IPSMover { public: - virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter); + virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter); virtual void show(); CPSZoneCylinder() @@ -335,7 +335,7 @@ class CPSZoneCylinder : public CPSZone, public IPSMover class CPSZoneRectangle : public CPSZone, public IPSMover { public: - virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter); + virtual void computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter); virtual void show(); CPSZoneRectangle() diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 2e74ae3fe..73b97d9cd 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -47,6 +47,7 @@ namespace NL3D using NLMISC::CVector; +using NLMISC::CVectorPacked; using NLMISC::CMatrix; using NLMISC::CRGBA; using NLMISC::CBitmap; diff --git a/code/nel/include/nel/misc/vector.h b/code/nel/include/nel/misc/vector.h index f11137764..d499a5dba 100644 --- a/code/nel/include/nel/misc/vector.h +++ b/code/nel/include/nel/misc/vector.h @@ -69,11 +69,11 @@ public: // Methods. /// @name Object. //@{ /// Constructor which does nothing. - CVector() {} + CVector() { if (((uintptr_t)(void *)(this) & 0xF) != 0) nlerror("Vector alignment error"); } /// Constructor . - CVector(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {} + CVector(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { if (((uintptr_t)(void *)(this) & 0xF) != 0) nlerror("Vector alignment error"); } /// Copy Constructor. - CVector(const CVector &v) : x(v.x), y(v.y), z(v.z) {} + CVector(const CVector &v) : x(v.x), y(v.y), z(v.z) { if (((uintptr_t)(void *)(this) & 0xF) != 0) nlerror("Vector alignment error"); } //@} /// @name Base Maths. @@ -181,6 +181,14 @@ public: return *this; } + CVectorPacked &operator -= (const CVector &v) + { + x -= v.x; + y -= v.y; + z -= v.z; + return *this; + } + operator CVector () const { return CVector(x, y, z); @@ -190,6 +198,16 @@ public: { f.serial(x,y,z); } + + CVector operator+(const CVector &v) const + { + return CVector(*this) + v; + } + + CVector operator-(const CVector &v) const + { + return CVector(*this) - v; + } }; // blend (faster version than the generic version found in algo.h) @@ -214,9 +232,25 @@ inline CVector blend(const CVector &v0, const CVector &v1, float lambda) } + } +namespace std { + inline void swap(NLMISC::CVectorPacked &v1, NLMISC::CVector &v2) + { + NLMISC::CVectorPacked temp = v2; + v2 = NLMISC::CVector(v1); + v1 = temp; + } + inline void swap(NLMISC::CVector &v1, NLMISC::CVectorPacked &v2) + { + NLMISC::CVectorPacked temp = v1; + v1 = NLMISC::CVector(v2); + v2 = temp; + } +} + #include "vector_inline.h" diff --git a/code/nel/src/3d/particle_system.cpp b/code/nel/src/3d/particle_system.cpp index 3b25c3e1e..ce8fbaae4 100644 --- a/code/nel/src/3d/particle_system.cpp +++ b/code/nel/src/3d/particle_system.cpp @@ -64,7 +64,7 @@ float CParticleSystem::RealEllapsedTimeRatio = 1.f; bool CParticleSystem::InsideSimLoop = false; bool CParticleSystem::InsideRemoveLoop = false; bool CParticleSystem::InsideNewElementsLoop = false;; -std::vector CParticleSystem::_SpawnPos; +std::vector CParticleSystem::_SpawnPos; diff --git a/code/nel/src/3d/ps_emitter.cpp b/code/nel/src/3d/ps_emitter.cpp index 0084111a0..ef0931eed 100644 --- a/code/nel/src/3d/ps_emitter.cpp +++ b/code/nel/src/3d/ps_emitter.cpp @@ -2790,7 +2790,7 @@ void CPSEmitter::doEmitOnce(uint firstInstanceIndex) CVector startPos; if (!_Owner->isParametricMotionEnabled()) { - startPos = _Owner->getPos()[k] - _Owner->getSpeed()[k] * CParticleSystem::EllapsedTime; + startPos = CVector(_Owner->getPos()[k]) - CVector(_Owner->getSpeed()[k]) * CParticleSystem::EllapsedTime; } else { @@ -2823,7 +2823,7 @@ void CPSEmitter::doEmitOnce(uint firstInstanceIndex) CVector startPos; if (!_Owner->isParametricMotionEnabled()) { - startPos = _Owner->getPos()[k] - _Owner->getSpeed()[k] * CParticleSystem::EllapsedTime; + startPos = CVector(_Owner->getPos()[k]) - CVector(_Owner->getSpeed()[k]) * CParticleSystem::EllapsedTime; } else { diff --git a/code/nel/src/3d/ps_face_look_at.cpp b/code/nel/src/3d/ps_face_look_at.cpp index ccc5907c5..782d5c70d 100644 --- a/code/nel/src/3d/ps_face_look_at.cpp +++ b/code/nel/src/3d/ps_face_look_at.cpp @@ -65,7 +65,7 @@ public: do { // tmp unoptimized slow version - CVector normedSpeed = (*speedIt).normed(); + CVector normedSpeed = CVector(*speedIt).normed(); float iProj = normedSpeed * I; float kProj = normedSpeed * K; dest->I = iProj * I + kProj * K; diff --git a/code/nel/src/3d/ps_force.cpp b/code/nel/src/3d/ps_force.cpp index 7659ce7af..f013dcc3a 100644 --- a/code/nel/src/3d/ps_force.cpp +++ b/code/nel/src/3d/ps_force.cpp @@ -862,8 +862,8 @@ void CPSCylindricVortex::computeForces(CPSLocated &target) p *= 1.f / d; // compute the speed vect that we should have (normalized) realTangentialSpeed = n ^ p; - tangentialSpeed = (*speedIt * realTangentialSpeed) * realTangentialSpeed; - radialSpeed = (p * *speedIt) * p; + tangentialSpeed = (CVector(*speedIt) * realTangentialSpeed) * realTangentialSpeed; + radialSpeed = (p * CVector(*speedIt)) * p; // update radial speed; *speedIt -= _RadialViscosity * CParticleSystem::EllapsedTime * radialSpeed; // update tangential speed @@ -981,7 +981,7 @@ void CPSMagneticForce::computeForces(CPSLocated &target) TPSAttribFloat::const_iterator invMassIt = target.getInvMass().begin(); for (; it != itend; ++it, ++invMassIt) { - (*it) += intensity * *invMassIt * (*it ^ toAdd); + (*it) += intensity * *invMassIt * (CVector(*it) ^ toAdd); } } else @@ -989,7 +989,7 @@ void CPSMagneticForce::computeForces(CPSLocated &target) float i = intensity / target.getInitialMass(); for (; it != itend; ++it) { - (*it) += i * (*it ^ toAdd); + (*it) += i * (CVector(*it) ^ toAdd); } } } diff --git a/code/nel/src/3d/ps_located.cpp b/code/nel/src/3d/ps_located.cpp index 57997e2be..0ef57fab1 100644 --- a/code/nel/src/3d/ps_located.cpp +++ b/code/nel/src/3d/ps_located.cpp @@ -502,6 +502,18 @@ bool CPSLocated::hasEmitters(void) const return false; } +/// *************************************************************************************** +void CPSLocated::getLODVect(NLMISC::CVectorPacked &v, float &offset, TPSMatrixMode matrixMode) +{ + NL_PS_FUNC(CPSLocated_getLODVect) + nlassert(_Owner); + CHECK_PS_INTEGRITY + CVector temp; + _Owner->getLODVect(temp, offset, matrixMode); + v = temp; + CHECK_PS_INTEGRITY +} + /// *************************************************************************************** void CPSLocated::getLODVect(NLMISC::CVector &v, float &offset, TPSMatrixMode matrixMode) { @@ -1866,7 +1878,7 @@ void CPSLocated::updateCollisions() if (_Time[currCollision->Index] >= 1.f) { // check whether particles died before the collision. If so, just continue (particle has already been inserted in the remove list), and cancel the collision - float timeToCollision = currCollision->Dist / _Speed[currCollision->Index].norm(); + float timeToCollision = currCollision->Dist / CVector(_Speed[currCollision->Index]).norm(); if (_Time[currCollision->Index] / _TimeIncrement[currCollision->Index] - timeToCollision * CParticleSystem::RealEllapsedTimeRatio >= 1.f) { // says that collision did not occurs @@ -2196,12 +2208,12 @@ void CPSLocated::removeOldParticles() if (_LifeScheme) { - _Pos[*it] -= _Speed[*it] * ((_Time[*it] - 1.f) / _TimeIncrement[*it]) * ellapsedTimeRatio; + _Pos[*it] -= CVector(_Speed[*it]) * ((_Time[*it] - 1.f) / _TimeIncrement[*it]) * ellapsedTimeRatio; timeUntilNextSimStep = (_Time[*it] - 1.f) / _TimeIncrement[*it]; } else { - _Pos[*it] -= _Speed[*it] * ((_Time[*it] - 1.f) * _InitialLife) * ellapsedTimeRatio; + _Pos[*it] -= CVector(_Speed[*it]) * ((_Time[*it] - 1.f) * _InitialLife) * ellapsedTimeRatio; timeUntilNextSimStep = (_Time[*it] - 1.f) * _InitialLife; } _Time[*it] = 0.9999f; @@ -2255,7 +2267,7 @@ void CPSLocated::removeOldParticles() { // move position backward (compute its position at death) timeUntilNextSimStep = ((_Time[*it] - 1.f) / _TimeIncrement[*it]) * ellapsedTimeRatio; - _Pos[*it] -= _Speed[*it] * timeUntilNextSimStep; + _Pos[*it] -= CVector(_Speed[*it]) * timeUntilNextSimStep; // force time to 1 because emitter 'on death' may rely on the date of emitter to compute its attributes _Time[*it] = 0.9999f; @@ -2283,7 +2295,7 @@ void CPSLocated::removeOldParticles() { // move position backward timeUntilNextSimStep = (_Time[*it] - 1.f) * _InitialLife * ellapsedTimeRatio; - _Pos[*it] -= _Speed[*it] * timeUntilNextSimStep; + _Pos[*it] -= CVector(_Speed[*it]) * timeUntilNextSimStep; // force time to 1 because emitter 'on death' may rely on the date of emitter to compute its attributes _Time[*it] = 0.9999f; } @@ -3038,7 +3050,7 @@ void CPSLocated::setZBias(float value) } /// *************************************************************************************** -void CPSLocated::computeCollisions(uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter) +void CPSLocated::computeCollisions(uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter) { NL_PS_FUNC(CPSLocated_computeCollisions) for(TDtorObserversVect::iterator it = _DtorObserversVect.begin(); it != _DtorObserversVect.end(); ++it) diff --git a/code/nel/src/3d/ps_plane_basis_maker.cpp b/code/nel/src/3d/ps_plane_basis_maker.cpp index f1ca718b9..2bec4c713 100644 --- a/code/nel/src/3d/ps_plane_basis_maker.cpp +++ b/code/nel/src/3d/ps_plane_basis_maker.cpp @@ -130,7 +130,7 @@ void *CPSPlaneBasisFollowSpeed::make(CPSLocated *loc, case XY: while (numAttrib --) { - const CVector *speedVect = &(*(speedIt + (fpIndex >> 16))); + const NLMISC::CVectorPacked *speedVect = &(*(speedIt + (fpIndex >> 16))); float norm = sqrtf(speedVect->x * speedVect->x + speedVect->y * speedVect->y); float invNorm = (norm != 0.f) ? 1.f / norm : 0.f; CPlaneBasis &pb = *(CPlaneBasis *) ptDat; @@ -143,7 +143,7 @@ void *CPSPlaneBasisFollowSpeed::make(CPSLocated *loc, case XZ: while (numAttrib --) { - const CVector *speedVect = &(*(speedIt + (fpIndex >> 16))); + const NLMISC::CVectorPacked *speedVect = &(*(speedIt + (fpIndex >> 16))); float norm = sqrtf(speedVect->x * speedVect->x + speedVect->z * speedVect->z); float invNorm = (norm != 0.f) ? 1.f / norm : 0.f; CPlaneBasis &pb = *(CPlaneBasis *) ptDat; @@ -156,7 +156,7 @@ void *CPSPlaneBasisFollowSpeed::make(CPSLocated *loc, case YZ: while (numAttrib --) { - const CVector *speedVect = &(*(speedIt + (fpIndex >> 16))); + const NLMISC::CVectorPacked *speedVect = &(*(speedIt + (fpIndex >> 16))); float norm = sqrtf(speedVect->y * speedVect->y + speedVect->z * speedVect->z); float invNorm = (norm != 0.f) ? 1.f / norm : 0.f; CPlaneBasis &pb = *(CPlaneBasis *) ptDat; diff --git a/code/nel/src/3d/ps_shockwave.cpp b/code/nel/src/3d/ps_shockwave.cpp index 4421faded..169ad2ec6 100644 --- a/code/nel/src/3d/ps_shockwave.cpp +++ b/code/nel/src/3d/ps_shockwave.cpp @@ -160,10 +160,10 @@ public: radVect = *ptCurrSize * (CPSUtil::getCos((sint32) currAngle) * ptCurrBasis->X + CPSUtil::getSin((sint32) currAngle) * ptCurrBasis->Y); innerVect = radiusRatio * radVect; CHECK_VERTEX_BUFFER(*vb, currVertex); - * (CVectorPacked *) currVertex = *posIt + radVect; + * (CVectorPacked *) currVertex = CVector(*posIt) + radVect; currVertex += vSize; CHECK_VERTEX_BUFFER(*vb, currVertex); - * (CVectorPacked *) currVertex = *posIt + innerVect; + * (CVectorPacked *) currVertex = CVector(*posIt) + innerVect; currVertex += vSize; currAngle += angleStep; } diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index a5ae6ad26..07aefd4cf 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -148,8 +148,8 @@ void CPSSound::step(TPSProcessPass pass) CPSAttrib::iterator it = _Sounds.begin(), endIt; - CPSAttrib::const_iterator posIt = _Owner->getPos().begin(); - CPSAttrib::const_iterator speedIt = _Owner->getSpeed().begin(); + CPSAttrib::const_iterator posIt = _Owner->getPos().begin(); + CPSAttrib::const_iterator speedIt = _Owner->getSpeed().begin(); do { diff --git a/code/nel/src/3d/ps_zone.cpp b/code/nel/src/3d/ps_zone.cpp index 813103896..250877e28 100644 --- a/code/nel/src/3d/ps_zone.cpp +++ b/code/nel/src/3d/ps_zone.cpp @@ -194,7 +194,7 @@ void CPSZonePlane::deleteElement(uint32 index) } -void CPSZonePlane::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter) +void CPSZonePlane::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter) { NL_PS_FUNC(CPSZonePlane_computeCollisions) MINI_TIMER(PSStatsZonePlane) @@ -213,9 +213,9 @@ void CPSZonePlane::computeCollisions(CPSLocated &target, uint firstInstanceIndex NLMISC::CPlane p; p.make(m.mulVector(*normalIt), m * (*planePosIt)); // deals with each particle - const NLMISC::CVector *itPosBefore = posBefore + firstInstanceIndex; - const NLMISC::CVector *itPosBeforeEnd = posBefore + target.getSize(); - const NLMISC::CVector *itPosAfter = posAfter + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBefore = posBefore + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBeforeEnd = posBefore + target.getSize(); + const NLMISC::CVectorPacked *itPosAfter = posAfter + firstInstanceIndex; while (itPosBefore != itPosBeforeEnd) { float posSide = p * *itPosBefore; @@ -235,7 +235,7 @@ void CPSZonePlane::computeCollisions(CPSLocated &target, uint firstInstanceIndex ci.Dist = startEnd.norm(); // we translate the particle from an epsilon so that it won't get hooked to the plane ci.NewPos = *itPosBefore + startEnd + PSCollideEpsilon * p.getNormal(); - const CVector &speed = target.getSpeed()[(uint32)(itPosBefore - posBefore)]; + const CVector speed = target.getSpeed()[(uint32)(itPosBefore - posBefore)]; ci.NewSpeed = _BounceFactor * (speed - 2.0f * (speed * p.getNormal()) * p.getNormal()); ci.CollisionZone = this; CPSLocated::_Collisions[itPosBefore - posBefore].update(ci); @@ -290,7 +290,7 @@ void CPSZonePlane::serial(NLMISC::IStream &f) throw(NLMISC::EStream) // sphere implementation // /////////////////////////// -void CPSZoneSphere::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter) +void CPSZoneSphere::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter) { NL_PS_FUNC(CPSZoneSphere_computeCollisions) MINI_TIMER(PSStatsZoneSphere) @@ -308,9 +308,9 @@ void CPSZoneSphere::computeCollisions(CPSLocated &target, uint firstInstanceInde const CMatrix &m = CPSLocated::getConversionMatrix(&target, this->_Owner); CVector center = m * *spherePosIt; // deals with each particle - const NLMISC::CVector *itPosBefore = posBefore + firstInstanceIndex; - const NLMISC::CVector *itPosBeforeEnd = posBefore + target.getSize(); - const NLMISC::CVector *itPosAfter = posAfter + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBefore = posBefore + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBeforeEnd = posBefore + target.getSize(); + const NLMISC::CVectorPacked *itPosAfter = posAfter + firstInstanceIndex; while (itPosBefore != itPosBeforeEnd) { // check whether the located is going through the sphere @@ -346,7 +346,7 @@ void CPSZoneSphere::computeCollisions(CPSLocated &target, uint firstInstanceInde ci.Dist = startEnd.norm(); // we translate the particle from an epsilon so that it won't get hooked to the sphere ci.NewPos = pos + startEnd + PSCollideEpsilon * normal; - const CVector &speed = target.getSpeed()[(uint32)(itPosBefore - posBefore)]; + const CVector speed = target.getSpeed()[(uint32)(itPosBefore - posBefore)]; ci.NewSpeed = _BounceFactor * (speed - 2.0f * (speed * normal) * normal); ci.CollisionZone = this; CPSLocated::_Collisions[itPosBefore - posBefore].update(ci); @@ -450,7 +450,7 @@ void CPSZoneSphere::deleteElement(uint32 index) //////////////////////////////// // CPSZoneDisc implementation // //////////////////////////////// -void CPSZoneDisc::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter) +void CPSZoneDisc::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter) { NL_PS_FUNC(CPSZoneDisc_computeCollisions) MINI_TIMER(PSStatsZoneDisc) @@ -477,9 +477,9 @@ void CPSZoneDisc::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const float epsilon = 0.5f * PSCollideEpsilon; // deals with each particle - const NLMISC::CVector *itPosBefore = posBefore + firstInstanceIndex; - const NLMISC::CVector *itPosBeforeEnd = posBefore + target.getSize(); - const NLMISC::CVector *itPosAfter = posAfter + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBefore = posBefore + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBeforeEnd = posBefore + target.getSize(); + const NLMISC::CVectorPacked *itPosAfter = posAfter + firstInstanceIndex; while (itPosBefore != itPosBeforeEnd) { float posSide = p * *itPosBefore; @@ -503,7 +503,7 @@ void CPSZoneDisc::computeCollisions(CPSLocated &target, uint firstInstanceIndex, hitRadius2 = (ci.NewPos - center) * (ci.NewPos - center); if (hitRadius2 < radiusIt->R2) // check collision against disc { - const CVector &speed = target.getSpeed()[(uint32)(itPosBefore - posBefore)]; + const CVector speed = target.getSpeed()[(uint32)(itPosBefore - posBefore)]; ci.NewSpeed = _BounceFactor * (speed - 2.0f * (speed * p.getNormal()) * p.getNormal()); ci.CollisionZone = this; CPSLocated::_Collisions[itPosBefore - posBefore].update(ci); @@ -847,7 +847,7 @@ void CPSZoneCylinder::performMotion(TAnimationTime ellapsedTime) */ -void CPSZoneCylinder::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter) +void CPSZoneCylinder::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter) { NL_PS_FUNC(CPSZoneCylinder_computeCollisions) MINI_TIMER(PSStatsZoneCylinder) @@ -873,9 +873,9 @@ void CPSZoneCylinder::computeCollisions(CPSLocated &target, uint firstInstanceIn CVector destProjectedPos, destTPos; // deals with each particle // deals with each particle - const NLMISC::CVector *itPosBefore = posBefore + firstInstanceIndex; - const NLMISC::CVector *itPosBeforeEnd = posBefore + target.getSize(); - const NLMISC::CVector *itPosAfter = posAfter + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBefore = posBefore + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBeforeEnd = posBefore + target.getSize(); + const NLMISC::CVectorPacked *itPosAfter = posAfter + firstInstanceIndex; while (itPosBefore != itPosBeforeEnd) { const CVector &pos = *itPosBefore; @@ -1123,7 +1123,7 @@ void CPSZoneCylinder::deleteElement(uint32 index) // implementation of CPSZoneRectangle // ////////////////////////////////////////////// -void CPSZoneRectangle::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVector *posBefore, const NLMISC::CVector *posAfter) +void CPSZoneRectangle::computeCollisions(CPSLocated &target, uint firstInstanceIndex, const NLMISC::CVectorPacked *posBefore, const NLMISC::CVectorPacked *posAfter) { NL_PS_FUNC(CPSZoneRectangle_computeCollisions) MINI_TIMER(PSStatsZoneRectangle) @@ -1149,9 +1149,9 @@ void CPSZoneRectangle::computeCollisions(CPSLocated &target, uint firstInstanceI p.make(X ^ Y, center); // deals with each particle const float epsilon = 0.5f * PSCollideEpsilon; - const NLMISC::CVector *itPosBefore = posBefore + firstInstanceIndex; - const NLMISC::CVector *itPosBeforeEnd = posBefore + target.getSize(); - const NLMISC::CVector *itPosAfter = posAfter + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBefore = posBefore + firstInstanceIndex; + const NLMISC::CVectorPacked *itPosBeforeEnd = posBefore + target.getSize(); + const NLMISC::CVectorPacked *itPosAfter = posAfter + firstInstanceIndex; while (itPosBefore != itPosBeforeEnd) { float posSide = p * *itPosBefore;