Skip to content

Commit

Permalink
Adjust sound origin to draw sound visualizations closer to the sound …
Browse files Browse the repository at this point in the history
…source
  • Loading branch information
danielkrupinski committed Nov 8, 2023
1 parent 32ec365 commit af9bd51
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Free and open-source game hack for **Counter-Strike 2**. Compatible with the lat

## What's new

* 8 November 2023 - Adjusted positions of sound visualizations to be closer to the sound source
* 1 November 2023 - **Visualize Bomb Plant** function was added to **Sound**
* 27 October 2023 - **Visualize Player Footsteps** function was added to **Sound**

Expand Down
8 changes: 7 additions & 1 deletion Source/FeatureHelpers/Sound/SoundWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SoundWatcher {
buffer.back() = '\0';

if (const auto sounds = getSoundsToAddTo(std::string_view{buffer.data()}, channel.guid))
sounds->addSound(PlayedSound{ .guid = channel.guid, .spawnTime = curtime, .origin = channelInfo2.memory[i].origin });
sounds->addSound(PlayedSound{ .guid = channel.guid, .spawnTime = curtime, .origin = correctSoundOrigin(channelInfo2.memory[i].origin) });
}
}

Expand Down Expand Up @@ -145,6 +145,12 @@ class SoundWatcher {
return soundName == cs2::kBombPlantSoundPath;
}

[[nodiscard]] static cs2::Vector correctSoundOrigin(cs2::Vector origin) noexcept
{
constexpr auto heightDifference = -18.0f;
return cs2::Vector{ origin.x, origin.y, origin.z + heightDifference };
}

cs2::SoundChannels** soundChannels{ SoundSystemPatterns::soundChannels() };
cs2::CBaseFileSystem** fileSystem{ FileSystemPatterns::fileSystem() };
GlobalVarsProvider globalVarsProvider;
Expand Down
2 changes: 1 addition & 1 deletion Source/Features/Sound/BombPlantVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BombPlantVisualizer : public TogglableFeature<BombPlantVisualizer> {
R"(
(function() {
var bombPlantPanel = $.CreatePanel('Panel', $.GetContextPanel().FindChildInLayoutFile("BombPlantContainer"), '', {
style: 'width: 100px; height: 100px; x: -50px; y: -50px;'
style: 'width: 100px; height: 100px; x: -50px; y: -100px; transform-origin: 50% 100%;'
});
$.CreatePanel('Image', bombPlantPanel, '', {
Expand Down
2 changes: 1 addition & 1 deletion Source/Features/Sound/FootstepVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class FootstepVisualizer : public TogglableFeature<FootstepVisualizer> {
R"(
(function() {
var footstepPanel = $.CreatePanel('Panel', $.GetContextPanel().FindChildInLayoutFile("FootstepContainer"), '', {
style: 'width: 50px; height: 50px; x: -25px; y: -25px;'
style: 'width: 50px; height: 50px; x: -25px; y: -50px; transform-origin: 50% 100%;'
});
$.CreatePanel('Image', footstepPanel, '', {
Expand Down

0 comments on commit af9bd51

Please sign in to comment.