Issues with vec2 inPlace calls
Shri

Gio,

 

In some of my steering code, I am seeing something which I can't figure out ?

I am passing in a source and target scene object. Seeks means return the desired velocity

to move from the source to the target - standard steering stuff.

 

When I code it the following way everything is ok and works as expected. With the source scene object moving to the target.

Steering.prototype.seekSO = function(source,target) {	var sP = source.getPosition();	var tP = target.getPosition();	var desiredVelocity = {x: tP.x - sP.x, y: tP.y - sP.y};	desiredVelocity = wade.vec2.normalizeIfPossible(desiredVelocity);	desiredVelocity = wade.vec2.scale(desiredVelocity,this.maxSpeed);	return desiredVelocity;};	// end seekSO

However, when I code it this way, the scene object is no where on the screen and I eventually get;

"warning some sprites have invalid coordinates, it isn't possible to render this frame"

Steering.prototype.seekSO = function(source,target) {	var sP = source.getPosition();	var tP = target.getPosition();	var desiredVelocity = {x: tP.x - sP.x, y: tP.y - sP.y};	wade.vec2.normalizeInPlaceIfPossible(desiredVelocity);	wade.vec2.scaleInPlace(desiredVelocity,this.maxSpeed);	return desiredVelocity;};	// end seekSO

They should be the same code functionally (I think) ?

The only difference is using the in place calls.

So, has anyone else noticed problems with the in place vector calls or am I missing something.

 

Not a problem for me because I can just use the non in place calls, but I wasn't sure if I had uncovered a bug or not ?

 

Anyway, as always AHYCPIA.

 

cheers,

Shri

 

1 Comment
Gio

Hi Shri

 

Yes there was indeed a bug with wade.vec2.normalizeInPlaceIfPossible in older versions of WADE. I suppose you are using 1.6.1? It was fixed in version 2.0

 

BugFix (B162): wade.vec2.normalizeInPlaceIfPossible() doesn't work

 

Thanks for reporting the problem anyway, please do let us know if you find any more

Post a reply
Add Attachment
Submit Reply
Login to Reply