← Back to team overview

nrtb-core team mailing list archive

[Merge] lp:~fpstovall/nrtb/sprint-005 into lp:nrtb

 

Rick Stovall has proposed merging lp:~fpstovall/nrtb/sprint-005 into lp:nrtb.

Requested reviews:
  NRTB Core (nrtb-core): code
Related bugs:
  Bug #1276332 in New Real Time Battle: "Delta V motion not applied properly"
  https://bugs.launchpad.net/nrtb/+bug/1276332

For more details, see:
https://code.launchpad.net/~fpstovall/nrtb/sprint-005/+merge/209358

Bugfixes: unit tested; build log below:

============= building all targets ===============
make[1]: Entering directory `/home/rstovall/development/nrtb/sprint-005'
cd cpp; make lib
make[2]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp'
============= building C++ code ===============
make[3]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp'
make[4]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common'
============= building common libs ===============
make[5]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/common_rl'
g++ -c -O3 common.cpp -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -c common_rl_test.cpp  -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -o common_rl_test common_rl_test.o common.o -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
=== Starting nrtb::common_rl unit test ===
	nrtb::upcase(): PASSED
	nrtb::downcase(): PASSED
	nrtb::gsub(): PASSED
	nrtb::split(): PASSED
	nrtb::mconvert(): PASSED
	nrtb::trim(): PASSED
	nrtb::dateflip(): PASSED
	nrtb::http_hextochar(): PASSED
	nrtb::http_chartohex(): PASSED
	nrtb::http_enhex(): PASSED
	nrtb::http_unhex(): PASSED
	nrtb::base_exception::comment(): PASSED
	nrtb::base_exception::age_in_ms(): PASSED
=== nrtb::common_rl unit test complete ===
‘common.h’ -> ‘../include/common.h’
‘common.o’ -> ‘../obj/common.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/common_rl'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/point'
g++ -O3 common_test.cpp -I ../include ../obj/common.o -o common_test -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
=== nrtb::triad Unit Test ===
	a = (1,2,3); b = (3,2,1)
	a + b = (4,4,4)
	a - b = (-2,0,2)
	a * b = (3,4,3)
	a / b = (0.3333333333,1,3)
	a += b; a = (4,4,4)
	a -= b; a = (1,2,3)
	a *= b; a = (3,4,3)
	a /= b; a = (1,2,3)
	a.pow(b) = (1,4,3)
	a.range(b) = 2.828427125
	a.magnatude() = 3.741657387
	a == a = 1
	a == b = 0
	a != b = 1
	a != a = 0
	a + 2 = (3,4,5)
	a - 2 = (-1,0,1)
	a * 2 = (2,4,6)
	a / 2 = (0.5,1,1.5)
	a += 2 = (3,4,5)
	a -= 2 = (1,2,3)
	a *= 2 = (2,4,6)
	a /= 2 = (1,2,3)
	a.pow(2) = (1,4,9)
	a.normalize() = (0.2672612419,0.5345224838,0.8017837257)
	a.normalize().magnatude() = 1
	a.dot_product(b) = 10
	a.vector_product(b) = (-4,8,-4)
	Input a new value for b "(2,3.5,7)": 
	b = (2,3.5,7)
	b.from_str(b.to_str(10)) = (2,3.5,7)
=== nrtb::triad Unit Test Complete ===
‘triad.h’ -> ‘../include/triad.h’
nrtb::triad build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/point'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/timer'
g++ -c -O3 hires_timer.cpp -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -c timer_test.cpp -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -o timer_test timer_test.o hires_timer.o -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
sleep 0.1 second
0.100143 | 0.100139 (stop)
sleep 0.3 seconds
0.40048 | 0.100139 (start)
sleep 0.2 seconds
0.600598 | 0.300208 (reset)
sleep 0.5 seconds
1.10097 | 0.500284
Extended interval_as_HMS() test: "1d, 6:24:32.8403" or "30:24:32.8403"
Total run time: 1.10123 seconds.
‘hires_timer.h’ -> ‘../include/hires_timer.h’
‘hires_timer.o’ -> ‘../obj/hires_timer.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/timer'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/abs_queue'
g++ -c abs_queue_test.cpp -I../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -o abs_queue_test abs_queue_test.o -lpthread -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
***** abs_queue unit test ******
cp 1 100:100
cp 2 125:125
cp 3 150:150 t1=138 t2=12
***** abs_queue TEST PASSED ******
‘abs_queue.h’ -> ‘../include/abs_queue.h’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/abs_queue'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/circular_queue'
g++ -c circular_queue_test.cpp -I../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -o circular_queue_test circular_queue_test.o -lpthread -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
***** circular_queue unit test *****
cp 1 100:50
cp 2 125:75
cp 3 150:100 t1=88 t2=12
***** circular_queue TEST PASSED ******
‘circular_queue.h’ -> ‘../include/circular_queue.h’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/circular_queue'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/linear_queue'
g++ -c linear_queue_test.cpp -I../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -o linear_queue_test linear_queue_test.o -lpthread -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
***** linear_queue unit test ******
cp 1 100:100
cp 2 125:125
cp 3 150:150 t1=138 t2=12
***** linear_queue TEST PASSED ******
‘linear_queue.h’ -> ‘../include/linear_queue.h’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/linear_queue'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/sockets'
g++ -c -O3 base_socket.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP 
g++ -c -O3 socket_test.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP 
g++ -o socket_test socket_test.o base_socket.o ../obj/common.o -lpthread -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
=========== tcp_socket and server test =============
Using 127.0.0.1:17501
test_server ready.
Request processor attached.
Request processor shut down.
Test Server Results:
	Accepted:  100
	Processed: 100
	Available: 0
	Discarded: 0
	Last Fault: 0
=========== tcp_socket and server test complete =============
‘base_socket.h’ -> ‘../include/base_socket.h’
‘base_socket.o’ -> ‘../obj/base_socket.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/sockets'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/serializer'
g++ -c serializer.cpp -I ../include -std=gnu++0x
g++ -c serializer_test.cpp -I../include -std=gnu++11
g++ -o serializer_test serializer_test.o serializer.o -lpthread -std=gnu++11
** nrtb::serializer unit test **
Default initialization
 0 1 2
Started from twenty
 20 21 22
Rollover Demonstration
 18446744073709551615 0 1
‘serializer.h’ -> ‘../include/serializer.h’
‘serializer.o’ -> ‘../obj/serializer.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/serializer'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/singleton'
g++ -c singleton_test.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -o singleton_test singleton_test.o ../obj/serializer.o -lpthread -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
============== singleton unit test ================
0123456789
=========== singleton test passed =============
‘singleton.h’ -> ‘../include/singleton.h’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/singleton'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/logger'
g++ -c -O3 logger.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP 
g++ -c -O3 logger_test.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP 
g++ -o logger_test logger_test.o logger.o -lpthread -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
=========== logger unit test =============
18 : 18 : 0
=========== tcp_socket and server test complete =============
‘logger.h’ -> ‘../include/logger.h’
‘logger.o’ -> ‘../obj/logger.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/logger'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/confreader'
g++ -c confreader.cpp -I../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
g++ -c conftest.cpp -I../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP 
g++ -o conftest conftest.o confreader.o ../obj/common.o ../obj/logger.o -lpthread -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP
WARNING:Problems reading configuration file "dummyfile"; data may be incomplete.Read 12 parameters.	"#starthash"="should start with hash (#) symbol"
	"--doit"=""
	"__exec_name"="./conftest"
	"fileversion"="version 1.0"
	"hashtest"="#surrounded# #by# #hashes#"
	"lastline"="this should be complete"
	"test"="1"
	"test"="duh!"
	"test"="21"
	"test2"="71.837486"
	"test2-2"=""
	"test3"="jack danials"
(int) test = 1
(int) test2 = 0
(string) test3 = "jack danials"
(double) test = 1
(double) test2 = 71.8375
?var "--doit" exists? Yes
valid int "test" values:
	0: 1
	1: 21
valid string "test" values:
	0: 1
	1: duh!
	2: 21
2014-3-4:19:59:40	INFO	config_test	Run Complete
‘confreader.h’ -> ‘../include/confreader.h’
‘confreader.o’ -> ‘../obj/confreader.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/confreader'
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/ipc_channel'
g++ -c -O3 ipc_channel.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  -I../include 
g++ -c -O3 ipc_channel_test.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  -I../include 
g++ -o ipc_channel_test ipc_channel_test.o ipc_channel.o -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  ../obj/common.o ../obj/logger.o  ../obj/serializer.o -lpthread
=========== IPC Channel test =============
worker started
worker ended
processed 100
main: 100 | 100
worker: 100 | 100
=========== IPC Channel test complete =============
‘ipc_channel.h’ -> ‘../include/ipc_channel.h’
‘ipc_channel.o’ -> ‘../obj/ipc_channel.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common/ipc_channel'
make[5]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common'
ar: creating ./lib/nrtb_common.a
============= common libs complete ===============
make[4]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common'
make[4]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine'
make[5]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/common'
make[5]: Nothing to be done for `lib'.
make[5]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/common'
============= building simulation engine ===============
make[5]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine'
cd messages; make lib
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine/messages'
g++ -c -O3 messages.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  -I../../common/include -I../include 
g++ -c -O3 messages_test.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  -I../../common/include -I../include 
g++ -o messages_test messages_test.o messages.o -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  ../../common/lib/nrtb_common.a -lpthread
=========== sim messages test =============
1:1:0:0
2:1:1:0x107a2c0
=========== sim_messages test complete =============
‘messages.h’ -> ‘../include/messages.h’
‘messages.o’ -> ‘../obj/messages.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine/messages'
cd main; make lib
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine/main'
g++ -c -O3 simengine.cpp -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  -I../../common/include -I../include 
g++ -o ../bin/simengine simengine.o -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  ../../common/lib/nrtb_common.a -lpthread
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine/main'
cd base_object; make lib
make[6]: Entering directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine/base_object'
g++ -c -O3 base_object.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  -I../../common/include -I../include 
g++ -c -O3 base_object_test.cpp -I ../include -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  -I../../common/include -I../include 
g++ -o base_object_test base_object_test.o base_object.o -std=gnu++11 -D _GLIBCXX_USE_SCHED_YIELD -D _GLIBCXX_USE_NANOSLEEP  ../../common/lib/nrtb_common.a -lpthread
========== base_object test =============
Object setup:
ID=0:loc=(0,0,0):att=(0,0,0):vel=(0,0,0):rot=(0,0,0):f=(0,0,0):t=(0,0,0):acc_mod=(0,0,0):t_mod=(0,0,0):mass=100:mass_mod=4.55926e-41:b_sphere=(0,0,0),0.5:pre=:posts=
ID=0:loc=(0,0,0):att=(0,0,0):vel=(0,0,0):rot=(0,0,0):f=(0,0,0):t=(0,0,0):acc_mod=(0,0,0):t_mod=(0,0,0):mass=100:mass_mod=4.55926e-41:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);:posts=
ID=0:loc=(0,0,0):att=(0,0,0):vel=(0,0,0):rot=(0,0,0):f=(0,0,0):t=(0,0,0):acc_mod=(0,0,0):t_mod=(0,0,0):mass=100:mass_mod=4.55926e-41:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,10000,0);:posts=
Launch:
0 sec.
ID=0:loc=(0,0.018038,0):att=(0,0,0):vel=(0,1.8038,0):rot=(0,0,0):f=(0,10000,0):t=(0,0,0):acc_mod=(0,-9.81,0):t_mod=(0,0,0):mass=100:mass_mod=0:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,10000,0);:posts=
0.02 sec.
ID=0:loc=(0,0.072152,0):att=(0,0,0):vel=(0,3.6076,0):rot=(0,0,0):f=(0,10000,0):t=(0,0,0):acc_mod=(0,-9.81,0):t_mod=(0,0,0):mass=100:mass_mod=0:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,10000,0);:posts=
0.04 sec.
ID=0:loc=(0,0.162342,0):att=(0,0,0):vel=(0,5.4114,0):rot=(0,0,0):f=(0,10000,0):t=(0,0,0):acc_mod=(0,-9.81,0):t_mod=(0,0,0):mass=100:mass_mod=0:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,10000,0);:posts=
0.06 sec.
ID=0:loc=(0,0.288608,0):att=(0,0,0):vel=(0,7.2152,0):rot=(0,0,0):f=(0,10000,0):t=(0,0,0):acc_mod=(0,-9.81,0):t_mod=(0,0,0):mass=100:mass_mod=0:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,10000,0);:posts=
0.08 sec.
ID=0:loc=(0,0.43095,0):att=(0,0,0):vel=(0,7.019,0):rot=(0,0,0):f=(0,0,0):t=(0,0,0):acc_mod=(0,-9.81,0):t_mod=(0,0,0):mass=100:mass_mod=0:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,0,0);:posts=
Peak:0.82 sec.
ID=0:loc=(0,2.94188,0):att=(0,0,0):vel=(0,-0.0441974,0):rot=(0,0,0):f=(0,0,0):t=(0,0,0):acc_mod=(0,-9.81,0):t_mod=(0,0,0):mass=100:mass_mod=0:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,0,0);:posts=
Impact:1.6 sec.
ID=0:loc=(0,-0.076796,0):att=(0,0,0):vel=(0,-7.69599,0):rot=(0,0,0):f=(0,0,0):t=(0,0,0):acc_mod=(0,-9.81,0):t_mod=(0,0,0):mass=100:mass_mod=0:b_sphere=(0,0,0),0.5:pre=gravity_0=(0,-9.81,0);rocket_1=(0,0,0);:posts=

