Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
c0492e54
Commit
c0492e54
authored
7 years ago
by
andreykproductengine
Browse files
Options
Downloads
Patches
Plain Diff
MAINT-989 Velocity and acceleration should take time into account
parent
6ccdc349
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/newview/llphysicsmotion.cpp
+9
-10
9 additions, 10 deletions
indra/newview/llphysicsmotion.cpp
with
9 additions
and
10 deletions
indra/newview/llphysicsmotion.cpp
+
9
−
10
View file @
c0492e54
...
@@ -171,8 +171,8 @@ class LLPhysicsMotion
...
@@ -171,8 +171,8 @@ class LLPhysicsMotion
F32
behavior_maxeffect
);
F32
behavior_maxeffect
);
F32
toLocal
(
const
LLVector3
&
world
);
F32
toLocal
(
const
LLVector3
&
world
);
F32
calculateVelocity_local
();
F32
calculateVelocity_local
(
const
F32
time_delta
);
F32
calculateAcceleration_local
(
F32
velocity_local
);
F32
calculateAcceleration_local
(
F32
velocity_local
,
const
F32
time_delta
);
private
:
private
:
const
std
::
string
mParamDriverName
;
const
std
::
string
mParamDriverName
;
const
std
::
string
mParamControllerName
;
const
std
::
string
mParamControllerName
;
...
@@ -425,23 +425,22 @@ F32 LLPhysicsMotion::toLocal(const LLVector3 &world)
...
@@ -425,23 +425,22 @@ F32 LLPhysicsMotion::toLocal(const LLVector3 &world)
return
world
*
dir_world
;
return
world
*
dir_world
;
}
}
F32
LLPhysicsMotion
::
calculateVelocity_local
()
F32
LLPhysicsMotion
::
calculateVelocity_local
(
const
F32
time_delta
)
{
{
const
F32
world_to_model_scale
=
100.0
f
;
const
F32
world_to_model_scale
=
100.0
f
;
LLJoint
*
joint
=
mJointState
->
getJoint
();
LLJoint
*
joint
=
mJointState
->
getJoint
();
const
LLVector3
position_world
=
joint
->
getWorldPosition
();
const
LLVector3
position_world
=
joint
->
getWorldPosition
();
const
LLVector3
last_position_world
=
mPosition_world
;
const
LLVector3
last_position_world
=
mPosition_world
;
const
LLVector3
positionchange_world
=
(
position_world
-
last_position_world
)
*
world_to_model_scale
;
const
LLVector3
positionchange_world
=
(
position_world
-
last_position_world
)
*
world_to_model_scale
;
const
LLVector3
velocity_world
=
positionchange_world
;
const
F32
velocity_local
=
toLocal
(
positionchange_world
)
/
time_delta
;
const
F32
velocity_local
=
toLocal
(
velocity_world
);
return
velocity_local
;
return
velocity_local
;
}
}
F32
LLPhysicsMotion
::
calculateAcceleration_local
(
const
F32
velocity_local
)
F32
LLPhysicsMotion
::
calculateAcceleration_local
(
const
F32
velocity_local
,
const
F32
time_delta
)
{
{
// const F32 smoothing = getParamValue("Smoothing");
// const F32 smoothing = getParamValue("Smoothing");
static
const
F32
smoothing
=
3.0
f
;
// Removed smoothing param since it's probably not necessary
static
const
F32
smoothing
=
3.0
f
;
// Removed smoothing param since it's probably not necessary
const
F32
acceleration_local
=
velocity_local
-
mVelocityJoint_local
;
const
F32
acceleration_local
=
(
velocity_local
-
mVelocityJoint_local
)
/
time_delta
;
const
F32
smoothed_acceleration_local
=
const
F32
smoothed_acceleration_local
=
acceleration_local
*
1.0
/
smoothing
+
acceleration_local
*
1.0
/
smoothing
+
...
@@ -544,9 +543,9 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
...
@@ -544,9 +543,9 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
// Calculate velocity and acceleration in parameter space.
// Calculate velocity and acceleration in parameter space.
//
//
//
const F32
velocity_
joint_local
= calculateVelocity_local(time_iteration_step)
;
const
F32
joint_local
_factor
=
30.0
;
const
F32
velocity_joint_local
=
calculateVelocity_local
();
const
F32
velocity_joint_local
=
calculateVelocity_local
(
time_delta
*
joint_local_factor
);
const
F32
acceleration_joint_local
=
calculateAcceleration_local
(
velocity_joint_local
);
const
F32
acceleration_joint_local
=
calculateAcceleration_local
(
velocity_joint_local
,
time_delta
*
joint_local_factor
);
//
//
// End velocity and acceleration
// End velocity and acceleration
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment