Skip to content

Commit

Permalink
Add methods for creating scale and translation transformations to Pan…
Browse files Browse the repository at this point in the history
…oramaTransformFactory
  • Loading branch information
danielkrupinski committed Nov 27, 2023
1 parent dc86105 commit a5c1ee1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
12 changes: 5 additions & 7 deletions Source/Features/Sound/BombBeepVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ class BombBeepVisualizer : public TogglableFeature<BombBeepVisualizer> {
style.setZIndex(-soundInClipSpace.z);

const auto deviceCoordinates = soundInClipSpace.toNormalizedDeviceCoordinates();
PanoramaTransformations{ params.transformFactory.create<cs2::CTransformScale3D>(
BombBeepSound::getScale(soundInClipSpace.z), BombBeepSound::getScale(soundInClipSpace.z), 1.0f
), params.transformFactory.create<cs2::CTransformTranslate3D>(
deviceCoordinates.getX(),
deviceCoordinates.getY(),
cs2::CUILength{ 0.0f, cs2::CUILength::k_EUILengthLength }
) }.applyTo(style);

PanoramaTransformations{
params.transformFactory.scale(BombBeepSound::getScale(soundInClipSpace.z)),
params.transformFactory.translate(deviceCoordinates.getX(), deviceCoordinates.getY())
}.applyTo(style);

++currentIndex;
});
Expand Down
11 changes: 4 additions & 7 deletions Source/Features/Sound/BombDefuseVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,10 @@ class BombDefuseVisualizer : public TogglableFeature<BombDefuseVisualizer> {
style.setZIndex(-soundInClipSpace.z);

const auto deviceCoordinates = soundInClipSpace.toNormalizedDeviceCoordinates();
PanoramaTransformations{ params.transformFactory.create<cs2::CTransformScale3D>(
BombDefuseSound::getScale(soundInClipSpace.z), BombDefuseSound::getScale(soundInClipSpace.z), 1.0f
), params.transformFactory.create<cs2::CTransformTranslate3D>(
deviceCoordinates.getX(),
deviceCoordinates.getY(),
cs2::CUILength{ 0.0f, cs2::CUILength::k_EUILengthLength }
) }.applyTo(style);
PanoramaTransformations{
params.transformFactory.scale(BombDefuseSound::getScale(soundInClipSpace.z)),
params.transformFactory.translate(deviceCoordinates.getX(), deviceCoordinates.getY())
}.applyTo(style);

++currentIndex;
});
Expand Down
11 changes: 4 additions & 7 deletions Source/Features/Sound/BombPlantVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,10 @@ class BombPlantVisualizer : public TogglableFeature<BombPlantVisualizer> {
style.setZIndex(-soundInClipSpace.z);

const auto deviceCoordinates = soundInClipSpace.toNormalizedDeviceCoordinates();
PanoramaTransformations{ params.transformFactory.create<cs2::CTransformScale3D>(
BombPlantSound::getScale(soundInClipSpace.z), BombPlantSound::getScale(soundInClipSpace.z), 1.0f
), params.transformFactory.create<cs2::CTransformTranslate3D>(
deviceCoordinates.getX(),
deviceCoordinates.getY(),
cs2::CUILength{ 0.0f, cs2::CUILength::k_EUILengthLength }
) }.applyTo(style);
PanoramaTransformations{
params.transformFactory.scale(BombPlantSound::getScale(soundInClipSpace.z)),
params.transformFactory.translate(deviceCoordinates.getX(), deviceCoordinates.getY())
}.applyTo(style);

++currentIndex;
});
Expand Down
11 changes: 4 additions & 7 deletions Source/Features/Sound/FootstepVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,10 @@ class FootstepVisualizer : public TogglableFeature<FootstepVisualizer> {
style.setZIndex(-soundInClipSpace.z);

const auto deviceCoordinates = soundInClipSpace.toNormalizedDeviceCoordinates();
PanoramaTransformations{ params.transformFactory.create<cs2::CTransformScale3D>(
FootstepSound::getScale(soundInClipSpace.z), FootstepSound::getScale(soundInClipSpace.z), 1.0f
), params.transformFactory.create<cs2::CTransformTranslate3D>(
deviceCoordinates.getX(),
deviceCoordinates.getY(),
cs2::CUILength{ 0.0f, cs2::CUILength::k_EUILengthLength }
) }.applyTo(style);
PanoramaTransformations{
params.transformFactory.scale(FootstepSound::getScale(soundInClipSpace.z)),
params.transformFactory.translate(deviceCoordinates.getX(), deviceCoordinates.getY())
}.applyTo(style);

++currentIndex;
});
Expand Down
12 changes: 11 additions & 1 deletion Source/Helpers/PanoramaTransformFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
#include <MemoryPatterns/ClientPatterns.h>

struct PanoramaTransformFactory {
[[nodiscard]] cs2::CTransform3D* scale(float scale) const noexcept
{
return create<cs2::CTransformScale3D>(scale, scale, 1.0f);
}

[[nodiscard]] cs2::CTransform3D* translate(cs2::CUILength x, cs2::CUILength y) const noexcept
{
return create<cs2::CTransformTranslate3D>(x, y, cs2::CUILength{ 0.0f, cs2::CUILength::k_EUILengthLength });
}

private:
template <typename T, typename... Args>
[[nodiscard]] T* create(Args&&... args) const noexcept
{
Expand All @@ -18,7 +29,6 @@ struct PanoramaTransformFactory {
return nullptr;
}

private:
template <typename T>
[[nodiscard]] const void* getVmt() const noexcept
{
Expand Down

0 comments on commit a5c1ee1

Please sign in to comment.