[Simian]
* Completed a partial port of OpenSim's LSL API. Thank you to everyone on the OpenSim team for their hard work on this incredibly large feature * Added Agent.GetSimulatorPosition() * Corrected default PrimFlags for agents and prims * Stubs for encoding/decoding prim linkset assets * Route chat through the scene * Stub for grid messaging (IM and email) * Add GetTerrainHeightAt(), removed duplicate heightmap storage in Movement.cs * Added a permissions manager stub * Store wind speeds, added functions to get wind speed * Make sure all of the important prim properties are set before creating an object * Lots of new object manipulation functions in scene * Properly clean up event queues on agent exit * Stubbed out a space for a scripting engine * Stubbed out task inventory * Added ScriptingConsole, which allows you to run LSL functions from the chat console * Added new PacketCategory, Messaging, for chat-related packets * Fixed InventoryObject overrides * Added a NotecardCache, useful for the scripting engine and may become generally useful later * Added several helper functions and new members to SimulationObject git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2462 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -30,7 +30,6 @@ namespace Simian.Extensions
|
||||
Simian server;
|
||||
Timer updateTimer;
|
||||
long lastTick;
|
||||
TerrainPatch[,] heightmap = new TerrainPatch[16, 16];
|
||||
|
||||
public int LastTick
|
||||
{
|
||||
@@ -46,8 +45,6 @@ namespace Simian.Extensions
|
||||
{
|
||||
this.server = server;
|
||||
|
||||
server.Scene.OnTerrainUpdate += Scene_OnTerrainUpdate;
|
||||
|
||||
server.UDP.RegisterPacketCallback(PacketType.AgentUpdate, AgentUpdateHandler);
|
||||
server.UDP.RegisterPacketCallback(PacketType.SetAlwaysRun, SetAlwaysRunHandler);
|
||||
|
||||
@@ -65,13 +62,6 @@ namespace Simian.Extensions
|
||||
}
|
||||
}
|
||||
|
||||
void Scene_OnTerrainUpdate(object sender, uint x, uint y, float[,] patchData)
|
||||
{
|
||||
TerrainPatch patch = new TerrainPatch(16, 16);
|
||||
patch.Height = patchData;
|
||||
heightmap[y, x] = patch;
|
||||
}
|
||||
|
||||
void UpdateTimer_Elapsed(object sender)
|
||||
{
|
||||
int tick = Environment.TickCount;
|
||||
@@ -118,9 +108,12 @@ namespace Simian.Extensions
|
||||
if ((heldForward || heldBack) && (heldLeft || heldRight))
|
||||
speed /= SQRT_TWO;
|
||||
|
||||
// adjust multiplier for Z dimension
|
||||
float oldFloor = GetLandHeightAt(agent.Avatar.Position);
|
||||
float newFloor = GetLandHeightAt(agent.Avatar.Position + (move * speed));
|
||||
Vector3 agentPosition = agent.GetSimulatorPosition(server.Scene);
|
||||
float oldFloor = server.Scene.GetTerrainHeightAt(agentPosition.X, agentPosition.Y);
|
||||
|
||||
agentPosition += (move * speed);
|
||||
float newFloor = server.Scene.GetTerrainHeightAt(agentPosition.X, agentPosition.Y);
|
||||
|
||||
if (!flying && newFloor != oldFloor)
|
||||
speed /= (1 + (SQRT_TWO * Math.Abs(newFloor - oldFloor)));
|
||||
|
||||
@@ -131,8 +124,6 @@ namespace Simian.Extensions
|
||||
// TODO: check our Z (minus height/2) compared to all the prim
|
||||
// bounding boxes, and define a new lowerLimit as a hack for platforms
|
||||
|
||||
|
||||
|
||||
// Z acceleration resulting from gravity
|
||||
float gravity = 0f;
|
||||
|
||||
@@ -376,65 +367,5 @@ namespace Simian.Extensions
|
||||
|
||||
agent.Running = run.AgentData.AlwaysRun;
|
||||
}
|
||||
|
||||
float GetLandHeightAt(Vector3 position)
|
||||
{
|
||||
int x = (int)position.X;
|
||||
int y = (int)position.Y;
|
||||
|
||||
if (x > 255) x = 255;
|
||||
else if (x < 0) x = 0;
|
||||
if (y > 255) y = 255;
|
||||
else if (y < 0) y = 0;
|
||||
|
||||
int patchX = x / 16;
|
||||
int patchY = y / 16;
|
||||
|
||||
if (heightmap[patchY, patchX] != null)
|
||||
{
|
||||
float center = heightmap[patchY, patchX].Height[y - (patchY * 16), x - (patchX * 16)];
|
||||
|
||||
float distX = position.X - (int)position.X;
|
||||
float distY = position.Y - (int)position.Y;
|
||||
|
||||
float nearestX;
|
||||
float nearestY;
|
||||
|
||||
if (distX > 0f)
|
||||
{
|
||||
int i = x < 255 ? 1 : 0;
|
||||
int newPatchX = (x + i) / 16;
|
||||
nearestX = heightmap[patchY, newPatchX].Height[y - (patchY * 16), (x + i) - (newPatchX * 16)];
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = x > 0 ? 1 : 0;
|
||||
int newPatchX = (x - i) / 16;
|
||||
nearestX = heightmap[patchY, newPatchX].Height[y - (patchY * 16), (x - i) - (newPatchX * 16)];
|
||||
}
|
||||
|
||||
if (distY > 0f)
|
||||
{
|
||||
int i = y < 255 ? 1 : 0;
|
||||
int newPatchY = (y + i) / 16;
|
||||
nearestY = heightmap[newPatchY, patchX].Height[(y + i) - (newPatchY * 16), x - (patchX * 16)];
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = y > 0 ? 1 : 0;
|
||||
int newPatchY = (y - i) / 16;
|
||||
nearestY = heightmap[newPatchY, patchX].Height[(y - i) - (newPatchY * 16), x - (patchX * 16)];
|
||||
}
|
||||
|
||||
float lerpX = Utils.Lerp(center, nearestX, Math.Abs(distX));
|
||||
float lerpY = Utils.Lerp(center, nearestY, Math.Abs(distY));
|
||||
|
||||
return ((lerpX + lerpY) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user