Skip to content
Merged
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
15 changes: 7 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,9 @@ endif()
# The build intention rejects non-finite rays and velocities; keep those guards when the application enables
# relaxed floating point.
if(MSVC AND NOT PERLIN_CLANG_CL_BUILD)
set_source_files_properties(src/client/player/Bridging.cpp src/client/player/HeldBuild.cpp PROPERTIES COMPILE_OPTIONS "/fp:strict")
set_source_files_properties(src/client/player/HeldBuild.cpp PROPERTIES COMPILE_OPTIONS "/fp:strict")
else()
set_source_files_properties(src/client/player/Bridging.cpp src/client/player/HeldBuild.cpp PROPERTIES COMPILE_OPTIONS "-fno-fast-math;-ffp-contract=off")
set_source_files_properties(src/client/player/HeldBuild.cpp PROPERTIES COMPILE_OPTIONS "-fno-fast-math;-ffp-contract=off")
endif()

include(CheckIPOSupported)
Expand Down Expand Up @@ -1028,15 +1028,14 @@ if(PERLIN_BUILD_TESTS AND NOT EMSCRIPTEN AND NOT ANDROID AND NOT PERLIN_IOS)
target_include_directories(hand_anim_selftest PRIVATE src)
target_compile_features(hand_anim_selftest PRIVATE cxx_std_23)
add_test(NAME hand_anim_selftest COMMAND hand_anim_selftest)
add_executable(bridging_selftest
tests/bridging_selftest.cpp
src/client/player/Bridging.cpp
add_executable(heldbuild_selftest
tests/heldbuild_selftest.cpp
src/client/player/HeldBuild.cpp
src/client/player/PlayerPhysics.cpp
src/client/player/BlockUse.cpp)
target_include_directories(bridging_selftest PRIVATE src "${glm_SOURCE_DIR}")
target_compile_features(bridging_selftest PRIVATE cxx_std_23)
add_test(NAME bridging_selftest COMMAND bridging_selftest)
target_include_directories(heldbuild_selftest PRIVATE src "${glm_SOURCE_DIR}")
target_compile_features(heldbuild_selftest PRIVATE cxx_std_23)
add_test(NAME heldbuild_selftest COMMAND heldbuild_selftest)
add_executable(entity_animation_selftest tests/entity_animation_selftest.cpp
src/client/entity/JavaAnimation.cpp src/client/attachable/Geometry.cpp
src/client/attachable/Animation.cpp src/client/attachable/Molang.cpp src/client/ui/Json.cpp)
Expand Down
21 changes: 15 additions & 6 deletions docs/bedrock-bridging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

Placing blocks always follows Bedrock Edition's own rules. They were
read out of the client (`ClientInstance::_tickBuildAction`, `GameMode::startBuildBlock`, `continueBuildBlock`,
`stopBuildBlock` and `GameMode::useItemOn`) and live in `src/client/player/HeldBuild.{hpp,cpp}`. Reach-around for
fresh presses (placing against the block you stand on while aiming past its edge) lives in
`src/client/player/Bridging.{hpp,cpp}`.
`stopBuildBlock` and `GameMode::useItemOn`) and live in `src/client/player/HeldBuild.{hpp,cpp}`.

## Click position

The build transaction's click position comes from the look ray, as in the Windows 26.60 client's build lambda
(`0x143771570`, reached from `GameMode` vtable slot 6 `0x14376B290`):

- block hit (`HitResult` type 0): `HitResult::mPos - BlockPos`, the real ray hit on the clicked face;
- no block hit (types 2 / 3): the block position itself, so the click is `(0, 0, 0)`;
- a build that continues an earlier one reuses the hit stored at `GameMode + 108` on the first placement.

There is no assist that targets a block the ray misses: a fresh press only places on the crosshair block.

## Fresh press

A new press places at the crosshair (or the reach-around target) immediately and starts a new build: the previous
A new press places at the crosshair block immediately and starts a new build: the previous
block's kind and any build line are forgotten. A block is never placed into the player's own body.

## Held use
Expand Down Expand Up @@ -53,8 +62,8 @@ corrected by the existing prediction expiry.

## Validation

