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

Function DrawWeaponObject

Descent3/WeaponFire.cpp:2589–2653  ·  view source on GitHub ↗

Draws a weapon

Source from the content-addressed store, hash-verified

2587
2588// Draws a weapon
2589void DrawWeaponObject(object *obj) {
2590 ASSERT(obj->type == OBJ_WEAPON || obj->type == OBJ_POWERUP);
2591 ASSERT(Weapons[obj->id].used > 0);
2592
2593 // Don't draw if spray
2594 if (!(Weapons[obj->id].flags & WF_INVISIBLE)) {
2595 if (Weapons[obj->id].flags & WF_ELECTRICAL) {
2596 DrawElectricalWeapon(obj);
2597 } else if ((Weapons[obj->id].flags & WF_IMAGE_BITMAP) || (Weapons[obj->id].flags & WF_IMAGE_VCLIP)) {
2598 int bm_handle;
2599 int objnum = obj - Objects;
2600 float rot_temp = Weapons[obj->id].phys_info.rotvel.z / 65536.0;
2601 int int_game = Gametime / rot_temp;
2602 float diff = Gametime - (int_game * rot_temp);
2603 int rot_angle = diff * 65536;
2604
2605 if (Weapons[obj->id].flags & WF_NO_ROTATE)
2606 rot_angle = (objnum * 1000) % 65536;
2607
2608 bm_handle = GetWeaponFireImage(obj->id, 0);
2609 ASSERT(bm_handle >= 0);
2610
2611 if (Weapons[obj->id].flags & WF_SATURATE)
2612 rend_SetAlphaType(AT_SATURATE_TEXTURE);
2613 else
2614 rend_SetAlphaType(AT_CONSTANT + AT_TEXTURE);
2615
2616 rend_SetAlphaValue(Weapons[obj->id].alpha * 255);
2617 rend_SetOverlayType(OT_NONE);
2618 rend_SetLighting(LS_NONE);
2619
2620 if (Weapons[obj->id].flags & WF_PLANAR) {
2621 vector norm = obj->mtype.phys_info.velocity;
2622 vm_NormalizeVectorFast(&norm);
2623 g3_DrawPlanarRotatedBitmap(&obj->pos, &norm, rot_angle, obj->size,
2624 (obj->size * bm_h(bm_handle, 0)) / bm_w(bm_handle, 0), bm_handle);
2625 } else
2626 g3_DrawRotatedBitmap(&obj->pos, rot_angle, obj->size, (obj->size * bm_h(bm_handle, 0)) / bm_w(bm_handle, 0),
2627 bm_handle);
2628 } else {
2629
2630 polymodel_effect pe = {0};
2631 int use_effect = 0;
2632
2633 if (obj->type == OBJ_WEAPON && !Detail_settings.Weapon_coronas_enabled) {
2634 pe.type |= PEF_NO_GLOWS;
2635 use_effect = 1;
2636 }
2637
2638 if (use_effect)
2639 SetPolymodelEffect(&pe);
2640
2641 DrawPolygonModel(&obj->pos, &obj->orient, obj->rtype.pobj_info.model_num, NULL, 0, 1.0, 1.0, 1.0, 0xFFFFFFFF,
2642 use_effect);
2643 }
2644 }
2645
2646 if (Weapons[obj->id].flags & WF_STREAMER) {

Callers 1

RenderObjectFunction · 0.85

Calls 15

DrawElectricalWeaponFunction · 0.85
GetWeaponFireImageFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85
bm_hFunction · 0.85
bm_wFunction · 0.85
g3_DrawRotatedBitmapFunction · 0.85
SetPolymodelEffectFunction · 0.85
DrawPolygonModelFunction · 0.85
DrawWeaponStreamerFunction · 0.85
DrawWeaponRingFunction · 0.85
rend_SetAlphaTypeFunction · 0.50

Tested by

no test coverage detected