Skip to content

Commit

Permalink
various API renames, added Object.getDirection/setDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Jun 15, 2018
1 parent 78f0834 commit 1333f08
Show file tree
Hide file tree
Showing 29 changed files with 83 additions and 84 deletions.
2 changes: 1 addition & 1 deletion h2d/Drawable.hx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Drawable extends Sprite {
}
m.identity();
if( col.hue != null ) m.colorHue(col.hue);
if( col.saturation != null ) m.colorSaturation(col.saturation);
if( col.saturation != null ) m.colorSaturate(col.saturation);
if( col.contrast != null ) m.colorContrast(col.contrast);
if( col.lightness != null ) m.colorLightness(col.lightness);
if( col.gain != null ) m.colorGain(col.gain.color, col.gain.alpha);
Expand Down
2 changes: 1 addition & 1 deletion h2d/Sprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ class Sprite {
y += dy * Math.sin(rotation);
}

public inline function setPos( x : Float, y : Float ) {
public inline function setPosition( x : Float, y : Float ) {
this.x = x;
this.y = y;
}
Expand Down
2 changes: 1 addition & 1 deletion h2d/filter/ColorMatrix.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ColorMatrix extends Filter {
public static function grayed() {
var m = new h3d.Matrix();
m.identity();
m.colorSaturation(-1);
m.colorSaturate(-1);
return new ColorMatrix(m);
}

Expand Down
43 changes: 22 additions & 21 deletions h3d/Matrix.hx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Matrix {
_41 = 0.0; _42 = 0.0; _43 = 0.0; _44 = 1.0;
}

public function initRotateX( a : Float ) {
public function initRotationX( a : Float ) {
var cos = Math.cos(a);
var sin = Math.sin(a);
_11 = 1.0; _12 = 0.0; _13 = 0.0; _14 = 0.0;
Expand All @@ -60,7 +60,7 @@ class Matrix {
_41 = 0.0; _42 = 0.0; _43 = 0.0; _44 = 1.0;
}

public function initRotateY( a : Float ) {
public function initRotationY( a : Float ) {
var cos = Math.cos(a);
var sin = Math.sin(a);
_11 = cos; _12 = 0.0; _13 = -sin; _14 = 0.0;
Expand All @@ -69,7 +69,7 @@ class Matrix {
_41 = 0.0; _42 = 0.0; _43 = 0.0; _44 = 1.0;
}

public function initRotateZ( a : Float ) {
public function initRotationZ( a : Float ) {
var cos = Math.cos(a);
var sin = Math.sin(a);
_11 = cos; _12 = sin; _13 = 0.0; _14 = 0.0;
Expand All @@ -78,7 +78,7 @@ class Matrix {
_41 = 0.0; _42 = 0.0; _43 = 0.0; _44 = 1.0;
}

public function initTranslate( x = 0., y = 0., z = 0. ) {
public function initTranslation( x = 0., y = 0., z = 0. ) {
_11 = 1.0; _12 = 0.0; _13 = 0.0; _14 = 0.0;
_21 = 0.0; _22 = 1.0; _23 = 0.0; _24 = 0.0;
_31 = 0.0; _32 = 0.0; _33 = 1.0; _34 = 0.0;
Expand All @@ -92,7 +92,7 @@ class Matrix {
_41 = 0.0; _42 = 0.0; _43 = 0.0; _44 = 1.0;
}

public function initRotateAxis( axis : Vector, angle : Float ) {
public function initRotationAxis( axis : Vector, angle : Float ) {
var cos = Math.cos(angle), sin = Math.sin(angle);
var cos1 = 1 - cos;
var x = -axis.x, y = -axis.y, z = -axis.z;
Expand All @@ -117,7 +117,7 @@ class Matrix {
_41 = 0.; _42 = 0.; _43 = 0.; _44 = 1.;
}

public function initRotate( x : Float, y : Float, z : Float ) {
public function initRotation( x : Float, y : Float, z : Float ) {
var cx = Math.cos(x);
var sx = Math.sin(x);
var cy = Math.cos(y);
Expand Down Expand Up @@ -176,27 +176,28 @@ class Matrix {

public function rotate( x, y, z ) {
var tmp = tmp;
tmp.initRotate(x,y,z);
tmp.initRotation(x,y,z);
multiply(this, tmp);
}

public function rotateAxis( axis, angle ) {
var tmp = tmp;
tmp.initRotateAxis(axis, angle);
tmp.initRotationAxis(axis, angle);
multiply(this, tmp);
}

public inline function pos( ?v : Vector ) {
if( v == null )
return new Vector( _41, _42 , _43 , _44 );
public inline function getPosition( ?v : Vector ) {
return new h3d.Vector(_41,_42,_43,_44);
}

public inline function setPosition( v : Vector ) {
v.x = _41;
v.y = _42;
v.z = _43;
v.w = _44;
return v;
}

public function prependTranslate( x = 0., y = 0., z = 0. ) {
public function prependTranslation( x = 0., y = 0., z = 0. ) {
var vx = _11 * x + _21 * y + _31 * z + _41;
var vy = _12 * x + _22 * y + _32 * z + _42;
var vz = _13 * x + _23 * y + _33 * z + _43;
Expand All @@ -220,15 +221,15 @@ class Matrix {
return v;
}

public function prependRotate( x, y, z ) {
public function prependRotation( x, y, z ) {
var tmp = tmp;
tmp.initRotate(x,y,z);
tmp.initRotation(x,y,z);
multiply(tmp, this);
}

public function prependRotateAxis( axis, angle ) {
public function prependRotationAxis( axis, angle ) {
var tmp = tmp;
tmp.initRotateAxis(axis, angle);
tmp.initRotationAxis(axis, angle);
multiply(tmp, this);
}

Expand Down Expand Up @@ -523,7 +524,7 @@ class Matrix {
hxd.Math.atan2(m._23, m._33),
hxd.Math.atan2(-m._13, cy),
hxd.Math.atan2(m._12, m._11));

var v2 = new h3d.Vector(
hxd.Math.atan2(-m._23, -m._33),
hxd.Math.atan2(-m._13, -cy),
Expand Down Expand Up @@ -581,7 +582,7 @@ class Matrix {
multiply3x4(this, tmp);
}

public function colorSaturation( sat : Float ) {
public function colorSaturate( sat : Float ) {
sat += 1;
var is = 1 - sat;
var r = is * lumR;
Expand Down Expand Up @@ -721,13 +722,13 @@ class Matrix {

public static function T( x = 0., y = 0., z = 0. ) {
var m = new Matrix();
m.initTranslate(x, y, z);
m.initTranslation(x, y, z);
return m;
}

public static function R(x,y,z) {
var m = new Matrix();
m.initRotate(x,y,z);
m.initRotation(x,y,z);
return m;
}

Expand Down
15 changes: 7 additions & 8 deletions h3d/Quat.hx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Quat {
}
}

public function initRotate( ax : Float, ay : Float, az : Float ) {
public function initRotation( ax : Float, ay : Float, az : Float ) {
var sinX = ( ax * 0.5 ).sin();
var cosX = ( ax * 0.5 ).cos();
var sinY = ( ay * 0.5 ).sin();
Expand All @@ -188,12 +188,6 @@ class Quat {
w = w2;
}

public function toMatrix() {
var m = new Matrix();
saveToMatrix(m);
return m;
}

public function toEuler() {
return toMatrix().getEulerAngles();
}
Expand Down Expand Up @@ -257,10 +251,15 @@ class Quat {
return x * q.x + y * q.y + z * q.z + w * q.w;
}

public inline function getDirection() {
return new h3d.Vector(1 - 2 * ( y * y + z * z ), 2 * ( x * y - z * w ), 2 * ( x * z + y * w ));
}

/**
Save to a Left-Handed matrix
**/
public function saveToMatrix( m : h3d.Matrix ) {
public function toMatrix( ?m : h3d.Matrix ) {
if( m == null ) m = new h3d.Matrix();
var xx = x * x;
var xy = x * y;
var xz = x * z;
Expand Down
2 changes: 1 addition & 1 deletion h3d/anim/LinearAnimation.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LinearFrame {
}
public function toMatrix() {
var m = new h3d.Matrix();
new h3d.Quat(qx, qy, qz, qw).saveToMatrix(m);
new h3d.Quat(qx, qy, qz, qw).toMatrix(m);
m.prependScale(sx, sy, sz);
m.translate(tx, ty, tz);
return m;
Expand Down
4 changes: 2 additions & 2 deletions h3d/anim/SmoothTarget.hx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class SmoothTarget extends Animation {
q1.set(m._12, m._13, m._21, m._23);
var sx = m._11, sy = m._22, sz = m._33;
var tx = m.tx, ty = m.ty, tz = m.tz;
q1.saveToMatrix(m);
q1.toMatrix(m);
m._11 *= sx;
m._12 *= sx;
m._13 *= sx;
Expand All @@ -122,7 +122,7 @@ class SmoothTarget extends Animation {
q1.set(m._12, m._13, m._21, m._23);
qout.lerp(o.q, q1, 1 - blend, true);
qout.normalize();
qout.saveToMatrix(mout);
qout.toMatrix(mout);

var sx = lerp(o.sx, m._11, blend);
var sy = lerp(o.sy, m._22, blend);
Expand Down
2 changes: 1 addition & 1 deletion h3d/anim/SmoothTransition.hx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class SmoothTransition extends Transition {
// shortest path
qout.lerp(q1, q2, a, true);
qout.normalize();
qout.saveToMatrix(m);
qout.toMatrix(m);
// interpolate scale
var sx = m1._11 * a + m2._11 * b;
var sy = m1._22 * a + m2._22 * b;
Expand Down
2 changes: 1 addition & 1 deletion h3d/parts/GpuParticles.hx
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ class GpuParticles extends h3d.scene.MultiMaterial {
r.normalize();
var q = new h3d.Quat();
q.initDirection(r);
q.saveToMatrix(g.pshader.cameraRotation);
q.toMatrix(g.pshader.cameraRotation);
}
if( g.emitMode == CameraBounds ) {
g.pshader.transform.load(camera.getInverseView());
Expand Down
4 changes: 2 additions & 2 deletions h3d/pass/Border.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ class Border extends ScreenFx<BorderShader> {
add(width-size, height);
add(width, height);

this.plan = new h3d.prim.RawPrimitive({ vbuf : bbuf, stride : 2, quads : true }, true);
this.plane = new h3d.prim.RawPrimitive({ vbuf : bbuf, stride : 2, quads : true }, true);
shader.color.set(1,1,1,1);
}

override function dispose() {
super.dispose();
this.plan.dispose();
this.plane.dispose();
}

}
6 changes: 3 additions & 3 deletions h3d/pass/ScreenFx.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ScreenFx<T:hxsl.Shader> {
public var shader : T;
var pass : h3d.mat.Pass;
var manager : ShaderManager;
var plan : h3d.prim.Primitive;
var plane : h3d.prim.Primitive;
var engine : h3d.Engine;
var shaders : hxsl.ShaderList;
var buffers : h3d.shader.Buffers;
Expand All @@ -17,7 +17,7 @@ class ScreenFx<T:hxsl.Shader> {
pass = new h3d.mat.Pass(Std.string(this), new hxsl.ShaderList(shader));
pass.culling = None;
pass.depth(false, Always);
plan = h3d.prim.Plan2D.get();
plane = h3d.prim.Plane2D.get();
engine = h3d.Engine.getCurrent();
}

Expand Down Expand Up @@ -66,7 +66,7 @@ class ScreenFx<T:hxsl.Shader> {
engine.uploadShaderBuffers(buffers, Globals);
engine.uploadShaderBuffers(buffers, Params);
engine.uploadShaderBuffers(buffers, Textures);
plan.render(engine);
plane.render(engine);
}

public function dispose() {
Expand Down
8 changes: 4 additions & 4 deletions h3d/prim/Plan2D.hx → h3d/prim/Plane2D.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package h3d.prim;

class Plan2D extends Primitive {
class Plane2D extends Primitive {

function new() {
}
Expand Down Expand Up @@ -45,10 +45,10 @@ class Plan2D extends Primitive {

public static function get() {
var engine = h3d.Engine.getCurrent();
var inst = @:privateAccess engine.resCache.get(Plan2D);
var inst = @:privateAccess engine.resCache.get(Plane2D);
if( inst == null ) {
inst = new Plan2D();
@:privateAccess engine.resCache.set(Plan2D, inst);
inst = new Plane2D();
@:privateAccess engine.resCache.set(Plane2D, inst);
}
return inst;
}
Expand Down
5 changes: 2 additions & 3 deletions h3d/scene/DirLight.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class DirLight extends Light {
dshader = new h3d.shader.DirLight();
super(dshader, parent);
priority = 100;
if(dir != null)
setDirection(dir.x, dir.y, dir.z);
if( dir != null ) setDirection(dir);
}

override function get_color() {
Expand All @@ -29,7 +28,7 @@ class DirLight extends Light {
}

override function getShadowDirection() : h3d.Vector {
return getDirection();
return absPos.front();
}

override function emit(ctx) {
Expand Down
9 changes: 0 additions & 9 deletions h3d/scene/Light.hx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ class Light extends Object {
return null;
}

public function getDirection() : h3d.Vector {
return absPos.front();
}

public function setDirection(x: Float, y: Float, z: Float) {
qRot.initDirection(new h3d.Vector(x, y, z));
posChanged = true;
}

#if hxbit
override function customSerialize(ctx:hxbit.Serializer) {
super.customSerialize(ctx);
Expand Down
Loading

0 comments on commit 1333f08

Please sign in to comment.