diff options
author | Armin Weatherwax | 2010-02-22 17:57:35 +0100 |
---|---|---|
committer | Jacek Antonelli | 2010-03-05 14:18:48 -0600 |
commit | d0936606412ccaf05a2e17894d2bc9a3c18506ab (patch) | |
tree | fb15bb14014eb9f6cc0512f4f3fbf408de8459e3 /linden/indra/newview/emeraldboobutils.cpp | |
parent | Fixed some notifications that were ported from 1.2 incorrectly. (diff) | |
download | meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.zip meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.tar.gz meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.tar.bz2 meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.tar.xz |
Ported breast physics from Emerald.
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/emeraldboobutils.cpp | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/linden/indra/newview/emeraldboobutils.cpp b/linden/indra/newview/emeraldboobutils.cpp new file mode 100644 index 0000000..f68d6a7 --- /dev/null +++ b/linden/indra/newview/emeraldboobutils.cpp | |||
@@ -0,0 +1,188 @@ | |||
1 | #include "emeraldboobutils.h" | ||
2 | |||
3 | std::ostream &operator<<(std::ostream &os, const EmeraldGlobalBoobConfig &v) | ||
4 | { | ||
5 | os << "EmeraldBoobConfig" << std::endl; | ||
6 | os << "enabled: " << v.enabled << std::endl; | ||
7 | os << "mass: " << v.mass << std::endl; | ||
8 | os << "hardness: " << v.hardness << std::endl; | ||
9 | os << "zMax: " << v.zMax << std::endl; | ||
10 | os << "velMin: " << v.velMin << std::endl; | ||
11 | os << "velMax: " << v.velMax << std::endl; | ||
12 | os << "zInfluence: " << v.zInfluence << std::endl; | ||
13 | os << "friction: " << v.friction << std::endl; | ||
14 | return os; | ||
15 | } | ||
16 | |||
17 | std::ostream &operator<<(std::ostream &os, const EmeraldAvatarLocalBoobConfig &v) | ||
18 | { | ||
19 | os << "EmeraldAvatarLocalBoobConfig" << std::endl; | ||
20 | os << "actualBoobGrav: " << v.actualBoobGrav << std::endl; | ||
21 | os << "boobSize: " << v.boobSize << std::endl; | ||
22 | return os; | ||
23 | } | ||
24 | |||
25 | std::ostream &operator<<(std::ostream &os, const EmeraldBoobState &v) | ||
26 | { | ||
27 | os << "EmeraldBoobState" << std::endl; | ||
28 | os << "boobGrav: " << v.boobGrav << std::endl; | ||
29 | os << "chestPosition: " << v.chestPosition << std::endl; | ||
30 | os << "chestRotation: " << v.chestRotation << std::endl; | ||
31 | os << "elapsedTime: " << v.elapsedTime << std::endl; | ||
32 | os << "frameDuration: " << v.frameDuration << std::endl; | ||
33 | os << "chestDisplacement: " << v.chestDisplacement << std::endl; | ||
34 | os << "localChestDisplacement: " << v.localChestDisplacement << std::endl; | ||
35 | os << "displacementForce: " << v.displacementForce << std::endl; | ||
36 | os << "mysteryValue: " << v.mysteryValue << std::endl; | ||
37 | os << "Number of bounceStates: " << v.bounceStates.size() << std::endl; | ||
38 | return os; | ||
39 | } | ||
40 | |||
41 | std::ostream &operator<<(std::ostream &os, const EmeraldBoobInputs &v) | ||
42 | { | ||
43 | os << "EmeraldBoobInputs" << std::endl; | ||
44 | os << "chestPosition: " << v.chestPosition << std::endl; | ||
45 | os << "chestRotation: " << v.chestRotation << std::endl; | ||
46 | os << "elapsedTime: " << v.elapsedTime << std::endl; | ||
47 | os << "appearanceFlag: " << v.appearanceFlag << std::endl; | ||
48 | os << "appearanceAnimating: " << v.appearanceAnimating << std::endl; | ||
49 | return os; | ||
50 | } | ||
51 | |||
52 | std::ostream &operator<<(std::ostream &os, const EmeraldBoobBounceState &v) | ||
53 | { | ||
54 | os << "EmeraldBoobBounceState" << std::endl; | ||
55 | os << "bounceStart: " << v.bounceStart << std::endl; | ||
56 | os << "bounceStartAmplitude: " << v.bounceStartAmplitude << std::endl; | ||
57 | os << "bounceStartFrameDuration: " << v.bounceStartFrameDuration << std::endl; | ||
58 | return os; | ||
59 | } | ||
60 | |||
61 | F32 EmeraldBoobUtils::convertMass(F32 displayMass) | ||
62 | { return displayMass/100.f*150.f; }; | ||
63 | |||
64 | F32 EmeraldBoobUtils::convertHardness(F32 displayHardness) | ||
65 | { return displayHardness/100.f*50; }; | ||
66 | |||
67 | F32 EmeraldBoobUtils::convertVelMax(F32 displayVelMax) | ||
68 | { return displayVelMax/100.f*0.01f; }; | ||
69 | |||
70 | F32 EmeraldBoobUtils::convertFriction(F32 displayFriction) | ||
71 | { return displayFriction/100.f*1.0f; }; | ||
72 | |||
73 | F32 EmeraldBoobUtils::convertVelMin(F32 displayVelMin) | ||
74 | { return displayVelMin/100.f; }; | ||
75 | |||
76 | EmeraldBoobState EmeraldBoobUtils::idleUpdate(const EmeraldGlobalBoobConfig &config, const EmeraldAvatarLocalBoobConfig &localConfig, const EmeraldBoobState &oldState, const EmeraldBoobInputs &inputs) | ||
77 | { | ||
78 | EmeraldBoobState newState; | ||
79 | F32 avatarLocalMass = 0.0f; | ||
80 | F32 partMod = 1.f; | ||
81 | |||
82 | if(!config.enabled || inputs.appearanceFlag || inputs.appearanceAnimating) | ||
83 | return newState; | ||
84 | |||
85 | if(inputs.type == 0) | ||
86 | { | ||
87 | newState.boobGrav = localConfig.actualBoobGrav; | ||
88 | avatarLocalMass = (llclamp(localConfig.boobSize, 0.0f, 0.5f) / 0.5f); | ||
89 | } | ||
90 | if(inputs.type == 1) | ||
91 | { | ||
92 | newState.boobGrav = localConfig.actualButtGrav; | ||
93 | partMod = 1.5f; | ||
94 | avatarLocalMass = llclamp(localConfig.actualButtGrav, 0.0f, 0.5f) / 0.5f; | ||
95 | } | ||
96 | if(inputs.type == 2) | ||
97 | { | ||
98 | newState.boobGrav = localConfig.actualFatGrav; | ||
99 | partMod = 1.3f; | ||
100 | avatarLocalMass = localConfig.actualFatGrav; | ||
101 | } | ||
102 | |||
103 | |||
104 | newState.elapsedTime = inputs.elapsedTime; | ||
105 | // seemed to create incorrect amounts of velocity when FPS varied | ||
106 | newState.frameDuration = inputs.elapsedTime - oldState.elapsedTime; | ||
107 | newState.chestPosition = inputs.chestPosition; | ||
108 | newState.chestRotation = inputs.chestRotation; | ||
109 | newState.chestDisplacement = inputs.chestPosition - oldState.chestPosition; | ||
110 | newState.localChestDisplacement = newState.chestDisplacement * ~inputs.chestRotation; | ||
111 | |||
112 | |||
113 | std::list<EmeraldBoobBounceState> bounceStates = oldState.bounceStates; | ||
114 | |||
115 | if(fabs(newState.localChestDisplacement.length()) > 0.f) | ||
116 | { | ||
117 | F32 boobVel = 0.f; | ||
118 | boobVel = newState.localChestDisplacement.mV[VZ]; | ||
119 | boobVel += newState.localChestDisplacement[VX] * config.XYInfluence; | ||
120 | boobVel += newState.localChestDisplacement.mV[VY] * config.XYInfluence; | ||
121 | boobVel *= newState.frameDuration * 0.3f * 100.f; | ||
122 | boobVel = llclamp(boobVel, -config.velMax, config.velMax); | ||
123 | if(fabs(boobVel) <= config.velMax * config.velMin * newState.frameDuration * 100.f) | ||
124 | boobVel = 0.0f; | ||
125 | else | ||
126 | { | ||
127 | EmeraldBoobBounceState bounceState; | ||
128 | bounceState.bounceStart = inputs.elapsedTime; | ||
129 | bounceState.bounceStartFrameDuration = newState.frameDuration; | ||
130 | bounceState.bounceStartAmplitude = boobVel; | ||
131 | bounceState.bounceStartAmplitude *= avatarLocalMass; | ||
132 | bounceState.bounceStartAmplitude *= config.mass; | ||
133 | bounceStates.push_front(bounceState); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | /*if(fabs(newState.localChestDisplacement.length()) >= 0.f) { | ||
138 | LLVector3 displacementInfluence = newState.localChestDisplacement; | ||
139 | displacementInfluence *= LLVector3(0.3f, 0.3f, 1.0f); | ||
140 | F32 clampedDisplacementInfluenceLength = llclamp(displacementInfluence.length(), 0.0f, config.velMax); | ||
141 | if(displacementInfluence[VZ]<0.f) | ||
142 | clampedDisplacementInfluenceLength= -clampedDisplacementInfluenceLength; | ||
143 | EmeraldBoobBounceState bounceState; | ||
144 | bounceState.bounceStart = inputs.elapsedTime; | ||
145 | bounceState.bounceStartFrameDuration = newState.frameDuration; | ||
146 | bounceState.bounceStartAmplitude = clampedDisplacementInfluenceLength; | ||
147 | if(fabs(bounceState.bounceStartAmplitude) < config.velMin * config.velMax) | ||
148 | bounceState.bounceStartAmplitude = 0.0f; | ||
149 | else | ||
150 | { | ||
151 | bounceState.bounceStartAmplitude *= config.mass; | ||
152 | bounceStates.push_front(bounceState); | ||
153 | } | ||
154 | } | ||
155 | */ | ||
156 | |||
157 | F32 totalNewAmplitude = 0.0f; | ||
158 | //std::cout << "Beginning bounce State processing at time " << inputs.elapsedTime << std::endl; | ||
159 | while(!bounceStates.empty()) { | ||
160 | EmeraldBoobBounceState bounceState = bounceStates.front(); | ||
161 | //std::cout << "Now processing " << bounceState; | ||
162 | bounceStates.pop_front(); | ||
163 | F32 bounceTime = newState.elapsedTime-bounceState.bounceStart; | ||
164 | F32 newAmplitude = bounceState.bounceStartAmplitude*pow(60.f*config.friction, -bounceTime)*cos(config.hardness*partMod*bounceTime); | ||
165 | if(fabs(newAmplitude) < 0.005f) { | ||
166 | newAmplitude = 0.0f; | ||
167 | } else { | ||
168 | newState.bounceStates.push_front(bounceState); | ||
169 | } | ||
170 | totalNewAmplitude+=newAmplitude; | ||
171 | } | ||
172 | //std::cout << "Total new amplitude: " << totalNewAmplitude << std::endl; | ||
173 | /* | ||
174 | if(inputs.type == 0) | ||
175 | newState.boobGrav = localConfig.actualBoobGrav + totalNewAmplitude; | ||
176 | if(inputs.type == 1) | ||
177 | newState.boobGrav = localConfig.actualButtGrav + totalNewAmplitude; | ||
178 | if(inputs.type == 2) | ||
179 | newState.boobGrav = localConfig.actualFatGrav + totalNewAmplitude; | ||
180 | */ | ||
181 | |||
182 | newState.boobGrav = totalNewAmplitude; | ||
183 | |||
184 | |||
185 | newState.boobGrav = llclamp(newState.boobGrav, -1.5f, 2.0f); | ||
186 | |||
187 | return newState; | ||
188 | } | ||