28 boost::shared_ptr<Event> SPEv(newEvent);
64 boost::shared_ptr<Event> SPEv(newEvent);
90 previousPos = r->
getEvents()->back()->getPosition();
178 decimal closestDistance = realImpact.distance(closestPoint);
181 return (closestDistance <= (thick / 2.));
215 boost::shared_ptr<Event> SPEv(newEvent);
218 unsigned int diff_nb_rays = 0;
233 (
unsigned int)(diff_nb_rays / pow(
static_cast<float>(2),
static_cast<int>(r->
getDiff())));
253 #ifdef _ALLOW_TARGETING_
254 void ValidRay::appendDirectionToEvent(boost::shared_ptr<Event> e,
TargetManager& targets)
256 std::vector<vec3>& ponctualTargets = targets.
getTargets();
258 std::vector<vec3> acceptableTargets;
259 for (
unsigned int i = 0; i < ponctualTargets.size(); i++)
261 vec3 response = ponctualTargets.at(i) - e->getPosition();
262 response.normalize();
263 if (e->isAcceptableResponse(response))
265 acceptableTargets.push_back(response);
269 if (acceptableTargets.size() <
static_cast<unsigned int>(e->getNbResponseLeft()))
271 for (
unsigned int i = 0; i < acceptableTargets.size(); i++)
273 e->appendTarget(acceptableTargets.at(i),
true);
278 for (
unsigned int i = 0; i < static_cast<unsigned int>(e->getNbResponseLeft()); i++)
280 int index = rand() % e->getNbResponseLeft();
281 e->appendTarget(acceptableTargets.at(index),
true);
Class defining the configuration of the acoustic ray tracer.
bool UsePathDifValidation
Flag to activate path validations during diffraction.
unsigned int NbRayWithDiffraction
Number of rays to throw during diffraction.
bool DiffractionDropDownNbRays
static AcousticRaytracerConfiguration * get()
Get access to the configuration.
double MaxPathDifference
Parameter (by default 24) for path validations during diffraction.
bool DiffractionUseDistanceAsFilter
virtual void setNbResponseLeft(int _nbResponseLeft)
Set the number of remaining rays to launch.
virtual bool getResponse(vec3 &r, bool force=false)
Computes the next response of the event in function of the number of responses left.
virtual double getAngle()
Get the angle between the incident ray and the diffraction edge.
Event that is only a point in a ray path with no direction change.
virtual bool getResponse(vec3 &r, bool force=false)
Return a direction vector for the impact. Ray direction vector in response of the event.
: Describes a ray by a pair of unsigned int. The first one gives the source number (in the range 0-40...
void setDirection(vec3 _direction)
set the direction if the ray
unsigned int getReflex() const
Return the reflections number encountered by the ray.
void setPosition(vec3 _position)
set the starting point ray
void setNbDiffraction(unsigned int _nbDiffraction)
set the diffractions number for the ray
Source * getSource()
Return the ray source.
void setCumulDistance(decimal _cumulDistance)
set the cumulative distance by the ray computed at each step
void setNbReflexion(unsigned int _nbReflexion)
set the reflections number for the ray
decimal getThickness(const decimal &distance, bool diffraction)
Compute the thickness of the ray after having traveled a certain distance depending on the type of so...
vec3 getPosition() const
Return starting point ray.
Base * getLastPertinentEventOrSource(typeevent evType=DIFFRACTION)
Return a pointer to the last event of type evType or source if none.
vec3 getDirection() const
Return direction of the ray.
decimal getCumulDelta() const
Return the cumulative difference between the rays length and its length when ignoring diffractions an...
decimal computePertinentLength(const vec3 &ref, const vec3 &lastPos, vec3 &closestPoint)
Compute ray length from last pertinent event (i.e. source or last diffraction) to the nearest point o...
void setCumulDelta(decimal _cumulDelta)
set the cumulative walking step difference by the ray computed at each step
unsigned int getDiff() const
Return the diffractions number encountered by the ray.
vec3 computeLocalOrigin(Base *ev)
Return position of ev which might be a source or an event.
void addEvent(boost::shared_ptr< Event > _event)
decimal getCumulDistance() const
Return the cumulative length since the last reflection event.
std::vector< boost::shared_ptr< Event > > * getEvents()
Return the events array encountered by the ray.
virtual unsigned int computeDiffractionNbr(const decimal &theta)
Return the number of rays to launch after a diffraction event.
vector< vec3 > * getVertices()
vector< unsigned int > * getLocalVertices()
Get local vertices.
virtual vec3 getNormal(const vec3 pos=vec3())
Get normal.
vec3 getPosition()
Get the position of the Source.
Sampler * getSampler()
Get the Sampler of this Source.
Specular reflection class Event.
virtual bool getResponse(vec3 &r, bool force=false)
Return a direction vector for the impact. Ray direction vector in response of the event.
std::vector< vec3 > & getTargets()
Return the targets.
bool isRayPassesNearRidge(Ray *r, const vec3 &impact, const vec3 &realImpact)
Return True if ray passes near enough the ridge for it be in the thickness of the ray.
bool validRayWithDoNothingEvent(Ray *r, Intersection *inter)
void computeCumulDistance(Ray *r, const vec3 &impact)
adds the distance between impact and the last REFLECTION/SOURCE of the ray to the cumulDistance of th...
bool pathDiffValidationForReflection(Ray *r, const vec3 &impact)
Tests if the addition of a reflection event at position impact does not cause the pathDifference to e...
bool validTriangleWithSpecularReflexion(Ray *r, Intersection *inter)
bool computeRealImpact(Ray *r, Intersection *inter, Cylindre *cylindre, vec3 &impact)
Try to compute the intersection of the ray and the ridge.
bool pathDiffValidationForDiffraction(Ray *r, const vec3 &impact)
Tests if the addition of a diffraction event at position impact does not cause the pathDifference to ...
bool validCylindreWithDiffraction(Ray *r, Intersection *inter)
bool LineLineIntersect(const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4, vec3 *pa, vec3 *pb, decimal *mua, decimal *mub)
Calculate the segment between the lines (p1,p2) and (p3,p4)
base_vec3< decimal > vec3