** Flight Test: Passed
2=0,1.01=0,1=1,0=1
** Collision Test: Passed
=========== base_object test complete =============
‘base_object.h’ -> ‘../include/base_object.h’
‘base_object.o’ -> ‘../obj/base_object.o’
build complete
make[6]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine/base_object'
make[5]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine'
============= simulation engine complete ===============
make[4]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp/sim_engine'
make[3]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp'
============= C++ build complete ===============
make[2]: Leaving directory `/home/rstovall/development/nrtb/sprint-005/cpp'
make[1]: Leaving directory `/home/rstovall/development/nrtb/sprint-005'
============= all targets complete ===============
-- 
https://code.launchpad.net/~fpstovall/nrtb/sprint-005/+merge/209358
Your team NRTB Core is requested to review the proposed merge of lp:~fpstovall/nrtb/sprint-005 into lp:nrtb.
=== modified file 'cpp/sim_engine/base_object/base_object.cpp'
--- cpp/sim_engine/base_object/base_object.cpp	2014-01-12 17:24:44 +0000
+++ cpp/sim_engine/base_object/base_object.cpp	2014-03-05 01:02:25 +0000
@@ -72,10 +72,15 @@
   float tmass = mass + mass_mod;
   triplet a = force / tmass;
   triplet ra = torque / (tmass * 0.5); // not accurate!!
