aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/head.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/head.cpp153
1 files changed, 0 insertions, 153 deletions
diff --git a/linden/indra/newview/head.cpp b/linden/indra/newview/head.cpp
deleted file mode 100644
index 54047cb..0000000
--- a/linden/indra/newview/head.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
1/**
2 * @file head.cpp
3 * @brief Head class implementation
4 *
5 * $LicenseInfo:firstyear=2000&license=viewergpl$
6 *
7 * Copyright (c) 2000-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32// implementation of a class that models the motion of a human head.
33// The physics aren't quite right, but it will suffice for right now.
34
35#include "llviewerprecompiledheaders.h"
36
37#include "head.h"
38
39#ifndef PI
40 #define PI ((F32) 3.14159265358979323846264338327)
41#endif
42
43// The friction force of the neck is modeled as:
44// friction = -E*phi_dot - F*phi_dot (for positive phi_dot)
45#define E1 0.75
46#define F1 0.0
47
48// TODO -- use the other PI defined in the math libs somewhere.
49
50// --------------------------------------------------
51// Misc. function delclarations...
52// --------------------------------------------------
53F32 phi_spring(F32 phi, F32 theta);
54F32 theta_spring(F32 theta, F32 phi);
55
56
57// --------------------------------------------------
58// Class Head member functions...
59// --------------------------------------------------
60
61Head::Head() {
62 mass = 1.0f;
63 radius = 1.0f;
64 inertia = 2.0f * mass * radius * radius / 5.0f;
65 phi = 0.0f;
66 theta = 0.0f;
67 //gettimeofday(&t, &tz);
68}
69
70Head::Head(F32 m, F32 r) {
71 mass = m;
72 radius = r;
73 inertia = 2.0f * mass * radius * radius / 5.0f;
74 phi = 0.0f;
75 theta = 0.0f;
76 //gettimeofday(&t, &tz);
77}
78
79F32 Head::setMass(F32 m) {
80 mass = m;
81 inertia = 2.0f * mass * radius * radius / 5.0f;
82 return mass;
83}
84
85F32 Head::setRadius(F32 r) {
86 radius = r;
87 inertia = 2.0f * mass * radius * radius / 5.0f;
88 return radius;
89}
90
91F32 Head::getMass() { return mass; }
92F32 Head::getRadius() { return radius; }
93F32 Head::getInertia() { return inertia; }
94
95void Head::propagate(F32 horizontal_force, F32 vertical_force, F32 dt) {
96 //struct timeval t1;
97 //F32 dt, temp;
98 F32 phi_torque, theta_torque;
99 F32 phi_dot, theta_dot;
100
101 //gettimeofday(&t1, &tz);
102 //dt = ((t1.tv_sec - t.tv_sec) * 1000000.0 + (t1.tv_usec - t.tv_usec)) / 1000000.0;
103 //dt = 0.033; // This is a kluge to prevent instabilities when using a stepper
104
105 // Calculate the return forces...
106 // Note: horizontal_force is positive toward right, so it's resultant torque
107 // is negative, since the phi spin angle is out the top of the head (using
108 // right-hand rule).
109 phi_torque = radius * (phi_spring(phi, theta) - horizontal_force);
110 theta_torque = radius * (theta_spring(phi, theta) + vertical_force);
111
112 // Propagate phi...
113 phi_dot = dt * phi_torque / inertia;
114
115 phi += dt * phi_dot;
116 if (phi >= PI/2.0f) {
117 phi = PI/2.0f;
118 }
119 else if (phi <= -PI/2.0f) {
120 phi = -PI/2.0f;
121 }
122
123 // Propagate theta...
124 theta_dot = dt * theta_torque / inertia;
125 theta += dt * theta_dot;
126 if (theta >= PI/2.0f) {
127 theta = PI/2.0f;
128 }
129 else if (theta <= -PI/2.0f) {
130 theta = -PI/2.0f;
131 }
132
133 //t = t1;
134 return;
135}
136
137
138F32 phi_spring(F32 phi, F32 theta) {
139// The srping force is linear with -phi and the magnitude of theta.
140 F32 phi_force;
141 phi_force = - 30 * phi;
142 phi_force = phi_force * (1.0f + (F32)fabs(theta) / PI);
143 return phi_force;
144}
145
146
147F32 theta_spring(F32 phi, F32 theta) {
148 return phi_spring(theta, phi);
149}
150
151
152
153