Esempio n. 1
0
void FluidSim::InitialiseParticles(void)
{
	KernelPow9 = glm::pow(SmoothingKernelSize, 9.0f);
	KernelPow6 = glm::pow(SmoothingKernelSize, 6.0f);
	KernelPow2 = glm::pow(SmoothingKernelSize, 2.0f);

	float pi = glm::pi<float>();

	DefaultKernelConstant = 315.0f / (64.0f * pi * KernelPow9);
	NormalKernelConstant = -945.0f / (32.0f * pi * KernelPow9);
	SurfaceKernelConstant = NormalKernelConstant;
	PressureKernelConstant = -45.0f  / (pi * KernelPow6);
	ViscosityKernelConstant = 45.0f / (pi * KernelPow6);

	particles.reserve(ParticleCount);

	for(int x = 0; x < ParticlesPerDimension; x++)
		for(int y = 0; y < ParticlesPerDimension; y++)
			for(int z = 0; z < ParticlesPerDimension; z++)
			{
				Particle* particle = new Particle(ParticleMass);
				particle->SetPosition(GetRandomValue(-HorizontalBounds, HorizontalBounds), GetRandomValue(0.0f, HorizontalBounds), GetRandomValue(-HorizontalBounds, HorizontalBounds));
				//particle->SetPosition(0.0f, 0.0f, 0.0f);
				particle->SetVelocity(0.0f, 0.0f, 0.0f);
				particles.push_back(particle);
			}

	container = Capsule();
	container.radius = HorizontalBounds;
	container.length = HorizontalBounds;
	container.centre = glm::vec3();

	innerContainer = Capsule();

	innerRadius = HorizontalBounds / 2.0f;
	innerLength = HorizontalBounds / 2.0f;

	innerContainer.radius = innerRadius;
	innerContainer.length = innerLength;
	innerContainer.centre = glm::vec3();

	container.CalculateCapsulePosition(glm::vec3());
	innerContainer.CalculateCapsulePosition(glm::vec3());

	crashCapsule = brokenCapsule = showNeighbours = showSurfaceParticles = hideSurfaceParticles = false;
	particleHighlightID = 0;
	wallEnabled = true;
}
Esempio n. 2
0
Capsule CoordinateFrame::toWorldSpace(const Capsule& c) const {
    return Capsule(
        pointToWorldSpace(c.point(0)),
        pointToWorldSpace(c.point(1)),
        c.radius());
}