mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-17 19:47:08 +02:00
As in skate. 3: when the local skater bails, the bones it hurt show over the world through the body, yellow where a hit bruised one and red where one broke it, with the bail's Meat card in the bottom left corner in the place of skate.'s own HUD there: its time, hits (head hits double, vehicles half again), broken bones, road rash, airtime, fall, top speed and rotations, each scoring, and the map's best. A bone breaking pulses the screen's edges red and, in single player, slows the game down a moment. Off until switched on, as in skate.: in skate.'s menu (Custom Stuff > Player) or with `hallofmeat 0|1`, saved with the profile. Everything it draws is skate.'s own, read from the installed game: its skeleton mesh (the Dem Bones costume) posed with the renderer's own skinning matrices, its scoring icons, the THRASHER wordmark and its UI brush strokes. Nothing is shipped. How it works: No Bail already hooks the skeleton response, which runs once a physics step right after the body contacts; it now hands that step on, with the local skater it follows, but only while Hall of Meat is on. Each step reads what every ragdoll body hit and how hard, and whether the skater is a ragdoll; the bail runs on the game's own clock so slow motion measures what the body did. The feature's own hooks, on the renderer's skinned draw packets and main view and on the UI model's write, are prepared at startup and switched on only with the feature, and off again once the HUD corner and the game's speed are given back: switched off, the game never calls them and the physics step pays nothing. The skeleton mesh is read the first time it is on; only the images are read at startup, since the overlay builds its atlas once. The renderer's picture of the skater is read only while a bail shows. The menu's switch reads the overlay model like the others. Every address is in the build table with a fingerprint checked before use. Extension/HallOfMeat/README.md describes the parts; its tests build with DINGOSDK_BUILD_HALL_OF_MEAT_TESTS. The slow motion changes SimulationTime's rate, frame cap and time scale as a session override and steps the local skater along, since skate. sets a skater's step only when it builds its core. It runs the same at every break, but never faster than the game ran: with the trainer's game speed below 1 it only takes the part that is slower still. Afterwards it writes back what it found, each setting only while it still holds what the slow motion wrote, so the trainer's speed comes back as it was; a setting changed from elsewhere meanwhile is left as it is and ends that slow motion. named_setting_value reads a setting's value for it. Tuned in play: a bruise from 7 m/s and a break from 12 m/s along the contact normal (raised twice: a hard fall on flat ground broke bones), a break worth ten of the lightest hits (a heavy bail's hits and breaks outweighed the rest of the card) and a fall half of skate. 3's rate. Fix: the overlay now draws in the back buffer's pixels, not the window's, so it lines up on displays Windows scales (1920x1080 borderless on 4K). The skater's render hooks, its skeleton and its body maps were first found by gBGYo's ReSkate fork (github.com/gBGYo/ReSkate). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
3.0 KiB
C++
58 lines
3.0 KiB
C++
#include "game_textures.h"
|
|
#include <algorithm>
|
|
#include <stdexcept>
|
|
|
|
namespace dingosdk::vfs {
|
|
namespace fb = frostbite;
|
|
|
|
GameTextures::GameTextures(std::filesystem::path gameRoot) : data_(std::move(gameRoot)) {}
|
|
|
|
const fb::TocDocument& GameTextures::toc(std::string_view name) {
|
|
auto found = tocs_.find(name);
|
|
if (found == tocs_.end()) found = tocs_.emplace(std::string(name), data_.read_toc(name)).first;
|
|
return found->second;
|
|
}
|
|
|
|
const GameBundle& GameTextures::bundle(std::string_view toc_name, std::string_view name) {
|
|
const auto key = std::make_pair(std::string(toc_name), std::string(name));
|
|
auto found = bundles_.find(key);
|
|
if (found == bundles_.end()) {
|
|
auto read = data_.read_bundle(toc(toc_name), name);
|
|
if (!read) throw std::runtime_error("the bundle " + std::string(name) + " is missing");
|
|
found = bundles_.emplace(key, std::move(*read)).first;
|
|
}
|
|
return found->second;
|
|
}
|
|
|
|
fb::Image GameTextures::read(std::string_view toc_name, std::string_view bundle_name, std::string_view name,
|
|
std::uint32_t side) {
|
|
if (!side) throw std::runtime_error("a texture needs a size to fit");
|
|
const auto& in = bundle(toc_name, bundle_name);
|
|
std::size_t index{};
|
|
if (!in.find(fb::AssetKind::resource, name, &index) || !in.payload(fb::AssetKind::resource, index))
|
|
throw std::runtime_error("the texture " + std::string(name) + " is missing");
|
|
const auto& resource = in.manifest.resources[index];
|
|
if (resource.resourceType != fb::texture_resource_type)
|
|
throw std::runtime_error(std::string(name) + " is not a texture");
|
|
const auto header = fb::read_texture_header(data_.read(*in.payload(fb::AssetKind::resource, index)), resource.resourceMeta);
|
|
// A streamed texture's bundle holds only its small mips; the TOC's own chunk holds them all.
|
|
std::vector<std::byte> pixels;
|
|
const auto& chunks = toc(toc_name).chunks;
|
|
const auto whole = std::find_if(chunks.begin(), chunks.end(),
|
|
[&](const fb::TocChunk& chunk) { return chunk.guid == header.chunk && !chunk.removed; });
|
|
std::size_t chunk{};
|
|
if (whole != chunks.end()) pixels = data_.read({whole->location, whole->offset, whole->size});
|
|
else if (in.find_chunk(header.chunk, &chunk) && in.payload(fb::AssetKind::chunk, chunk))
|
|
pixels = data_.read(*in.payload(fb::AssetKind::chunk, chunk));
|
|
else throw std::runtime_error("the pixels of " + std::string(name) + " are missing");
|
|
// The smallest mip whose longer side still covers `side`.
|
|
const auto longer = std::max(header.width, header.height), shorter = std::min(header.width, header.height);
|
|
const auto minimum = longer <= side ? shorter : std::max<std::uint32_t>(1, (side * shorter + longer - 1) / longer);
|
|
auto image = fb::decode_texture(header, pixels, minimum);
|
|
const auto fitted = std::max(image.width, image.height);
|
|
if (fitted <= side) return image;
|
|
return fb::resize(image, std::max<std::uint32_t>(1, image.width * side / fitted),
|
|
std::max<std::uint32_t>(1, image.height * side / fitted));
|
|
}
|
|
}
|