Beispiel #1
0
 // ----------------------------------------------------------------------------------
 void GameObject::SetParent(GameObject* parent)
 {
     InvalidateBounds(); // mark 'old' ancestors as dirty.
     m_parent = parent;
     InvalidateBounds(); // mark 'new' ancestors as dirty.
     InvalidateWorld();  // mark world as dirty.
 }
Beispiel #2
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BuildAnimation: load raw animation frame animation from given file, and build a 
// animation specific to this model
CSkeletonAnim* CModel::BuildAnimation(const VfsPath& pathname, const CStr& name, float speed, float actionpos, float actionpos2, float soundpos)
{
	CSkeletonAnimDef* def = m_SkeletonAnimManager.GetAnimation(pathname);
	if (!def)
		return NULL;

	CSkeletonAnim* anim = new CSkeletonAnim();
	anim->m_Name = name;
	anim->m_AnimDef = def;
	anim->m_Speed = speed;

	if (actionpos == -1.f)
		anim->m_ActionPos = -1.f;
	else
		anim->m_ActionPos = actionpos * anim->m_AnimDef->GetDuration();

	if (actionpos2 == -1.f)
		anim->m_ActionPos2 = -1.f;
	else
		anim->m_ActionPos2 = actionpos2 * anim->m_AnimDef->GetDuration();

	if (soundpos == -1.f)
		anim->m_SoundPos = -1.f;
	else
		anim->m_SoundPos = soundpos * anim->m_AnimDef->GetDuration();

	anim->m_ObjectBounds.SetEmpty();
	InvalidateBounds();

	return anim;
}
Beispiel #3
0
void DisplayElement::SetWidth (DISPLAY_INT w)
{
	mRect.SetWidth(w);
	if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
	{
		InvalidateBounds();
	}
}
Beispiel #4
0
void DisplayElement::SizeTo(DISPLAY_INT w, DISPLAY_INT h)
{
	mRect.SizeTo(w,h);
	if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
	{
		InvalidateBounds();
	}
}
Beispiel #5
0
void DisplayElement::MoveTo(DISPLAY_INT x, DISPLAY_INT y)
{
	mRect.MoveTo(x, y);
	if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
	{
		InvalidateBounds();
	}
}
Beispiel #6
0
void DisplayElement::Move(WebRect * pRect)
{
	mRect.Set(pRect);
	if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
	{
		InvalidateBounds();
	}
}
Beispiel #7
0
void CModelParticleEmitter::ValidatePosition()
{
	// TODO: do we need to do anything here?

	// This is a convenient (though possibly not particularly appropriate) place
	// to invalidate bounds so they'll be recomputed from the recent particle data
	InvalidateBounds();
}
Beispiel #8
0
 // ----------------------------------------------------------------------------------
 void Locator::AddResource(ResourceReference* r, int /*index*/)
 {
     m_resource = r;
     m_modelTransforms.clear();
     m_renderables.clear();
     InvalidateBounds();
     InvalidateWorld();        
 }
