my broken version of vehicle mouse steer on ubOde (no bank,needs better damp)

LSLKeyTest
UbitUmarov 2016-08-28 03:51:20 +01:00
parent e7b0963db8
commit 804d4971e2
5 changed files with 146 additions and 48 deletions

View File

@ -406,6 +406,16 @@ namespace OpenSim.Region.Framework.Scenes
ph.SetVehicle(vd); ph.SetVehicle(vd);
} }
public bool CameraDecoupled
{
get
{
if((vd.m_flags & VehicleFlag.CAMERA_DECOUPLED) != 0)
return true;
return false;
}
}
private XmlTextWriter writer; private XmlTextWriter writer;
private void XWint(string name, int i) private void XWint(string name, int i)

View File

@ -5431,7 +5431,6 @@ Label_GroupsDone:
} }
} }
} }
} }
public void DeleteFromStorage(UUID uuid) public void DeleteFromStorage(UUID uuid)

View File

@ -2162,9 +2162,19 @@ namespace OpenSim.Region.Framework.Scenes
{ {
AddToPhysics(isPhysical, isPhantom, building, isPhysical); AddToPhysics(isPhysical, isPhantom, building, isPhysical);
UpdatePhysicsSubscribedEvents(); // not sure if appliable here UpdatePhysicsSubscribedEvents(); // not sure if appliable here
if(!_VolumeDetectActive &&
m_vehicleParams != null &&
m_vehicleParams.CameraDecoupled &&
m_localId == ParentGroup.RootPart.LocalId)
AddFlag(PrimFlags.CameraDecoupled);
else
RemFlag(PrimFlags.CameraDecoupled);
} }
else else
{
PhysActor = null; // just to be sure PhysActor = null; // just to be sure
RemFlag(PrimFlags.CameraDecoupled);
}
} }
} }
@ -3539,6 +3549,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
set set
{ {
m_vehicleParams = value; m_vehicleParams = value;
} }
} }
@ -4662,6 +4673,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
if (ParentGroup != null) if (ParentGroup != null)
{ {
if(UsePhysics && !SetPhantom && m_localId == ParentGroup.RootPart.LocalId &&
m_vehicleParams != null && m_vehicleParams.CameraDecoupled)
AddFlag(PrimFlags.CameraDecoupled);
else
RemFlag(PrimFlags.CameraDecoupled);
ParentGroup.HasGroupChanged = true; ParentGroup.HasGroupChanged = true;
ScheduleFullUpdate(); ScheduleFullUpdate();
} }
@ -4722,9 +4738,16 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
if (VolumeDetectActive) // change if not the default only if (VolumeDetectActive) // change if not the default only
pa.SetVolumeDetect(1); pa.SetVolumeDetect(1);
if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) if (m_vehicleParams != null && m_localId == ParentGroup.RootPart.LocalId)
{
m_vehicleParams.SetVehicle(pa); m_vehicleParams.SetVehicle(pa);
if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled)
AddFlag(PrimFlags.CameraDecoupled);
else
RemFlag(PrimFlags.CameraDecoupled);
}
else
RemFlag(PrimFlags.CameraDecoupled);
// we are going to tell rest of code about physics so better have this here // we are going to tell rest of code about physics so better have this here
PhysActor = pa; PhysActor = pa;
@ -4800,6 +4823,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this);
} }
RemFlag(PrimFlags.CameraDecoupled);
PhysActor = null; PhysActor = null;
} }

View File

@ -5442,6 +5442,7 @@ namespace OpenSim.Region.Framework.Scenes
Valid = true, Valid = true,
MouseLook = this.m_mouseLook, MouseLook = this.m_mouseLook,
CameraRotation = this.CameraRotation, CameraRotation = this.CameraRotation,
CameraAtAxis = this.CameraAtAxis
}; };
} }

View File

@ -648,6 +648,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
break; break;
} }
// disable mouse steering
m_flags &= ~(VehicleFlag.MOUSELOOK_STEER |
VehicleFlag.MOUSELOOK_BANK |
VehicleFlag.CAMERA_DECOUPLED);
m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale); m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale);
m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
@ -794,6 +798,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
float ldampZ = 0; float ldampZ = 0;
bool mousemode = false;
if((m_flags & (VehicleFlag.MOUSELOOK_STEER |VehicleFlag.MOUSELOOK_BANK)) != 0 )
mousemode = true;
float bankingEfficiency;
if(mousemode)
bankingEfficiency = 0;
else
bankingEfficiency = m_bankingEfficiency;
// linear motor // linear motor
if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000) if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000)
{ {
@ -967,7 +981,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
torque.Y += effpitch * ftmp; torque.Y += effpitch * ftmp;
} }
if (m_bankingEfficiency != 0 && Math.Abs(effroll) > 0.01) if (bankingEfficiency != 0 && Math.Abs(effroll) > 0.01)
{ {
float broll = effroll; float broll = effroll;
@ -1018,6 +1032,56 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_amdampZ = 1 / m_angularFrictionTimescale.Z; m_amdampZ = 1 / m_angularFrictionTimescale.Z;
} }
if(mousemode)
{
CameraData cam = rootPrim.TryGetCameraData();
if(cam.Valid && cam.MouseLook)
{
Vector3 dirv = cam.CameraAtAxis * irotq;
float tmp;
if(Math.Abs(dirv.X) > 0.01f)
{
if (Math.Abs(dirv.Z) > 0.01)
{
tmp = -(float)Math.Atan2(dirv.Z, dirv.X) * m_angularMotorDirection.Y;
if(tmp < -4f)
tmp = -4f;
else if(tmp > 4f)
tmp = 4f;
torque.Y += (tmp - curLocalAngVel.Y) / m_angularMotorTimescale;
}
if (Math.Abs(dirv.Y) > 0.01)
{
tmp = (float)Math.Atan2(dirv.Y, dirv.X) * m_angularMotorDirection.Z;
if(tmp < -4f)
tmp = -4f;
else if(tmp > 4f)
tmp = 4f;
torque.Z += (tmp - curLocalAngVel.Z) / m_angularMotorTimescale;
}
}
// angular friction
if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
{
torque.X -= curLocalAngVel.X * m_amdampX;
torque.Y -= curLocalAngVel.Y * m_amdampY;
torque.Z -= curLocalAngVel.Z * m_amdampZ;
}
}
else
{
if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
{
torque.X -= curLocalAngVel.X * 10f;
torque.Y -= curLocalAngVel.Y * 10f;
torque.Z -= curLocalAngVel.Z * 10f;
}
}
}
else
{
// angular motor // angular motor
if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000) if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000)
{ {
@ -1063,13 +1127,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
} }
// angular friction
if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0) if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
{ {
torque.X -= curLocalAngVel.X * m_amdampX; torque.X -= curLocalAngVel.X * m_amdampX;
torque.Y -= curLocalAngVel.Y * m_amdampY; torque.Y -= curLocalAngVel.Y * m_amdampY;
torque.Z -= curLocalAngVel.Z * m_amdampZ; torque.Z -= curLocalAngVel.Z * m_amdampZ;
} }
}
force *= dmass.mass; force *= dmass.mass;