MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / RenderObject

Function RenderObject

Descent3/renderobject.cpp:1206–1454  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Render an object. Calls one of several routines based on type

Source from the content-addressed store, hash-verified

1204// -----------------------------------------------------------------------------
1205// Render an object. Calls one of several routines based on type
1206void RenderObject(object *obj) {
1207 float normalized_time[MAX_SUBOBJECTS];
1208 bool render_it = false;
1209 if (obj->type == OBJ_NONE) {
1210 mprintf(1, "ERROR!!!! Bogus obj %d in room %d is rendering!\n", OBJNUM(obj), obj->roomnum);
1211 Int3();
1212 return;
1213 }
1214 if (obj->type == OBJ_DUMMY)
1215 return;
1216 if (obj->flags & OF_ATTACHED) {
1217 // See if we should be rendered, because our attach parent might be invisible
1218 object *parent_obj = ObjGet(obj->attach_ultimate_handle);
1219 if (!parent_obj)
1220 return;
1221 if (parent_obj->render_type == RT_NONE && parent_obj->type != OBJ_POWERUP &&
1222 (parent_obj->type == OBJ_PLAYER || parent_obj->movement_type != MT_NONE))
1223 return;
1224 }
1225 if (OBJECT_OUTSIDE(obj))
1226 render_it = SetupTerrainObject(obj);
1227 else
1228 render_it = SetupMineObject(obj);
1229 if (!render_it)
1230 return;
1231 if (!(obj->flags & OF_SAFE_TO_RENDER))
1232 return;
1233 // Mark this a rendered this frame
1234 obj->flags |= OF_RENDERED;
1235 // If we're not rendering from a mirror, mark this object as rendered
1236 if (Render_mirror_for_room == false)
1237 obj->flags &= ~OF_SAFE_TO_RENDER;
1238 obj->renderframe = FrameCount % 65536;
1239 if (obj->control_type == CT_AI && (GetFunctionMode() == GAME_MODE || GetFunctionMode() == EDITOR_GAME_MODE)) {
1240 AI_RenderedList[AI_NumRendered] = OBJNUM(obj);
1241 AI_NumRendered += 1;
1242 }
1243#ifdef EDITOR
1244 ddgr_color oldcolor;
1245 if (TSearch_on && obj->type != OBJ_ROOM) {
1246 rend_SetPixel(GR_RGB(16, 255, 64), TSearch_x, TSearch_y);
1247 oldcolor = rend_GetPixel(TSearch_x, TSearch_y); // will be different in 15/16-bit color
1248 }
1249#endif
1250 switch (obj->render_type) {
1251 case RT_NONE:
1252 break;
1253 case RT_EDITOR_SPHERE: // to render objects in editor mode
1254#ifdef EDITOR
1255 if ((GetFunctionMode() == EDITOR_MODE)) { // only render if in editor mode
1256 if (!UseHardware) {
1257 g3Point sphere_point;
1258 g3_RotatePoint(&sphere_point, &obj->pos);
1259 g3_DrawSphere(obj->rtype.sphere_color, &sphere_point, obj->size);
1260 } else {
1261 // Let me take this opportunity to say how much it pisses me off that
1262 // the DrawColoredDisk() function takes r,g,b as floats, when the standard
1263 // in our graphics system is to pass color as a ddgr_color

Callers 4

RenderAllTerrainObjectsFunction · 0.85
DisplayTerrainListFunction · 0.85
PostRenderFunction · 0.85
RenderRoomObjectsFunction · 0.85

Calls 15

ObjGetFunction · 0.85
SetupTerrainObjectFunction · 0.85
SetupMineObjectFunction · 0.85
GetFunctionModeFunction · 0.85
g3_RotatePointFunction · 0.85
g3_DrawSphereFunction · 0.85
GR_COLOR_REDFunction · 0.85
GR_COLOR_GREENFunction · 0.85
GR_COLOR_BLUEFunction · 0.85
DrawColoredDiskFunction · 0.85
SetNormalizedTimeObjFunction · 0.85

Tested by

no test coverage detected