-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
143 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "RayCastTypes.h" | ||
|
||
RayCastVoxelHit::RayCastVoxelHit() | ||
{ | ||
this->facing = static_cast<VoxelFacing3D>(-1); | ||
} | ||
|
||
RayCastHit::RayCastHit() | ||
{ | ||
this->t = 0.0; | ||
this->type = static_cast<RayCastHitType>(-1); | ||
} | ||
|
||
RayCastEntityHit::RayCastEntityHit() | ||
{ | ||
this->id = -1; | ||
} | ||
|
||
void RayCastHit::initVoxel(double t, const CoordDouble3 &coord, const VoxelInt3 &voxel, VoxelFacing3D facing) | ||
{ | ||
this->t = t; | ||
this->coord = coord; | ||
|
||
this->type = RayCastHitType::Voxel; | ||
this->voxelHit.voxel = voxel; | ||
this->voxelHit.facing = facing; | ||
} | ||
|
||
void RayCastHit::initEntity(double t, const CoordDouble3 &coord, EntityInstanceID id) | ||
{ | ||
this->t = t; | ||
this->coord = coord; | ||
|
||
this->type = RayCastHitType::Entity; | ||
this->entityHit.id = id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef RAY_CAST_TYPES_H | ||
#define RAY_CAST_TYPES_H | ||
|
||
#include <limits> | ||
|
||
#include "../Entities/EntityInstance.h" | ||
#include "../Math/Vector3.h" | ||
#include "../Voxels/VoxelUtils.h" | ||
|
||
enum class RayCastHitType | ||
{ | ||
Voxel, | ||
Entity | ||
}; | ||
|
||
struct RayCastVoxelHit | ||
{ | ||
VoxelInt3 voxel; | ||
VoxelFacing3D facing; | ||
|
||
RayCastVoxelHit(); | ||
}; | ||
|
||
struct RayCastEntityHit | ||
{ | ||
EntityInstanceID id; | ||
|
||
RayCastEntityHit(); | ||
}; | ||
|
||
// Intersection data for ray casts. | ||
struct RayCastHit | ||
{ | ||
static constexpr double NO_HIT_DISTANCE = std::numeric_limits<double>::infinity(); | ||
|
||
double t; // Distance from ray start. | ||
CoordDouble3 coord; // Hit point in the scene. | ||
|
||
RayCastHitType type; | ||
RayCastVoxelHit voxelHit; | ||
RayCastEntityHit entityHit; | ||
|
||
RayCastHit(); | ||
|
||
void initVoxel(double t, const CoordDouble3 &coord, const VoxelInt3 &voxel, VoxelFacing3D facing); | ||
void initEntity(double t, const CoordDouble3 &coord, EntityInstanceID id); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.