Skip to content

update: add Vector2.hpp based on old vector3 functions - #148

Open
Hugo-Cathelain wants to merge 1 commit into
mainfrom
hc/Vector2--Add
Open

update: add Vector2.hpp based on old vector3 functions#148
Hugo-Cathelain wants to merge 1 commit into
mainfrom
hc/Vector2--Add

Conversation

@Hugo-Cathelain

@Hugo-Cathelain Hugo-Cathelain commented Sep 12, 2026

Copy link
Copy Markdown
Member

Closes #{LINK TO GITHUB ISSUE}

Type of Change

  • 🐞 Bug Fix (non-breaking change which fixes an issue)
  • ✨ New Feature (non-breaking change which adds functionality)
  • 💥 Breaking Change (fix or feature that would cause existing functionality to not work as expected)
  • 🧹 Refactor (code cleanup, architectural improvement, or progressive abstraction)
  • 📖 Documentation Update
  • 🧪 Tests / CI / Build System (CMake) Update

Description

Adding old Vector2 that wasn't pushed at the time and were sitting on another machine

Docs

like old vector3 docs and will need change ^^

Checklist

  • My code follows the gp-engine C++ Coding Standard.
  • I have compiled the engine successfully using the modern C++23 toolchain (GCC 13+, Clang 16+, or MSVC 19.38+) and CMake.
  • I have performed a self-review of my code and added comments, especially in complex areas like shader programming or math-heavy algorithms.
  • I have updated the relevant API reference or learning path documentation (if applicable).
  • My changes generate no new compiler warnings in the build log.
  • I have read and agree to the Code of Conduct and Contributing Guidelines.

GP Contributor License Agreement

I give to the Graphical Playground Team, LLC permission to license my contributions on any terms
they like. I am giving them this license in order to make it possible for them to accept my
contributions into their project.

As far as the law allows, my contributions come as is, without any warranty or condition, and I
will not be liable to anyone for any damages related to this software or this license, under any
kind of legal claim.

@Hugo-Cathelain Hugo-Cathelain self-assigned this Sep 12, 2026
@Hugo-Cathelain
Hugo-Cathelain requested a review from a team as a code owner September 12, 2026 06:10
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Graphical Playground (gp-engine), @Hugo-Cathelain! 🎉

We are thrilled to have you here and appreciate you opening your first Pull Request!

What's next?

  • Please ensure your code follows our formatting guidelines.
  • If you haven't already, take a quick look at our Contributing Guidelines.
  • A maintainer will review your code shortly.

Thanks again for your contribution!

@github-actions github-actions Bot added topic:core Involves core engine functionality topic:maths Involves math libraries, algorithms, or calculations labels Sep 12, 2026
@mallory-scotton mallory-scotton added the enhancement Improvement to an existing feature label Sep 12, 2026
@mallory-scotton
mallory-scotton self-requested a review September 12, 2026 06:14

@mallory-scotton mallory-scotton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, but please review the small nitpicks I commented

/// @return A reference to this vector after the division.
constexpr Vector3<T>& operator/=(const Vector3<T>& other) noexcept
{
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code hasn't be formatted using clang-format, otherwise, this spaces wouldn't been there, please format the code !

template <concepts::IsArithmetic U>
constexpr Vector2<T>& operator/=(const U scale) noexcept
{
x /= static_cast<T>(scale);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the invScale to gain a bit of performance per CPU cycle

x /= static_cast<T>(scale);
y /= static_cast<T>(scale);
z /= static_cast<T>(scale);
GP_ASSERT(scale != T(0), "Division by zero");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GP_ASSERT(scale != T(0), "Division by zero");
GP_ASSERT(scale != T{ 0 }, "Division by zero");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement to an existing feature topic:core Involves core engine functionality topic:maths Involves math libraries, algorithms, or calculations

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants