Ejemplo n.º 1
0
	void Body::update(float mFrameTime)
	{
		onPreUpdate();

		if(_static) { spatialInfo.preUpdate(); return; }
		if(outOfBounds) { onOutOfBounds(); outOfBounds = false; return; }

		oldShape = shape;
		integrate(mFrameTime);
		spatialInfo.preUpdate();
		bodiesToResolve.clear();

		for(const auto& body : spatialInfo.getBodiesToCheck())
		{
			if(body == this || !isOverlapping(shape, body->getShape())) continue;

			auto intersection(getMinIntersection(shape, body->getShape()));

			onDetection({*body, mFrameTime, body->getUserData(), intersection});
			body->onDetection({*this, mFrameTime, userData, -intersection});

			if(!resolve || containsAny(body->getGroups(), getGroupsNoResolve())) continue;
			bodiesToResolve.push_back(body);
		}

		if(!bodiesToResolve.empty()) resolver.resolve(*this, bodiesToResolve);
		if(oldShape != shape) spatialInfo.invalidate();

		spatialInfo.postUpdate();
		onPostUpdate();
	}
Ejemplo n.º 2
0
void ActorStateMachine::update(GameTime& time)
{
    if (running)
    {
        onPreUpdate(time);
        currentState->onUpdate(time);
        onPostUpdate(time);
    }
}
Ejemplo n.º 3
0
bool SceneNode::update()
{
	if( !_dirty ) return false;
	
	bool bBoxChanged = false;
	
	onPreUpdate();
	
	// Calculate absolute matrix
	if( _parent != 0x0 )
		//_absTrans = _parent->_absTrans * _relTrans;
		_absTrans.fastMult( _parent->_absTrans, _relTrans );
	else
		_absTrans = _relTrans;
	
	// If there is a local bounding box, transform it to world space
	BoundingBox *locBBox = getLocalBBox();
	if( locBBox != 0x0 )
	{
		_bBox = *locBBox;
		_bBox.transform( _absTrans );
		bBoxChanged = true;
	}

	_dirty = false;
	
	onPostUpdate();

	// Visit children
	for( uint32 i = 0, s = (uint32)_children.size(); i < s; ++i )
	{
		bBoxChanged |= _children[i]->update();
	}	

	// Recalculate bounding box if necessary
	if( bBoxChanged )
	{
		if( locBBox == 0x0 )
		{	
			bBoxChanged = false;
			_bBox.clear();
		}

		for( uint32 i = 0, s = (uint32)_children.size(); i < s; ++i )
		{
			bBoxChanged |= _bBox.makeUnion( _children[i]->_bBox ); 
		}
	}
	
	return bBoxChanged;
}