ClosestNotUsRayResultCallback (code)

Post Reply
Adrian Lopez
Posts: 10
Joined: Thu Jan 21, 2010 7:07 pm

ClosestNotUsRayResultCallback (code)

Post by Adrian Lopez » Fri Apr 16, 2010 2:46 am

I wish to contribute the following code to Bullet's official sources. This code is based on Bullet's own btKinematicClosestNotMeRayResultCallback, but any part of it that may be considered original I hereby place into the public domain.

ClosestNotUsRayResultCallback.h:

Code: Select all

#ifndef CLOSESTNOTUSRAYRESULTCALLBACK_H
#define CLOSESTNOTUSRAYRESULTCALLBACK_H

#include <btBulletCollisionCommon.h>

class ClosestNotUsRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{
public:
	ClosestNotUsRayResultCallback(const btVector3  &rayFromWorld, const btVector3  &rayToWorld, const btCollisionObjectArray &exclude);

	btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace);

private:
	const btCollisionObjectArray *p_exclude;
};

#endif
ClosestNotUsRayResultCallback.cpp:

Code: Select all

#include "ClosestNotUsRayResultCallback.h"

ClosestNotUsRayResultCallback::ClosestNotUsRayResultCallback(const btVector3  &rayFromWorld, const btVector3  &rayToWorld, const btCollisionObjectArray &exclude) : btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld), p_exclude(&exclude)
{}

btScalar ClosestNotUsRayResultCallback::addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
{
	int found = 0;
	if (p_exclude->size() > 0)
		found = p_exclude->findBinarySearch(rayResult.m_collisionObject);

	if (found == p_exclude->size())
		return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
	else
		return 1.0f;
}

Adrian Lopez
Posts: 10
Joined: Thu Jan 21, 2010 7:07 pm

Re: ClosestNotUsRayResultCallback (code)

Post by Adrian Lopez » Sun Apr 18, 2010 9:21 pm

BTW - Is there an official place to submit contributed code?

ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway
Contact:

Re: ClosestNotUsRayResultCallback (code)

Post by ola » Sun Apr 18, 2010 9:59 pm

You can submit it to the issue tracker:
http://code.google.com/p/bullet/issues/list

Cheers,
Ola

Post Reply