Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of a Hexagon Cell Grid in the GridMap node #822

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
11 changes: 6 additions & 5 deletions core/math/math_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
/**************************************************************************/
/* This file is part of: */
/* REDOT ENGINE */
/* https://redotengine.org */
/* https://www.redotengine.org/ */
/**************************************************************************/
/* Copyright (c) 2024-present Redot Engine contributors */
/* (see REDOT_AUTHORS.md) */
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* Copyright © 2024-present by the Redot community. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
Expand All @@ -29,6 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
/* Work done by Octetdev2 and BSChad. */
/* Merging done by Wasabi_Cheetah. */
/**************************************************************************/
Copy link
Member

@decryptedchaos decryptedchaos Oct 31, 2024

Choose a reason for hiding this comment

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

About this, we can see what the rest of the team says.

But for future references, this is generally not a good practice to add credits to the preamble, if we allowed one person to do this everyone would want to do it and then suddenly you have 100 names in the preamble.

Copy link
Member

@Spartan322 Spartan322 Oct 31, 2024

Choose a reason for hiding this comment

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

Co-authors are supposed to be added to the commit message anyway, like what I did with 2d1c65b for WhalesState, but this won't be merged anyway cause the Godot PR is still WIP.


#ifndef MATH_DEFS_H
#define MATH_DEFS_H
Expand All @@ -41,6 +41,7 @@

#define Math_SQRT12 0.7071067811865475244008443621048490
#define Math_SQRT2 1.4142135623730950488016887242
#define Math_SQRT3 1.7320508075688772935274463415059
Copy link
Member

Choose a reason for hiding this comment

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

This is a trivial math change, it does not need attribution.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, thanks for letting me know, wanted to be thorough.

#define Math_LN2 0.6931471805599453094172321215
#define Math_TAU 6.2831853071795864769252867666
#define Math_PI 3.1415926535897932384626433833
Expand Down
33 changes: 33 additions & 0 deletions modules/gridmap/doc_classes/GridMap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
The orientation of the cell at the given grid coordinates. [code]-1[/code] is returned if the cell is empty.
</description>
</method>
<method name="get_cell_neighbors" qualifiers="const">
<return type="Vector3i[]" />
<param index="0" name="cell" type="Vector3i" />
<description>
Returns an array of [Vector3i] map coordinates that neighbor the cell at coordinates [param cell], including unused cells. Use [method get_cell_item] to check if the cell is used.
</description>
</method>
<method name="get_collision_layer_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
Expand Down Expand Up @@ -116,6 +123,14 @@
Returns an array of all cells with the given item index specified in [param item].
</description>
</method>
<method name="local_region_to_map" qualifiers="const">
<return type="Vector3i[]" />
<param index="0" name="local_position_a" type="Vector3" />
<param index="1" name="local_position_b" type="Vector3" />
<description>
Returns an array containing map coordinates for all cells within the GridMap's local coordinate space that fall within the axis-aligned bounding box defined by points [param local_position_a] and [param local_position_b]. See also [method local_to_map].
</description>
</method>
<method name="local_to_map" qualifiers="const">
<return type="Vector3i" />
<param index="0" name="local_position" type="Vector3" />
Expand Down Expand Up @@ -200,8 +215,12 @@
The scale of the cell items.
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
</member>
<member name="cell_shape" type="int" setter="set_cell_shape" getter="get_cell_shape" enum="GridMap.CellShape" default="0">
The shape of the grid's cells.
</member>
<member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3(2, 2, 2)">
The dimensions of the grid's cells.
When [member cell_shape] is set to Hexagon, the [code]cell_size.x[/code] value represents the radius of the cell (from center to vertex), and the [code]cell_size.y[/code] value represents the height of the cell. The [code]cell_size.z[/code] value is ignored for hexagonal cells.
This does not affect the size of the meshes. See [member cell_scale].
</member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
Expand All @@ -222,6 +241,11 @@
</member>
</members>
<signals>
<signal name="cell_shape_changed">
<param index="0" name="cell_shape" type="int" />
<description>
</description>
</signal>
<signal name="cell_size_changed">
<param index="0" name="cell_size" type="Vector3" />
<description>
Expand All @@ -235,6 +259,15 @@
</signal>
</signals>
<constants>
<constant name="CELL_SHAPE_SQUARE" value="0" enum="CellShape">
Rectangular cell shape.
</constant>
<constant name="CELL_SHAPE_HEXAGON" value="1" enum="CellShape">
Hexagonal cell shape.
</constant>
<constant name="CELL_SHAPE_MAX" value="2" enum="CellShape">
Count of all cell shapes. Not a valid selection.
</constant>
<constant name="INVALID_CELL_ITEM" value="-1">
Invalid cell item that can be used in [method set_cell_item] to clear cells (or represent an empty cell in [method get_cell_item]).
</constant>
Expand Down
Loading