Skip to content

Commit 8c76d5b

Browse files
committed
Fixed leaky materials bug with pinned particles
1 parent ff23af5 commit 8c76d5b

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

GalaxyEngine/include/parameters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct UpdateVariables{
7171
float halfDomainWidth = domainSize.x * 0.5f;
7272
float halfDomainHeight = domainSize.y * 0.5f;
7373

74-
bool fullscreenState = true;
74+
bool fullscreenState = false;
7575

7676
int targetFPS = 144;
7777

GalaxyEngine/src/Physics/SPH.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void SPH::PCISPH(std::vector<ParticlePhysics>& pParticles, std::vector<ParticleR
8787
#pragma omp parallel for
8888
for (size_t i = 0; i < N; ++i) {
8989

90-
if (!rParticles[i].isSPH || rParticles[i].isPinned || rParticles[i].isBeingDrawn) continue;
90+
if (!rParticles[i].isSPH || rParticles[i].isBeingDrawn) continue;
9191

9292
auto& p = pParticles[i];
9393
p.predVel = p.vel + dt * 1.5f * (sphForce[i] / p.sphMass);

GalaxyEngine/src/Physics/physics.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,6 @@ void Physics::physicsUpdate(std::vector<ParticlePhysics>& pParticles, std::vecto
418418
if (myVar.isPeriodicBoundaryEnabled) {
419419
for (size_t i = 0; i < pParticles.size(); i++) {
420420

421-
if (rParticles[i].isPinned) {
422-
continue;
423-
}
424-
425421
ParticlePhysics& pParticle = pParticles[i];
426422

427423
pParticle.prevVel = pParticle.vel;
@@ -459,10 +455,6 @@ void Physics::physicsUpdate(std::vector<ParticlePhysics>& pParticles, std::vecto
459455
else {
460456
for (size_t i = 0; i < pParticles.size(); ) {
461457

462-
if (rParticles[i].isPinned) {
463-
continue;
464-
}
465-
466458
ParticlePhysics& pParticle = pParticles[i];
467459

468460
pParticle.prevVel = pParticle.vel;

GalaxyEngine/src/globalLogic.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ void pinParticles() {
4848
for (size_t i = 0; i < myParam.pParticles.size(); i++) {
4949
if (myParam.rParticles[i].isSelected) {
5050
myParam.rParticles[i].isPinned = true;
51+
myParam.pParticles[i].vel *= 0.0f;
52+
myParam.pParticles[i].prevVel *= 0.0f;
53+
myParam.pParticles[i].acc *= 0.0f;
54+
myParam.pParticles[i].ke *= 0.0f;
55+
myParam.pParticles[i].prevKe *= 0.0f;
5156
}
5257
}
5358
myVar.pinFlag = false;
@@ -61,6 +66,16 @@ void pinParticles() {
6166
}
6267
myVar.unPinFlag = false;
6368
}
69+
70+
for (size_t i = 0; i < myParam.pParticles.size(); i++) {
71+
if (myParam.rParticles[i].isPinned) {
72+
myParam.pParticles[i].vel *= 0.0f;
73+
myParam.pParticles[i].prevVel *= 0.0f;
74+
myParam.pParticles[i].acc *= 0.0f;
75+
myParam.pParticles[i].ke *= 0.0f;
76+
myParam.pParticles[i].prevKe *= 0.0f;
77+
}
78+
}
6479
}
6580

6681
void updateScene() {
@@ -139,7 +154,7 @@ void updateScene() {
139154
#pragma omp parallel for schedule(dynamic)
140155
for (size_t i = 0; i < myParam.pParticles.size(); i++) {
141156

142-
if (myParam.rParticles[i].isBeingDrawn && myVar.isBrushDrawing && myVar.isSPHEnabled) {
157+
if ((myParam.rParticles[i].isBeingDrawn && myVar.isBrushDrawing && myVar.isSPHEnabled) || myParam.rParticles[i].isPinned) {
143158
continue;
144159
}
145160

0 commit comments

Comments
 (0)