Represents an area with collision shapes and nodes. More...
#include <physics.h>
Public Member Functions | |
void | constructor (int signal_id) |
Constructor for the physics area class. | |
void | load (FILE *file, Camera **c, Script *scripts, Node *editor) |
Loads data from a file and initializes the given camera, scripts, and editor node. | |
void | collect_node (Node *node, float distance, vec3 impactPoint) |
Collects a node based on the given distance and calculates the impact point. | |
void | is_area (bool *area) |
Checks if the given area is valid. | |
void | sort_nodes () |
Sorts the nodes in the physics area. | |
void | update (vec3 pos, vec3 rot, vec3 scale) |
Updates the position, rotation, and scale of an object. | |
void | get_collisions_shapes (Node ****shapes, u8 **length) |
Retrieves the collision shapes and their lengths. | |
void | get_node_collection (CollectedNode **nodes, u8 *length) |
Retrieves a collection of nodes. | |
void | save (FILE *file) |
Saves the current state of the physics area to a file. | |
![]() | |
void | free () |
Frees the resources allocated for the PhysicalNode instance. | |
![]() | |
void | constructor () |
Constructor for the Node class. | |
void | initialize_node () |
Initializes a node. | |
void | get_glow_shader (Shader *shader) |
Retrieves the glow shader. | |
void | get_settings_data (void ***ptr, int *length) |
Retrieves settings data. | |
void | load () |
Loads the necessary resources or data for the node. | |
void | save (FILE *file) |
Saves the current state to the specified file. | |
void | prepare_render (mat4 modelMatrix, Shader activeShader) |
Renders a node using the specified model matrix and shader. | |
void | render () |
Renders the node. | |
void | update_global_position (vec3 pos, vec3 rot, vec3 scale) |
Updates the global position of a node. | |
void | update (vec3 pos, vec3 rot, vec3 scale) |
Updates the position, rotation, and scale of a node. | |
void | on_resize () |
Handles the resize event for the node. | |
void | free () |
Frees the resources allocated by the object. | |
void | is_cshape (bool *cshape) |
Checks if the current shape is a custom shape. | |
void | is_body (bool *body) |
Sets the body status of the node. | |
void | is_area (bool *area) |
Checks if the current node is within a specified area. | |
void | is_render_target (bool *render_target) |
Sets the render target status. | |
void | is_gui_element (bool *result) |
Determines if the current node is a GUI element. | |
void | add_child (Node *child) |
Adds a child node to a parent node. | |
void | add_child_and_realloc (Node *child) |
Adds a child node to a parent node and reallocates memory if necessary. | |
void | remove_child (Node *child) |
Removes a child node from a parent node. | |
void | remove_child_and_realloc (Node *child) |
Removes a child node from a parent node and reallocates memory if necessary. | |
void | remove_child_and_free (Node *child) |
Removes a child node from a parent node and frees the memory of the child node. | |
void | remove_child_and_free_and_realloc (Node *child) |
Removes a child node from a parent node, frees the memory of the child node, and reallocates memory if necessary. | |
int | index_of_child (Node *child) |
Retrieves the index of a child node in a parent node's children array. | |
void | print (int level) |
Prints the details of a node at a specified level of indentation. | |
void | emit_ready (...) |
Emits the 'ready' signal for the node. | |
void | emit_update (...) |
Emits an update event for the node. | |
void | emit_signal (...) |
Emits a signal if the node has a script and the script has a signal handler. | |
Static Public Member Functions | |
static int | compare_distance_nodes (const void *a, const void *b) |
Compares the distances of two nodes. | |
Public Attributes | |
struct Node ** | collisionsShapes |
u8 | length |
struct CollectedNode * | collectedNodes |
u32 | collectedLength |
u16 | signal_id |
![]() | |
void * | object |
struct Node ** | children |
struct Node * | parent |
u16 | length |
u8 | type |
u8 | flags |
vec3 | pos |
vec3 | rot |
vec3 | scale |
vec3 | globalPos |
vec3 | globalRot |
vec3 | globalScale |
Behavior * | behavior |
BehaviorAttribute * | attribute |
u8 | attributes_count |
Shader | shader |
Additional Inherited Members | |
![]() | |
static Shader | glowShader = 0 |
A static Shader variable used for glow effect. | |
Represents an area with collision shapes and nodes.
This structure holds information about an area, including its collision shapes, collected nodes, and sorted nodes.
|
inline |
Constructor for the physics area class.
This function initializes a new instance of the physics area class with the given signal ID.
signal_id | The signal ID to initialize the physics area instance with. |
Loads data from a file and initializes the given camera, scripts, and editor node.
This function reads data from the specified file and uses it to initialize the provided camera, scripts, and editor node. The exact format and content of the file are assumed to be known by the caller.
file | A pointer to the FILE object from which data will be read. |
c | A double pointer to a Camera object that will be initialized with data from the file. |
scripts | A pointer to a Script object that will be initialized with data from the file. |
editor | A pointer to a Node object representing the editor that will be initialized with data from the file. |
|
inline |
Collects a node based on the given distance and calculates the impact point.
This function processes a given node and calculates the impact point based on the specified distance.
node | A pointer to the Node structure that needs to be processed. |
distance | A double value representing the distance used in the calculation. |
impactPoint | Vec3 where the calculated impact point will be stored. |
|
inline |
Checks if the given area is valid.
This function takes a pointer to a boolean variable and checks if the area is valid.
area | A pointer to a boolean variable that indicates the validity of the area. |
|
inlinestatic |
Compares the distances of two nodes.
This function is used to compare the distances of two nodes. It is typically used in sorting algorithms where nodes need to be ordered based on their distances.
a | Pointer to the first node to compare. |
b | Pointer to the second node to compare. |
|
inline |
Sorts the nodes in the physics area.
This function sorts the nodes in the physics area based on a specific criterion. The sorting algorithm and criterion are not specified in the provided code snippet.
|
inline |
Updates the position, rotation, and scale of an object.
This function takes pointers to the position, rotation, and scale of an object and updates them accordingly.
pos | Vec3 position of the object. It is expected to be a float array of size 3 representing x, y, and z coordinates. |
rot | Vec3 rotation of the object. It is expected to be a float array of size 3 representing rotation angles around x, y, and z axes. |
scale | Vec3 scale of the object. It is expected to be a float array of size 3 representing scaling factors along x, y, and z axes. |
Retrieves the collision shapes and their lengths.
This function populates the provided pointers with the collision shapes and their corresponding lengths.
shapes | A pointer to a 4-dimensional array of Node pointers. This will be populated with the collision shapes. |
length | A pointer to an array of unsigned 8-bit integers. This will be populated with the lengths of the collision shapes. |
|
inline |
Retrieves a collection of nodes.
This function populates the provided array with a collection of nodes and sets the length of the collection.
[out] | nodes | A pointer to an array of CollectedNode pointers that will be populated with the nodes. |
[out] | length | A pointer to an unsigned 8-bit integer that will be set to the length of the node collection. |
|
inline |
Saves the current state of the physics area to a file.
This function writes the current state of the physics area to the specified file. The file should be opened in a mode that allows writing before calling this function.
file | A pointer to a FILE object that identifies the file to which the state will be saved. |
struct Node** Area::collisionsShapes |
u8 Area::length |
< Array of collected nodes with distances.
struct CollectedNode* Area::collectedNodes |
< Number of collision shapes.
u32 Area::collectedLength |
< Array of collected nodes with distances.
u16 Area::signal_id |
< Number of collected nodes.