tags:

views:

164

answers:

1

Edit: Solved it on my own, had one of those small typos that are hard to notice in a different section, works perfectly now.

I have a particle generator in C++ that I got off the internet. It was basically a sample of some things you can do, so I have studied it and know what is going on and what I need to do to add the features I want into it. I am working on this one right now. I have another method that I use to create the GravPoint then this one does the math involved. The comments describe what is going on and where my error is.

// Update velocity with respect to any GravPoints in range
// Start at the head of the list
ppGravPoint = &m_pGravPoints;

// Temporary D3DXVECTOR3
D3DXVECTOR3 vTemp;

// While there is still a node on the list
while ( *ppGravPoint )
{
    pGravPoint = *ppGravPoint;
    // vTemp becomes a vector pointing from m_vCurPos to m_vPoint
    // I'm getting an error at this line, it opens up d3dx9math.inl
    // and points at this piece of code:
    // D3DXINLINE D3DXVECTOR3
    // D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const
    // {
    //     return D3DXVECTOR3(x - v.x, y - v.y, z - v.z);
    // }
    vTemp = pGravPoint->m_vPoint - pParticle->m_vCurPos;
    // if ||vTemp|| (length of vTemp) < m_fMaxDist (FLOAT m_fMaxDist)
    if((sqrt((vTemp.x * vTemp.x) + (vTemp.y * vTemp.y) + (vTemp.z * vTemp.z)) < pGravPoint->m_fMaxDist))
    {
     // Then the velocity of the current particle being rendered is adjusted
     // to be attracted towards the gravpoint. Pretty sure this is right
     pParticle->m_vCurVel += (vTemp * (pGravPoint->m_fStrength * fElpasedTime));
    }
    // Go to next point if there is one.
    ppGravPoint = &pGravPoint->m_gpNext;
}
A: 

What is the error message? Your example would suggest that pParticle->m_vCurPos is NULL.