mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 22:56:30 -10:00
Jump nodes previously used SCP_list; refactor to use SCP_vector. Also improve resource handling and life cycle management. Follow-up to #7431.
118 lines
3.4 KiB
C++
118 lines
3.4 KiB
C++
/*
|
|
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
|
*
|
|
* All source code herein is the property of Volition, Inc. You may not sell
|
|
* or otherwise commercially exploit the source or things you created based on the
|
|
* source.
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __JUMPNODE_H__
|
|
#define __JUMPNODE_H__
|
|
|
|
#include <cstdlib>
|
|
|
|
#include "globalincs/globals.h"
|
|
#include "globalincs/pstypes.h"
|
|
#include "graphics/2d.h"
|
|
|
|
struct vec3d;
|
|
class object;
|
|
|
|
class model_draw_list;
|
|
|
|
//Jump node flags
|
|
#define JN_USE_DISPLAY_COLOR (1<<0) //Use display_color instead of HUD color
|
|
#define JN_SHOW_POLYS (1<<1) //Display model normally, rather than as wireframe
|
|
#define JN_HIDE (1<<2) //Hides a jump node
|
|
#define JN_SPECIAL_MODEL (1<<3) //If non-default model
|
|
#define JN_HAS_DISPLAY_NAME (1<<4) //If it has a display name
|
|
|
|
#define JN_DEFAULT_MODEL "subspacenode.pof"
|
|
|
|
class CJumpNode
|
|
{
|
|
private:
|
|
char m_name[NAME_LENGTH];
|
|
char m_display[NAME_LENGTH];
|
|
float m_radius {0.0f};
|
|
|
|
int m_modelnum {-1};
|
|
int m_objnum {-1}; // objnum of this jump node
|
|
int m_polymodel_instance_num {-1}; // polymodel instance number, used for rotations
|
|
|
|
int m_flags {0};
|
|
color m_display_color; // Color node will be shown in (Default:0/255/0/255)
|
|
SCP_string m_fred_layer = "Default"; // FRED view layer assignment
|
|
|
|
// jumpnode_delete() detaches the node from its object by resetting m_objnum
|
|
friend void jumpnode_delete(object *objp);
|
|
|
|
public:
|
|
//Constructors
|
|
CJumpNode();
|
|
CJumpNode(const vec3d *position);
|
|
|
|
// Following the pattern of other object types, a CJumpNode does not free its object or model
|
|
// resources on destruction; that is done by jumpnode_delete(), via obj_delete(). So jump nodes
|
|
// can be safely moved around, e.g. by SCP_vector operations.
|
|
CJumpNode(CJumpNode&&) noexcept = default;
|
|
CJumpNode& operator=(CJumpNode&&) noexcept = default;
|
|
|
|
CJumpNode(const CJumpNode&) = delete;
|
|
CJumpNode& operator=(const CJumpNode&) = delete;
|
|
|
|
//Getting
|
|
const char *GetName() const;
|
|
const char *GetDisplayName() const;
|
|
int GetModelNumber() const;
|
|
float GetRadius() const;
|
|
int GetSCPObjectNumber() const;
|
|
int GetPolymodelInstanceNum() const;
|
|
const object *GetSCPObject() const;
|
|
const color &GetColor() const;
|
|
const vec3d *GetPosition() const;
|
|
|
|
//Setting
|
|
void SetAlphaColor(int r, int g, int b, int alpha);
|
|
void SetModel(const char *model_name, bool show_polys = false);
|
|
void SetName(const char *new_name);
|
|
void SetDisplayName(const char* new_name);
|
|
void SetVisibility(bool enabled);
|
|
|
|
//Resource management
|
|
void FreeModelResources();
|
|
|
|
//Getting/Setting FRED layer
|
|
const SCP_string& GetFredLayer() const { return m_fred_layer; }
|
|
void SetFredLayer(const SCP_string& layer) { m_fred_layer = layer; }
|
|
|
|
//Query
|
|
bool IsHidden() const;
|
|
bool IsColored() const;
|
|
bool IsSpecialModel() const;
|
|
bool HasDisplayName() const;
|
|
|
|
//Rendering
|
|
void Render(const vec3d *pos, const vec3d *view_pos = nullptr) const;
|
|
void Render(model_draw_list *scene, const vec3d *pos, const vec3d *view_pos = nullptr) const;
|
|
};
|
|
|
|
//-----Globals------
|
|
extern SCP_vector<CJumpNode> Jump_nodes;
|
|
|
|
//-----Functions-----
|
|
CJumpNode *jumpnode_get_by_name(const char *name);
|
|
int jumpnode_lookup(const char *name);
|
|
CJumpNode *jumpnode_get_by_objnum(int objnum);
|
|
CJumpNode *jumpnode_get_by_objp(const object *objp);
|
|
CJumpNode *jumpnode_get_which_in(const object *objp);
|
|
|
|
void jumpnode_render_all();
|
|
void jumpnode_level_close();
|
|
void jumpnode_delete(object *objp);
|
|
|
|
#endif
|