Revision: 1601
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1601&view=rev
Author: aperion
Date: 2011-01-26 04:25:22 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
removed duplicate code for recalculating the node positions.
Modified Paths:
--------------
trunk/source/main/Beam.cpp
Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp 2011-01-26 03:31:54 UTC (rev 1600)
+++ trunk/source/main/Beam.cpp 2011-01-26 04:25:22 UTC (rev 1601)
@@ -1619,6 +1619,29 @@
return 0;
}
+void Beam::updateTruckPosition()
+{
+ // calculate average position (and smooth)
+ if(freecinecamera > 0)
+ {
+ // fix for detaching beams
+ position = nodes[cinecameranodepos[0]].AbsPosition -
cinecam_avg_offset;
+ for (int n=0; n < free_node; n++)
+ {
+ nodes[n].smoothpos = nodes[n].AbsPosition;
+ }
+ } else
+ {
+ Vector3 aposition = Vector3::ZERO;
+ for (int n=0; n < free_node; n++)
+ {
+ nodes[n].smoothpos = nodes[n].AbsPosition;
+ aposition += nodes[n].smoothpos;
+ }
+ position = aposition / free_node;
+ }
+
+}
void Beam::resetAngle(float rot)
{
@@ -2683,25 +2706,7 @@
if (trucks[t]->reset_requested)
trucks[t]->SyncReset();
if (trucks[t]->state!=SLEEPING &&
trucks[t]->state!=NETWORKED && trucks[t]->state!=RECYCLE)
{
- // calculate average position (and
smooth)
- if(trucks[t]->freecinecamera > 0)
- {
- // fix for detaching beams
- trucks[t]->position =
trucks[t]->nodes[cinecameranodepos[0]].AbsPosition - cinecam_avg_offset;
- for (int n=0;
n<trucks[t]->free_node; n++)
- {
-
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
- }
- } else
- {
- Vector3 aposition =
Vector3::ZERO;
- for (int n=0;
n<trucks[t]->free_node; n++)
- {
-
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
- aposition +=
trucks[t]->nodes[n].smoothpos;
- }
- trucks[t]->position = aposition
/ free_node;
- }
+ trucks[t]->updateTruckPosition();
}
if (floating_origin_enable &&
trucks[t]->nodes[0].RelPosition.length()>100.0)
{
@@ -2735,25 +2740,7 @@
if (trucks[t]->reset_requested)
trucks[t]->SyncReset();
if (trucks[t]->state!=SLEEPING &&
trucks[t]->state!=NETWORKED && trucks[t]->state!=RECYCLE)
{
- // calculate average position (and
smooth)
- if(trucks[t]->freecinecamera > 0)
- {
- // fix for detaching beams
- trucks[t]->position =
trucks[t]->nodes[cinecameranodepos[0]].AbsPosition - cinecam_avg_offset;
- for (int n=0;
n<trucks[t]->free_node; n++)
- {
-
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
- }
- } else
- {
- Vector3 aposition =
Vector3::ZERO;
- for (int n=0;
n<trucks[t]->free_node; n++)
- {
-
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
- aposition +=
trucks[t]->nodes[n].smoothpos;
- }
- trucks[t]->position = aposition
/ free_node;
- }
+ trucks[t]->updateTruckPosition();
}
if (floating_origin_enable &&
trucks[t]->nodes[0].RelPosition.length()>100.0)
{
@@ -2786,25 +2773,7 @@
if (state!=SLEEPING && state!=NETWORKED &&
state!=RECYCLE)
{
- // calculate average position (and smooth)
- if(freecinecamera > 0)
- {
- // fix for detaching beams
- position =
nodes[cinecameranodepos[0]].AbsPosition - cinecam_avg_offset;
- for (int n=0; n<free_node; n++)
- {
- nodes[n].smoothpos =
nodes[n].AbsPosition;
- }
- } else
- {
- Vector3 aposition = Vector3::ZERO;
- for (int n=0; n<free_node; n++)
- {
- nodes[n].smoothpos =
nodes[n].AbsPosition;
- aposition += nodes[n].smoothpos;
- }
- position = aposition / free_node;
- }
+ updateTruckPosition();
}
if (floating_origin_enable &&
nodes[0].RelPosition.length()>100.0)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel