[Opal-commits] opal/src testRaycastSensor.cpp,NONE,1.1 testsolid.cpp,1.2,1.3
Status: Inactive
Brought to you by:
tylerstreeter
|
From: Olex <ole...@us...> - 2005-11-15 03:32:52
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3176/src Modified Files: testsolid.cpp Added Files: testRaycastSensor.cpp Log Message: New unit tests. Index: testsolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testsolid.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testsolid.cpp 13 Nov 2005 18:51:20 -0000 1.2 --- testsolid.cpp 15 Nov 2005 03:32:43 -0000 1.3 *************** *** 68,71 **** --- 68,74 ---- f.s->setName( "baba" ); QT_CHECK_EQUAL( "baba", f.s->getName() ); + + f.s->setName( "another_baba" ); + QT_CHECK_EQUAL( "another_baba", f.s->getName() ); } --- NEW FILE: testRaycastSensor.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // system headers #include <quicktest.h> // project headers #include "opal.h" using namespace opal; namespace testRayCastSensor { class Fixture { public: Fixture() { sim = createSimulator(); sim->setGravity( Vec3r( 0, -9.81, 0 ) ); caster = sim->createSolid(); caster->setName( "caster" ); { SphereShapeData data; data.radius = 1; caster->addShape( data ); } sensor = sim->createRaycastSensor(); plane = sim->createSolid(); plane->setName( "plane" ); plane->setStatic( true ); { PlaneShapeData data; real plane_params[ 4 ] = {1, 0, 1, 0}; for ( int i = 0; i < 4; ++i ) data.abcd[ i ] = plane_params[ i ]; plane->addShape( data ); } { RaycastSensorData data; data.solid = caster; data.ray.setOrigin( caster->getPosition() ); data.ray.setDir( Vec3r( 0, -1, 0 ) ); sensor->init( data ); } } ~Fixture() { sim->destroySensor( sensor ); sim->destroySolid( caster ); sim->destroy(); } Simulator * sim; Solid * caster; Solid * plane; RaycastSensor * sensor; }; QT_TEST( testRay_on_Plane ) { Fixture f; f.caster->setPosition( 0, 10, 0 ); RaycastResult r = f.sensor->fireRay(); Point3r hitPoint = r.intersection; QT_CHECK_EQUAL( hitPoint, Point3r( 0, 0, 0 ) ); real diff = r.distance; QT_CHECK_EQUAL( diff, 10 ); } QT_TEST( testRay_Sphere_before_Plane ) { Fixture f; f.caster->setPosition( 0, 10, 0 ); Solid * intheway = f.sim->createSolid(); intheway->setPosition( 0, 5, 0 ); intheway->setName( "in the way" ); { SphereShapeData data; data.radius = 1; intheway->addShape( data ); } intheway->setStatic( false ); RaycastResult r = f.sensor->fireRay(); Point3r hitPoint = r.intersection; Solid * hit = r.solid; real diff = r.distance; QT_CHECK_EQUAL( diff, 5 ); f.sim->destroySolid( intheway ); } } |