Home
Reply
Contributor
emilio_c
Posts: 8

Problem with api_ray_fire using an ENTITY_LIST

Hi

I'm experiencing inconsistencies between the two signatures provided by the api_ray_fire(...) API. The one accepting a single ENTITY works as expected, but if I use the one accepting an ENTITY_LIST I get unexpected results. Is there a difference between the two versions of api_ray_fire()?

This little piece of code shows the problem:

BODY* body1 = 0;
BODY* body2 = 0;
{
	API_BEGIN
		result = api_solid_block(SPAposition(0,0,0), SPAposition(10,2,20), body1);
		result = api_solid_block(SPAposition(20,0,0), SPAposition(30,2,20), body2);
	API_END
}

ray test_ray( SPAposition(25,1,40), SPAunit_vector(0,0,-1), 100.0*SPAresabs, 1 );

// Single entity ray fire
{
	entity_hit_list hit_list;
	rayfire_options options;
	API_NOP_BEGIN
		result = api_ray_fire(body2, test_ray, hit_list, &options);
	API_NOP_END

	assert(hit_list.count() == 1); // This is fine
}

// Entity list ray fire
{
	entity_hit_list hit_list;
	rayfire_options options;
	ENTITY_LIST list;
	list.add(body1);
	list.add(body2);
	API_NOP_BEGIN
		result = api_ray_fire(list, test_ray, hit_list, &options);
	API_NOP_END

	assert(hit_list.count() == 1); // This fails! hit_list.count() gives back zero.
}

Thanks

Emilio