Пример #1
0
// ****************************************************************************
//
//  Function Name:	RSelectionTracker::ContinueTracking( )
//
//  Description:		Called to continue tracking; ie. when the mouse moves.
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RSelectionTracker::ContinueTracking( const RRealPoint& mousePoint, YModifierKey modifierKeys )
	{
	// Constrain the mouse point
	RRealPoint constrainedPoint = mousePoint;
	ApplyConstraint( constrainedPoint );

	// Call the base class
	RMouseTracker::ContinueTracking( constrainedPoint, modifierKeys );

	// Draw feedback
	m_pFeedbackRenderer->ContinueTracking( constrainedPoint );
	}
Пример #2
0
// ****************************************************************************
//
//  Function Name:	RDragSelectionTracker::EndTracking( )
//
//  Description:		Called when tracking ends; ie. when the mouse button goes
//							up.
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RDragSelectionTracker::EndTracking( const RRealPoint& mousePoint, YModifierKey modifierKeys )
	{
	// Constrain the mouse point
	RRealPoint constrainedPoint = mousePoint;
	ApplyConstraint( constrainedPoint );

	// Call the base method
	RSelectionTracker::EndTracking( constrainedPoint, modifierKeys );

	// Create and do a move selection action
	RMoveSelectionAction* pAction = new RMoveSelectionAction( m_pSelection, constrainedPoint - m_TrackingMouseDownPoint ); 
	m_pView->GetRDocument( )->SendAction( pAction );
	}
Пример #3
0
// ****************************************************************************
//
//  Function Name:	RResizeSelectionTracker::EndTracking( )
//
//  Description:		Called when tracking ends; ie. when the mouse button goes
//							up.
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RResizeSelectionTracker::EndTracking( const RRealPoint& mousePoint, YModifierKey modifierKeys )
	{
	// Constrain the mouse point
	RRealPoint constrainedPoint = mousePoint;
	ApplyConstraint( constrainedPoint );

	// Call the base class
	RSelectionTracker::EndTracking( constrainedPoint, modifierKeys );

	// Compute the final scale factor
	RRealSize scaleFactor = CalcScaleFactor( constrainedPoint );

	// Create and do a resize selection action
	RResizeSelectionAction* pAction = new RResizeSelectionAction( m_pSelection, m_ScalingCenter, scaleFactor, m_fMaintainAspectRatio );
	m_pView->GetRDocument( )->SendAction( pAction );
	}
Пример #4
0
// ****************************************************************************
//
//  Function Name:	RRotateSelectionTracker::EndTracking( )
//
//  Description:		Called when tracking ends; ie. when the mouse button goes
//							up.
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RRotateSelectionTracker::EndTracking( const RRealPoint& mousePoint, YModifierKey modifierKeys )
	{
	// Constrain the mouse point
	RRealPoint constrainedPoint = mousePoint;
	ApplyConstraint( constrainedPoint );

	// Call the base class
	RSelectionTracker::EndTracking( constrainedPoint, modifierKeys );

	// Calculate the angle
	YAngle angle = CalcAngle( constrainedPoint );

	// Create and do a rotate selection action
	RRotateSelectionAction* pAction = new RRotateSelectionAction( m_pSelection, m_TrackingRotationCenter, angle ); 
	m_pView->GetRDocument( )->SendAction( pAction );
	}
Пример #5
0
		void Corpse::Update(float dt) {
			SPADES_MARK_FUNCTION();
			float damp = 1.f;
            float damp2 = 1.f;
			if(dt > 0.f){
				damp = powf(.9f, dt);
				damp2 = powf(.371f, dt);
            }
			//dt *= 0.1f;
			
			for(int i = 0; i <NodeCount; i++){
				Node& node = nodes[i];
				Vector3 oldPos = node.lastPos;
				node.pos += node.vel * dt;
				
				SPAssert(!isnan(node.pos.x));
				SPAssert(!isnan(node.pos.y));
				SPAssert(!isnan(node.pos.z));
				
				if(node.pos.z > 63.f){
					node.vel.z -= dt * 6.f; // buoyancy
					node.vel *= damp;
				}else{
                    node.vel.z += dt * 32.f; // gravity
                    node.vel.z *= damp2;
                }
				
				//node.vel *= damp;
				
				if(!map->ClipBox(oldPos.x, oldPos.y, oldPos.z)){
					
					if(map->ClipBox(node.pos.x,
									oldPos.y,
									oldPos.z)){
						node.vel.x = -node.vel.x * .2f;
						if(fabsf(node.vel.x) < .3f)
							node.vel.x = 0.f;
						node.pos.x = oldPos.x;
						
						node.vel.y *= .5f;
						node.vel.z *= .5f;
					}
					
					if(map->ClipBox(node.pos.x,
									node.pos.y,
									oldPos.z)){
						node.vel.y = -node.vel.y * .2f;
						if(fabsf(node.vel.y) < .3f)
							node.vel.y = 0.f;
						node.pos.y = oldPos.y;
						
						node.vel.x *= .5f;
						node.vel.z *= .5f;
					}
					
					if(map->ClipBox(node.pos.x,
									node.pos.y,
									node.pos.z)){
						node.vel.z = -node.vel.z * .2f;
						if(fabsf(node.vel.z) < .3f)
							node.vel.z = 0.f;
						node.pos.z = oldPos.z;
						
						node.vel.x *= .5f;
						node.vel.y *= .5f;
					}
					
					if(map->ClipBox(node.pos.x, node.pos.y, node.pos.z)){
						// TODO: getting out block
						//node.pos = oldPos;
						//node.vel *= .5f;
					}
				}
				
				/*
				if(map->ClipBox(node.pos.x,
								node.pos.y,
								node.pos.z)){
					if(!map->ClipBox(node.pos.x,
									node.pos.y,
									oldPos.z)){
						node.vel.z = -node.vel.z * .2f;
						if(fabsf(node.vel.z) < .3f)
							node.vel.z = 0.f;
						node.pos.z = oldPos.z;
					}
					if(!map->ClipBox(node.pos.x,
									 oldPos.y,
									 node.pos.z)){
						node.vel.y = -node.vel.y * .2f;
						if(fabsf(node.vel.y) < .3f)
							node.vel.y = 0.f;
						node.pos.y = oldPos.y;
					}
					if(!map->ClipBox(oldPos.x,
									 node.pos.y,
									 node.pos.z)){
						node.vel.x = -node.vel.x * .2f;
						if(fabsf(node.vel.x) < .3f)
							node.vel.x = 0.f;
						node.pos.x = oldPos.x;
					}
					node.vel *= .8f;
					//node.pos = oldPos;
					
					if(node.vel.GetLength() < .02f){
						node.vel *= 0.f;
					}
				}*/
				
				node.lastPos = node.pos;
				node.lastForce = node.vel;
			}
			ApplyConstraint(dt);
			
			for(int i = 0; i <NodeCount; i++){
				nodes[i].lastForce = nodes[i].vel - nodes[i].lastForce;
			}
			
		}