Skip to content

Commit 86e982d

Browse files
committed
Merge branch 'master' into bindless
2 parents 5e23d6b + 0cf23cc commit 86e982d

File tree

5 files changed

+65
-9
lines changed

5 files changed

+65
-9
lines changed

h3d/col/Cylinder.hx

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,73 @@ class Cylinder extends Collider {
55
public var a : Point;
66
public var b : Point;
77
public var r : Float;
8+
static var tmpSphere = new Sphere(0., 0., 0., 0.);
89

9-
public inline function new(a : Point, b : Point, r : Float) {
10+
public inline function new( a : Point, b : Point, r : Float ) {
1011
this.a = a;
1112
this.b = b;
1213
this.r = r;
1314
}
1415

1516
public function rayIntersection( r : Ray, bestMatch : Bool ) : Float {
16-
throw "Not implemented";
17+
var ro = r.getPos();
18+
var rd = r.getDir();
19+
var ra = this.r;
20+
var pa = a;
21+
var pb = b;
22+
var ba = pb - pa;
23+
var oa = ro - pa;
24+
var baba = ba.dot(ba);
25+
var bard = ba.dot(rd);
26+
var baoa = ba.dot(oa);
27+
var rdoa = rd.dot(oa);
28+
var oaoa = oa.dot(oa);
29+
var a = baba - bard * bard;
30+
var b = baba * rdoa - baoa * bard;
31+
var c = baba * oaoa - baoa * baoa - ra * ra * baba;
32+
var h = b * b - a * c;
33+
if ( h >= 0.0 ) {
34+
var hs = hxd.Math.sqrt(h);
35+
var t = (-b - hs)/a;
36+
var y = baoa + t * bard;
37+
if ( y > 0.0 && y < baba )
38+
return t;
39+
t = ((y < 0.0 ? 0.0 : baba) - baoa) / bard;
40+
if( hxd.Math.abs(b + a * t) < hs )
41+
return t;
42+
}
43+
return -1;
1744
}
1845

1946
public inline function contains( p : Point ) : Bool {
20-
throw "Not implemented";
47+
var t = p.sub(a).dot(b.sub(a)) / a.distanceSq(b);
48+
if( t < 0 || t > 1 )
49+
return false;
50+
return p.distanceSq(new Point(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z))) < r * r;
2151
}
2252

2353
public function inFrustum( f : Frustum, ?m : h3d.Matrix ) : Bool {
24-
throw "Not implemented";
54+
if( m != null )
55+
throw "Not implemented";
56+
tmpSphere.load(a.x + (b.x-a.x), a.y + (b.y-a.y), a.z + (b.z-a.z), dimension() * 0.5);
57+
return tmpSphere.inFrustum(f);
2558
}
2659

2760
public function inSphere( s : Sphere ) : Bool {
28-
throw "Not implemented";
61+
tmpSphere.load(a.x + (b.x-a.x), a.y + (b.y-a.y), a.z + (b.z-a.z), dimension() * 0.5);
62+
return tmpSphere.inSphere(s);
2963
}
3064

3165
public function toString() {
3266
return "Cylinder{" + a + "," + b + "," + hxd.Math.fmt(r) + "}";
3367
}
3468

35-
public function dimension() : Float {
36-
throw "Not implemented";
69+
public inline function dimension() : Float {
70+
var h2 = a.distance(b) * 0.5;
71+
return 2 * hxd.Math.sqrt(h2 * h2 + r * r);
3772
}
3873

39-
public function closestPoint(p : Point) : Point {
74+
public function closestPoint( p : Point ) : Point {
4075
throw "not implemented";
4176
}
4277

hxd/Cursor.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ enum Cursor {
66
Move;
77
TextInput;
88
Hide;
9+
ResizeNS;
10+
ResizeWE;
11+
ResizeNWSE;
12+
ResizeNESW;
913
Custom( custom : CustomCursor );
1014
/**
1115
When this cursor is selected, call the function itself, which can handle complex logic and is responsible to call hxd.System.setCursor

hxd/System.hl.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,20 @@ class System {
274274
cur = Cursor.createSystem(SizeALL);
275275
case TextInput:
276276
cur = Cursor.createSystem(IBeam);
277+
#if (hlsdl || hldx >= version("1.16.0"))
278+
case ResizeNS:
279+
cur = Cursor.createSystem(SizeNS);
280+
case ResizeWE:
281+
cur = Cursor.createSystem(SizeWE);
282+
case ResizeNWSE:
283+
cur = Cursor.createSystem(SizeNWSE);
284+
case ResizeNESW:
285+
cur = Cursor.createSystem(SizeNESW);
286+
#else
287+
// fallback for old hldx versions that don't have all the CursorKind values for SizeXX
288+
case ResizeNS, ResizeWE, ResizeNWSE, ResizeNESW:
289+
cur = Cursor.createSystem(SizeALL);
290+
#end
277291
case Callback(_), Hide:
278292
throw "assert";
279293
case Custom(c):

hxd/System.js.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class System {
9595
case Move: "move";
9696
case TextInput: "text";
9797
case Hide: "none";
98+
case ResizeNS: "ns-resize";
99+
case ResizeWE: "ew-resize"; // not a typo, WE is reversed in css
100+
case ResizeNWSE: "nwse-resize";
101+
case ResizeNESW: "nesw-resize";
98102
case Callback(_): throw "assert";
99103
case Custom(cur):
100104
if ( cur.alloc == null ) {

hxsl/CacheFileBuilder.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ class CacheFileBuilder {
197197
var tmpSrc = tmpFile + ".hlsl";
198198
var tmpOut = tmpFile + ".sb";
199199
var sign = @:privateAccess dx12Driver.computeRootSignature(r);
200-
out.baseRegister = (rd.kind == Vertex) ? 0 : sign.registers[1].start;
201200
var code = out.run(rd.data);
202201
var serializeRootSignature = @:privateAccess dx12Driver.stringifyRootSignature(sign.sign, "ROOT_SIGNATURE", sign.params, sign.paramsCount);
203202
code = serializeRootSignature + code;

0 commit comments

Comments
 (0)