Revision: 2516
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2516&view=rev
Author: ulteq
Date: 2012-05-06 07:06:55 +0000 (Sun, 06 May 2012)
Log Message:
-----------
-Feature: re-enabled createCollisionDebugVisualization(), style++
Modified Paths:
--------------
trunk/source/main/physics/collision/collisions.cpp
Modified: trunk/source/main/physics/collision/collisions.cpp
===================================================================
--- trunk/source/main/physics/collision/collisions.cpp 2012-05-06 07:02:55 UTC
(rev 2515)
+++ trunk/source/main/physics/collision/collisions.cpp 2012-05-06 07:06:55 UTC
(rev 2516)
@@ -511,10 +511,13 @@
Ogre::Vector3 p(px, py, pz);
Ogre::Vector3 sc(scx, scy, scz);
collision_box_t& coll_box = collision_boxes[free_collision_box];
+
coll_box.enabled = true;
+
// set refined box anyway
coll_box.relo = l*sc;
coll_box.rehi = h*sc;
+
// calculate selfcenter anyway
coll_box.selfcenter = coll_box.relo;
coll_box.selfcenter += coll_box.rehi;
@@ -523,8 +526,8 @@
// and center too (we need it)
coll_box.center = p;
coll_box.virt = virt;
+ coll_box.event_filter = event_filter;
- coll_box.event_filter = event_filter;
// camera stuff
coll_box.camforced = forcecam;
if (forcecam)
@@ -539,10 +542,13 @@
coll_box.selfrotated = true;
coll_box.selfrot = Quaternion(Degree(srx),
Vector3::UNIT_X)*Quaternion(Degree(sry),
Vector3::UNIT_Y)*Quaternion(Degree(srz), Vector3::UNIT_Z);
coll_box.selfunrot = coll_box.selfrot.Inverse();
+ } else
+ {
+ coll_box.selfrotated = false;
}
- else coll_box.selfrotated = false;
coll_box.eventsourcenum = -1;
+
if (strlen(eventname) > 0)
{
//LOG("COLL: adding "+TOSTRING(free_eventsource)+"
"+String(instancename)+" "+String(eventname));
@@ -572,7 +578,12 @@
coll_box.unrot = rotation.Inverse();
}
- SceneNode *debugsn = debugMode ?
smgr->getRootSceneNode()->createChildSceneNode() : 0;
+ SceneNode *debugsn = 0;
+
+ if (debugMode)
+ {
+ debugsn = smgr->getRootSceneNode()->createChildSceneNode();
+ }
// set raw box
// 8 points of a cube
@@ -1103,7 +1114,6 @@
if (ogm)
*ogm=defaultgm;
}
}
-
} else
{
if (cbox->eventsourcenum!=-1 &&
permitEvent(cbox->event_filter))
@@ -1145,8 +1155,7 @@
}
}
}
- }
- else
+ } else
{
// tri collision
collision_tri_t
*ctri=&collision_tris[(*cell)[k]-MAX_COLLISION_BOXES];
@@ -1250,7 +1259,7 @@
eventsource_t *Collisions::isTruckInEventBox(Beam *truck)
{
- if(!truck) return 0;
+ if (!truck) return 0;
// check all boxes
for (int i=0; i<free_eventsource; i++)
{
@@ -1282,7 +1291,6 @@
bool Collisions::isInside(Vector3 pos, char* instance, char* box, float border)
{
-
collision_box_t *cbox=getBox(instance, box);
return isInside(pos, cbox, border);
}
@@ -1292,28 +1300,33 @@
if (!cbox) return false;
if (pos + border > cbox->lo
- && pos - border < cbox->hi)
+ && pos - border < cbox->hi)
{
if (cbox->refined || cbox->selfrotated)
{
// we may have a collision, do a change of repere
- Vector3 rpos=pos-cbox->center;
- if (cbox->refined) rpos=cbox->unrot*rpos;
+ Vector3 rpos = pos - cbox->center;
+ if (cbox->refined)
+ {
+ rpos = cbox->unrot * rpos;
+ }
if (cbox->selfrotated)
{
- rpos=rpos-cbox->selfcenter;
- rpos=cbox->selfunrot*rpos;
- rpos=rpos+cbox->selfcenter;
+ rpos = rpos - cbox->selfcenter;
+ rpos = cbox->selfunrot * rpos;
+ rpos = rpos + cbox->selfcenter;
}
// now test with the inner box
- if (rpos >cbox->relo
- && rpos < cbox->rehi)
+ if (rpos > cbox->relo
+ && rpos < cbox->rehi)
{
return true;
}
+ } else
+ {
+ return true;
}
- else return true;
}
return false;
}
@@ -1321,9 +1334,9 @@
bool Collisions::groundCollision(node_t *node, float dt, ground_model_t** ogm,
float *nso)
{
if (!hfinder) return false;
- if(landuse) *ogm = landuse->getGroundModelAt(node->AbsPosition.x,
node->AbsPosition.z);
+ if (landuse) *ogm = landuse->getGroundModelAt(node->AbsPosition.x,
node->AbsPosition.z);
// when landuse fails or we dont have it, use the default value
- if(!*ogm) *ogm = defaultgroundgm;
+ if (!*ogm) *ogm = defaultgroundgm;
last_used_ground_model = *ogm;
// new ground collision code
@@ -1452,7 +1465,8 @@
int Collisions::createCollisionDebugVisualization()
{
- return 0;
+ LOG("COLL: Creating collision debug visualization ...");
+
static int loaded = 0;
// prevent double calling
if (loaded != 0) return -1;
@@ -1518,7 +1532,8 @@
groundheight+=0.1; // 10 cm hover
// ground height should fit
- int deep = 0, cc=(int)cell->size();
+ //int deep = 0;
+ int cc = (int)cell->size();
float percent = cc / (float)CELL_BLOCKSIZE;
float percentd = percent;
@@ -1555,7 +1570,6 @@
mo->setBoundingBox(AxisAlignedBox(0, 0, 0,
CELL_SIZE, 1, CELL_SIZE));
mo_node->attachObject(mo);
-
#if 0
// setup the label
String labelName = "label_"+cell_name;
@@ -1647,8 +1661,8 @@
size_t shared_offset = vertex_count;
size_t next_offset = vertex_count;
size_t index_offset = index_count;
- size_t prev_vert = vertex_count;
- size_t prev_ind = index_count;
+ //size_t prev_vert = vertex_count;
+ //size_t prev_ind = index_count;
// Calculate how many vertices and indices we're going to need
for(int i = 0;i < mesh->getNumSubMeshes();i++)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel