mirror of
https://github.com/DrBeef/Doom3Quest.git
synced 2025-04-24 16:18:51 +00:00
Various haptic improvements
This commit is contained in:
parent
b3ee1869fc
commit
5a3ac980ef
3 changed files with 56 additions and 45 deletions
|
@ -12612,8 +12612,9 @@ void idPlayer::Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &di
|
|||
}
|
||||
}
|
||||
|
||||
if ( IsType( idPlayer::Type ) ) {
|
||||
|
||||
if ( IsType( idPlayer::Type ) &&
|
||||
//Save the effort of going through this code if bhaptics isn't enabled
|
||||
vr_bhaptics.GetBool()) {
|
||||
idVec3 bodyOrigin = vec3_zero;
|
||||
idMat3 bodyAxis;
|
||||
GetViewPos( bodyOrigin, bodyAxis );
|
||||
|
@ -12626,17 +12627,16 @@ void idPlayer::Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &di
|
|||
if (damageYaw >= 360.0f)
|
||||
damageYaw -= 360.0f;
|
||||
|
||||
//Use a min value of 40, otherwise things like SMG bullets barely make a blip
|
||||
float hapticDamage = damage * 5;
|
||||
hapticDamage = Max(40.0F, hapticDamage);
|
||||
//Ensure a decent level of haptic feedback for any damage
|
||||
float hapticLevel = 80 + Min<float>(damage * 4, 120.0);
|
||||
|
||||
//Indicate head damage if appropriate
|
||||
if ( location >= 0 && location < damageGroups.Size() &&
|
||||
strstr( damageGroups[location].c_str(), "head" ) ) {
|
||||
common->HapticEvent(damageDefName, 3, 0, damage * 4, 0, 0);
|
||||
}
|
||||
|
||||
common->HapticEvent(damageDefName, 0, 0, damage * 4, damageYaw, yHeight);
|
||||
common->HapticEvent(damageDefName, 4, 0, hapticLevel, damageYaw, yHeight);
|
||||
} else {
|
||||
common->HapticEvent(damageDefName, 0, 0, hapticLevel, damageYaw, yHeight);
|
||||
}
|
||||
}
|
||||
|
||||
lastDamageDef = damageDef->Index();
|
||||
|
|
Binary file not shown.
|
@ -132,6 +132,7 @@ public class bHaptics {
|
|||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Door_Open.tact", "dooropen", "door");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Door_Close.tact", "doorclose", "door");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Scan.tact", PositionType.Vest, "scan", "environment", 1.0f, 1.15f);
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Scan.tact", PositionType.Vest, "decontaminate", "environment", 0.5f, 0.65f);
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Chamber_Up.tact", "liftup", "environment");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Chamber_Down.tact", "liftdown", "environment");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Machine.tact", "machine", "environment");
|
||||
|
@ -308,10 +309,11 @@ public class bHaptics {
|
|||
|
||||
/*
|
||||
position values:
|
||||
0 - Will play on both arms if tactosy tact files present for both
|
||||
1 - Will play on left arm only if tactosy tact files present for left
|
||||
2 - Will play on right arm only if tactosy tact files present for right
|
||||
0 - Will play on vest and both arms if tactosy tact files present for both
|
||||
1 - Will play on vest and on left arm only if tactosy tact files present for left
|
||||
2 - Will play on vest and on right arm only if tactosy tact files present for right
|
||||
3 - Will play on head only (if present)
|
||||
4 - Will play on all devices (that have a pattern defined for them)
|
||||
|
||||
flag values:
|
||||
0 - No flags set
|
||||
|
@ -366,46 +368,52 @@ public class bHaptics {
|
|||
intensity = 100;
|
||||
}
|
||||
|
||||
if (position > 0)
|
||||
{
|
||||
BhapticsManager manager = BhapticsModule.getBhapticsManager();
|
||||
|
||||
//If playing left position and haptic type is right, don;t play that one
|
||||
if (position == 1 && haptic.type == PositionType.ForearmR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//If playing right position and haptic type is left, don;t play that one
|
||||
if (position == 2 && haptic.type == PositionType.ForearmL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (position == 3 &&
|
||||
(haptic.type != PositionType.Head || !manager.isDeviceConnected(BhapticsManager.DeviceType.Head)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (position != 3 && haptic.type == PositionType.Head)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (haptic != null) {
|
||||
float flIntensity = ((intensity / 100.0F) * haptic.intensity);
|
||||
float duration = haptic.duration;
|
||||
float flAngle = angle;
|
||||
float flDuration = haptic.duration;
|
||||
|
||||
//Special hack for heartbeat
|
||||
if (position > 0)
|
||||
{
|
||||
BhapticsManager manager = BhapticsModule.getBhapticsManager();
|
||||
|
||||
//If playing left position and haptic type is right, don;t play that one
|
||||
if (position == 1 && haptic.type == PositionType.ForearmR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//If playing right position and haptic type is left, don;t play that one
|
||||
if (position == 2 && haptic.type == PositionType.ForearmL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (position == 3 &&
|
||||
(haptic.type != PositionType.Head || !manager.isDeviceConnected(BhapticsManager.DeviceType.Head)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (haptic.type == PositionType.Head) {
|
||||
if (position < 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Zero angle for head
|
||||
flAngle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Special values for heartbeat
|
||||
if (haptic.group.compareTo("health") == 0)
|
||||
{
|
||||
//The worse condition we are in, the faster the heart beats!
|
||||
float health = intensity;
|
||||
duration = 1.0f - (0.4f * ((40 - health) / 40));
|
||||
flDuration = 1.0f - (0.4f * ((40 - health) / 40));
|
||||
flIntensity = 1.0f;
|
||||
flAngle = 0;
|
||||
}
|
||||
|
||||
//If this is a repeating event, then add to the set to play in begin frame
|
||||
|
@ -414,7 +422,7 @@ public class bHaptics {
|
|||
repeatingHaptics.put(key, haptic);
|
||||
}
|
||||
else {
|
||||
player.submitRegistered(haptic.key, haptic.altKey, flIntensity, duration, angle, yHeight);
|
||||
player.submitRegistered(haptic.key, haptic.altKey, flIntensity, flDuration, flAngle, yHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,6 +487,9 @@ public class bHaptics {
|
|||
} else if (key.contains("entrance_scanner") || key.contains("scanner_rot1s"))
|
||||
{
|
||||
key = "scan";
|
||||
} else if (key.contains("decon_started"))
|
||||
{
|
||||
key = "decontaminate";
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue