mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Raycasting world now returns intersection location and face
This commit is contained in:
@@ -380,7 +380,7 @@ namespace Sandbox.VoxelFun
|
||||
Renderer.Submit(_quadGeometryBinding, _effect, transform);
|
||||
}
|
||||
|
||||
_effect.Variables["BaseColor"].SetData(_squareColor1);
|
||||
//_effect.Variables["BaseColor"].SetData(_squareColor1);
|
||||
|
||||
_texture.Bind();
|
||||
Renderer.Submit(_quadGeometryBinding, _textureEffect, .Scaling(1.5f));
|
||||
@@ -392,8 +392,6 @@ namespace Sandbox.VoxelFun
|
||||
|
||||
//Ray ray = .(.(0.5f, 128.5f, 0.5f), .(0, -0.1f, -0.1f));
|
||||
|
||||
_effect.Variables["BaseColor"].SetData(.Red);
|
||||
|
||||
_texture.Bind();
|
||||
|
||||
Matrix mat = .Translation(ray.Start);
|
||||
@@ -415,15 +413,21 @@ namespace Sandbox.VoxelFun
|
||||
Renderer.Submit(_lineGeometryBinding, _textureEffect, mat3);
|
||||
|
||||
//Point3 lookedAtBlock = _world.RaycastBlock(ray, 10, _cubeGeo, _textureEffect);
|
||||
Point3 lookedAtBlock = _world.RaycastBlock(.(_camera.Position, _camera.Transform.Forward), 10, _cubeGeo, _textureEffect);
|
||||
Point3 lookedAtBlock = _world.RaycastBlock(.(_camera.Position, _camera.Transform.Forward), 10, _cubeGeo, _textureEffect, let intersection, let intersectFace);
|
||||
|
||||
intersectFace.ToString(intersectedFaceName..Clear());
|
||||
|
||||
Renderer.Submit(_cubeGeo, _textureEffect, .Translation((Vector3)lookedAtBlock));
|
||||
|
||||
Renderer.Submit(_cubeGeo, _textureEffect, .Translation(intersection) * .Scaling(0.1f) * .Translation(-0.5f, -0.5f, -0.5f));
|
||||
|
||||
_world.ChunkManager.Draw();
|
||||
|
||||
Renderer.EndScene();
|
||||
}
|
||||
|
||||
String intersectedFaceName = new String() ~ delete _;
|
||||
|
||||
ColorRGBA _squareColor0 = ColorRGBA.CornflowerBlue;
|
||||
ColorRGBA _squareColor1;
|
||||
|
||||
@@ -450,6 +454,8 @@ namespace Sandbox.VoxelFun
|
||||
|
||||
ImGui.Begin("Test");
|
||||
|
||||
ImGui.LabelText("Intersected Face", intersectedFaceName);
|
||||
|
||||
ImGui.DragFloat("Slow Speed", &movementSpeed, 1.0f, 0.01f, 100.0f);
|
||||
ImGui.DragFloat("Fast Speed", &movementSpeedFast, 1.0f, 1f, 10000.0f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user