SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PlanetGravityManager Class Reference

Registers and holds individual PlanetGravity instances. Also provides the main function for calculating the gravity vector at a specified position in a stage's space. More...

#include <PlanetGravityManager.hpp>

Inheritance diagram for PlanetGravityManager:
NameObj

Public Member Functions

 PlanetGravityManager (const char *pName)
 Constructs a new PlanetGravityManager instance.
 
virtual void init (const JMapInfoIter &rIter)
 Effectively does nothing.
 
bool calcTotalGravityVector (TVec3f *pGravity, GravityInfo *pInfo, const TVec3f &rPosition, u32 gravityType, u32 requester) const
 Calculates the total gravity vector at the specified position in space. If the object that requests gravity matches the host of one or more gravity instances, these instances won't be taken into account when calculating the total gravity vector. Furthermore, gravity instances that do not affect the specified gravity contexts will be ignored as well.
 
void registerGravity (PlanetGravity *pGravity)
 Registers a PlanetGravity instance to the array of gravities. The higher the gravity's priority is, the closer it will be placed towards the array's beginning.
 
- Public Member Functions inherited from NameObj
 NameObj (const char *pName)
 Constructs a new NameObj instance.
 
virtual void initAfterPlacement ()
 
virtual void movement ()
 
virtual void draw () const
 Draws the object. Does nothing until overridden.
 
virtual void calcAnim ()
 
virtual void calcViewAndEntry ()
 
void initWithoutIter ()
 Initializes a NameObj without a JMapInfoIter instance.
 
void setName (const char *pName)
 Sets the NameObj's mName.
 
void executeMovement ()
 
void requestSuspend ()
 
void requestResume ()
 
void syncWithFlags ()
 

Private Member Functions

void sortGravities ()
 Sorts all PlanetGravity instances by their priority in reverse order. The higher the priority is, the lower it gets positioned in the array.
 
void bubbleDown (int i)
 Swaps the PlanetGravity instance at the specified index with the one instance right before it.
 

Private Attributes

PlanetGravitymGravities [128]
 
s32 mNumGravities
 

Additional Inherited Members

- Public Attributes inherited from NameObj
const char * mName
 A string to identify the NameObj.
 
volatile u16 mFlags
 Flags in relation to movement.
 
s16 mExecutorIdx
 The index into the NameObjExecuteInfo array.
 

Detailed Description

Registers and holds individual PlanetGravity instances. Also provides the main function for calculating the gravity vector at a specified position in a stage's space.

Definition at line 9 of file PlanetGravityManager.hpp.

Constructor & Destructor Documentation

◆ PlanetGravityManager()

PlanetGravityManager::PlanetGravityManager ( const char * pName)

Constructs a new PlanetGravityManager instance.

Parameters
pNameThe new name assigned to the object.

Definition at line 3 of file PlanetGravityManager.cpp.

◆ ~PlanetGravityManager()

virtual PlanetGravityManager::~PlanetGravityManager ( )
inlinevirtual

Definition at line 15 of file PlanetGravityManager.hpp.

Member Function Documentation

◆ init()

void PlanetGravityManager::init ( const JMapInfoIter & rIter)
virtual

Effectively does nothing.

Parameters
rIterReference to the JMapInfoIter that supplies BCSV information.

Reimplemented from NameObj.

Definition at line 7 of file PlanetGravityManager.cpp.

◆ calcTotalGravityVector()

bool PlanetGravityManager::calcTotalGravityVector ( TVec3f * pGravity,
GravityInfo * pInfo,
const TVec3f & rPosition,
u32 gravityType,
u32 requester ) const

Calculates the total gravity vector at the specified position in space. If the object that requests gravity matches the host of one or more gravity instances, these instances won't be taken into account when calculating the total gravity vector. Furthermore, gravity instances that do not affect the specified gravity contexts will be ignored as well.

Parameters
pGravityThe 3D vector to store the total gravity vector in.
pInfoHolder to be filled with information about highest priority gravity affecting the position.
rPositionThe position in space to calculate the gravity at.
gravityTypeThe affected gravity context (normal, shadow, magnet, etc.)
requesterThe pointer of the object requesting the gravity vector.

Definition at line 11 of file PlanetGravityManager.cpp.

◆ registerGravity()

void PlanetGravityManager::registerGravity ( PlanetGravity * pGravity)

Registers a PlanetGravity instance to the array of gravities. The higher the gravity's priority is, the closer it will be placed towards the array's beginning.

Parameters
pGravityThe PlanetGravity instance to be registered.

Definition at line 90 of file PlanetGravityManager.cpp.

◆ sortGravities()

void PlanetGravityManager::sortGravities ( )
inlineprivate

Sorts all PlanetGravity instances by their priority in reverse order. The higher the priority is, the lower it gets positioned in the array.

Definition at line 98 of file PlanetGravityManager.cpp.

◆ bubbleDown()

void PlanetGravityManager::bubbleDown ( int i)
inlineprivate

Swaps the PlanetGravity instance at the specified index with the one instance right before it.

Parameters
iThe index of the instance to be bubbled down.

Definition at line 109 of file PlanetGravityManager.cpp.

Member Data Documentation

◆ mGravities

PlanetGravity* PlanetGravityManager::mGravities[128]
private

Definition at line 48 of file PlanetGravityManager.hpp.

◆ mNumGravities

s32 PlanetGravityManager::mNumGravities
private

Definition at line 49 of file PlanetGravityManager.hpp.