Beispiel #9
0
void DisplayElement::SetHeight (DISPLAY_INT h)
{
	mRect.SetHeight(h);
	if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
	{
		InvalidateBounds();
	}
}
Beispiel #10
0
void CurveGob::RemovePoint(ControlPointGob* point)
{
    assert(point->Parent() == this );
    point->SetParent(NULL);
    auto it = std::find(m_points.begin(), m_points.end(), point);
    m_points.erase(it);    
    m_needsRebuild = true;
    InvalidateBounds();
}
Beispiel #11
0
void DisplayElement::Remove(DisplayElement *pChild)
{
	Unlink(pChild);
	pChild->mpParent = 0;
	pChild->SetManager(0);
	if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
	{
		InvalidateBounds();
	}
}
Beispiel #12
0
///////////////////////////////////////////////////////////////////////////////
// Initialize: setup patch data
void CPatch::Initialize(CTerrain* parent,ssize_t x,ssize_t z)
{
	delete m_RenderData;
	m_RenderData=0;

	m_Parent=parent;
	m_X=x;
	m_Z=z;

	InvalidateBounds();
}
Beispiel #13
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CopyAnimation
void CModel::CopyAnimationFrom(CModel* source)
{
	m_Anim = source->m_Anim;
	m_AnimTime = source->m_AnimTime;

	m_Flags &= ~MODELFLAG_CASTSHADOWS;
	if (source->m_Flags & MODELFLAG_CASTSHADOWS)
		m_Flags |= MODELFLAG_CASTSHADOWS;

	m_ObjectBounds.SetEmpty();
	InvalidateBounds();
}
Beispiel #14
0
void CurveGob::AddPoint(ControlPointGob* point, int index)
{    
    assert(point->Parent() == NULL);
    point->SetParent(this);
    if(index >=0)
    {
        m_points.insert(m_points.begin() + index, point);
    }
    else
    {
        m_points.push_back(point);
    }    
    m_needsRebuild = true;
    InvalidateBounds();
}
Beispiel #15
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SetAnimation: set the given animation as the current animation on this model;
// return false on error, else true
bool CModel::SetAnimation(CSkeletonAnim* anim, bool once)
{
	m_Anim = NULL; // in case something fails

	if (anim)
	{
		m_Flags &= ~MODELFLAG_NOLOOPANIMATION;

		if (once)
			m_Flags |= MODELFLAG_NOLOOPANIMATION;

		if (!m_BoneMatrices && anim->m_AnimDef)
		{
			// not boned, can't animate
			return false;
		}

		if (m_BoneMatrices && !anim->m_AnimDef)
		{
			// boned, but animation isn't valid
			// (e.g. the default (static) idle animation on an animated unit)
			return false;
		}

		if (anim->m_AnimDef && anim->m_AnimDef->GetNumKeys() != m_pModelDef->GetNumBones())
		{
			// mismatch between model's skeleton and animation's skeleton
			LOGERROR(L"Mismatch between model's skeleton and animation's skeleton (%lu model bones != %lu animation keys)",
					(unsigned long)m_pModelDef->GetNumBones(), (unsigned long)anim->m_AnimDef->GetNumKeys());
			return false;
		}

		// reset the cached bounds when the animation is changed
		m_ObjectBounds.SetEmpty();
		InvalidateBounds();

		// start anim from beginning 
		m_AnimTime = 0;
	} 

	m_Anim = anim;

	return true;
}
Beispiel #16
0
void DisplayElement::InsertBefore (DisplayElement *pPlace, DisplayElement *pChild)
{
	WEBC_ASSERT(pPlace != pChild);
	WEBC_ASSERT(pPlace->mpParent == this);

	if (pChild->mpParent)
	{
		pChild->mpParent->Unlink(pChild);
		if (pChild->mpParent != this)
		{
			if (pChild->mpParent->mFlags & DISPLAY_FLAG_BOUNDS_VALID)
			{
				pChild->mpParent->InvalidateBounds();
			}
		}
	}

	if (pChild->mpParent != this)
	{
		if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
		{
			InvalidateBounds();
		}
		pChild->mpParent = this;
		pChild->SetManager(GetManager());
	}

	pChild->mpNext = pPlace;
	pChild->mpPrev = pPlace->mpPrev;
	if (pPlace->mpPrev)
	{
		pPlace->mpPrev->mpNext = pChild;
	}
	else
	{
		mpFirstChild = pChild;
	}
	pPlace->mpPrev = pChild;
}
Beispiel #17
0
void DisplayElement::InsertLast(DisplayElement *pChild)
{
	if (pChild->mpParent)
	{
		pChild->mpParent->Unlink(pChild);
		if (pChild->mpParent != this)
		{
			if (pChild->mpParent->mFlags & DISPLAY_FLAG_BOUNDS_VALID)
			{
				pChild->mpParent->InvalidateBounds();
			}
		}
	}

	if (pChild->mpParent != this)
	{
		if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
		{
			InvalidateBounds();
		}
		pChild->mpParent = this;
		pChild->SetManager(GetManager());
	}

	pChild->mpPrev = mpLastChild;
	pChild->mpNext = 0;
	if (mpLastChild)
	{
		mpLastChild->mpNext = pChild;
	}
	else
	{
		mpFirstChild = pChild;
	}
	mpLastChild = pChild;
}
Beispiel #18
0
 // ----------------------------------------------------------------------------------
 void GameObject::InvalidateWorld()
 {
     m_worldDirty = true;
     InvalidateBounds();
 }
Beispiel #19
0
 // ----------------------------------------------------------------------------------
 void GameObject::SetVisible(bool visible)
 {
     InvalidateBounds(); // mark 'old' ancestors as dirty.
     m_visible = visible;
 }
Beispiel #20
0
 // ----------------------------------------------------------------------------------
 void GameObject::SetTransform(const Matrix& xform)
 {
     m_local = xform;
     InvalidateWorld();
     InvalidateBounds();
 }
Beispiel #21
0
void CurveGob::SetInterpolationType(int type)
{
    m_type = (InterpolationType)type;    
    m_needsRebuild = true;
    InvalidateBounds();    
}
Beispiel #22
0
void CurveGob::SetSteps(int steps)
{
    m_steps = steps;    
    m_needsRebuild = true;
    InvalidateBounds();    
}
Beispiel #23
0
void CurveGob::SetClosed(bool closed)
{
    m_closed = closed;
    InvalidateBounds();
    m_needsRebuild = true;    
}