Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ set( SOURCES
main.cpp
renderer/core/Backend.cpp
renderer/core/OptixRenderer.cpp
renderer/core/MaterialManager.cpp
renderer/core/Scene.cpp
renderer/core/Entity.cpp
renderer/core/Character.cpp
Expand All @@ -129,6 +130,7 @@ set( SOURCES
renderer/animation/VertexSkinning.cu
voxelengine/VoxelEngine.cu
voxelengine/VoxelSceneGen.cu
voxelengine/ChunkGeometryBuffer.cpp
voxelengine/Noise.cpp
renderer/shaders/AliasTable.cu
)
Expand Down Expand Up @@ -249,6 +251,7 @@ set( OFFLINE_SOURCES
renderer/core/OfflineBackend.cpp
renderer/core/SceneConfig.cpp
renderer/core/OptixRenderer.cpp
renderer/core/MaterialManager.cpp
renderer/core/Scene.cpp
renderer/core/Entity.cpp
renderer/core/Character.cpp
Expand All @@ -271,6 +274,7 @@ set( OFFLINE_SOURCES
renderer/animation/VertexSkinning.cu
voxelengine/VoxelEngine.cu
voxelengine/VoxelSceneGen.cu
voxelengine/ChunkGeometryBuffer.cpp
voxelengine/Noise.cpp
renderer/shaders/AliasTable.cu
)
Expand Down
19 changes: 19 additions & 0 deletions data/perf/performance_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,22 @@
2025-07-30 17:20:37.549 | 64 | 3840x2160 | 50.09 | 6.77 | 0.18 | 0.48 | 23.77 | 0.09 | 23.94 | default run
2025-07-30 23:53:10.988 | 64 | 3840x2160 | 43.72 | 6.67 | 0.20 | 0.53 | 23.03 | 0.10 | 18.16 | default run
2025-07-31 18:40:44.927 | 64 | 3840x2160 | 42.86 | 6.64 | 0.20 | 0.47 | 22.64 | 0.08 | 17.84 | default run
2025-08-06 14:51:03.266 | 64 | 3840x2160 | 29.08 | 7.61 | 0.24 | 0.49 | 7.59 | 0.09 | 19.02 | default run
2025-08-06 14:53:04.882 | 64 | 3840x2160 | 26.35 | 7.68 | 0.22 | 0.49 | 0.25 | 0.09 | 23.55 | default run
2025-08-06 14:53:47.715 | 64 | 3840x2160 | 29.22 | 7.25 | 0.20 | 0.50 | 7.69 | 0.08 | 19.11 | default run
2025-08-06 15:37:41.198 | 64 | 3840x2160 | 7.93 | 7.64 | 0.22 | 0.51 | 1.56 | 0.09 | 3.88 | default run
2025-08-06 15:38:21.300 | 64 | 3840x2160 | 8.18 | 9.24 | 0.29 | 0.49 | 1.56 | 0.09 | 3.91 | default run
2025-08-06 15:38:43.664 | 64 | 3840x2160 | 7.89 | 7.48 | 0.23 | 0.46 | 1.58 | 0.08 | 3.92 | default run
2025-08-06 15:39:07.172 | 64 | 3840x2160 | 8.04 | 8.20 | 0.23 | 0.47 | 1.56 | 0.08 | 3.88 | default run
2025-08-06 15:42:13.133 | 64 | 3840x2160 | 8.16 | 7.64 | 0.23 | 0.51 | 1.61 | 0.08 | 4.05 | default run
2025-08-06 15:49:26.877 | 64 | 3840x2160 | 20.30 | 7.76 | 0.22 | 0.50 | 1.60 | 0.09 | 16.25 | default run
2025-08-06 15:56:22.497 | 64 | 3840x2160 | 22.78 | 7.48 | 0.21 | 0.48 | 4.09 | 0.08 | 16.27 | default run
2025-08-06 15:57:15.202 | 64 | 3840x2160 | 22.83 | 8.27 | 0.23 | 0.48 | 3.99 | 0.09 | 16.24 | default run
2025-08-06 16:01:25.499 | 64 | 3840x2160 | 22.75 | 7.45 | 0.20 | 0.49 | 4.09 | 0.08 | 16.25 | default run
2025-08-06 16:04:50.478 | 64 | 3840x2160 | 22.79 | 7.47 | 0.21 | 0.48 | 4.08 | 0.08 | 16.30 | default run
2025-08-06 16:52:13.436 | 64 | 3840x2160 | 29.10 | 7.25 | 0.22 | 0.48 | 7.70 | 0.08 | 19.00 | default run
2025-08-06 16:52:23.644 | 64 | 3840x2160 | 29.11 | 7.18 | 0.18 | 0.48 | 7.56 | 0.08 | 19.14 | default run
2025-08-06 17:12:03.225 | 64 | 3840x2160 | 27.50 | 7.42 | 0.23 | 0.49 | 6.05 | 0.09 | 19.01 | default run
2025-08-06 17:19:41.012 | 64 | 3840x2160 | 27.48 | 7.62 | 0.28 | 0.48 | 6.01 | 0.09 | 18.99 | default run
2025-08-06 17:57:25.761 | 64 | 3840x2160 | 27.56 | 8.34 | 0.24 | 0.48 | 5.97 | 0.09 | 18.96 | default run
2025-08-06 18:01:15.626 | 64 | 3840x2160 | 27.51 | 7.71 | 0.22 | 0.48 | 6.00 | 0.08 | 19.02 | default run
68 changes: 66 additions & 2 deletions renderer/core/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Character::Character(const EntityTransform &transform)
m_movement.yaw = transform.rotation.y;
m_movement.targetYaw = transform.rotation.y;

// Initialize character at ground level
checkGroundCollision();
// Initialize character at ground level with collision check
initializeCharacterPosition();

// Initialize animation clips after a short delay to ensure entity is loaded
initializeAnimationClips();
Expand Down Expand Up @@ -1090,4 +1090,68 @@ void Character::triggerPlaceAnimation()

// Start the additive place animation using multiple additive system
getAnimationManager()->startMultipleAdditiveAnimation(m_animation.placeClipIndex, placeSpeed);
}

void Character::initializeCharacterPosition()
{
EntityTransform transform = getTransform();
Float3 currentPos = transform.position;

// Check if character's whole body is colliding with blocks
if (!isPositionValid(currentPos))
{
// Character is colliding, find the highest solid block within the character's footprint
float radius = m_physics.radius;
int blockX = static_cast<int>(floor(currentPos.x));
int blockZ = static_cast<int>(floor(currentPos.z));

// Find the highest solid block in the area around the character
int maxSolidY = -1;

// Check blocks in a circular area around the character
for (int dx = -1; dx <= 1; dx++)
{
for (int dz = -1; dz <= 1; dz++)
{
int checkX = blockX + dx;
int checkZ = blockZ + dz;

// Only check if this position is within character's radius
Float3 blockCenter = Float3(checkX + 0.5f, 0, checkZ + 0.5f);
Float3 charCenter = Float3(currentPos.x, 0, currentPos.z);
if (length(blockCenter - charCenter) <= radius + 0.5f) // Add small margin
{
// Find highest solid block at this X,Z position
for (int y = 255; y >= 0; y--)
{
Voxel voxel = VoxelEngine::Get().getVoxelAtGlobal(checkX, y, checkZ);
if (voxel.id != BlockTypeEmpty)
{
maxSolidY = std::max(maxSolidY, y);
break; // Found highest solid block at this position
}
}
}
}
}

if (maxSolidY >= 0)
{
// Place character on top of the highest solid block
float newY = static_cast<float>(maxSolidY + 1) + 0.01f; // Small offset above ground
currentPos.y = newY;

// Update transform
transform.position = currentPos;
setTransform(transform);

// Reset physics state for safe initialization
m_physics.velocity = Float3(0.0f, 0.0f, 0.0f);
m_physics.isGrounded = true;
m_physics.canJump = true;
}
}

// Final ground collision check to ensure proper state
checkGroundCollision();
}
1 change: 1 addition & 0 deletions renderer/core/Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,5 @@ class Character : public Entity
float getTerrainHeightAt(const Float3 &worldPos);
bool isPositionValid(const Float3 &position);
bool hasGroundSupport(const Float3 &position, float groundHeight);
void initializeCharacterPosition();
};
Loading