Created
July 1, 2013 23:52
-
-
Save ryzed/5905715 to your computer and use it in GitHub Desktop.
object in flash.memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ryz.sengine.mesh; | |
import flash.Memory; | |
import ryz.math.V3; | |
/** | |
* ... | |
* @author ryz | |
*/ | |
private typedef M = Memory; | |
abstract PtrFVtx(Int) from Int to Int | |
{ | |
inline public function new(adr:Int) | |
{ | |
this = adr; | |
} | |
// offsets | |
private static inline var V3:Int = 0; | |
private static inline var U:Int = V3 + 4; | |
private static inline var V:Int = U + 4; | |
private static inline var ISX:Int = V + 4; | |
private static inline var ISY:Int = ISX + 4; | |
public static inline var SIZE:Int = ISY + 4; | |
// props | |
public var v3(get, set):PtrMV3; // link to V3 | |
public var u(get, set):Float; | |
public var v(get, set):Float; | |
inline function get_v3():PtrMV3 { return M.getI32(this + V3); } | |
inline function set_v3(v) { M.setI32(this + V3, v); return v; } | |
inline function get_u() { return M.getFloat(this + U); } | |
inline function set_u(v) { M.setFloat(this + U, v); return v; } | |
inline function get_v() { return M.getFloat(this + V); } | |
inline function set_v(v) { M.setFloat(this + V, v); return v; } | |
// int screen crds (temps for common triangle render) | |
public var isx(get, set):Int; | |
public var isy(get, set):Int; | |
inline function get_isx() { return M.getI32(this + ISX); } | |
inline function set_isx(v) { M.setI32(this + ISX, v); return v; } | |
inline function get_isy() { return M.getI32(this + ISY); } | |
inline function set_isy(v) { M.setI32(this + ISY, v); return v; } | |
// next in mem | |
inline public function next():PtrFVtx { return (this + SIZE); } | |
inline public function next2():PtrFVtx { return (this + SIZE * 2); } | |
// just helpers | |
inline public function setUV(au:Float, av:Float):Void | |
{ | |
u = au; | |
v = av; | |
} | |
inline public function setUVV(vv:V3):Void | |
{ | |
u = vv.x; | |
v = vv.y; | |
} | |
inline public function toString():String | |
{ | |
return '(PtrFVtx at $this : u = $u, v = $v, v3 = $v3, isx = $isx, isy = $isy)'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment