Combine Vectors/Vector3I.h, combine Block/BlockEnums.h

This commit is contained in:
UnknownShadow200 2017-08-09 15:17:19 +10:00
parent 10d880980b
commit fb4f16c24e
34 changed files with 234 additions and 287 deletions

View File

@ -1,25 +1,25 @@
#region --- License ---
/* Licensed under the MIT/X11 license.
* Copyright (c) 2006-2008 the OpenTK Team.
* This notice may not be removed from any source distribution.
* See license.txt for licensing details.
*/
#endregion
using System;
namespace OpenTK {
/// <summary> Enumerates available window states. </summary>
public enum WindowState {
/// <summary> The window is in its normal state. </summary>
Normal = 0,
/// <summary> The window is minimized to the taskbar (also known as 'iconified'). </summary>
Minimized,
/// <summary> The window covers the whole working area, which includes the desktop but not the taskbar and/or panels. </summary>
Maximized,
/// <summary> The window covers the whole screen, including all taskbars and/or panels. </summary>
Fullscreen
}
}
#region --- License ---
/* Licensed under the MIT/X11 license.
* Copyright (c) 2006-2008 the OpenTK Team.
* This notice may not be removed from any source distribution.
* See license.txt for licensing details.
*/
#endregion
using System;
namespace OpenTK {
/// <summary> Enumerates available window states. </summary>
public enum WindowState {
/// <summary> The window is in its normal state. </summary>
Normal = 0,
/// <summary> The window is minimized to the taskbar (also known as 'iconified'). </summary>
Minimized,
/// <summary> The window covers the whole working area, which includes the desktop but not the taskbar and/or panels. </summary>
Maximized,
/// <summary> The window covers the whole screen, including all taskbars and/or panels. </summary>
Fullscreen,
}
}

View File

@ -8,4 +8,12 @@ Rectangle2D Rectangle2D_Make(Int32 x, Int32 y, Int32 width, Int32 height) {
bool Rectangle2D_Contains(Rectangle2D a, Int32 x, Int32 y) {
return x >= a.X && y >= a.Y && x < (a.X + a.Width) && y < (a.Y + a.Height);
}
Size2D Size2D_Make(Int32 width, Int32 height) {
Size2D s; s.Width = width; s.Height = height; return s;
}
Point2D Point2D_Make(Int32 x, Int32 y) {
Point2D p; p.X = x; p.Y = y; return p;
}

View File

@ -13,10 +13,26 @@ typedef struct Rectangle2D_ {
Int32 Width, Height;
} Rectangle2D;
/* Stores a coordinate in 2D space.*/
typedef struct Point2D_ {
Int32 X, Y;
} Point2D;
/* Stores a point in 2D space. */
typedef struct Size2D_ {
Int32 Width, Height;
} Size2D;
/* Creates a new rectangle. */
Rectangle2D Rectangle2D_Make(Int32 x, Int32 y, Int32 width, Int32 height);
/* Returns whether the given rectangle contains the given point. */
bool Rectangle2D_Contains(Rectangle2D a, Int32 x, Int32 y);
/* Creates a new size. */
Size2D Size2D_Make(Int32 width, Int32 height);
/* Creates a new point. */
Point2D Point2D_Make(Int32 x, Int32 y);
#endif

View File

@ -3,7 +3,6 @@
#define CS_BLOCK_H
#include "Typedefs.h"
#include "BlockID.h"
#include "BlockEnums.h"
#include "String.h"
#include "PackedCol.h"
#include "Game.h"
@ -11,11 +10,74 @@
#include "Bitmap.h"
#include "Constants.h"
#include "Compiler.h"
/* Stores properties for blocks
/* Stores properties and data for blocks
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Sides of a block. TODO: Map this to CPE PlayerClicked blockface enums. */
typedef UInt8 Face;
/* Face X = 0. */
#define Face_XMin 0
/* Face X = 1. */
#define Face_XMax 1
/* Face Z = 0. */
#define Face_ZMin 2
/* Face Z = 1. */
#define Face_ZMax 3
/* Face Y = 0. */
#define Face_YMin 4
/* Face Y = 1. */
#define Face_YMax 5
/* Number of faces on a cube. */
#define Face_Count 6
/* Sound types for blocks. */
typedef UInt8 SoundType;
#define SoundType_None 0
#define SoundType_Wood 1
#define SoundType_Gravel 2
#define SoundType_Grass 3
#define SoundType_Stone 4
#define SoundType_Metal 5
#define SoundType_Glass 6
#define SoundType_Cloth 7
#define SoundType_Sand 8
#define SoundType_Snow 9
/* Describes how a block is rendered in the world. */
typedef UInt8 DrawType;
/* Completely covers blocks behind (e.g. dirt). */
#define DrawType_Opaque 0
/* Blocks behind show (e.g. glass). Pixels are either fully visible or invisible. */
#define DrawType_Transparent 1
/* Same as Transparent, but all neighbour faces show. (e.g. leaves) */
#define DrawType_TransparentThick 2
/* Blocks behind show (e.g. water). Pixels blend with other blocks behind. */
#define DrawType_Translucent 3
/* Does not show (e.g. air). Can still be collided with. */
#define DrawType_Gas 4
/* Block renders as an X sprite (e.g. sapling). Pixels are either fully visible or invisible. */
#define DrawType_Sprite 5
/* Describes the interaction a block has with a player when they collide with it. */
typedef UInt8 CollideType;
/* No interaction when player collides. */
#define CollideType_Gas 0
/* 'swimming'/'bobbing' interaction when player collides. */
#define CollideType_Liquid 1
/* Block completely stops the player when they are moving. */
#define CollideType_Solid 2
/* Block is solid and partially slidable on. */
#define CollideType_Ice 3
/* Block is solid and fully slidable on. */
#define CollideType_SlipperyIce 4
/* Water style 'swimming'/'bobbing' interaction when player collides. */
#define CollideType_LiquidWater 5
/* Lava style 'swimming'/'bobbing' interaction when player collides. */
#define CollideType_LiquidLava 6
/* Array of block names. */
UInt8 Block_NamesBuffer[String_BufferSize(STRING_SIZE) * Block_Count];

View File

@ -1,74 +0,0 @@
#ifndef CS_BLOCKENUMS_H
#define CS_BLOCKENUMS_H
#include "Typedefs.h"
/* Block related enumerations.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Sides of a block. TODO: Map this to CPE PlayerClicked blockface enums. */
typedef UInt8 Face;
/* Face X = 0. */
#define Face_XMin 0
/* Face X = 1. */
#define Face_XMax 1
/* Face Z = 0. */
#define Face_ZMin 2
/* Face Z = 1. */
#define Face_ZMax 3
/* Face Y = 0. */
#define Face_YMin 4
/* Face Y = 1. */
#define Face_YMax 5
/* Number of faces on a cube. */
#define Face_Count 6
/* Sound types for blocks. */
typedef UInt8 SoundType;
#define SoundType_None 0
#define SoundType_Wood 1
#define SoundType_Gravel 2
#define SoundType_Grass 3
#define SoundType_Stone 4
#define SoundType_Metal 5
#define SoundType_Glass 6
#define SoundType_Cloth 7
#define SoundType_Sand 8
#define SoundType_Snow 9
/* Describes how a block is rendered in the world. */
typedef UInt8 DrawType;
/* Completely covers blocks behind (e.g. dirt). */
#define DrawType_Opaque 0
/* Blocks behind show (e.g. glass). Pixels are either fully visible or invisible. */
#define DrawType_Transparent 1
/* Same as Transparent, but all neighbour faces show. (e.g. leaves) */
#define DrawType_TransparentThick 2
/* Blocks behind show (e.g. water). Pixels blend with other blocks behind. */
#define DrawType_Translucent 3
/* Does not show (e.g. air). Can still be collided with. */
#define DrawType_Gas 4
/* Block renders as an X sprite (e.g. sapling). Pixels are either fully visible or invisible. */
#define DrawType_Sprite 5
/* Describes the interaction a block has with a player when they collide with it. */
typedef UInt8 CollideType;
/* No interaction when player collides. */
#define CollideType_Gas 0
/* 'swimming'/'bobbing' interaction when player collides. */
#define CollideType_Liquid 1
/* Block completely stops the player when they are moving. */
#define CollideType_Solid 2
/* Block is solid and partially slidable on. */
#define CollideType_Ice 3
/* Block is solid and fully slidable on. */
#define CollideType_SlipperyIce 4
/* Water style 'swimming'/'bobbing' interaction when player collides. */
#define CollideType_LiquidWater 5
/* Lava style 'swimming'/'bobbing' interaction when player collides. */
#define CollideType_LiquidLava 6
#endif

View File

@ -5,7 +5,6 @@
#include "World.h"
#include "WorldEnv.h"
#include "Block.h"
#include "BlockEnums.h"
#include "GraphicsAPI.h"
#include "GraphicsCommon.h"
#include "GraphicsEnums.h"

View File

@ -2,7 +2,7 @@
#ifndef CS_BUILDER_H
#define CS_BUILDER_H
#include "Typedefs.h"
#include "BlockEnums.h"
#include "Block.h"
#include "PackedCol.h"
#include "ChunkInfo.h"
#include "BlockID.h"

View File

@ -3,7 +3,7 @@
#define CS_BUILDER1DPART_H
#include "Typedefs.h"
#include "VertexStructs.h"
#include "BlockEnums.h"
#include "Block.h"
/* Contains state for vertices for a portion of a chunk mesh (vertices that are in a 1D atlas)
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/

View File

@ -4,7 +4,6 @@
#include "MapRenderer.h"
#include "GameProps.h"
#include "Vectors.h"
#include "Vector3I.h"
#include "Constants.h"
void ChunkSorter_UpdateSortOrder(void) {

View File

@ -3,7 +3,7 @@
#define CS_CHUNKUPDATER_H
#include "Typedefs.h"
#include "ChunkInfo.h"
#include "Vector3I.h"
#include "Vectors.h"
#include "WorldEvents.h"
/* Manages the process of building/deleting chunk meshes, in addition to calculating the visibility of chunks
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -174,7 +174,6 @@
<ClInclude Include="AnimatedComp.h" />
<ClInclude Include="AutoRotate.h" />
<ClInclude Include="AxisLinesRenderer.h" />
<ClInclude Include="BlockEnums.h" />
<ClInclude Include="BlockID.h" />
<ClInclude Include="Block.h" />
<ClInclude Include="Builder.h" />
@ -250,7 +249,6 @@
<ClInclude Include="Texture.h" />
<ClInclude Include="TextureRec.h" />
<ClInclude Include="Typedefs.h" />
<ClInclude Include="Vector3I.h" />
<ClInclude Include="Vectors.h" />
<ClInclude Include="VertexStructs.h" />
<ClInclude Include="World.h" />
@ -319,7 +317,6 @@
<ClCompile Include="TickQueue.c" />
<ClCompile Include="TiltComp.c" />
<ClCompile Include="TreeGen.c" />
<ClCompile Include="Vector3I.c" />
<ClCompile Include="Vectors.c" />
<ClCompile Include="VertexStructs.c" />
<ClCompile Include="WeatherRenderer.c" />

View File

@ -192,9 +192,6 @@
<ClInclude Include="Bitmap.h">
<Filter>Header Files\2D\Utils</Filter>
</ClInclude>
<ClInclude Include="BlockEnums.h">
<Filter>Header Files\Blocks</Filter>
</ClInclude>
<ClInclude Include="Vectors.h">
<Filter>Header Files\Math</Filter>
</ClInclude>
@ -222,9 +219,6 @@
<ClInclude Include="ErrorHandler.h">
<Filter>Header Files\Platform</Filter>
</ClInclude>
<ClInclude Include="Vector3I.h">
<Filter>Header Files\Math</Filter>
</ClInclude>
<ClInclude Include="World.h">
<Filter>Header Files\Map</Filter>
</ClInclude>
@ -455,9 +449,6 @@
<ClCompile Include="GraphicsCommon.c">
<Filter>Source Files\Graphics</Filter>
</ClCompile>
<ClCompile Include="Vector3I.c">
<Filter>Source Files\Math</Filter>
</ClCompile>
<ClCompile Include="ExtMath.c">
<Filter>Source Files\Math</Filter>
</ClCompile>

View File

@ -1,6 +1,6 @@
#if 0
#include "BlockID.h"
#include "BlockEnums.h"
#include "Block.h"
#include "DefaultSet.h"
Real32 DefaultSet_Height(BlockID b) {

View File

@ -2,7 +2,7 @@
#ifndef CS_DEFAULT_BLOCKS_H
#define CS_DEFAULT_BLOCKS_H
#include "Typedefs.h"
#include "BlockEnums.h"
#include "Block.h"
#include "PackedCol.h"
/* List of properties for core blocks.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -3,7 +3,7 @@
#include "Typedefs.h"
#include "String.h"
#include "Stream.h"
#include "Vector3I.h"
#include "Vectors.h"
/* Helper method for managing events.
Copyright 2017 ClassicalSharp | Licensed under BSD-3
*/

View File

@ -2,7 +2,7 @@
#include "GraphicsAPI.h"
#include "GraphicsEnums.h"
#include "Platform.h"
#include "BlockEnums.h"
#include "Block.h"
void GfxCommon_Init(void) {
GfxCommon_quadVb = Gfx_CreateDynamicVb(VertexFormat_P3fC4b, 4);

View File

@ -4,7 +4,7 @@
#include "Typedefs.h"
#include "Vectors.h"
#include "PackedCol.h"
#include "BlockEnums.h"
#include "Block.h"
#include "Entity.h"
#include "AABB.h"
#include "GraphicsEnums.h"

View File

@ -7,7 +7,6 @@
#include "PackedCol.h"
#include "ExtMath.h"
#include "Block.h"
#include "BlockEnums.h"
#include "TerrainAtlas1D.h"
Int32 iso_count;

View File

@ -4,7 +4,7 @@
#include "Typedefs.h"
#include "GraphicsEnums.h"
#include "VertexStructs.h"
#include "BlockEnums.h"
#include "Block.h"
/* Draws 2D isometric blocks for the hotbar and inventory UIs.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/

View File

@ -1,7 +1,6 @@
#if 0
#include "Lighting.h"
#include "Block.h"
#include "BlockEnums.h"
#include "Funcs.h"
#include "MapRenderer.h"
#include "Platform.h"

View File

@ -1,7 +1,6 @@
#if 0
#include "MapRenderer.h"
#include "Block.h"
#include "BlockEnums.h"
#include "GameProps.h"
#include "GraphicsAPI.h"
#include "GraphicsEnums.h"
@ -9,7 +8,6 @@
#include "World.h"
#include "WorldEnv.h"
#include "Vectors.h"
#include "Vector3I.h"
#include "ChunkSorter.h"
#include "ChunkUpdater.h"
bool inTranslucent;

View File

@ -3,7 +3,7 @@
#define CS_NORMALBUILDER_H
#include "Builder.h"
#include "Typedefs.h"
#include "BlockEnums.h"
#include "Block.h"
#include "PackedCol.h"
/* Implements a simple chunk mesh builder, where each block face is a single colour.
(whatever lighting engine returns as light colour for given block face at given coordinates)

View File

@ -10,7 +10,6 @@
#include "ExtMath.h"
#include "TickQueue.h"
#include "Block.h"
#include "BlockEnums.h"
#include "Lighting.h"
#include "Options.h"
#include "TreeGen.h"

View File

@ -3,7 +3,7 @@
#define CS_PHYSICS_H
#include "Typedefs.h"
#include "BlockID.h"
#include "Vector3I.h"
#include "Vectors.h"
#include "TickQueue.h"
/* Implements simple block physics.
Copyright 2014 - 2017 ClassicalSharp | Licensed under BSD-3

View File

@ -2,9 +2,8 @@
#ifndef CS_PICKEDPOS_H
#define CS_PICKEDPOS_H
#include "Typedefs.h"
#include "Vector3I.h"
#include "Vectors.h"
#include "BlockEnums.h"
#include "Block.h"
/* Data for picked/selected block by the user, and related methods.
Copyright 2014 - 2017 ClassicalSharp | Licensed under BSD-3
*/

View File

@ -3,7 +3,6 @@
#include "ExtMath.h"
#include "World.h"
#include "Block.h"
#include "BlockEnums.h"
#include "Funcs.h"
#include "Entity.h"

View File

@ -4,7 +4,6 @@
#include "Typedefs.h"
#include "PackedCol.h"
#include "Vectors.h"
#include "Vector3I.h"
#include "VertexStructs.h"
/* Describes a selection box, and contains methods related to the selection box.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -3,7 +3,7 @@
#define CS_TREE_GEN_H
#include "Typedefs.h"
#include "Random.h"
#include "Vector3I.h"
#include "Vectors.h"
/* Implements original classic vanilla map generation
Based on: https://github.com/UnknownShadow200/ClassicalSharp/wiki/Minecraft-Classic-map-generation-algorithm
Thanks to Jerralish for originally reverse engineering classic's algorithm, then preparing a high level overview of the algorithm.

View File

@ -1,69 +0,0 @@
#include "Vector3I.h"
#include "Funcs.h"
#include "ExtMath.h"
Vector3I Vector3I_Create1(Int32 value) {
Vector3I v; v.X = value; v.Y = value; v.Z = value; return v;
}
Vector3I Vector3I_Create3(Int32 x, Int32 y, Int32 z) {
Vector3I v; v.X = x; v.Y = y; v.Z = z; return v;
}
void Vector3I_Add(Vector3I* result, Vector3I* a, Vector3I* b) {
result->X = a->X + b->X;
result->Y = a->Y + b->Y;
result->Z = a->Z + b->Z;
}
void Vector3I_Subtract(Vector3I* result, Vector3I* a, Vector3I* b) {
result->X = a->X - b->X;
result->Y = a->Y - b->Y;
result->Z = a->Z - b->Z;
}
void Vector3I_Multiply1(Vector3I* result, Vector3I* a, Int32 scale) {
result->X = a->X * scale;
result->Y = a->Y * scale;
result->Z = a->Z * scale;
}
void Vector3I_Negate(Vector3I* result, Vector3I* a) {
result->X = -a->X;
result->Y = -a->Y;
result->Z = -a->Z;
}
bool Vector3I_Equals(Vector3I* a, Vector3I* b) {
return a->X == b->X && a->Y == b->Y && a->Z == b->Z;
}
bool Vector3I_NotEquals(Vector3I* a, Vector3I* b) {
return a->X != b->X || a->Y != b->Y || a->Z != b->Z;
}
void Vector3I_Floor(Vector3I* result, Vector3* a) {
result->X = Math_Floor(a->X);
result->Y = Math_Floor(a->Y);
result->Z = Math_Floor(a->Z);
}
void Vector3I_ToVector3(Vector3* result, Vector3I* a) {
result->X = (Real32)a->X;
result->Y = (Real32)a->Y;
result->Z = (Real32)a->Z;
}
void Vector3I_Min(Vector3I* result, Vector3I* a, Vector3I* b) {
result->X = min(a->X, b->X);
result->Y = min(a->Y, b->Y);
result->Z = min(a->Z, b->Z);
}
void Vector3I_Max(Vector3I* result, Vector3I* a, Vector3I* b) {
result->X = max(a->X, b->X);
result->Y = max(a->Y, b->Y);
result->Z = max(a->Z, b->Z);
}

View File

@ -1,57 +0,0 @@
#ifndef CS_VECTOR3I_H
#define CS_VECTOR3I_H
#include "Typedefs.h"
#include "Vectors.h"
#include "Compiler.h"
/* Represents 3 dimensional integer vector.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
typedef struct Vector3I_ { Int32 X, Y, Z; } Vector3I;
/* Constructs a 3D vector with X, Y and Z set to given value. */
Vector3I Vector3I_Create1(Int32 value);
/* Constructs a 3D vector from the given coordinates. */
Vector3I Vector3I_Create3(Int32 x, Int32 y, Int32 z);
#define Vector3I_UnitX Vector3I_Create3(1, 0, 0)
#define Vector3I_UnitY Vector3I_Create3(0, 1, 0)
#define Vector3I_UnitZ Vector3I_Create3(0, 0, 1)
#define Vector3I_Zero Vector3I_Create3(0, 0, 0)
#define Vector3I_One Vector3I_Create3(1, 1, 1)
#define Vector3I_MinusOne Vector3I_Create3(-1, -1, -1)
/* Adds a and b. */
void Vector3I_Add(Vector3I* result, Vector3I* a, Vector3I* b);
/* Subtracts b from a. */
void Vector3I_Subtract(Vector3I* result, Vector3I* a, Vector3I* b);
/* Multiplies all components of a by scale. */
void Vector3I_Multiply1(Vector3I* result, Vector3I* a, Int32 scale);
/* Negates components of a. */
void Vector3I_Negate(Vector3I* result, Vector3I* a);
/* Returns whether the two vectors are exact same on all axes. */
bool Vector3I_Equals(Vector3I* a, Vector3I* b);
/* Returns whether the two vectors are different on any axes. */
bool Vector3I_NotEquals(Vector3I* a, Vector3I* b);
/* Returns a vector such that each component is floor of input floating-point component.*/
void Vector3I_Floor(Vector3I* result, Vector3* a);
/* Returns a vector with the integer components converted to floating-point components.*/
void Vector3I_ToVector3(Vector3* result, Vector3I* a);
/* Returns a vector such that each component is minimum of corresponding a and b component.*/
void Vector3I_Min(Vector3I* result, Vector3I* a, Vector3I* b);
/* Returns a vector such that each component is maximum of corresponding a and b component.*/
void Vector3I_Max(Vector3I* result, Vector3I* a, Vector3I* b);
#endif

View File

@ -1,5 +1,6 @@
#include "Vectors.h"
#include "ExtMath.h"
#include "Funcs.h"
Vector2 Vector2_Create2(Real32 x, Real32 y) {
Vector2 v; v.X = x; v.Y = y; return v;
@ -13,6 +14,13 @@ Vector3 Vector3_Create3(Real32 x, Real32 y, Real32 z) {
Vector3 v; v.X = x; v.Y = y; v.Z = z; return v;
}
Vector3I Vector3I_Create1(Int32 value) {
Vector3I v; v.X = value; v.Y = value; v.Z = value; return v;
}
Vector3I Vector3I_Create3(Int32 x, Int32 y, Int32 z) {
Vector3I v; v.X = x; v.Y = y; v.Z = z; return v;
}
Real32 Vector3_Length(Vector3* v) {
Real32 lenSquared = v->X * v->X + v->Y * v->Y + v->Z * v->Z;
@ -23,31 +31,34 @@ Real32 Vector3_LengthSquared(Vector3* v) {
return v->X * v->X + v->Y * v->Y + v->Z * v->Z;
}
#define Vec3_Add(result, a, b)\
result->X = a->X + b->X;\
result->Y = a->Y + b->Y;\
result->Z = a->Z + b->Z;
void Vector3_Add(Vector3* result, Vector3* a, Vector3* b) {
result->X = a->X + b->X;
result->Y = a->Y + b->Y;
result->Z = a->Z + b->Z;
}
void Vector3_Add(Vector3* result, Vector3* a, Vector3* b) { Vec3_Add(result, a, b); }
void Vector3I_Add(Vector3I* result, Vector3I* a, Vector3I* b) { Vec3_Add(result, a, b); }
void Vector3_Add1(Vector3* result, Vector3* a, Real32 b) {
result->X = a->X + b;
result->Y = a->Y + b;
result->Z = a->Z + b;
}
void Vector3_Subtract(Vector3* result, Vector3* a, Vector3* b) {
result->X = a->X - b->X;
result->Y = a->Y - b->Y;
result->Z = a->Z - b->Z;
}
#define Vec3_Sub(result, a, b)\
result->X = a->X - b->X;\
result->Y = a->Y - b->Y;\
result->Z = a->Z - b->Z;
void Vector3_Multiply1(Vector3* result, Vector3* a, Real32 scale) {
result->X = a->X * scale;
result->Y = a->Y * scale;
result->Z = a->Z * scale;
}
void Vector3_Subtract(Vector3* result, Vector3* a, Vector3* b) { Vec3_Sub(result, a, b); }
void Vector3I_Subtract(Vector3I* result, Vector3I* a, Vector3I* b) { Vec3_Sub(result, a, b); }
#define Vec3_Mul1(result, a, scale)\
result->X = a->X * scale;\
result->Y = a->Y * scale;\
result->Z = a->Z * scale;
void Vector3_Multiply1(Vector3* result, Vector3* a, Real32 scale) { Vec3_Mul1(result, a, scale); }
void Vector3I_Multiply1(Vector3I* result, Vector3I* a, Int32 scale) { Vec3_Mul1(result, a, scale); }
void Vector3_Multiply3(Vector3* result, Vector3* a, Vector3* scale) {
result->X = a->X * scale->X;
result->Y = a->Y * scale->Y;
@ -64,6 +75,12 @@ void Vector3_Divide3(Vector3* result, Vector3* a, Vector3* scale) {
result->Z = a->Z / scale->Z;
}
void Vector3I_Negate(Vector3I* result, Vector3I* a) {
result->X = -a->X;
result->Y = -a->Y;
result->Z = -a->Z;
}
void Vector3_Lerp(Vector3* result, Vector3* a, Vector3* b, Real32 blend) {
result->X = blend * (b->X - a->X) + a->X;
@ -88,7 +105,6 @@ void Vector3_Normalize(Vector3* result, Vector3* a) {
result->Z = a->Z * scale;
}
void Vector3_Transform(Vector3* result, Vector3* a, Matrix* mat) {
result->X = a->X * mat->Row0.X + a->Y * mat->Row1.X + a->Z * mat->Row2.X + mat->Row3.X;
result->Y = a->X * mat->Row0.Y + a->Y * mat->Row1.Y + a->Z * mat->Row2.Y + mat->Row3.Y;
@ -134,10 +150,35 @@ Vector3 Vector3_RotateZ(Vector3 v, Real32 angle) {
}
bool Vector3_Equals(Vector3* a, Vector3* b) {
return a->X == b->X && a->Y == b->Y && a->Z == b->Z;
#define Vec3_EQ(a, b) a->X == b->X && a->Y == b->Y && a->Z == b->Z
#define Vec3_NE(a, b) a->X != b->X || a->Y != b->Y || a->Z != b->Z
bool Vector3_Equals(Vector3* a, Vector3* b) { return Vec3_EQ(a, b); }
bool Vector3_NotEquals(Vector3* a, Vector3* b) { return Vec3_NE(a, b); }
bool Vector3I_Equals(Vector3I* a, Vector3I* b) { return Vec3_EQ(a, b); }
bool Vector3I_NotEquals(Vector3I* a, Vector3I* b) { return Vec3_NE(a, b); }
void Vector3I_Floor(Vector3I* result, Vector3* a) {
result->X = Math_Floor(a->X);
result->Y = Math_Floor(a->Y);
result->Z = Math_Floor(a->Z);
}
bool Vector3_NotEquals(Vector3* a, Vector3* b) {
return a->X != b->X || a->Y != b->Y || a->Z != b->Z;
void Vector3I_ToVector3(Vector3* result, Vector3I* a) {
result->X = (Real32)a->X;
result->Y = (Real32)a->Y;
result->Z = (Real32)a->Z;
}
void Vector3I_Min(Vector3I* result, Vector3I* a, Vector3I* b) {
result->X = min(a->X, b->X);
result->Y = min(a->Y, b->Y);
result->Z = min(a->Z, b->Z);
}
void Vector3I_Max(Vector3I* result, Vector3I* a, Vector3I* b) {
result->X = max(a->X, b->X);
result->Y = max(a->Y, b->Y);
result->Z = max(a->Z, b->Z);
}

View File

@ -9,7 +9,7 @@
typedef struct Vector2_ { Real32 X, Y; } Vector2;
typedef struct Vector3_ { Real32 X, Y, Z; } Vector3;
typedef struct Vector3I_ { Int32 X, Y, Z; } Vector3I;
/* Constructs a 2D vector from the given coordinates. */
@ -21,6 +21,11 @@ Vector3 Vector3_Create1(Real32 value);
/* Constructs a 3D vector from the given coordinates. */
Vector3 Vector3_Create3(Real32 x, Real32 y, Real32 z);
/* Constructs a 3D vector with X, Y and Z set to given value. */
Vector3I Vector3I_Create1(Int32 value);
/* Constructs a 3D vector from the given coordinates. */
Vector3I Vector3I_Create3(Int32 x, Int32 y, Int32 z);
/* Returns the length of the given vector. */
Real32 Vector3_Length(Vector3* v);
@ -40,19 +45,35 @@ Real32 Vector3_LengthSquared(Vector3* v);
#define Vector3_Zero Vector3_Create3(0.0f, 0.0f, 0.0f)
#define Vector3_One Vector3_Create3(1.0f, 1.0f, 1.0f)
#define Vector3I_UnitX Vector3I_Create3(1, 0, 0)
#define Vector3I_UnitY Vector3I_Create3(0, 1, 0)
#define Vector3I_UnitZ Vector3I_Create3(0, 0, 1)
#define Vector3I_Zero Vector3I_Create3(0, 0, 0)
#define Vector3I_One Vector3I_Create3(1, 1, 1)
#define Vector3I_MinusOne Vector3I_Create3(-1, -1, -1)
/* Adds a and b. */
void Vector3_Add(Vector3* result, Vector3* a, Vector3* b);
/* Adds a and b. */
void Vector3I_Add(Vector3I* result, Vector3I* a, Vector3I* b);
/* Adds b to all components of a. */
void Vector3_Add1(Vector3* result, Vector3* a, Real32 b);
/* Subtracts b from a. */
void Vector3_Subtract(Vector3* result, Vector3* a, Vector3* b);
/* Subtracts b from a. */
void Vector3I_Subtract(Vector3I* result, Vector3I* a, Vector3I* b);
/* Multiplies all components of a by scale. */
void Vector3_Multiply1(Vector3* result, Vector3* a, Real32 scale);
/* Multiplies all components of a by scale. */
void Vector3I_Multiply1(Vector3I* result, Vector3I* a, Int32 scale);
/* Multiplies components of a by scale. */
void Vector3_Multiply3(Vector3* result, Vector3* a, Vector3* scale);
@ -62,6 +83,9 @@ void Vector3_Divide1(Vector3* result, Vector3* a, Real32 scale);
/* Divides components of a by scale. */
void Vector3_Divide3(Vector3* result, Vector3* a, Vector3* scale);
/* Negates components of a. */
void Vector3I_Negate(Vector3I* result, Vector3I* a);
/* Linearly interpolates between two vectors. */
void Vector3_Lerp(Vector3* result, Vector3* a, Vector3* b, Real32 blend);
@ -106,4 +130,23 @@ bool Vector3_Equals(Vector3* a, Vector3* b);
/* Returns whether the two vectors are different on any axis. */
bool Vector3_NotEquals(Vector3* a, Vector3* b);
/* Returns whether the two vectors are exact same on all axes. */
bool Vector3I_Equals(Vector3I* a, Vector3I* b);
/* Returns whether the two vectors are different on any axes. */
bool Vector3I_NotEquals(Vector3I* a, Vector3I* b);
/* Returns a vector such that each component is floor of input floating-point component.*/
void Vector3I_Floor(Vector3I* result, Vector3* a);
/* Returns a vector with the integer components converted to floating-point components.*/
void Vector3I_ToVector3(Vector3* result, Vector3I* a);
/* Returns a vector such that each component is minimum of corresponding a and b component.*/
void Vector3I_Min(Vector3I* result, Vector3I* a, Vector3I* b);
/* Returns a vector such that each component is maximum of corresponding a and b component.*/
void Vector3I_Max(Vector3I* result, Vector3I* a, Vector3I* b);
#endif

View File

@ -1,7 +1,6 @@
#if 0
#include "WeatherRenderer.h"
#include "Block.h"
#include "BlockEnums.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "EventHandler.h"
@ -13,7 +12,7 @@
#include "MiscEvents.h"
#include "PackedCol.h"
#include "Platform.h"
#include "Vector3I.h"
#include "Vectors.h"
#include "VertexStructs.h"
#include "World.h"
#include "WorldEnv.h"

View File

@ -3,7 +3,7 @@
#define CS_WORLD_H
#include "Typedefs.h"
#include "String.h"
#include "Vector3I.h"
#include "Vectors.h"
/* Represents a fixed size 3D array of blocks.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/