-
Notifications
You must be signed in to change notification settings - Fork 23
/
params.cpp
113 lines (97 loc) · 3.69 KB
/
params.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <NvFlex.h>
#include <NvFlexExt.h>
#include <NvFlexDevice.h>
#include "declarations.h"
#include <float.h>
float simFPS = 60.f;
void FLEX_API::initParams() {
flexParams->gravity[0] = 0.0f;
flexParams->gravity[1] = 0.0f;
flexParams->gravity[2] = -9.8f;
flexParams->wind[0] = 0.0f;
flexParams->wind[1] = 0.0f;
flexParams->wind[2] = 0.0f;
flexParams->radius = 0.f;
flexParams->viscosity = 0.0f;
flexParams->dynamicFriction = 0.25f; //5/r
flexParams->staticFriction = 0.25f;
flexParams->particleFriction = 0.01f; // scale friction between particles by default
flexParams->freeSurfaceDrag = 0.0f;
flexParams->drag = 0.0f;
flexParams->lift = 1.0f;
flexParams->numIterations = 3;
flexParams->fluidRestDistance = 0.f;
flexParams->solidRestDistance = 0.f;
flexParams->anisotropyScale = 0.0f;
flexParams->anisotropyMin = 0.0f;
flexParams->anisotropyMax = 0.0f;
flexParams->smoothing = 0.0f;
flexParams->dissipation = 0.01f;
flexParams->damping = 0.0f;
flexParams->particleCollisionMargin = 0.f;
flexParams->shapeCollisionMargin = 0.f;
flexParams->collisionDistance = 0.f; // Needed for tri-particle intersection
flexParams->sleepThreshold = 0.1f;
flexParams->shockPropagation = 0.0f;
flexParams->restitution = 1.0f;
flexParams->maxSpeed = FLT_MAX;
flexParams->maxAcceleration = 128.0f; // approximately 10x gravity
flexParams->relaxationMode = eNvFlexRelaxationLocal;
flexParams->relaxationFactor = 0.0f;
flexParams->solidPressure = 0.5f;
flexParams->adhesion = 0.0f;
flexParams->cohesion = 0.01f;
flexParams->surfaceTension = 0.0f;
flexParams->vorticityConfinement = 0.0f;
flexParams->buoyancy = 1.0f;
flexParams->diffuseThreshold = 3.f;
flexParams->diffuseBuoyancy = 1.f;
flexParams->diffuseDrag = 0.8;
flexParams->diffuseBallistic = 0;
flexParams->diffuseLifetime = 30.0f;
// planes created after particles
flexParams->planes[0][0] = 0.f;
flexParams->planes[0][1] = 0.f;
flexParams->planes[0][2] = 1.f;
flexParams->planes[0][3] = 32768.f;
flexParams->numPlanes = 1;
flexMap["viscosity"] = &(flexParams->viscosity);
flexMap["drag"] = &(flexParams->drag);
flexMap["dissipation"] = &(flexParams->dissipation);
flexMap["damping"] = &(flexParams->damping);
flexMap["sleepThreshold"] = &(flexParams->sleepThreshold);
flexMap["maxSpeed"] = &(flexParams->maxSpeed);
flexMap["maxAcceleration"] = &(flexParams->maxAcceleration);
flexMap["adhesion"] = &(flexParams->adhesion);
flexMap["cohesion"] = &(flexParams->cohesion);
flexMap["surfaceTension"] = &(flexParams->surfaceTension);
flexMap["solidPressure"] = &(flexParams->solidPressure);
flexMap["vorticityConfinement"] = &(flexParams->vorticityConfinement);
flexMap["gravityX"] = &(flexParams->gravity[0]);
flexMap["gravityY"] = &(flexParams->gravity[1]);
flexMap["gravityZ"] = &(flexParams->gravity[2]);
flexMap["windX"] = &(flexParams->wind[0]);
flexMap["windY"] = &(flexParams->wind[1]);
flexMap["windZ"] = &(flexParams->wind[2]);
flexMap["dynamicFriction"] = &(flexParams->dynamicFriction); //5/r
flexMap["staticFriction"] = &(flexParams->staticFriction);
flexMap["particleFriction"] = &(flexParams->particleFriction); // scale friction between particles by default
flexMap["simFPS"] = &simFPS;
}
void FLEX_API::initParamsRadius(float r) {
radius = r;
flexParams->radius = r;
flexParams->fluidRestDistance = r * 0.75f;
flexParams->solidRestDistance = r * 0.5f;
flexParams->particleCollisionMargin = r * 0.5f;
flexParams->shapeCollisionMargin = r * 0.25f;
flexParams->collisionDistance = r * 0.5f; // Needed for tri-particle intersection
}
void FLEX_API::updateParam(std::string str, float n) {
try {
*flexMap.at(str) = n;
}
catch (std::exception e) {
GlobalLUA->ThrowError(("Invalid parameter \"" + str + "\"!").c_str());
}
}