Will this work? (Can't test it atm)
BlitzMax Forums/BlitzMax Beginners Area/Will this work? (Can't test it atm)
| ||
The part below I'm wondering about is the 'b:TBlah=Self'. Since it's a Method, can you use Self as a default argument?Type TBlah Field x,y Method Do(a:TBlah,b:TBlah=Self) Self.x = a.x + b.x Self.y = a.x + b.x End Method End Type |
| ||
No. |
| ||
Thanks for testing. |
| ||
You can fudge it a bitType TBlah Field x,y Method Do(a:TBlah,b:TBlah=Null) If Not b then b = Self Self.x = a.x + b.x Self.y = a.x + b.x End Method End Type |
| ||
Hah! That's exactly what I did. I think the hit is negligible...the purists/speedfreaks will cry foul of course. I was trying to do that with subtraction but it's a different ballgame... |
| ||
Meh nm...I guess the spirits are helping me...Method Do2(a:TVec3,b:TVec3=Null) If Not b Then b = Self Else b = a Self.x = b.x - a.x Self.y = b.y - a.y Self.z = b.z - a.z End Method |
| ||
Hmm...seems I need an operator that changes a variable to the opposite of what it is. I thought it was the bitwise but that doesn't work on floats... Nm: Forgot about putting a "-" in front. |
| ||
Bleh...this works... Method Sub(a:TVec3,b:TVec3=Null) If Not b b = a a = Self EndIf Self.x = a.x - b.x Self.y = a.y - b.y Self.z = a.z - b.z End Method |
| ||
Why would you want to pass `Self` when Self is only useable within the method anyway? |
| ||
Don't take this the wrong way, but I think you're trying to be too clever for your own good. It looks like you are trying to implement some kind of clever trick or shortcut. Just stick to straightforward vector methods and keep things simple :P |