void OpenGLSceneViewCore::drawCurrentManipulator()
{
    if (_manipulated != NULL && _manipulated->selectedCount() > 0)
	{
        _currentManipulator->position = _manipulated->selectionCenter();
        
		if (_cameraMode == CameraMode::Perspective)
        {
            Vector3D manipulatorPosition = _manipulated->selectionCenter();
            Vector3D cameraPosition = -_camera->GetCenter() + (_camera->GetAxisZ() * _camera->GetZoom());
            
            float distance = cameraPosition.Distance(manipulatorPosition);
            
            _currentManipulator->size = distance * 0.15f;
        }
		else
        {
            _currentManipulator->size = _camera->GetZoom() * 0.17f;
        }
        
        _scaleManipulator->rotation = _manipulated->selectionRotation();
        if (_currentManipulator != _defaultManipulator)
            _currentManipulator->draw(_camera->GetAxisZ(), _manipulated->selectionCenter());
	}
}
Example #2
0
	void Mesh::MergeVertexPairs()
	{
		Trace::WriteLine("MergeVertexPairs");
		
		for (int i = 0; i < (int)selected->size(); i++)
		{
			if (selected->at(i))
			{
				Vector3D firstVertex = GetVertex(i);
				float smallestDistance = 10.0f; // maximum distance between vertices in pair
				int secondIndex = -1;
				for (int j = i + 1; j < (int)selected->size(); j++)
				{
					if (selected->at(j))
					{
						Vector3D secondVertex = GetVertex(j);
						float currentDistance = firstVertex.Distance(secondVertex);
						if (currentDistance < smallestDistance)
						{
							secondIndex = j;
							smallestDistance = currentDistance;
						}
					}
				}
				
				if (secondIndex > -1)
				{
					this->FastMergeVertex(i, secondIndex);
					i--;
				}
			}
		}
		
		this->RemoveDegeneratedTriangles();
		this->RemoveNonUsedVertices();
		
		Trace::WriteLine(vertices->size() == selected->size(), "vertices->size() == selected->size()");
	}
void SPHSolver::ComputeForcesBrute()
{


	float norm,c,pTerm,vTerm;
	Vector3D r;
	Vector3D u;
	float pressTotal = 0;

	for(int i =0; i<mTotalParticles; i++)
	{
		Fluid* f_i = &mParticles[i];
		f_i->force.x = 0;
		f_i->force.y = 0;
		f_i->force.z = 0;
	
		if(f_i->density == 0)
			continue;

		for(int j=0; j < mTotalParticles; j++)
		{
			Fluid* f_j = &mParticles[j];
			if(f_i == f_j)
				continue;
		 if(f_j->density == 0)
			continue;


			r.x = f_i->pos.x - f_j->pos.x;
			r.y = f_i->pos.y - f_j->pos.y;
			r.z = f_i->pos.z - f_j->pos.z;

			u.x = f_j->vel.x - f_i->vel.x;
			u.y = f_j->vel.y - f_i->vel.y;
			u.z = f_j->vel.z - f_i->vel.z;
			norm = r.Distance();

			if(norm > mSmoothRadius)
				continue;

			c = (mSmoothRadius- norm);

			pTerm = -f_i->density*f_j->mass*pressureKernal*c*c/norm;

			pressTotal = (f_i->press/(f_i->density*f_i->density)) +
			(f_j->press/(f_j->density*f_j->density));
			pTerm *=pressTotal;

			
			f_i->force.x += r.x*pTerm;
		    f_i->force.y += r.y*pTerm;
			f_i->force.z += r.z*pTerm;

			

			float vTerm = f_i->visc*f_j->mass*viscosityKernal*c/f_j->density;
			Vector3D viscosityForce = u*vTerm;
			f_i->force += viscosityForce;
		}
	}
}