`bridging_selftest` covers reach-around targeting.
`heldbuild_selftest` covers held repeats, build lines, body overlap and block-use rules.

```sh
cmake --build build --target bridging_selftest && ./build/bridging_selftest
cmake --build build --target heldbuild_selftest && ./build/heldbuild_selftest
```
5 changes: 3 additions & 2 deletions docs/bedrock-native-placement.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ strings and field usage, not from symbols.
`sendContinuousPickHitResult`. These are event notifications, not the ray
itself.
- There are no strings for a bridging assist or air-targeting placement.
Whether the vanilla client builds against air next to a block is therefore
still unconfirmed.
The 26.60 build lambda (`0x143771570`) takes the click from the player's
`HitResult`: `mPos - BlockPos` on a block hit, `(0, 0, 0)` without one, so a
click that the look ray does not reach never comes from the vanilla client.

## Open questions

Expand Down
34 changes: 0 additions & 34 deletions src/client/PerlinInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ namespace perlin {
const glm::vec3 buildEye(camera.x, camera.y, camera.z);
const int64_t buildNow =
std::chrono::duration_cast<std::chrono::nanoseconds>(detail::Clock::now().time_since_epoch()).count();
static const int kFaceNormal[6][3] = {{0, -1, 0}, {0, 1, 0}, {0, 0, -1},
{0, 0, 1}, {-1, 0, 0}, {1, 0, 0}};
const auto aimAt = [&](glm::ivec3 support, int face, glm::dvec3 point) {
useAim.kind = AimHit::Kind::Block;
useAim.bx = support.x;
Expand All @@ -313,38 +311,6 @@ namespace perlin {
useAim.face = face;
useAim.point = point;
};
if (bedrockBuild && live && levelRenderer && aimHit.kind == AimHit::Kind::None) {
Level& level = live->NetLevel();
const LevelCollision collision(level, &levelRenderer->Blocks());
auto& palette = BlockPalette::Instance();
const auto& shape =
LevelCollision::ShapeOf(palette.InternRuntime(static_cast<int32_t>(held.blockRuntimeId)));
const std::vector<physics::Box> heldShape(shape.boxes.begin(), shape.boxes.end());
bridging::Request request;
request.eye = {camera.x, camera.y, camera.z};
request.direction = glm::dvec3(targeting::ViewVector(camera.yaw, camera.pitch));
request.body = physics::BoundingBox(player.State(), player.Sneaking());
request.sneaking = player.Sneaking();
request.reach = PickRange(creative, 1);
request.placedShape = heldShape;
request.horizontalSlab = held.name.contains("slab") && heldShape.size() == 1 &&
std::abs(heldShape[0].y1 - heldShape[0].y0 - 0.5) < 1e-5;
const auto around = bridging::FindTarget(request, [&](glm::ivec3 position) {
bridging::Cell cell;
bool loaded = false;
const uint16_t id = level.GetBlock(position.x, position.y, position.z, loaded);
const std::string& name = palette.Name(id);
cell.loaded = loaded;
cell.replaceable = blockuse::IsReplaceableCell(loaded, id, name);
cell.interactive = blockuse::IsInteractive(name);
if (loaded && !cell.replaceable) {
collision.Selection(position.x, position.y, position.z, cell.collision);
}
return cell;
});
if (around)
aimAt(around->anchor, around->face, around->point);
}
if (bedrockBuild && inputManager.Pressed(Action::Use))
heldBuild.Start(player.TickCount(), useAim.kind == AimHit::Kind::Block);
bool heldRepeat = false;
Expand Down
1 change: 0 additions & 1 deletion src/client/PerlinInternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "client/player/BlockCollision.hpp"
#include "client/player/BlockDestroy.hpp"
#include "client/player/BlockUse.hpp"
#include "client/player/Bridging.hpp"
#include "client/player/DamageEffect.hpp"
#include "client/renderer/DynamicLights.hpp"
#include "client/renderer/Environment.hpp"
Expand Down
167 changes: 0 additions & 167 deletions src/client/player/Bridging.cpp

This file was deleted.

57 changes: 0 additions & 57 deletions src/client/player/Bridging.hpp

This file was deleted.

Loading
Loading