-  velocity += (a * quanta) + (accel_mod * quanta);
-  rotation += (ra * quanta) + (torque_mod * quanta);
-  location += velocity * quanta;
-  attitude += rotation * quanta;
+  // compute quanta effective Vs
+  triplet ev = velocity + (((a + accel_mod)/2) * quanta);
+  triplet er = rotation + (((ra + torque_mod)/2) * quanta);
+  // compute final velocities for the quanta
+  velocity += (a  + accel_mod) * quanta;
+  rotation += (ra + torque_mod) * quanta;
+  // update position, attitude
+  location += ev * quanta;
+  attitude += er * quanta;
   // apply post-effectors
   bool killme (false);
   for (auto e : post_attribs)
@@ -84,11 +89,12 @@
   return killme;
 };
 
-bool base_object::check_collision(sphere s)
+bool base_object::check_collision(object_p o)
 {
-  float r = s.radius + bounding_sphere.radius;
-  return r <= 
-    s.center.range(bounding_sphere.center+location);
+  float r = o->bounding_sphere.radius + bounding_sphere.radius;
+  triplet adjusted = o->bounding_sphere.center;
+  adjusted += o->location;
+  return (r >= adjusted.range(bounding_sphere.center+location));
 };
 
 void base_object::add_pre(abs_effector* e)

