Geometry Generation now in Block

This commit is contained in:
Simon Lübeß
2021-03-18 17:22:41 +01:00
parent 4e87f5f144
commit 8320689d3e
8 changed files with 280 additions and 126 deletions
+12 -23
View File
@@ -88,6 +88,9 @@ namespace Sandbox.VoxelFun
[AllowAppend]
public this() : base("VoxelTest")
{
Blocks.Init();
Models.Init();
_context = Application.Get().Window.Context..AddRef();
_effectLibrary = new EffectLibrary(_context);
@@ -178,7 +181,7 @@ namespace Sandbox.VoxelFun
uint32 i = 0;
VoxelGeometryGenerator.GenerateBlockModel(Blocks.Stone, .Zero, .All, vertices, indices, ref i);
(scope BlockModel(.HotPink)).GenerateGeometry(Blocks.Air, .Zero, .All, vertices, indices, ref i);
let qvb = new VertexBuffer(_context, typeof(VertexColorTexture), (.)vertices.Count, .Immutable);
qvb.SetData<VertexColorTexture>(vertices);
@@ -406,31 +409,15 @@ namespace Sandbox.VoxelFun
{
if(Input.IsMouseButtonPressing(.LeftButton))
{
_world.SetBlock(intersectInfo.Coordinate, Blocks.Air);
_world.BreakBlock(intersectInfo.Coordinate);
}
else if(Input.IsMouseButtonPressing(.RightButton))
{
var newBlockCoord = intersectInfo.Coordinate;
switch(intersectInfo.Face)
{
case .Front:
newBlockCoord.Z--;
case .Back:
newBlockCoord.Z++;
case .Left:
newBlockCoord.X--;
case .Right:
newBlockCoord.X++;
case .Bottom:
newBlockCoord.Y--;
case .Top:
newBlockCoord.Y++;
default:
Log.ClientLogger.Error("Unknown block face.");
}
_world.SetBlock(newBlockCoord, Blocks.Stone);
_world.PlaceBlock(intersectInfo.Coordinate, rightHandBlock, intersectInfo.Face);
}
else if(Input.IsMouseButtonPressing(.MiddleButton))
{
rightHandBlock = _world.GetBlock(intersectInfo.Coordinate);
}
}
@@ -439,6 +426,8 @@ namespace Sandbox.VoxelFun
Renderer.EndScene();
}
Block rightHandBlock = Blocks.Stone;
struct IntersectionInfo
{
public Int32_3 Coordinate;