Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions code/jumpnode/jumpnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,40 @@ SCP_list<CJumpNode> Jump_nodes;
* Constructor for CJumpNode class, default
*/
CJumpNode::CJumpNode()
{
{
gr_init_alphacolor(&m_display_color, 0, 255, 0, 255);

m_name[0] = '\0';
m_display[0] = '\0';

m_pos.xyz.x = 0.0f;
m_pos.xyz.y = 0.0f;
m_pos.xyz.z = 0.0f;
}

/**
* Constructor for CJumpNode class, with world position argument
*/
CJumpNode::CJumpNode(const vec3d* position)
{
Assert(position != NULL);

{
Assertion(position != nullptr, "Position should not be null!");
if (position == nullptr)
position = &vmd_zero_vector;

gr_init_alphacolor(&m_display_color, 0, 255, 0, 255);

// Set m_name and m_display
sprintf(m_name, XSTR( "Jump Node %d", 632), Jump_nodes.size());
m_display[0] = '\0';

// Set m_modelnum and m_radius
m_modelnum = model_load(NOX(JN_DEFAULT_MODEL), nullptr, ErrorType::WARNING);
if (m_modelnum == -1) {
Warning(LOCATION, "Could not load default model for %s", m_name);
} else {
m_radius = model_get_radius(m_modelnum);
}

m_pos.xyz.x = position->xyz.x;
m_pos.xyz.y = position->xyz.y;
m_pos.xyz.z = position->xyz.z;


// Create the object
flagset<Object::Object_Flags> default_flags;
default_flags.set(Object::Object_Flags::Renders);
m_objnum = obj_create(OBJ_JUMP_NODE, -1, -1, NULL, &m_pos, m_radius, default_flags);
flagset<Object::Object_Flags> default_flags;
default_flags.set(Object::Object_Flags::Renders);
m_objnum = obj_create(OBJ_JUMP_NODE, -1, -1, nullptr, position, m_radius, default_flags);

if (m_modelnum >= 0) {
// set up animation in case of instrinsic_rotate
Expand All @@ -81,7 +75,6 @@ CJumpNode::CJumpNode(CJumpNode&& other) noexcept
other.m_fred_layer = "Default";

m_display_color = other.m_display_color;
m_pos = other.m_pos;

strcpy_s(m_name, other.m_name);
strcpy_s(m_display, other.m_display);
Expand All @@ -106,7 +99,6 @@ CJumpNode& CJumpNode::operator=(CJumpNode&& other) noexcept
other.m_fred_layer = "Default";

m_display_color = other.m_display_color;
m_pos = other.m_pos;

strcpy_s(m_name, other.m_name);
strcpy_s(m_display, other.m_display);
Expand Down Expand Up @@ -160,6 +152,14 @@ int CJumpNode::GetModelNumber() const
return m_modelnum;
}

/**
* @return Radius of jump node model
*/
float CJumpNode::GetRadius() const
{
return m_radius;
}

/**
* @return Index into Objects[]
*/
Expand Down Expand Up @@ -190,7 +190,8 @@ const color &CJumpNode::GetColor() const
*/
const vec3d *CJumpNode::GetPosition() const
{
return &m_pos;
Assert(m_objnum != -1);
return &Objects[m_objnum].pos;
}

/*
Expand Down Expand Up @@ -536,7 +537,7 @@ CJumpNode *jumpnode_get_which_in(const object *objp)
if(jnp->GetModelNumber() < 0)
continue;

radius = model_get_radius( jnp->GetModelNumber() );
radius = jnp->GetRadius();
dist = vm_vec_dist( &objp->pos, &jnp->GetSCPObject()->pos );
if ( dist <= radius ) {
return &(*jnp);
Expand Down
2 changes: 1 addition & 1 deletion code/jumpnode/jumpnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class CJumpNode

int m_flags {0};
color m_display_color; // Color node will be shown in (Default:0/255/0/255)
vec3d m_pos;
SCP_string m_fred_layer = "Default"; // FRED view layer assignment

CJumpNode(const CJumpNode&);
Expand All @@ -65,6 +64,7 @@ class CJumpNode
const char *GetName() const;
const char *GetDisplayName() const;
int GetModelNumber() const;
float GetRadius() const;
int GetSCPObjectNumber() const;
int GetPolymodelInstanceNum() const;
const object *GetSCPObject() const;
Expand Down
Loading