=== modified file 'cpp/sim_engine/base_object/base_object.h'
--- cpp/sim_engine/base_object/base_object.h	2014-01-05 00:33:52 +0000
+++ cpp/sim_engine/base_object/base_object.h	2014-03-05 01:02:25 +0000
@@ -76,9 +76,12 @@
   virtual void add_post(abs_effector * e);
   virtual abs_effector & get_post(unsigned long long i);
   // sim methods
+  // returns true if a collision is detected.
+  virtual bool check_collision(object_p o);
+  // the following return true if the object is destroyed.
   virtual bool tick(int time);
   virtual bool apply(int time, float quanta);
-  virtual bool check_collision(sphere s);
+  virtual bool apply_collision(object_p o) = 0;
 protected:
   effector_list pre_attribs;
   effector_list post_attribs;    

=== modified file 'cpp/sim_engine/base_object/base_object_test.cpp'
--- cpp/sim_engine/base_object/base_object_test.cpp	2014-01-12 17:13:10 +0000
+++ cpp/sim_engine/base_object/base_object_test.cpp	2014-03-05 01:02:25 +0000
@@ -72,14 +72,22 @@
   };  
 };
 
+class my_object : public base_object
+{
+  bool apply_collision(object_p o) 
+  {
+    return false;
+  };
+};
+
 int main()
 {
   bool failed = false;
-  cout << "=========== sim messages test ============="
+  cout << "========== base_object test ============="
     << endl;
 
   cout << "Object setup:" << endl;
-  base_object rocket_ball;
+  my_object rocket_ball;
   rocket_ball.mass = 100;
   rocket_ball.bounding_sphere.center = triplet(0);
   rocket_ball.bounding_sphere.radius = 0.5;
@@ -123,8 +131,44 @@
   cout << "Impact:" << time*0.02<< " sec." << endl;
   cout << rocket_ball.as_str() << endl;
   failed = failed or (time != 80);
-
-  cout << "=========== sim_messages test complete ============="
+  
+  cout << "\n** Flight Test: " << (failed ? "Failed" : "Passed") << endl;
+  
+  // collision tests.
+  my_object fixed = rocket_ball;
+  fixed.location = 0;
+  object_p mobile(new my_object);
+  mobile->bounding_sphere = fixed.bounding_sphere;
+  stringstream results;
+  
+  // check at various distances.
+  mobile->location = triplet(0,2,0);
+  bool t = fixed.check_collision(mobile);
+  results << fixed.location.range(mobile->location)
+    << "=" << t << ",";
+  
+  mobile->location = triplet(0,1.01,0);
+  t = fixed.check_collision(mobile);
+  results << fixed.location.range(mobile->location)
+    << "=" << t << ",";
+
+  mobile->location = triplet(0,1,0);
+  t = fixed.check_collision(mobile);
+  results << fixed.location.range(mobile->location)
+    << "=" << t << ",";
+
+  mobile->location = triplet(0);
+  t = fixed.check_collision(mobile);
+  results << fixed.location.range(mobile->location)
+    << "=" << t;
+  
+  bool c = results.str() != "2=0,1.01=0,1=1,0=1";
+  cout << results.str() << endl;
+  cout << "** Collision Test: " << (c ? "Failed" : "Passed") << endl;
+  
+  failed = failed or c;
+  
+  cout << "=========== base_object test complete ============="
     << endl;
   
   return failed;


Follow ups