MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / UpdateFlashlight

Method UpdateFlashlight

ogsr_engine/xrGame/Weapon.cpp:1048–1114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1046}
1047
1048void CWeapon::UpdateFlashlight()
1049{
1050 if (flashlight_render)
1051 {
1052 auto io = smart_cast<CInventoryOwner*>(H_Parent());
1053 if (!flashlight_render->get_active() && IsFlashlightOn() && (!H_Parent() || (io && this == io->inventory().ActiveItem())))
1054 {
1055 flashlight_render->set_active(true);
1056 flashlight_omni->set_active(true);
1057 UpdateAddonsVisibility();
1058 }
1059 else if (flashlight_render->get_active() && (!IsFlashlightOn() || !(!H_Parent() || (io && this == io->inventory().ActiveItem()))))
1060 {
1061 flashlight_render->set_active(false);
1062 flashlight_omni->set_active(false);
1063 UpdateAddonsVisibility();
1064 }
1065
1066 if (flashlight_render->get_active())
1067 {
1068 Fvector flashlight_pos_omni, flashlight_dir, flashlight_dir_omni;
1069
1070 if (GetHUDmode())
1071 {
1072 GetBoneOffsetPosDir(flashlight_attach_bone, flashlight_pos, flashlight_dir, flashlight_attach_offset);
1073 CorrectDirFromWorldToHud(flashlight_dir);
1074
1075 GetBoneOffsetPosDir(flashlight_attach_bone, flashlight_pos_omni, flashlight_dir_omni, flashlight_omni_attach_offset);
1076 CorrectDirFromWorldToHud(flashlight_dir_omni);
1077 }
1078 else
1079 {
1080 flashlight_dir = get_LastFD();
1081 XFORM().transform_tiny(flashlight_pos, flashlight_world_attach_offset);
1082
1083 flashlight_dir_omni = get_LastFD();
1084 XFORM().transform_tiny(flashlight_pos_omni, flashlight_omni_world_attach_offset);
1085 }
1086
1087 Fmatrix flashlightXForm;
1088 flashlightXForm.identity();
1089 flashlightXForm.k.set(flashlight_dir);
1090 Fvector::generate_orthonormal_basis_normalized(flashlightXForm.k, flashlightXForm.j, flashlightXForm.i);
1091 flashlight_render->set_position(flashlight_pos);
1092 flashlight_render->set_rotation(flashlightXForm.k, flashlightXForm.i);
1093
1094 Fmatrix flashlightomniXForm;
1095 flashlightomniXForm.identity();
1096 flashlightomniXForm.k.set(flashlight_dir_omni);
1097 Fvector::generate_orthonormal_basis_normalized(flashlightomniXForm.k, flashlightomniXForm.j, flashlightomniXForm.i);
1098 flashlight_omni->set_position(flashlight_pos_omni);
1099 flashlight_omni->set_rotation(flashlightomniXForm.k, flashlightomniXForm.i);
1100
1101 // calc color animator
1102 if (flashlight_lanim)
1103 {
1104 int frame;
1105 const u32 clr = flashlight_lanim->CalculateBGR(Device.fTimeGlobal, frame);

Callers

nothing calls this directly

Calls 15

H_ParentFunction · 0.85
XFORMFunction · 0.85
color_get_BFunction · 0.85
color_get_GFunction · 0.85
color_get_RFunction · 0.85
get_activeMethod · 0.80
ActiveItemMethod · 0.80
transform_tinyMethod · 0.80
CalculateBGRMethod · 0.80
set_colorMethod · 0.80
set_activeMethod · 0.45
identityMethod · 0.45

Tested by

no test coverage detected