aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/PrimitiveBaseShape.cs
diff options
context:
space:
mode:
authorUbitUmarov2018-11-17 18:52:16 +0000
committerUbitUmarov2018-11-17 18:52:16 +0000
commit87a723cbc8ea3eca2e70aa5b7d9b851c19d4e6c4 (patch)
treee6c3be5d2ca05175c7ebbbf1376ca21122cb324d /OpenSim/Framework/PrimitiveBaseShape.cs
parentcode aesthetics (diff)
downloadopensim-SC-87a723cbc8ea3eca2e70aa5b7d9b851c19d4e6c4.zip
opensim-SC-87a723cbc8ea3eca2e70aa5b7d9b851c19d4e6c4.tar.gz
opensim-SC-87a723cbc8ea3eca2e70aa5b7d9b851c19d4e6c4.tar.bz2
opensim-SC-87a723cbc8ea3eca2e70aa5b7d9b851c19d4e6c4.tar.xz
code aesthetics and simplification
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs178
1 files changed, 56 insertions, 122 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 5056c04..49745bc 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -1026,117 +1026,109 @@ namespace OpenSim.Framework
1026 { 1026 {
1027// m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); 1027// m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()");
1028 1028
1029 ushort FlexiEP = 0x10; 1029 const byte FlexiEP = 0x10;
1030 ushort LightEP = 0x20; 1030 const byte LightEP = 0x20;
1031 ushort SculptEP = 0x30; 1031 const byte SculptEP = 0x30;
1032 ushort ProjectionEP = 0x40; 1032 const byte ProjectionEP = 0x40;
1033 1033
1034 int i = 0; 1034 int TotalBytesLength = 1; // ExtraParamsNum
1035 uint TotalBytesLength = 1; // ExtraParamsNum
1036 1035
1037 uint ExtraParamsNum = 0; 1036 uint ExtraParamsNum = 0;
1038 if (_flexiEntry) 1037 if (_flexiEntry)
1039 { 1038 {
1040 ExtraParamsNum++; 1039 ExtraParamsNum++;
1041 TotalBytesLength += 16;// data 1040 TotalBytesLength += 16 + 2 + 4;// data
1042 TotalBytesLength += 2 + 4; // type
1043 } 1041 }
1044 1042
1045 if (_lightEntry) 1043 if (_lightEntry)
1046 { 1044 {
1047 ExtraParamsNum++; 1045 ExtraParamsNum++;
1048 TotalBytesLength += 16;// data 1046 TotalBytesLength += 16 + 2 + 4; // data
1049 TotalBytesLength += 2 + 4; // type
1050 } 1047 }
1051 1048
1052 if (_sculptEntry) 1049 if (_sculptEntry)
1053 { 1050 {
1054 ExtraParamsNum++; 1051 ExtraParamsNum++;
1055 TotalBytesLength += 17;// data 1052 TotalBytesLength += 17 + 2 + 4;// data
1056 TotalBytesLength += 2 + 4; // type
1057 } 1053 }
1058 1054
1059 if (_projectionEntry) 1055 if (_projectionEntry)
1060 { 1056 {
1061 ExtraParamsNum++; 1057 ExtraParamsNum++;
1062 TotalBytesLength += 28;// data 1058 TotalBytesLength += 28 + 2 + 4; // data
1063 TotalBytesLength += 2 + 4;// type
1064 } 1059 }
1065 1060
1066 byte[] returnbytes = new byte[TotalBytesLength]; 1061 byte[] returnBytes = new byte[TotalBytesLength];
1062
1063 returnBytes[0] = (byte)ExtraParamsNum;
1067 1064
1068 // uint paramlength = ExtraParamsNum; 1065 if(ExtraParamsNum == 0)
1066 return returnBytes;
1069 1067
1070 // Stick in the number of parameters 1068 int i = 1;
1071 returnbytes[i++] = (byte)ExtraParamsNum;
1072 1069
1073 if (_flexiEntry) 1070 if (_flexiEntry)
1074 { 1071 {
1075 byte[] FlexiData = GetFlexiBytes(); 1072 returnBytes[i] = FlexiEP; // 2 bytes id code
1073 i += 2;
1074 returnBytes[i] = 16; // 4 bytes size
1075 i += 4;
1076 1076
1077 returnbytes[i++] = (byte)(FlexiEP % 256); 1077 // Softness is packed in the upper bits of tension and drag
1078 returnbytes[i++] = (byte)((FlexiEP >> 8) % 256); 1078 returnBytes[i] = (byte)((_flexiSoftness & 2) << 6);
1079 returnBytes[i + 1] = (byte)((_flexiSoftness & 1) << 7);
1079 1080
1080 returnbytes[i++] = (byte)(FlexiData.Length % 256); 1081 returnBytes[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F);
1081 returnbytes[i++] = (byte)((FlexiData.Length >> 8) % 256); 1082 returnBytes[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F);
1082 returnbytes[i++] = (byte)((FlexiData.Length >> 16) % 256); 1083 returnBytes[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f);
1083 returnbytes[i++] = (byte)((FlexiData.Length >> 24) % 256); 1084 returnBytes[i++] = (byte)(_flexiWind * 10.01f);
1084 Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length); 1085 Vector3 lForce = new Vector3(_flexiForceX, _flexiForceY, _flexiForceZ);
1085 i += FlexiData.Length; 1086 lForce.GetBytes().CopyTo(returnBytes, i);
1087 i += 12;
1086 } 1088 }
1087 1089
1088 if (_lightEntry) 1090 if (_lightEntry)
1089 { 1091 {
1090 byte[] LightData = GetLightBytes(); 1092 returnBytes[i] = LightEP;
1091 1093 i += 2;
1092 returnbytes[i++] = (byte)(LightEP % 256); 1094 returnBytes[i] = 16;
1093 returnbytes[i++] = (byte)((LightEP >> 8) % 256); 1095 i += 4;
1094 1096
1095 returnbytes[i++] = (byte)(LightData.Length % 256); 1097 // Alpha channel in color is intensity
1096 returnbytes[i++] = (byte)((LightData.Length >> 8) % 256); 1098 Color4 tmpColor = new Color4(_lightColorR, _lightColorG, _lightColorB, _lightIntensity);
1097 returnbytes[i++] = (byte)((LightData.Length >> 16) % 256); 1099 tmpColor.GetBytes().CopyTo(returnBytes, i);
1098 returnbytes[i++] = (byte)((LightData.Length >> 24) % 256); 1100 Utils.FloatToBytes(_lightRadius).CopyTo(returnBytes, i + 4);
1099 Array.Copy(LightData, 0, returnbytes, i, LightData.Length); 1101 Utils.FloatToBytes(_lightCutoff).CopyTo(returnBytes, i + 8);
1100 i += LightData.Length; 1102 Utils.FloatToBytes(_lightFalloff).CopyTo(returnBytes, i + 12);
1103 i += 16;
1101 } 1104 }
1102 1105
1103 if (_sculptEntry) 1106 if (_sculptEntry)
1104 { 1107 {
1105 byte[] SculptData = GetSculptBytes(); 1108 returnBytes[i] = SculptEP;
1106 1109 i += 2;
1107 returnbytes[i++] = (byte)(SculptEP % 256); 1110 returnBytes[i] = 17;
1108 returnbytes[i++] = (byte)((SculptEP >> 8) % 256); 1111 i += 4;
1109 1112
1110 returnbytes[i++] = (byte)(SculptData.Length % 256); 1113 _sculptTexture.GetBytes().CopyTo(returnBytes, i);
1111 returnbytes[i++] = (byte)((SculptData.Length >> 8) % 256); 1114 i += 16;
1112 returnbytes[i++] = (byte)((SculptData.Length >> 16) % 256); 1115 returnBytes[i++] = _sculptType;
1113 returnbytes[i++] = (byte)((SculptData.Length >> 24) % 256);
1114 Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length);
1115 i += SculptData.Length;
1116 } 1116 }
1117 1117
1118 if (_projectionEntry) 1118 if (_projectionEntry)
1119 { 1119 {
1120 byte[] ProjectionData = GetProjectionBytes(); 1120 returnBytes[i] = ProjectionEP;
1121 1121 i += 2;
1122 returnbytes[i++] = (byte)(ProjectionEP % 256); 1122 returnBytes[i] = 28;
1123 returnbytes[i++] = (byte)((ProjectionEP >> 8) % 256); 1123 i += 4;
1124 returnbytes[i++] = (byte)((ProjectionData.Length) % 256);
1125 returnbytes[i++] = (byte)((ProjectionData.Length >> 16) % 256);
1126 returnbytes[i++] = (byte)((ProjectionData.Length >> 20) % 256);
1127 returnbytes[i++] = (byte)((ProjectionData.Length >> 24) % 256);
1128 Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length);
1129 i += ProjectionData.Length;
1130 }
1131 1124
1132 if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry) 1125 _projectionTextureID.GetBytes().CopyTo(returnBytes, i);
1133 { 1126 Utils.FloatToBytes(_projectionFOV).CopyTo(returnBytes, i + 16);
1134 byte[] returnbyte = new byte[1]; 1127 Utils.FloatToBytes(_projectionFocus).CopyTo(returnBytes, i + 20);
1135 returnbyte[0] = 0; 1128 Utils.FloatToBytes(_projectionAmb).CopyTo(returnBytes, i + 24);
1136 return returnbyte;
1137 } 1129 }
1138 1130
1139 return returnbytes; 1131 return returnBytes;
1140 } 1132 }
1141 1133
1142 public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data) 1134 public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data)
@@ -1283,16 +1275,6 @@ namespace OpenSim.Framework
1283 //m_log.Info("[SCULPT]:" + SculptUUID.ToString()); 1275 //m_log.Info("[SCULPT]:" + SculptUUID.ToString());
1284 } 1276 }
1285 1277
1286 public byte[] GetSculptBytes()
1287 {
1288 byte[] data = new byte[17];
1289
1290 _sculptTexture.GetBytes().CopyTo(data, 0);
1291 data[16] = (byte)_sculptType;
1292
1293 return data;
1294 }
1295
1296 public void ReadFlexiData(byte[] data, int pos) 1278 public void ReadFlexiData(byte[] data, int pos)
1297 { 1279 {
1298 if (data.Length-pos >= 16) 1280 if (data.Length-pos >= 16)
@@ -1324,25 +1306,6 @@ namespace OpenSim.Framework
1324 } 1306 }
1325 } 1307 }
1326 1308
1327 public byte[] GetFlexiBytes()
1328 {
1329 byte[] data = new byte[16];
1330 int i = 0;
1331
1332 // Softness is packed in the upper bits of tension and drag
1333 data[i] = (byte)((_flexiSoftness & 2) << 6);
1334 data[i + 1] = (byte)((_flexiSoftness & 1) << 7);
1335
1336 data[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F);
1337 data[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F);
1338 data[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f);
1339 data[i++] = (byte)(_flexiWind * 10.01f);
1340 Vector3 lForce = new Vector3(_flexiForceX, _flexiForceY, _flexiForceZ);
1341 lForce.GetBytes().CopyTo(data, i);
1342
1343 return data;
1344 }
1345
1346 public void ReadLightData(byte[] data, int pos) 1309 public void ReadLightData(byte[] data, int pos)
1347 { 1310 {
1348 if (data.Length - pos >= 16) 1311 if (data.Length - pos >= 16)
@@ -1373,21 +1336,6 @@ namespace OpenSim.Framework
1373 } 1336 }
1374 } 1337 }
1375 1338
1376 public byte[] GetLightBytes()
1377 {
1378 byte[] data = new byte[16];
1379
1380 // Alpha channel in color is intensity
1381 Color4 tmpColor = new Color4(_lightColorR,_lightColorG,_lightColorB,_lightIntensity);
1382
1383 tmpColor.GetBytes().CopyTo(data, 0);
1384 Utils.FloatToBytes(_lightRadius).CopyTo(data, 4);
1385 Utils.FloatToBytes(_lightCutoff).CopyTo(data, 8);
1386 Utils.FloatToBytes(_lightFalloff).CopyTo(data, 12);
1387
1388 return data;
1389 }
1390
1391 public void ReadProjectionData(byte[] data, int pos) 1339 public void ReadProjectionData(byte[] data, int pos)
1392 { 1340 {
1393 byte[] ProjectionTextureUUID = new byte[16]; 1341 byte[] ProjectionTextureUUID = new byte[16];
@@ -1412,19 +1360,6 @@ namespace OpenSim.Framework
1412 } 1360 }
1413 } 1361 }
1414 1362
1415 public byte[] GetProjectionBytes()
1416 {
1417 byte[] data = new byte[28];
1418
1419 _projectionTextureID.GetBytes().CopyTo(data, 0);
1420 Utils.FloatToBytes(_projectionFOV).CopyTo(data, 16);
1421 Utils.FloatToBytes(_projectionFocus).CopyTo(data, 20);
1422 Utils.FloatToBytes(_projectionAmb).CopyTo(data, 24);
1423
1424 return data;
1425 }
1426
1427
1428 /// <summary> 1363 /// <summary>
1429 /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values 1364 /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values
1430 /// </summary> 1365 /// </summary>
@@ -1436,7 +1371,6 @@ namespace OpenSim.Framework
1436 new Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); 1371 new Quaternion(0.0f, 0.0f, 0.0f, 1.0f));
1437 } 1372 }
1438 1373
1439
1440 /// <summary> 1374 /// <summary>
1441 /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values 1375 /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values
1442 /// </summary> 1376 /// </summary>