SceneObjectPart.cs 135 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Drawing;
  30. using System.Reflection;
  31. using System.Runtime.Serialization;
  32. using System.Security.Permissions;
  33. using System.Xml;
  34. using System.Xml.Serialization;
  35. using log4net;
  36. using OpenMetaverse;
  37. using OpenMetaverse.Packets;
  38. using OpenSim.Framework;
  39. using OpenSim.Region.Framework.Interfaces;
  40. using OpenSim.Region.Framework.Scenes.Scripting;
  41. using OpenSim.Region.Physics.Manager;
  42. namespace OpenSim.Region.Framework.Scenes
  43. {
  44. #region Enumerations
  45. [Flags]
  46. public enum Changed : uint
  47. {
  48. INVENTORY = 1,
  49. COLOR = 2,
  50. SHAPE = 4,
  51. SCALE = 8,
  52. TEXTURE = 16,
  53. LINK = 32,
  54. ALLOWED_DROP = 64,
  55. OWNER = 128,
  56. REGION_RESTART = 256,
  57. REGION = 512,
  58. TELEPORT = 1024
  59. }
  60. // I don't really know where to put this except here.
  61. // Can't access the OpenSim.Region.ScriptEngine.Common.LSL_BaseClass.Changed constants
  62. [Flags]
  63. public enum ExtraParamType
  64. {
  65. Something1 = 1,
  66. Something2 = 2,
  67. Something3 = 4,
  68. Something4 = 8,
  69. Flexible = 16,
  70. Light = 32,
  71. Sculpt = 48,
  72. Something5 = 64,
  73. Something6 = 128
  74. }
  75. [Flags]
  76. public enum TextureAnimFlags : byte
  77. {
  78. NONE = 0x00,
  79. ANIM_ON = 0x01,
  80. LOOP = 0x02,
  81. REVERSE = 0x04,
  82. PING_PONG = 0x08,
  83. SMOOTH = 0x10,
  84. ROTATE = 0x20,
  85. SCALE = 0x40
  86. }
  87. #endregion Enumerations
  88. [Serializable]
  89. public class SceneObjectPart : IScriptHost, ISerializable
  90. {
  91. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  92. // use only one serializer to give the runtime a chance to optimize it (it won't do that if you
  93. // use a new instance every time)
  94. private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
  95. #region Fields
  96. [XmlIgnore]
  97. public bool AllowedDrop = false;
  98. [XmlIgnore]
  99. public bool DIE_AT_EDGE = false;
  100. // TODO: This needs to be persisted in next XML version update!
  101. [XmlIgnore]
  102. public int[] PayPrice = {-2,-2,-2,-2,-2};
  103. [XmlIgnore]
  104. public PhysicsActor PhysActor = null;
  105. //Xantor 20080528 Sound stuff:
  106. // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet.
  107. // Not a big problem as long as the script that sets it remains in the prim on startup.
  108. // for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script)
  109. [XmlIgnore]
  110. public UUID Sound;
  111. [XmlIgnore]
  112. public byte SoundFlags;
  113. [XmlIgnore]
  114. public double SoundGain;
  115. [XmlIgnore]
  116. public double SoundRadius;
  117. [XmlIgnore]
  118. public uint TimeStampFull = 0;
  119. [XmlIgnore]
  120. public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
  121. [XmlIgnore]
  122. public uint TimeStampTerse = 0;
  123. [XmlIgnore]
  124. public UUID FromAssetID = UUID.Zero;
  125. /// <value>
  126. /// The UUID of the user inventory item from which this object was rezzed if this is a root part.
  127. /// If UUID.Zero then either this is not a root part or there is no connection with a user inventory item.
  128. /// </value>
  129. private UUID m_fromUserInventoryItemID = UUID.Zero;
  130. [XmlIgnore]
  131. public UUID FromUserInventoryItemID
  132. {
  133. get { return m_fromUserInventoryItemID; }
  134. }
  135. [XmlIgnore]
  136. public bool IsAttachment = false;
  137. [XmlIgnore]
  138. public scriptEvents AggregateScriptEvents = 0;
  139. [XmlIgnore]
  140. public UUID AttachedAvatar = UUID.Zero;
  141. [XmlIgnore]
  142. public Vector3 AttachedPos = Vector3.Zero;
  143. [XmlIgnore]
  144. public uint AttachmentPoint = (byte)0;
  145. [XmlIgnore]
  146. public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f);
  147. [XmlIgnore]
  148. public bool VolumeDetectActive = false; // XmlIgnore set to avoid problems with persistance until I come to care for this
  149. // Certainly this must be a persistant setting finally
  150. /// <summary>
  151. /// This part's inventory
  152. /// </summary>
  153. [XmlIgnore]
  154. public IEntityInventory Inventory
  155. {
  156. get { return m_inventory; }
  157. }
  158. protected SceneObjectPartInventory m_inventory;
  159. [XmlIgnore]
  160. public bool Undoing = false;
  161. [XmlIgnore]
  162. private PrimFlags LocalFlags = 0;
  163. private byte[] m_TextureAnimation;
  164. private byte m_clickAction = 0;
  165. private Color m_color = Color.Black;
  166. private string m_description = String.Empty;
  167. private readonly List<uint> m_lastColliders = new List<uint>();
  168. // private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero;
  169. private int m_linkNum = 0;
  170. [XmlIgnore]
  171. private int m_scriptAccessPin = 0;
  172. [XmlIgnore]
  173. private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
  174. private string m_sitName = String.Empty;
  175. private Quaternion m_sitTargetOrientation = Quaternion.Identity;
  176. private Vector3 m_sitTargetPosition = Vector3.Zero;
  177. private string m_sitAnimation = "SIT";
  178. private string m_text = String.Empty;
  179. private string m_touchName = String.Empty;
  180. private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
  181. private UUID _creatorID;
  182. /// <summary>
  183. /// Only used internally to schedule client updates.
  184. /// 0 - no update is scheduled
  185. /// 1 - terse update scheduled
  186. /// 2 - full update scheduled
  187. ///
  188. /// TODO - This should be an enumeration
  189. /// </summary>
  190. private byte m_updateFlag;
  191. protected Vector3 m_acceleration;
  192. protected Vector3 m_angularVelocity;
  193. //unkown if this will be kept, added as a way of removing the group position from the group class
  194. protected Vector3 m_groupPosition;
  195. protected uint m_localId;
  196. protected Material m_material = (Material)3; // Wood
  197. protected string m_name;
  198. protected Vector3 m_offsetPosition;
  199. // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out.
  200. protected SceneObjectGroup m_parentGroup;
  201. protected byte[] m_particleSystem = new byte[0];
  202. protected ulong m_regionHandle;
  203. protected Quaternion m_rotationOffset;
  204. protected PrimitiveBaseShape m_shape = null;
  205. protected UUID m_uuid;
  206. protected Vector3 m_velocity;
  207. // TODO: Those have to be changed into persistent properties at some later point,
  208. // or sit-camera on vehicles will break on sim-crossing.
  209. private Vector3 m_cameraEyeOffset = new Vector3(0.0f, 0.0f, 0.0f);
  210. private Vector3 m_cameraAtOffset = new Vector3(0.0f, 0.0f, 0.0f);
  211. private bool m_forceMouselook = false;
  212. // TODO: Collision sound should have default.
  213. private UUID m_collisionSound = UUID.Zero;
  214. private float m_collisionSoundVolume = 0.0f;
  215. #endregion Fields
  216. #region Constructors
  217. /// <summary>
  218. /// No arg constructor called by region restore db code
  219. /// </summary>
  220. public SceneObjectPart()
  221. {
  222. // It's not necessary to persist this
  223. m_TextureAnimation = new byte[0];
  224. m_particleSystem = new byte[0];
  225. Rezzed = DateTime.Now;
  226. m_inventory = new SceneObjectPartInventory(this);
  227. }
  228. /// <summary>
  229. /// Create a completely new SceneObjectPart (prim). This will need to be added separately to a SceneObjectGroup
  230. /// </summary>
  231. /// <param name="ownerID"></param>
  232. /// <param name="shape"></param>
  233. /// <param name="position"></param>
  234. /// <param name="rotationOffset"></param>
  235. /// <param name="offsetPosition"></param>
  236. public SceneObjectPart(
  237. UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
  238. Quaternion rotationOffset, Vector3 offsetPosition)
  239. {
  240. m_name = "Primitive";
  241. Rezzed = DateTime.Now;
  242. _creationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  243. _ownerID = ownerID;
  244. _creatorID = _ownerID;
  245. _lastOwnerID = UUID.Zero;
  246. UUID = UUID.Random();
  247. Shape = shape;
  248. // Todo: Add More Object Parameter from above!
  249. _ownershipCost = 0;
  250. _objectSaleType = (byte) 0;
  251. _salePrice = 0;
  252. _category = (uint) 0;
  253. _lastOwnerID = _creatorID;
  254. // End Todo: ///
  255. GroupPosition = groupPosition;
  256. OffsetPosition = offsetPosition;
  257. RotationOffset = rotationOffset;
  258. Velocity = new Vector3(0, 0, 0);
  259. AngularVelocity = new Vector3(0, 0, 0);
  260. Acceleration = new Vector3(0, 0, 0);
  261. m_TextureAnimation = new byte[0];
  262. m_particleSystem = new byte[0];
  263. // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
  264. // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
  265. // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
  266. _flags = 0;
  267. _flags |= PrimFlags.CreateSelected;
  268. TrimPermissions();
  269. //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
  270. m_inventory = new SceneObjectPartInventory(this);
  271. }
  272. protected SceneObjectPart(SerializationInfo info, StreamingContext context)
  273. {
  274. //m_log.Debug("SceneObjectPart Deserialize BGN");
  275. m_TextureAnimation = new byte[0];
  276. m_particleSystem = new byte[0];
  277. if (info == null)
  278. {
  279. throw new ArgumentNullException("info");
  280. }
  281. /*
  282. m_queue = (Queue<SceneObjectPart>)info.GetValue("m_queue", typeof(Queue<SceneObjectPart>));
  283. m_ids = (List<UUID>)info.GetValue("m_ids", typeof(List<UUID>));
  284. */
  285. //m_log.Debug("SceneObjectPart Deserialize END");
  286. Rezzed = DateTime.Now;
  287. m_inventory = new SceneObjectPartInventory(this);
  288. }
  289. #endregion Constructors
  290. #region XML Schema
  291. private UUID _lastOwnerID;
  292. private UUID _ownerID;
  293. private UUID _groupID;
  294. private int _ownershipCost;
  295. private byte _objectSaleType;
  296. private int _salePrice;
  297. private uint _category;
  298. private Int32 _creationDate;
  299. private uint _parentID = 0;
  300. private UUID m_sitTargetAvatar = UUID.Zero;
  301. private uint _baseMask = (uint)PermissionMask.All;
  302. private uint _ownerMask = (uint)PermissionMask.All;
  303. private uint _groupMask = (uint)PermissionMask.None;
  304. private uint _everyoneMask = (uint)PermissionMask.None;
  305. private uint _nextOwnerMask = (uint)PermissionMask.All;
  306. private PrimFlags _flags = 0;
  307. private DateTime m_expires;
  308. private DateTime m_rezzed;
  309. public UUID CreatorID
  310. {
  311. get
  312. {
  313. return _creatorID;
  314. }
  315. set
  316. {
  317. _creatorID = value;
  318. }
  319. }
  320. /// <summary>
  321. /// A relic from when we we thought that prims contained folder objects. In
  322. /// reality, prim == folder
  323. /// Exposing this is not particularly good, but it's one of the least evils at the moment to see
  324. /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
  325. /// </summary>
  326. public UUID FolderID
  327. {
  328. get { return UUID; }
  329. set { } // Don't allow assignment, or legacy prims wil b0rk - but we need the setter for legacy serialization.
  330. }
  331. /// <value>
  332. /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
  333. /// </value>
  334. public uint InventorySerial
  335. {
  336. get { return m_inventory.Serial; }
  337. set { m_inventory.Serial = value; }
  338. }
  339. /// <value>
  340. /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
  341. /// </value>
  342. public TaskInventoryDictionary TaskInventory
  343. {
  344. get { return m_inventory.Items; }
  345. set { m_inventory.Items = value; }
  346. }
  347. public uint ObjectFlags
  348. {
  349. get { return (uint)_flags; }
  350. set { _flags = (PrimFlags)value; }
  351. }
  352. public UUID UUID
  353. {
  354. get { return m_uuid; }
  355. set { m_uuid = value; }
  356. }
  357. public uint LocalId
  358. {
  359. get { return m_localId; }
  360. set { m_localId = value; }
  361. }
  362. public virtual string Name
  363. {
  364. get { return m_name; }
  365. set
  366. {
  367. m_name = value;
  368. if (PhysActor != null)
  369. {
  370. PhysActor.SOPName = value;
  371. }
  372. }
  373. }
  374. public byte Material
  375. {
  376. get { return (byte) m_material; }
  377. set { m_material = (Material)value; }
  378. }
  379. public ulong RegionHandle
  380. {
  381. get { return m_regionHandle; }
  382. set { m_regionHandle = value; }
  383. }
  384. public int ScriptAccessPin
  385. {
  386. get { return m_scriptAccessPin; }
  387. set { m_scriptAccessPin = (int)value; }
  388. }
  389. [XmlIgnore]
  390. public Byte[] TextureAnimation
  391. {
  392. get { return m_TextureAnimation; }
  393. set { m_TextureAnimation = value; }
  394. }
  395. [XmlIgnore]
  396. public Byte[] ParticleSystem
  397. {
  398. get { return m_particleSystem; }
  399. set { m_particleSystem = value; }
  400. }
  401. [XmlIgnore]
  402. public DateTime Expires
  403. {
  404. get { return m_expires; }
  405. set { m_expires = value; }
  406. }
  407. [XmlIgnore]
  408. public DateTime Rezzed
  409. {
  410. get { return m_rezzed; }
  411. set { m_rezzed = value; }
  412. }
  413. /// <summary>
  414. /// The position of the entire group that this prim belongs to.
  415. /// </summary>
  416. public Vector3 GroupPosition
  417. {
  418. get
  419. {
  420. // If this is a linkset, we don't want the physics engine mucking up our group position here.
  421. if (PhysActor != null && _parentID == 0)
  422. {
  423. m_groupPosition.X = PhysActor.Position.X;
  424. m_groupPosition.Y = PhysActor.Position.Y;
  425. m_groupPosition.Z = PhysActor.Position.Z;
  426. }
  427. if (IsAttachment)
  428. {
  429. ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
  430. if (sp != null)
  431. {
  432. return sp.AbsolutePosition;
  433. }
  434. }
  435. return m_groupPosition;
  436. }
  437. set
  438. {
  439. StoreUndoState();
  440. m_groupPosition = value;
  441. if (PhysActor != null)
  442. {
  443. try
  444. {
  445. // Root prim actually goes at Position
  446. if (_parentID == 0)
  447. {
  448. PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
  449. }
  450. else
  451. {
  452. // To move the child prim in respect to the group position and rotation we have to calculate
  453. Vector3 resultingposition = GetWorldPosition();
  454. PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z);
  455. Quaternion resultingrot = GetWorldRotation();
  456. PhysActor.Orientation = resultingrot;
  457. }
  458. // Tell the physics engines that this prim changed.
  459. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  460. }
  461. catch (Exception e)
  462. {
  463. m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
  464. }
  465. }
  466. // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
  467. if (m_sitTargetAvatar != UUID.Zero)
  468. {
  469. if (m_parentGroup != null) // TODO can there be a SOP without a SOG?
  470. {
  471. ScenePresence avatar;
  472. if (m_parentGroup.Scene.TryGetAvatar(m_sitTargetAvatar, out avatar))
  473. {
  474. avatar.ParentPosition = GetWorldPosition();
  475. }
  476. }
  477. }
  478. }
  479. }
  480. public Vector3 OffsetPosition
  481. {
  482. get { return m_offsetPosition; }
  483. set
  484. {
  485. StoreUndoState();
  486. m_offsetPosition = value;
  487. if (ParentGroup != null && !ParentGroup.IsDeleted)
  488. {
  489. if (_parentID != 0 && PhysActor != null)
  490. {
  491. Vector3 resultingposition = GetWorldPosition();
  492. PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z);
  493. Quaternion resultingrot = GetWorldRotation();
  494. PhysActor.Orientation = resultingrot;
  495. // Tell the physics engines that this prim changed.
  496. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  497. }
  498. }
  499. }
  500. }
  501. public Quaternion RotationOffset
  502. {
  503. get
  504. {
  505. // We don't want the physics engine mucking up the rotations in a linkset
  506. if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null))
  507. {
  508. if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0
  509. || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0)
  510. {
  511. m_rotationOffset = PhysActor.Orientation;
  512. }
  513. }
  514. return m_rotationOffset;
  515. }
  516. set
  517. {
  518. StoreUndoState();
  519. m_rotationOffset = value;
  520. if (PhysActor != null)
  521. {
  522. try
  523. {
  524. // Root prim gets value directly
  525. if (_parentID == 0)
  526. {
  527. PhysActor.Orientation = value;
  528. //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString());
  529. }
  530. else
  531. {
  532. // Child prim we have to calculate it's world rotationwel
  533. Quaternion resultingrotation = GetWorldRotation();
  534. PhysActor.Orientation = resultingrotation;
  535. //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString());
  536. }
  537. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  538. //}
  539. }
  540. catch (Exception ex)
  541. {
  542. m_log.Error("[SCENEOBJECTPART]: ROTATIONOFFSET" + ex.Message);
  543. }
  544. }
  545. }
  546. }
  547. /// <summary></summary>
  548. public Vector3 Velocity
  549. {
  550. get
  551. {
  552. //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0
  553. //|| PhysActor.Velocity.Z != 0)
  554. //{
  555. if (PhysActor != null)
  556. {
  557. if (PhysActor.IsPhysical)
  558. {
  559. m_velocity.X = PhysActor.Velocity.X;
  560. m_velocity.Y = PhysActor.Velocity.Y;
  561. m_velocity.Z = PhysActor.Velocity.Z;
  562. }
  563. }
  564. return m_velocity;
  565. }
  566. set
  567. {
  568. m_velocity = value;
  569. if (PhysActor != null)
  570. {
  571. if (PhysActor.IsPhysical)
  572. {
  573. PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
  574. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  575. }
  576. }
  577. }
  578. }
  579. public Vector3 RotationalVelocity
  580. {
  581. get { return AngularVelocity; }
  582. set { AngularVelocity = value; }
  583. }
  584. /// <summary></summary>
  585. public Vector3 AngularVelocity
  586. {
  587. get
  588. {
  589. if ((PhysActor != null) && PhysActor.IsPhysical)
  590. {
  591. m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0);
  592. }
  593. return m_angularVelocity;
  594. }
  595. set { m_angularVelocity = value; }
  596. }
  597. /// <summary></summary>
  598. public Vector3 Acceleration
  599. {
  600. get { return m_acceleration; }
  601. set { m_acceleration = value; }
  602. }
  603. public string Description
  604. {
  605. get { return m_description; }
  606. set
  607. {
  608. m_description = value;
  609. if (PhysActor != null)
  610. {
  611. PhysActor.SOPDescription = value;
  612. }
  613. }
  614. }
  615. public Color Color
  616. {
  617. get { return m_color; }
  618. set
  619. {
  620. m_color = value;
  621. TriggerScriptChangedEvent(Changed.COLOR);
  622. /* ScheduleFullUpdate() need not be called b/c after
  623. * setting the color, the text will be set, so then
  624. * ScheduleFullUpdate() will be called. */
  625. //ScheduleFullUpdate();
  626. }
  627. }
  628. public string Text
  629. {
  630. get
  631. {
  632. string returnstr = m_text;
  633. if (returnstr.Length > 255)
  634. {
  635. returnstr = returnstr.Substring(0, 254);
  636. }
  637. return returnstr;
  638. }
  639. set
  640. {
  641. m_text = value;
  642. }
  643. }
  644. public string SitName
  645. {
  646. get { return m_sitName; }
  647. set { m_sitName = value; }
  648. }
  649. public string TouchName
  650. {
  651. get { return m_touchName; }
  652. set { m_touchName = value; }
  653. }
  654. public int LinkNum
  655. {
  656. get { return m_linkNum; }
  657. set { m_linkNum = value; }
  658. }
  659. public byte ClickAction
  660. {
  661. get { return m_clickAction; }
  662. set
  663. {
  664. m_clickAction = value;
  665. }
  666. }
  667. public PrimitiveBaseShape Shape
  668. {
  669. get { return m_shape; }
  670. set
  671. {
  672. bool shape_changed = false;
  673. // TODO: this should really be restricted to the right
  674. // set of attributes on shape change. For instance,
  675. // changing the lighting on a shape shouldn't cause
  676. // this.
  677. if (m_shape != null)
  678. shape_changed = true;
  679. m_shape = value;
  680. if (shape_changed)
  681. TriggerScriptChangedEvent(Changed.SHAPE);
  682. }
  683. }
  684. public Vector3 Scale
  685. {
  686. get { return m_shape.Scale; }
  687. set
  688. {
  689. StoreUndoState();
  690. if (m_shape != null) {
  691. m_shape.Scale = value;
  692. if (PhysActor != null && m_parentGroup != null)
  693. {
  694. if (m_parentGroup.Scene != null)
  695. {
  696. if (m_parentGroup.Scene.PhysicsScene != null)
  697. {
  698. PhysActor.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z);
  699. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  700. }
  701. }
  702. }
  703. }
  704. TriggerScriptChangedEvent(Changed.SCALE);
  705. }
  706. }
  707. public byte UpdateFlag
  708. {
  709. get { return m_updateFlag; }
  710. set { m_updateFlag = value; }
  711. }
  712. #endregion
  713. //---------------
  714. #region Public Properties with only Get
  715. public Vector3 AbsolutePosition
  716. {
  717. get {
  718. if (IsAttachment)
  719. return GroupPosition;
  720. return m_offsetPosition + m_groupPosition; }
  721. }
  722. public UUID ObjectCreator
  723. {
  724. get { return _creatorID; }
  725. }
  726. public UUID ObjectOwner
  727. {
  728. get { return _ownerID; }
  729. }
  730. public SceneObjectGroup ParentGroup
  731. {
  732. get { return m_parentGroup; }
  733. }
  734. public scriptEvents ScriptEvents
  735. {
  736. get { return AggregateScriptEvents; }
  737. }
  738. public Quaternion SitTargetOrientation
  739. {
  740. get { return m_sitTargetOrientation; }
  741. set { m_sitTargetOrientation = value; }
  742. }
  743. public Vector3 SitTargetPosition
  744. {
  745. get { return m_sitTargetPosition; }
  746. set { m_sitTargetPosition = value; }
  747. }
  748. // This sort of sucks, but I'm adding these in to make some of
  749. // the mappings more consistant.
  750. public Vector3 SitTargetPositionLL
  751. {
  752. get { return new Vector3(m_sitTargetPosition.X, m_sitTargetPosition.Y,m_sitTargetPosition.Z); }
  753. set { m_sitTargetPosition = value; }
  754. }
  755. public Quaternion SitTargetOrientationLL
  756. {
  757. get
  758. {
  759. return new Quaternion(
  760. m_sitTargetOrientation.X,
  761. m_sitTargetOrientation.Y,
  762. m_sitTargetOrientation.Z,
  763. m_sitTargetOrientation.W
  764. );
  765. }
  766. set { m_sitTargetOrientation = new Quaternion(value.X, value.Y, value.Z, value.W); }
  767. }
  768. public bool Stopped
  769. {
  770. get {
  771. double threshold = 0.02;
  772. return (Math.Abs(Velocity.X) < threshold &&
  773. Math.Abs(Velocity.Y) < threshold &&
  774. Math.Abs(Velocity.Z) < threshold &&
  775. Math.Abs(AngularVelocity.X) < threshold &&
  776. Math.Abs(AngularVelocity.Y) < threshold &&
  777. Math.Abs(AngularVelocity.Z) < threshold);
  778. }
  779. }
  780. public uint ParentID
  781. {
  782. get { return _parentID; }
  783. set { _parentID = value; }
  784. }
  785. public int CreationDate
  786. {
  787. get { return _creationDate; }
  788. set { _creationDate = value; }
  789. }
  790. public uint Category
  791. {
  792. get { return _category; }
  793. set { _category = value; }
  794. }
  795. public int SalePrice
  796. {
  797. get { return _salePrice; }
  798. set { _salePrice = value; }
  799. }
  800. public byte ObjectSaleType
  801. {
  802. get { return _objectSaleType; }
  803. set { _objectSaleType = value; }
  804. }
  805. public int OwnershipCost
  806. {
  807. get { return _ownershipCost; }
  808. set { _ownershipCost = value; }
  809. }
  810. public UUID GroupID
  811. {
  812. get { return _groupID; }
  813. set { _groupID = value; }
  814. }
  815. public UUID OwnerID
  816. {
  817. get { return _ownerID; }
  818. set { _ownerID = value; }
  819. }
  820. public UUID LastOwnerID
  821. {
  822. get { return _lastOwnerID; }
  823. set { _lastOwnerID = value; }
  824. }
  825. public uint BaseMask
  826. {
  827. get { return _baseMask; }
  828. set { _baseMask = value; }
  829. }
  830. public uint OwnerMask
  831. {
  832. get { return _ownerMask; }
  833. set { _ownerMask = value; }
  834. }
  835. public uint GroupMask
  836. {
  837. get { return _groupMask; }
  838. set { _groupMask = value; }
  839. }
  840. public uint EveryoneMask
  841. {
  842. get { return _everyoneMask; }
  843. set { _everyoneMask = value; }
  844. }
  845. public uint NextOwnerMask
  846. {
  847. get { return _nextOwnerMask; }
  848. set { _nextOwnerMask = value; }
  849. }
  850. public PrimFlags Flags
  851. {
  852. get { return _flags; }
  853. set { _flags = value; }
  854. }
  855. [XmlIgnore]
  856. public UUID SitTargetAvatar
  857. {
  858. get { return m_sitTargetAvatar; }
  859. set { m_sitTargetAvatar = value; }
  860. }
  861. [XmlIgnore]
  862. public virtual UUID RegionID
  863. {
  864. get
  865. {
  866. if (ParentGroup != null && ParentGroup.Scene != null)
  867. return ParentGroup.Scene.RegionInfo.RegionID;
  868. else
  869. return UUID.Zero;
  870. }
  871. set {} // read only
  872. }
  873. private UUID _parentUUID = UUID.Zero;
  874. [XmlIgnore]
  875. public UUID ParentUUID
  876. {
  877. get
  878. {
  879. if (ParentGroup != null)
  880. {
  881. _parentUUID = ParentGroup.UUID;
  882. }
  883. return _parentUUID;
  884. }
  885. set { _parentUUID = value; }
  886. }
  887. [XmlIgnore]
  888. public string SitAnimation
  889. {
  890. get { return m_sitAnimation; }
  891. set { m_sitAnimation = value; }
  892. }
  893. public UUID CollisionSound
  894. {
  895. get { return m_collisionSound; }
  896. set
  897. {
  898. m_collisionSound = value;
  899. aggregateScriptEvents();
  900. }
  901. }
  902. public float CollisionSoundVolume
  903. {
  904. get { return m_collisionSoundVolume; }
  905. set { m_collisionSoundVolume = value; }
  906. }
  907. #endregion Public Properties with only Get
  908. #region Private Methods
  909. private uint ApplyMask(uint val, bool set, uint mask)
  910. {
  911. if (set)
  912. {
  913. return val |= mask;
  914. }
  915. else
  916. {
  917. return val &= ~mask;
  918. }
  919. }
  920. /// <summary>
  921. /// Clear all pending updates of parts to clients
  922. /// </summary>
  923. private void ClearUpdateSchedule()
  924. {
  925. m_updateFlag = 0;
  926. }
  927. private void SendObjectPropertiesToClient(UUID AgentID)
  928. {
  929. List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
  930. for (int i = 0; i < avatars.Count; i++)
  931. {
  932. // Ugly reference :(
  933. if (avatars[i].UUID == AgentID)
  934. {
  935. m_parentGroup.GetProperties(avatars[i].ControllingClient);
  936. }
  937. }
  938. }
  939. private void handleTimerAccounting(uint localID, double interval)
  940. {
  941. if (localID == LocalId)
  942. {
  943. float sec = (float)interval;
  944. if (m_parentGroup != null)
  945. {
  946. if (sec == 0)
  947. {
  948. if (m_parentGroup.scriptScore + 0.001f >= float.MaxValue - 0.001)
  949. m_parentGroup.scriptScore = 0;
  950. m_parentGroup.scriptScore += 0.001f;
  951. return;
  952. }
  953. if (m_parentGroup.scriptScore + (0.001f / sec) >= float.MaxValue - (0.001f / sec))
  954. m_parentGroup.scriptScore = 0;
  955. m_parentGroup.scriptScore += (0.001f / sec);
  956. }
  957. }
  958. }
  959. #endregion Private Methods
  960. #region Public Methods
  961. public void ResetExpire()
  962. {
  963. Expires = DateTime.Now + new TimeSpan(600000000);
  964. }
  965. public void AddFlag(PrimFlags flag)
  966. {
  967. // PrimFlags prevflag = Flags;
  968. if ((ObjectFlags & (uint) flag) == 0)
  969. {
  970. //m_log.Debug("Adding flag: " + ((PrimFlags) flag).ToString());
  971. _flags |= flag;
  972. if (flag == PrimFlags.TemporaryOnRez)
  973. ResetExpire();
  974. }
  975. // m_log.Debug("Aprev: " + prevflag.ToString() + " curr: " + Flags.ToString());
  976. }
  977. /// <summary>
  978. /// Tell all scene presences that they should send updates for this part to their clients
  979. /// </summary>
  980. public void AddFullUpdateToAllAvatars()
  981. {
  982. List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
  983. for (int i = 0; i < avatars.Count; i++)
  984. {
  985. avatars[i].QueuePartForUpdate(this);
  986. }
  987. }
  988. public void AddFullUpdateToAvatar(ScenePresence presence)
  989. {
  990. presence.QueuePartForUpdate(this);
  991. }
  992. public void AddNewParticleSystem(Primitive.ParticleSystem pSystem)
  993. {
  994. m_particleSystem = pSystem.GetBytes();
  995. }
  996. public void RemoveParticleSystem()
  997. {
  998. m_particleSystem = new byte[0];
  999. }
  1000. /// Terse updates
  1001. public void AddTerseUpdateToAllAvatars()
  1002. {
  1003. List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
  1004. for (int i = 0; i < avatars.Count; i++)
  1005. {
  1006. avatars[i].QueuePartForUpdate(this);
  1007. }
  1008. }
  1009. public void AddTerseUpdateToAvatar(ScenePresence presence)
  1010. {
  1011. presence.QueuePartForUpdate(this);
  1012. }
  1013. public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim)
  1014. {
  1015. byte[] data = new byte[16];
  1016. int pos = 0;
  1017. // The flags don't like conversion from uint to byte, so we have to do
  1018. // it the crappy way. See the above function :(
  1019. data[pos] = ConvertScriptUintToByte((uint)pTexAnim.Flags); pos++;
  1020. data[pos] = (byte)pTexAnim.Face; pos++;
  1021. data[pos] = (byte)pTexAnim.SizeX; pos++;
  1022. data[pos] = (byte)pTexAnim.SizeY; pos++;
  1023. Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos);
  1024. Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4);
  1025. Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8);
  1026. m_TextureAnimation = data;
  1027. }
  1028. public void AdjustSoundGain(double volume)
  1029. {
  1030. if (volume > 1)
  1031. volume = 1;
  1032. if (volume < 0)
  1033. volume = 0;
  1034. List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
  1035. foreach (ScenePresence p in avatarts)
  1036. {
  1037. p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume);
  1038. }
  1039. }
  1040. /// <summary>
  1041. /// hook to the physics scene to apply impulse
  1042. /// This is sent up to the group, which then finds the root prim
  1043. /// and applies the force on the root prim of the group
  1044. /// </summary>
  1045. /// <param name="impulsei">Vector force</param>
  1046. /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
  1047. public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF)
  1048. {
  1049. PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z);
  1050. if (localGlobalTF)
  1051. {
  1052. Quaternion grot = GetWorldRotation();
  1053. Quaternion AXgrot = grot;
  1054. Vector3 AXimpulsei = impulsei;
  1055. Vector3 newimpulse = AXimpulsei * AXgrot;
  1056. impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z);
  1057. }
  1058. if (m_parentGroup != null)
  1059. {
  1060. m_parentGroup.applyImpulse(impulse);
  1061. }
  1062. }
  1063. /// <summary>
  1064. /// hook to the physics scene to apply angular impulse
  1065. /// This is sent up to the group, which then finds the root prim
  1066. /// and applies the force on the root prim of the group
  1067. /// </summary>
  1068. /// <param name="impulsei">Vector force</param>
  1069. /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
  1070. public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF)
  1071. {
  1072. PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z);
  1073. if (localGlobalTF)
  1074. {
  1075. Quaternion grot = GetWorldRotation();
  1076. Quaternion AXgrot = grot;
  1077. Vector3 AXimpulsei = impulsei;
  1078. Vector3 newimpulse = AXimpulsei * AXgrot;
  1079. impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z);
  1080. }
  1081. if (m_parentGroup != null)
  1082. {
  1083. m_parentGroup.applyAngularImpulse(impulse);
  1084. }
  1085. }
  1086. /// <summary>
  1087. /// hook to the physics scene to apply angular impulse
  1088. /// This is sent up to the group, which then finds the root prim
  1089. /// and applies the force on the root prim of the group
  1090. /// </summary>
  1091. /// <param name="impulsei">Vector force</param>
  1092. /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
  1093. public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF)
  1094. {
  1095. PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z);
  1096. if (localGlobalTF)
  1097. {
  1098. Quaternion grot = GetWorldRotation();
  1099. Quaternion AXgrot = grot;
  1100. Vector3 AXimpulsei = impulsei;
  1101. Vector3 newimpulse = AXimpulsei * AXgrot;
  1102. impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z);
  1103. }
  1104. if (m_parentGroup != null)
  1105. {
  1106. m_parentGroup.setAngularImpulse(impulse);
  1107. }
  1108. }
  1109. public Vector3 GetTorque()
  1110. {
  1111. if (m_parentGroup != null)
  1112. {
  1113. m_parentGroup.GetTorque();
  1114. }
  1115. return Vector3.Zero;
  1116. }
  1117. /// <summary>
  1118. /// Apply physics to this part.
  1119. /// </summary>
  1120. /// <param name="rootObjectFlags"></param>
  1121. /// <param name="m_physicalPrim"></param>
  1122. public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool m_physicalPrim)
  1123. {
  1124. bool isPhysical = (((rootObjectFlags & (uint) PrimFlags.Physics) != 0) && m_physicalPrim);
  1125. bool isPhantom = ((rootObjectFlags & (uint) PrimFlags.Phantom) != 0);
  1126. if (IsJoint())
  1127. {
  1128. DoPhysicsPropertyUpdate(isPhysical, true);
  1129. }
  1130. else
  1131. {
  1132. // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored
  1133. if (VolumeDetectActive)
  1134. isPhantom = false;
  1135. // Added clarification.. since A rigid body is an object that you can kick around, etc.
  1136. bool RigidBody = isPhysical && !isPhantom;
  1137. // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition
  1138. if (!isPhantom && !IsAttachment)
  1139. {
  1140. PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
  1141. Name,
  1142. Shape,
  1143. new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z),
  1144. new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
  1145. RotationOffset,
  1146. RigidBody);
  1147. // Basic Physics returns null.. joy joy joy.
  1148. if (PhysActor != null)
  1149. {
  1150. PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info
  1151. PhysActor.SOPDescription = this.Description;
  1152. PhysActor.LocalID = LocalId;
  1153. DoPhysicsPropertyUpdate(RigidBody, true);
  1154. PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
  1155. }
  1156. }
  1157. }
  1158. }
  1159. public void ClearUndoState()
  1160. {
  1161. lock (m_undo)
  1162. {
  1163. m_undo.Clear();
  1164. }
  1165. StoreUndoState();
  1166. }
  1167. public byte ConvertScriptUintToByte(uint indata)
  1168. {
  1169. byte outdata = (byte)TextureAnimFlags.NONE;
  1170. if ((indata & 1) != 0) outdata |= (byte)TextureAnimFlags.ANIM_ON;
  1171. if ((indata & 2) != 0) outdata |= (byte)TextureAnimFlags.LOOP;
  1172. if ((indata & 4) != 0) outdata |= (byte)TextureAnimFlags.REVERSE;
  1173. if ((indata & 8) != 0) outdata |= (byte)TextureAnimFlags.PING_PONG;
  1174. if ((indata & 16) != 0) outdata |= (byte)TextureAnimFlags.SMOOTH;
  1175. if ((indata & 32) != 0) outdata |= (byte)TextureAnimFlags.ROTATE;
  1176. if ((indata & 64) != 0) outdata |= (byte)TextureAnimFlags.SCALE;
  1177. return outdata;
  1178. }
  1179. /// <summary>
  1180. /// Duplicates this part.
  1181. /// </summary>
  1182. /// <returns></returns>
  1183. public SceneObjectPart Copy(uint localID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed)
  1184. {
  1185. SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone();
  1186. dupe.m_shape = m_shape.Copy();
  1187. dupe.m_regionHandle = m_regionHandle;
  1188. if (userExposed)
  1189. dupe.UUID = UUID.Random();
  1190. //memberwiseclone means it also clones the physics actor reference
  1191. // This will make physical prim 'bounce' if not set to null.
  1192. if (!userExposed)
  1193. dupe.PhysActor = null;
  1194. dupe._ownerID = AgentID;
  1195. dupe._groupID = GroupID;
  1196. dupe.GroupPosition = GroupPosition;
  1197. dupe.OffsetPosition = OffsetPosition;
  1198. dupe.RotationOffset = RotationOffset;
  1199. dupe.Velocity = new Vector3(0, 0, 0);
  1200. dupe.Acceleration = new Vector3(0, 0, 0);
  1201. dupe.AngularVelocity = new Vector3(0, 0, 0);
  1202. dupe.ObjectFlags = ObjectFlags;
  1203. dupe._ownershipCost = _ownershipCost;
  1204. dupe._objectSaleType = _objectSaleType;
  1205. dupe._salePrice = _salePrice;
  1206. dupe._category = _category;
  1207. dupe.m_rezzed = m_rezzed;
  1208. dupe.m_inventory = new SceneObjectPartInventory(dupe);
  1209. dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone();
  1210. if (userExposed)
  1211. {
  1212. dupe.ResetIDs(linkNum);
  1213. dupe.m_inventory.HasInventoryChanged = true;
  1214. }
  1215. else
  1216. {
  1217. dupe.m_inventory.HasInventoryChanged = m_inventory.HasInventoryChanged;
  1218. }
  1219. // Move afterwards ResetIDs as it clears the localID
  1220. dupe.LocalId = localID;
  1221. // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
  1222. dupe._lastOwnerID = ObjectOwner;
  1223. byte[] extraP = new byte[Shape.ExtraParams.Length];
  1224. Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
  1225. dupe.Shape.ExtraParams = extraP;
  1226. if (userExposed)
  1227. {
  1228. if (dupe.m_shape.SculptEntry && dupe.m_shape.SculptTexture != UUID.Zero)
  1229. {
  1230. m_parentGroup.Scene.CommsManager.AssetCache.GetAsset(
  1231. dupe.m_shape.SculptTexture, dupe.SculptTextureCallback, true);
  1232. }
  1233. bool UsePhysics = ((dupe.ObjectFlags & (uint)PrimFlags.Physics) != 0);
  1234. dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
  1235. }
  1236. return dupe;
  1237. }
  1238. public static SceneObjectPart Create()
  1239. {
  1240. SceneObjectPart part = new SceneObjectPart();
  1241. part.UUID = UUID.Random();
  1242. PrimitiveBaseShape shape = PrimitiveBaseShape.Create();
  1243. part.Shape = shape;
  1244. part.Name = "Primitive";
  1245. part._ownerID = UUID.Random();
  1246. return part;
  1247. }
  1248. public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
  1249. {
  1250. if (IsJoint())
  1251. {
  1252. if (UsePhysics)
  1253. {
  1254. // by turning a joint proxy object physical, we cause creation of a joint in the ODE scene.
  1255. // note that, as a special case, joints have no bodies or geoms in the physics scene, even though they are physical.
  1256. PhysicsJointType jointType;
  1257. if (IsHingeJoint())
  1258. {
  1259. jointType = PhysicsJointType.Hinge;
  1260. }
  1261. else if (IsBallJoint())
  1262. {
  1263. jointType = PhysicsJointType.Ball;
  1264. }
  1265. else
  1266. {
  1267. jointType = PhysicsJointType.Ball;
  1268. }
  1269. List<string> bodyNames = new List<string>();
  1270. string RawParams = Description;
  1271. string[] jointParams = RawParams.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);
  1272. string trackedBodyName = null;
  1273. if (jointParams.Length >= 2)
  1274. {
  1275. for (int iBodyName = 0; iBodyName < 2; iBodyName++)
  1276. {
  1277. string bodyName = jointParams[iBodyName];
  1278. bodyNames.Add(bodyName);
  1279. if (bodyName != "NULL")
  1280. {
  1281. if (trackedBodyName == null)
  1282. {
  1283. trackedBodyName = bodyName;
  1284. }
  1285. }
  1286. }
  1287. }
  1288. SceneObjectPart trackedBody = m_parentGroup.Scene.GetSceneObjectPart(trackedBodyName); // FIXME: causes a sequential lookup
  1289. Quaternion localRotation = Quaternion.Identity;
  1290. if (trackedBody != null)
  1291. {
  1292. localRotation = Quaternion.Inverse(trackedBody.RotationOffset) * this.RotationOffset;
  1293. }
  1294. else
  1295. {
  1296. // error, output it below
  1297. }
  1298. PhysicsJoint joint;
  1299. joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType,
  1300. new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z),
  1301. this.RotationOffset,
  1302. Description,
  1303. bodyNames,
  1304. trackedBodyName,
  1305. localRotation);
  1306. if (trackedBody == null)
  1307. {
  1308. ParentGroup.Scene.jointErrorMessage(joint, "warning: tracked body name not found! joint location will not be updated properly. joint: " + Name);
  1309. }
  1310. }
  1311. else
  1312. {
  1313. if (isNew)
  1314. {
  1315. // if the joint proxy is new, and it is not physical, do nothing. There is no joint in ODE to
  1316. // delete, and if we try to delete it, due to asynchronous processing, the deletion request
  1317. // will get processed later at an indeterminate time, which could cancel a later-arriving
  1318. // joint creation request.
  1319. }
  1320. else
  1321. {
  1322. // here we turn off the joint object, so remove the joint from the physics scene
  1323. m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed?
  1324. // make sure client isn't interpolating the joint proxy object
  1325. Velocity = new Vector3(0, 0, 0);
  1326. RotationalVelocity = new Vector3(0, 0, 0);
  1327. Acceleration = new Vector3(0, 0, 0);
  1328. }
  1329. }
  1330. }
  1331. else
  1332. {
  1333. if (PhysActor != null)
  1334. {
  1335. if (UsePhysics != PhysActor.IsPhysical || isNew)
  1336. {
  1337. if (PhysActor.IsPhysical) // implies UsePhysics==false for this block
  1338. {
  1339. if (!isNew)
  1340. ParentGroup.Scene.RemovePhysicalPrim(1);
  1341. PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
  1342. PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
  1343. PhysActor.delink();
  1344. if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew))
  1345. {
  1346. // destroy all joints connected to this now deactivated body
  1347. m_parentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor);
  1348. }
  1349. // stop client-side interpolation of all joint proxy objects that have just been deleted
  1350. // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback,
  1351. // which stops client-side interpolation of deactivated joint proxy objects.
  1352. }
  1353. if (!UsePhysics && !isNew)
  1354. {
  1355. // reset velocity to 0 on physics switch-off. Without that, the client thinks the
  1356. // prim still has velocity and continues to interpolate its position along the old
  1357. // velocity-vector.
  1358. Velocity = new Vector3(0, 0, 0);
  1359. Acceleration = new Vector3(0, 0, 0);
  1360. AngularVelocity = new Vector3(0, 0, 0);
  1361. //RotationalVelocity = new Vector3(0, 0, 0);
  1362. }
  1363. PhysActor.IsPhysical = UsePhysics;
  1364. // If we're not what we're supposed to be in the physics scene, recreate ourselves.
  1365. //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
  1366. /// that's not wholesome. Had to make Scene public
  1367. //PhysActor = null;
  1368. if ((ObjectFlags & (uint)PrimFlags.Phantom) == 0)
  1369. {
  1370. if (UsePhysics)
  1371. {
  1372. ParentGroup.Scene.AddPhysicalPrim(1);
  1373. PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
  1374. PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
  1375. if (_parentID != 0 && _parentID != LocalId)
  1376. {
  1377. if (ParentGroup.RootPart.PhysActor != null)
  1378. {
  1379. PhysActor.link(ParentGroup.RootPart.PhysActor);
  1380. }
  1381. }
  1382. }
  1383. }
  1384. }
  1385. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  1386. }
  1387. }
  1388. }
  1389. /// <summary>
  1390. /// Restore this part from the serialized xml representation.
  1391. /// </summary>
  1392. /// <param name="xmlReader"></param>
  1393. /// <returns></returns>
  1394. public static SceneObjectPart FromXml(XmlReader xmlReader)
  1395. {
  1396. return FromXml(UUID.Zero, xmlReader);
  1397. }
  1398. /// <summary>
  1399. /// Restore this part from the serialized xml representation.
  1400. /// </summary>
  1401. /// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param>
  1402. /// <param name="xmlReader"></param>
  1403. /// <returns></returns>
  1404. public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader)
  1405. {
  1406. SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader);
  1407. part.m_fromUserInventoryItemID = fromUserInventoryItemId;
  1408. // for tempOnRez objects, we have to fix the Expire date.
  1409. if ((part.Flags & PrimFlags.TemporaryOnRez) != 0) part.ResetExpire();
  1410. return part;
  1411. }
  1412. public UUID GetAvatarOnSitTarget()
  1413. {
  1414. return m_sitTargetAvatar;
  1415. }
  1416. public bool GetDieAtEdge()
  1417. {
  1418. if (m_parentGroup == null)
  1419. return false;
  1420. if (m_parentGroup.IsDeleted)
  1421. return false;
  1422. return m_parentGroup.RootPart.DIE_AT_EDGE;
  1423. }
  1424. public double GetDistanceTo(Vector3 a, Vector3 b)
  1425. {
  1426. float dx = a.X - b.X;
  1427. float dy = a.Y - b.Y;
  1428. float dz = a.Z - b.Z;
  1429. return Math.Sqrt(dx * dx + dy * dy + dz * dz);
  1430. }
  1431. public uint GetEffectiveObjectFlags()
  1432. {
  1433. PrimFlags f = _flags;
  1434. if (m_parentGroup == null || m_parentGroup.RootPart == this)
  1435. f &= ~(PrimFlags.Touch | PrimFlags.Money);
  1436. return (uint)_flags | (uint)LocalFlags;
  1437. }
  1438. public Vector3 GetGeometricCenter()
  1439. {
  1440. if (PhysActor != null)
  1441. {
  1442. return new Vector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z);
  1443. }
  1444. else
  1445. {
  1446. return new Vector3(0, 0, 0);
  1447. }
  1448. }
  1449. public float GetMass()
  1450. {
  1451. if (PhysActor != null)
  1452. {
  1453. return PhysActor.Mass;
  1454. }
  1455. else
  1456. {
  1457. return 0;
  1458. }
  1459. }
  1460. public PhysicsVector GetForce()
  1461. {
  1462. if (PhysActor != null)
  1463. return PhysActor.Force;
  1464. else
  1465. return new PhysicsVector();
  1466. }
  1467. [SecurityPermission(SecurityAction.LinkDemand,
  1468. Flags = SecurityPermissionFlag.SerializationFormatter)]
  1469. public virtual void GetObjectData(
  1470. SerializationInfo info, StreamingContext context)
  1471. {
  1472. if (info == null)
  1473. {
  1474. throw new ArgumentNullException("info");
  1475. }
  1476. info.AddValue("m_inventoryFileName", Inventory.GetInventoryFileName());
  1477. info.AddValue("m_folderID", UUID);
  1478. info.AddValue("PhysActor", PhysActor);
  1479. Dictionary<Guid, TaskInventoryItem> TaskInventory_work = new Dictionary<Guid, TaskInventoryItem>();
  1480. lock (TaskInventory)
  1481. {
  1482. foreach (UUID id in TaskInventory.Keys)
  1483. {
  1484. TaskInventory_work.Add(id.Guid, TaskInventory[id]);
  1485. }
  1486. }
  1487. info.AddValue("TaskInventory", TaskInventory_work);
  1488. info.AddValue("LastOwnerID", _lastOwnerID.Guid);
  1489. info.AddValue("OwnerID", _ownerID.Guid);
  1490. info.AddValue("GroupID", _groupID.Guid);
  1491. info.AddValue("OwnershipCost", _ownershipCost);
  1492. info.AddValue("ObjectSaleType", _objectSaleType);
  1493. info.AddValue("SalePrice", _salePrice);
  1494. info.AddValue("Category", _category);
  1495. info.AddValue("CreationDate", _creationDate);
  1496. info.AddValue("ParentID", _parentID);
  1497. info.AddValue("OwnerMask", _ownerMask);
  1498. info.AddValue("NextOwnerMask", _nextOwnerMask);
  1499. info.AddValue("GroupMask", _groupMask);
  1500. info.AddValue("EveryoneMask", _everyoneMask);
  1501. info.AddValue("BaseMask", _baseMask);
  1502. info.AddValue("m_particleSystem", m_particleSystem);
  1503. info.AddValue("TimeStampFull", TimeStampFull);
  1504. info.AddValue("TimeStampTerse", TimeStampTerse);
  1505. info.AddValue("TimeStampLastActivity", TimeStampLastActivity);
  1506. info.AddValue("m_updateFlag", m_updateFlag);
  1507. info.AddValue("CreatorID", _creatorID.Guid);
  1508. info.AddValue("m_inventorySerial", m_inventory.Serial);
  1509. info.AddValue("m_uuid", m_uuid.Guid);
  1510. info.AddValue("m_localID", m_localId);
  1511. info.AddValue("m_name", m_name);
  1512. info.AddValue("m_flags", _flags);
  1513. info.AddValue("m_material", m_material);
  1514. info.AddValue("m_regionHandle", m_regionHandle);
  1515. info.AddValue("m_groupPosition.X", m_groupPosition.X);
  1516. info.AddValue("m_groupPosition.Y", m_groupPosition.Y);
  1517. info.AddValue("m_groupPosition.Z", m_groupPosition.Z);
  1518. info.AddValue("m_offsetPosition.X", m_offsetPosition.X);
  1519. info.AddValue("m_offsetPosition.Y", m_offsetPosition.Y);
  1520. info.AddValue("m_offsetPosition.Z", m_offsetPosition.Z);
  1521. info.AddValue("m_rotationOffset.W", m_rotationOffset.W);
  1522. info.AddValue("m_rotationOffset.X", m_rotationOffset.X);
  1523. info.AddValue("m_rotationOffset.Y", m_rotationOffset.Y);
  1524. info.AddValue("m_rotationOffset.Z", m_rotationOffset.Z);
  1525. info.AddValue("m_velocity.X", m_velocity.X);
  1526. info.AddValue("m_velocity.Y", m_velocity.Y);
  1527. info.AddValue("m_velocity.Z", m_velocity.Z);
  1528. info.AddValue("m_rotationalvelocity.X", RotationalVelocity.X);
  1529. info.AddValue("m_rotationalvelocity.Y", RotationalVelocity.Y);
  1530. info.AddValue("m_rotationalvelocity.Z", RotationalVelocity.Z);
  1531. info.AddValue("m_angularVelocity.X", m_angularVelocity.X);
  1532. info.AddValue("m_angularVelocity.Y", m_angularVelocity.Y);
  1533. info.AddValue("m_angularVelocity.Z", m_angularVelocity.Z);
  1534. info.AddValue("m_acceleration.X", m_acceleration.X);
  1535. info.AddValue("m_acceleration.Y", m_acceleration.Y);
  1536. info.AddValue("m_acceleration.Z", m_acceleration.Z);
  1537. info.AddValue("m_description", m_description);
  1538. info.AddValue("m_color", m_color);
  1539. info.AddValue("m_text", m_text);
  1540. info.AddValue("m_sitName", m_sitName);
  1541. info.AddValue("m_touchName", m_touchName);
  1542. info.AddValue("m_clickAction", m_clickAction);
  1543. info.AddValue("m_shape", m_shape);
  1544. info.AddValue("m_parentGroup", m_parentGroup);
  1545. info.AddValue("PayPrice", PayPrice);
  1546. }
  1547. public void GetProperties(IClientAPI client)
  1548. {
  1549. client.SendObjectPropertiesReply(
  1550. m_fromUserInventoryItemID, (ulong)_creationDate, _creatorID, UUID.Zero, UUID.Zero,
  1551. _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID,
  1552. ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description,
  1553. ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask,
  1554. ParentGroup.RootPart._baseMask,
  1555. ParentGroup.RootPart.ObjectSaleType,
  1556. ParentGroup.RootPart.SalePrice);
  1557. }
  1558. public UUID GetRootPartUUID()
  1559. {
  1560. if (m_parentGroup != null)
  1561. {
  1562. return m_parentGroup.UUID;
  1563. }
  1564. return UUID.Zero;
  1565. }
  1566. /// <summary>
  1567. /// Method for a prim to get it's world position from the group.
  1568. /// Remember, the Group Position simply gives the position of the group itself
  1569. /// </summary>
  1570. /// <returns>A Linked Child Prim objects position in world</returns>
  1571. public Vector3 GetWorldPosition()
  1572. {
  1573. Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
  1574. Vector3 axPos = OffsetPosition;
  1575. axPos *= parentRot;
  1576. Vector3 translationOffsetPosition = axPos;
  1577. return GroupPosition + translationOffsetPosition;
  1578. }
  1579. /// <summary>
  1580. /// Gets the rotation of this prim offset by the group rotation
  1581. /// </summary>
  1582. /// <returns></returns>
  1583. public Quaternion GetWorldRotation()
  1584. {
  1585. Quaternion newRot;
  1586. if (this.LinkNum == 0)
  1587. {
  1588. newRot = RotationOffset;
  1589. }
  1590. else
  1591. {
  1592. Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
  1593. Quaternion oldRot = RotationOffset;
  1594. newRot = parentRot * oldRot;
  1595. }
  1596. return newRot;
  1597. }
  1598. public void MoveToTarget(Vector3 target, float tau)
  1599. {
  1600. if (tau > 0)
  1601. {
  1602. m_parentGroup.moveToTarget(target, tau);
  1603. }
  1604. else
  1605. {
  1606. StopMoveToTarget();
  1607. }
  1608. }
  1609. public virtual void OnGrab(Vector3 offsetPos, IClientAPI remoteClient)
  1610. {
  1611. }
  1612. public void PhysicsCollision(EventArgs e)
  1613. {
  1614. // single threaded here
  1615. if (e == null)
  1616. {
  1617. return;
  1618. }
  1619. CollisionEventUpdate a = (CollisionEventUpdate)e;
  1620. Dictionary<uint, float> collissionswith = a.m_objCollisionList;
  1621. List<uint> thisHitColliders = new List<uint>();
  1622. List<uint> endedColliders = new List<uint>();
  1623. List<uint> startedColliders = new List<uint>();
  1624. // calculate things that started colliding this time
  1625. // and build up list of colliders this time
  1626. foreach (uint localid in collissionswith.Keys)
  1627. {
  1628. if (localid != 0)
  1629. {
  1630. thisHitColliders.Add(localid);
  1631. if (!m_lastColliders.Contains(localid))
  1632. {
  1633. startedColliders.Add(localid);
  1634. }
  1635. //m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
  1636. }
  1637. }
  1638. // calculate things that ended colliding
  1639. foreach (uint localID in m_lastColliders)
  1640. {
  1641. if (!thisHitColliders.Contains(localID))
  1642. {
  1643. endedColliders.Add(localID);
  1644. }
  1645. }
  1646. //add the items that started colliding this time to the last colliders list.
  1647. foreach (uint localID in startedColliders)
  1648. {
  1649. m_lastColliders.Add(localID);
  1650. }
  1651. // remove things that ended colliding from the last colliders list
  1652. foreach (uint localID in endedColliders)
  1653. {
  1654. m_lastColliders.Remove(localID);
  1655. }
  1656. if (m_parentGroup == null)
  1657. return;
  1658. if (m_parentGroup.IsDeleted)
  1659. return;
  1660. // play the sound.
  1661. if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f)
  1662. {
  1663. SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0);
  1664. }
  1665. if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0)
  1666. {
  1667. // do event notification
  1668. if (startedColliders.Count > 0)
  1669. {
  1670. ColliderArgs StartCollidingMessage = new ColliderArgs();
  1671. List<DetectedObject> colliding = new List<DetectedObject>();
  1672. foreach (uint localId in startedColliders)
  1673. {
  1674. // always running this check because if the user deletes the object it would return a null reference.
  1675. if (m_parentGroup == null)
  1676. return;
  1677. if (m_parentGroup.Scene == null)
  1678. return;
  1679. SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
  1680. if (obj != null)
  1681. {
  1682. DetectedObject detobj = new DetectedObject();
  1683. detobj.keyUUID = obj.UUID;
  1684. detobj.nameStr = obj.Name;
  1685. detobj.ownerUUID = obj._ownerID;
  1686. detobj.posVector = obj.AbsolutePosition;
  1687. detobj.rotQuat = obj.GetWorldRotation();
  1688. detobj.velVector = obj.Velocity;
  1689. detobj.colliderType = 0;
  1690. detobj.groupUUID = obj._groupID;
  1691. colliding.Add(detobj);
  1692. }
  1693. else
  1694. {
  1695. List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences();
  1696. if (avlist != null)
  1697. {
  1698. foreach (ScenePresence av in avlist)
  1699. {
  1700. if (av.LocalId == localId)
  1701. {
  1702. DetectedObject detobj = new DetectedObject();
  1703. detobj.keyUUID = av.UUID;
  1704. detobj.nameStr = av.ControllingClient.Name;
  1705. detobj.ownerUUID = av.UUID;
  1706. detobj.posVector = av.AbsolutePosition;
  1707. detobj.rotQuat = av.Rotation;
  1708. detobj.velVector = av.Velocity;
  1709. detobj.colliderType = 0;
  1710. detobj.groupUUID = av.ControllingClient.ActiveGroupId;
  1711. colliding.Add(detobj);
  1712. }
  1713. }
  1714. }
  1715. }
  1716. }
  1717. if (colliding.Count > 0)
  1718. {
  1719. StartCollidingMessage.Colliders = colliding;
  1720. // always running this check because if the user deletes the object it would return a null reference.
  1721. if (m_parentGroup == null)
  1722. return;
  1723. if (m_parentGroup.Scene == null)
  1724. return;
  1725. m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, StartCollidingMessage);
  1726. }
  1727. }
  1728. }
  1729. if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision) != 0)
  1730. {
  1731. if (m_lastColliders.Count > 0)
  1732. {
  1733. ColliderArgs CollidingMessage = new ColliderArgs();
  1734. List<DetectedObject> colliding = new List<DetectedObject>();
  1735. foreach (uint localId in m_lastColliders)
  1736. {
  1737. // always running this check because if the user deletes the object it would return a null reference.
  1738. if (localId == 0)
  1739. continue;
  1740. if (m_parentGroup == null)
  1741. return;
  1742. if (m_parentGroup.Scene == null)
  1743. return;
  1744. SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
  1745. if (obj != null)
  1746. {
  1747. DetectedObject detobj = new DetectedObject();
  1748. detobj.keyUUID = obj.UUID;
  1749. detobj.nameStr = obj.Name;
  1750. detobj.ownerUUID = obj._ownerID;
  1751. detobj.posVector = obj.AbsolutePosition;
  1752. detobj.rotQuat = obj.GetWorldRotation();
  1753. detobj.velVector = obj.Velocity;
  1754. detobj.colliderType = 0;
  1755. detobj.groupUUID = obj._groupID;
  1756. colliding.Add(detobj);
  1757. }
  1758. else
  1759. {
  1760. List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences();
  1761. if (avlist != null)
  1762. {
  1763. foreach (ScenePresence av in avlist)
  1764. {
  1765. if (av.LocalId == localId)
  1766. {
  1767. DetectedObject detobj = new DetectedObject();
  1768. detobj.keyUUID = av.UUID;
  1769. detobj.nameStr = av.Name;
  1770. detobj.ownerUUID = av.UUID;
  1771. detobj.posVector = av.AbsolutePosition;
  1772. detobj.rotQuat = av.Rotation;
  1773. detobj.velVector = av.Velocity;
  1774. detobj.colliderType = 0;
  1775. detobj.groupUUID = av.ControllingClient.ActiveGroupId;
  1776. colliding.Add(detobj);
  1777. }
  1778. }
  1779. }
  1780. }
  1781. }
  1782. if (colliding.Count > 0)
  1783. {
  1784. CollidingMessage.Colliders = colliding;
  1785. // always running this check because if the user deletes the object it would return a null reference.
  1786. if (m_parentGroup == null)
  1787. return;
  1788. if (m_parentGroup.Scene == null)
  1789. return;
  1790. m_parentGroup.Scene.EventManager.TriggerScriptColliding(LocalId, CollidingMessage);
  1791. }
  1792. }
  1793. }
  1794. if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_end) != 0)
  1795. {
  1796. if (endedColliders.Count > 0)
  1797. {
  1798. ColliderArgs EndCollidingMessage = new ColliderArgs();
  1799. List<DetectedObject> colliding = new List<DetectedObject>();
  1800. foreach (uint localId in endedColliders)
  1801. {
  1802. if (localId == 0)
  1803. continue;
  1804. // always running this check because if the user deletes the object it would return a null reference.
  1805. if (m_parentGroup == null)
  1806. return;
  1807. if (m_parentGroup.Scene == null)
  1808. return;
  1809. SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
  1810. if (obj != null)
  1811. {
  1812. DetectedObject detobj = new DetectedObject();
  1813. detobj.keyUUID = obj.UUID;
  1814. detobj.nameStr = obj.Name;
  1815. detobj.ownerUUID = obj._ownerID;
  1816. detobj.posVector = obj.AbsolutePosition;
  1817. detobj.rotQuat = obj.GetWorldRotation();
  1818. detobj.velVector = obj.Velocity;
  1819. detobj.colliderType = 0;
  1820. detobj.groupUUID = obj._groupID;
  1821. colliding.Add(detobj);
  1822. }
  1823. else
  1824. {
  1825. List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences();
  1826. if (avlist != null)
  1827. {
  1828. foreach (ScenePresence av in avlist)
  1829. {
  1830. if (av.LocalId == localId)
  1831. {
  1832. DetectedObject detobj = new DetectedObject();
  1833. detobj.keyUUID = av.UUID;
  1834. detobj.nameStr = av.Name;
  1835. detobj.ownerUUID = av.UUID;
  1836. detobj.posVector = av.AbsolutePosition;
  1837. detobj.rotQuat = av.Rotation;
  1838. detobj.velVector = av.Velocity;
  1839. detobj.colliderType = 0;
  1840. detobj.groupUUID = av.ControllingClient.ActiveGroupId;
  1841. colliding.Add(detobj);
  1842. }
  1843. }
  1844. }
  1845. }
  1846. }
  1847. if (colliding.Count > 0)
  1848. {
  1849. EndCollidingMessage.Colliders = colliding;
  1850. // always running this check because if the user deletes the object it would return a null reference.
  1851. if (m_parentGroup == null)
  1852. return;
  1853. if (m_parentGroup.Scene == null)
  1854. return;
  1855. m_parentGroup.Scene.EventManager.TriggerScriptCollidingEnd(LocalId, EndCollidingMessage);
  1856. }
  1857. }
  1858. }
  1859. }
  1860. public void PhysicsOutOfBounds(PhysicsVector pos)
  1861. {
  1862. m_log.Info("[PHYSICS]: Physical Object went out of bounds.");
  1863. RemFlag(PrimFlags.Physics);
  1864. DoPhysicsPropertyUpdate(false, true);
  1865. //m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  1866. }
  1867. public void PhysicsRequestingTerseUpdate()
  1868. {
  1869. if (PhysActor != null)
  1870. {
  1871. Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0);
  1872. if (newpos.X > 257f || newpos.X < -1f || newpos.Y > 257f || newpos.Y < -1f)
  1873. {
  1874. m_parentGroup.AbsolutePosition = newpos;
  1875. return;
  1876. }
  1877. }
  1878. ScheduleTerseUpdate();
  1879. //SendTerseUpdateToAllClients();
  1880. }
  1881. public void PreloadSound(string sound)
  1882. {
  1883. // UUID ownerID = OwnerID;
  1884. UUID objectID = UUID;
  1885. UUID soundID = UUID.Zero;
  1886. if (!UUID.TryParse(sound, out soundID))
  1887. {
  1888. //Trys to fetch sound id from prim's inventory.
  1889. //Prim's inventory doesn't support non script items yet
  1890. lock (TaskInventory)
  1891. {
  1892. foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
  1893. {
  1894. if (item.Value.Name == sound)
  1895. {
  1896. soundID = item.Value.ItemID;
  1897. break;
  1898. }
  1899. }
  1900. }
  1901. }
  1902. List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
  1903. foreach (ScenePresence p in avatarts)
  1904. {
  1905. // TODO: some filtering by distance of avatar
  1906. p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
  1907. }
  1908. }
  1909. public void RemFlag(PrimFlags flag)
  1910. {
  1911. // PrimFlags prevflag = Flags;
  1912. if ((ObjectFlags & (uint) flag) != 0)
  1913. {
  1914. //m_log.Debug("Removing flag: " + ((PrimFlags)flag).ToString());
  1915. _flags &= ~flag;
  1916. }
  1917. //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
  1918. //ScheduleFullUpdate();
  1919. }
  1920. public void RemoveScriptEvents(UUID scriptid)
  1921. {
  1922. lock (m_scriptEvents)
  1923. {
  1924. if (m_scriptEvents.ContainsKey(scriptid))
  1925. {
  1926. scriptEvents oldparts = scriptEvents.None;
  1927. oldparts = (scriptEvents) m_scriptEvents[scriptid];
  1928. // remove values from aggregated script events
  1929. AggregateScriptEvents &= ~oldparts;
  1930. m_scriptEvents.Remove(scriptid);
  1931. aggregateScriptEvents();
  1932. }
  1933. }
  1934. }
  1935. /// <summary>
  1936. /// Reset UUIDs for this part. This involves generate this part's own UUID and
  1937. /// generating new UUIDs for all the items in the inventory.
  1938. /// </summary>
  1939. /// <param name="linkNum">Link number for the part</param>
  1940. public void ResetIDs(int linkNum)
  1941. {
  1942. UUID = UUID.Random();
  1943. LinkNum = linkNum;
  1944. LocalId = 0;
  1945. Inventory.ResetInventoryIDs();
  1946. }
  1947. /// <summary>
  1948. /// Resize this part.
  1949. /// </summary>
  1950. /// <param name="scale"></param>
  1951. public void Resize(Vector3 scale)
  1952. {
  1953. StoreUndoState();
  1954. m_shape.Scale = scale;
  1955. ParentGroup.HasGroupChanged = true;
  1956. ScheduleFullUpdate();
  1957. }
  1958. /// <summary>
  1959. /// Schedules this prim for a full update
  1960. /// </summary>
  1961. public void ScheduleFullUpdate()
  1962. {
  1963. if (m_parentGroup != null)
  1964. {
  1965. m_parentGroup.QueueForUpdateCheck();
  1966. }
  1967. int timeNow = Util.UnixTimeSinceEpoch();
  1968. // If multiple updates are scheduled on the same second, we still need to perform all of them
  1969. // So we'll force the issue by bumping up the timestamp so that later processing sees these need
  1970. // to be performed.
  1971. if (timeNow <= TimeStampFull)
  1972. {
  1973. TimeStampFull += 1;
  1974. }
  1975. else
  1976. {
  1977. TimeStampFull = (uint)timeNow;
  1978. }
  1979. m_updateFlag = 2;
  1980. // m_log.DebugFormat(
  1981. // "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}",
  1982. // UUID, Name, TimeStampFull);
  1983. }
  1984. /// <summary>
  1985. /// Schedule a terse update for this prim. Terse updates only send position,
  1986. /// rotation, velocity, rotational velocity and shape information.
  1987. /// </summary>
  1988. public void ScheduleTerseUpdate()
  1989. {
  1990. if (m_updateFlag < 1)
  1991. {
  1992. if (m_parentGroup != null)
  1993. {
  1994. m_parentGroup.HasGroupChanged = true;
  1995. m_parentGroup.QueueForUpdateCheck();
  1996. }
  1997. TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
  1998. m_updateFlag = 1;
  1999. // m_log.DebugFormat(
  2000. // "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}",
  2001. // UUID, Name, TimeStampTerse);
  2002. }
  2003. }
  2004. public void ScriptSetPhantomStatus(bool Phantom)
  2005. {
  2006. if (m_parentGroup != null)
  2007. {
  2008. m_parentGroup.ScriptSetPhantomStatus(Phantom);
  2009. }
  2010. }
  2011. public void ScriptSetTemporaryStatus(bool Temporary)
  2012. {
  2013. if (m_parentGroup != null)
  2014. {
  2015. m_parentGroup.ScriptSetTemporaryStatus(Temporary);
  2016. }
  2017. }
  2018. public void ScriptSetPhysicsStatus(bool UsePhysics)
  2019. {
  2020. if (m_parentGroup == null)
  2021. DoPhysicsPropertyUpdate(UsePhysics, false);
  2022. else
  2023. m_parentGroup.ScriptSetPhysicsStatus(UsePhysics);
  2024. }
  2025. public void ScriptSetVolumeDetect(bool SetVD)
  2026. {
  2027. if (m_parentGroup != null)
  2028. {
  2029. m_parentGroup.ScriptSetVolumeDetect(SetVD);
  2030. }
  2031. }
  2032. public void SculptTextureCallback(UUID textureID, AssetBase texture)
  2033. {
  2034. if (m_shape.SculptEntry)
  2035. {
  2036. if (texture != null)
  2037. {
  2038. m_shape.SculptData = texture.Data;
  2039. if (PhysActor != null)
  2040. {
  2041. // Tricks physics engine into thinking we've changed the part shape.
  2042. PrimitiveBaseShape m_newshape = m_shape.Copy();
  2043. PhysActor.Shape = m_newshape;
  2044. m_shape = m_newshape;
  2045. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  2046. }
  2047. }
  2048. }
  2049. }
  2050. /// <summary>
  2051. ///
  2052. /// </summary>
  2053. /// <param name="remoteClient"></param>
  2054. public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
  2055. {
  2056. m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
  2057. }
  2058. /// <summary>
  2059. ///
  2060. /// </summary>
  2061. public void SendFullUpdateToAllClients()
  2062. {
  2063. List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
  2064. for (int i = 0; i < avatars.Count; i++)
  2065. {
  2066. // Ugly reference :(
  2067. m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
  2068. avatars[i].GenerateClientFlags(UUID));
  2069. }
  2070. }
  2071. public void SendFullUpdateToAllClientsExcept(UUID agentID)
  2072. {
  2073. List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
  2074. for (int i = 0; i < avatars.Count; i++)
  2075. {
  2076. // Ugly reference :(
  2077. if (avatars[i].UUID != agentID)
  2078. {
  2079. m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
  2080. avatars[i].GenerateClientFlags(UUID));
  2081. }
  2082. }
  2083. }
  2084. /// <summary>
  2085. /// Sends a full update to the client
  2086. /// </summary>
  2087. /// <param name="remoteClient"></param>
  2088. /// <param name="clientFlags"></param>
  2089. public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientflags)
  2090. {
  2091. Vector3 lPos;
  2092. lPos = OffsetPosition;
  2093. SendFullUpdateToClient(remoteClient, lPos, clientflags);
  2094. }
  2095. /// <summary>
  2096. /// Sends a full update to the client
  2097. /// </summary>
  2098. /// <param name="remoteClient"></param>
  2099. /// <param name="lPos"></param>
  2100. /// <param name="clientFlags"></param>
  2101. public void SendFullUpdateToClient(IClientAPI remoteClient, Vector3 lPos, uint clientFlags)
  2102. {
  2103. // Suppress full updates during attachment editing
  2104. //
  2105. if (ParentGroup.IsSelected && IsAttachment)
  2106. return;
  2107. if (ParentGroup.IsDeleted)
  2108. return;
  2109. clientFlags &= ~(uint) PrimFlags.CreateSelected;
  2110. if (remoteClient.AgentId == _ownerID)
  2111. {
  2112. if ((uint) (_flags & PrimFlags.CreateSelected) != 0)
  2113. {
  2114. clientFlags |= (uint) PrimFlags.CreateSelected;
  2115. _flags &= ~PrimFlags.CreateSelected;
  2116. }
  2117. }
  2118. //bool isattachment = IsAttachment;
  2119. //if (LocalId != ParentGroup.RootPart.LocalId)
  2120. //isattachment = ParentGroup.RootPart.IsAttachment;
  2121. byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
  2122. remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape,
  2123. lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID,
  2124. m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment,
  2125. AttachmentPoint,FromAssetID, Sound, SoundGain, SoundFlags, SoundRadius);
  2126. }
  2127. /// <summary>
  2128. /// Tell all the prims which have had updates scheduled
  2129. /// </summary>
  2130. public void SendScheduledUpdates()
  2131. {
  2132. if (m_updateFlag == 1) //some change has been made so update the clients
  2133. {
  2134. AddTerseUpdateToAllAvatars();
  2135. ClearUpdateSchedule();
  2136. // This causes the Scene to 'poll' physical objects every couple of frames
  2137. // bad, so it's been replaced by an event driven method.
  2138. //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0)
  2139. //{
  2140. // Only send the constant terse updates on physical objects!
  2141. //ScheduleTerseUpdate();
  2142. //}
  2143. }
  2144. else
  2145. {
  2146. if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
  2147. {
  2148. AddFullUpdateToAllAvatars();
  2149. ClearUpdateSchedule();
  2150. }
  2151. }
  2152. }
  2153. /// <summary>
  2154. /// Trigger or play an attached sound in this part's inventory.
  2155. /// </summary>
  2156. /// <param name="sound"></param>
  2157. /// <param name="volume"></param>
  2158. /// <param name="triggered"></param>
  2159. /// <param name="flags"></param>
  2160. public void SendSound(string sound, double volume, bool triggered, byte flags)
  2161. {
  2162. if (volume > 1)
  2163. volume = 1;
  2164. if (volume < 0)
  2165. volume = 0;
  2166. UUID ownerID = _ownerID;
  2167. UUID objectID = UUID;
  2168. UUID parentID = GetRootPartUUID();
  2169. UUID soundID = UUID.Zero;
  2170. Vector3 position = AbsolutePosition; // region local
  2171. ulong regionHandle = m_parentGroup.Scene.RegionInfo.RegionHandle;
  2172. if (!UUID.TryParse(sound, out soundID))
  2173. {
  2174. // search sound file from inventory
  2175. lock (TaskInventory)
  2176. {
  2177. foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
  2178. {
  2179. if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
  2180. {
  2181. soundID = item.Value.ItemID;
  2182. break;
  2183. }
  2184. }
  2185. }
  2186. }
  2187. if (soundID == UUID.Zero)
  2188. return;
  2189. ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>();
  2190. if (soundModule != null)
  2191. {
  2192. if (triggered)
  2193. soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle);
  2194. else
  2195. soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags);
  2196. }
  2197. }
  2198. /// <summary>
  2199. /// Send a terse update to all clients
  2200. /// </summary>
  2201. public void SendTerseUpdateToAllClients()
  2202. {
  2203. List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
  2204. for (int i = 0; i < avatars.Count; i++)
  2205. {
  2206. SendTerseUpdateToClient(avatars[i].ControllingClient);
  2207. }
  2208. }
  2209. public void SetAttachmentPoint(uint AttachmentPoint)
  2210. {
  2211. this.AttachmentPoint = AttachmentPoint;
  2212. if (AttachmentPoint != 0)
  2213. {
  2214. IsAttachment = true;
  2215. }
  2216. else
  2217. {
  2218. IsAttachment = false;
  2219. }
  2220. // save the attachment point.
  2221. //if (AttachmentPoint != 0)
  2222. //{
  2223. m_shape.State = (byte)AttachmentPoint;
  2224. //}
  2225. }
  2226. public void SetAvatarOnSitTarget(UUID avatarID)
  2227. {
  2228. m_sitTargetAvatar = avatarID;
  2229. if (ParentGroup != null)
  2230. ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
  2231. }
  2232. public void SetAxisRotation(int axis, int rotate)
  2233. {
  2234. if (m_parentGroup != null)
  2235. {
  2236. m_parentGroup.SetAxisRotation(axis, rotate);
  2237. }
  2238. }
  2239. public void SetBuoyancy(float fvalue)
  2240. {
  2241. if (PhysActor != null)
  2242. {
  2243. PhysActor.Buoyancy = fvalue;
  2244. }
  2245. }
  2246. public void SetDieAtEdge(bool p)
  2247. {
  2248. if (m_parentGroup == null)
  2249. return;
  2250. if (m_parentGroup.IsDeleted)
  2251. return;
  2252. m_parentGroup.RootPart.DIE_AT_EDGE = p;
  2253. }
  2254. public void SetFloatOnWater(int floatYN)
  2255. {
  2256. if (PhysActor != null)
  2257. {
  2258. if (floatYN == 1)
  2259. {
  2260. PhysActor.FloatOnWater = true;
  2261. }
  2262. else
  2263. {
  2264. PhysActor.FloatOnWater = false;
  2265. }
  2266. }
  2267. }
  2268. public void SetForce(PhysicsVector force)
  2269. {
  2270. if (PhysActor != null)
  2271. {
  2272. PhysActor.Force = force;
  2273. }
  2274. }
  2275. public void SetVehicleType(int type)
  2276. {
  2277. if (PhysActor != null)
  2278. {
  2279. PhysActor.VehicleType = type;
  2280. }
  2281. }
  2282. public void SetVehicleFloatParam(int param, float value)
  2283. {
  2284. if (PhysActor != null)
  2285. {
  2286. PhysActor.VehicleFloatParam(param, value);
  2287. }
  2288. }
  2289. public void SetVehicleVectorParam(int param, PhysicsVector value)
  2290. {
  2291. if (PhysActor != null)
  2292. {
  2293. PhysActor.VehicleVectorParam(param, value);
  2294. }
  2295. }
  2296. public void SetVehicleRotationParam(int param, Quaternion rotation)
  2297. {
  2298. if (PhysActor != null)
  2299. {
  2300. PhysActor.VehicleRotationParam(param, rotation);
  2301. }
  2302. }
  2303. public void SetGroup(UUID groupID, IClientAPI client)
  2304. {
  2305. _groupID = groupID;
  2306. if (client != null)
  2307. GetProperties(client);
  2308. m_updateFlag = 2;
  2309. }
  2310. /// <summary>
  2311. ///
  2312. /// </summary>
  2313. public void SetParent(SceneObjectGroup parent)
  2314. {
  2315. m_parentGroup = parent;
  2316. }
  2317. // Use this for attachments! LocalID should be avatar's localid
  2318. public void SetParentLocalId(uint localID)
  2319. {
  2320. _parentID = localID;
  2321. }
  2322. public void SetPhysicsAxisRotation()
  2323. {
  2324. if (PhysActor != null)
  2325. {
  2326. PhysActor.LockAngularMotion(RotationAxis);
  2327. m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
  2328. }
  2329. }
  2330. public void SetScriptEvents(UUID scriptid, int events)
  2331. {
  2332. // scriptEvents oldparts;
  2333. lock (m_scriptEvents)
  2334. {
  2335. if (m_scriptEvents.ContainsKey(scriptid))
  2336. {
  2337. // oldparts = m_scriptEvents[scriptid];
  2338. // remove values from aggregated script events
  2339. if (m_scriptEvents[scriptid] == (scriptEvents) events)
  2340. return;
  2341. m_scriptEvents[scriptid] = (scriptEvents) events;
  2342. }
  2343. else
  2344. {
  2345. m_scriptEvents.Add(scriptid, (scriptEvents) events);
  2346. }
  2347. }
  2348. aggregateScriptEvents();
  2349. }
  2350. /// <summary>
  2351. /// Set the text displayed for this part.
  2352. /// </summary>
  2353. /// <param name="text"></param>
  2354. public void SetText(string text)
  2355. {
  2356. Text = text;
  2357. ParentGroup.HasGroupChanged = true;
  2358. ScheduleFullUpdate();
  2359. }
  2360. /// <summary>
  2361. /// Set the text displayed for this part.
  2362. /// </summary>
  2363. /// <param name="text"></param>
  2364. /// <param name="color"></param>
  2365. /// <param name="alpha"></param>
  2366. public void SetText(string text, Vector3 color, double alpha)
  2367. {
  2368. Color = Color.FromArgb(0xff - (int) (alpha*0xff),
  2369. (int) (color.X*0xff),
  2370. (int) (color.Y*0xff),
  2371. (int) (color.Z*0xff));
  2372. SetText(text);
  2373. }
  2374. public void StopMoveToTarget()
  2375. {
  2376. m_parentGroup.stopMoveToTarget();
  2377. m_parentGroup.ScheduleGroupForTerseUpdate();
  2378. //m_parentGroup.ScheduleGroupForFullUpdate();
  2379. }
  2380. public void StoreUndoState()
  2381. {
  2382. if (!Undoing)
  2383. {
  2384. if (m_parentGroup != null)
  2385. {
  2386. lock (m_undo)
  2387. {
  2388. if (m_undo.Count > 0)
  2389. {
  2390. UndoState last = m_undo.Peek();
  2391. if (last != null)
  2392. {
  2393. if (last.Compare(this))
  2394. return;
  2395. }
  2396. }
  2397. if (m_parentGroup.GetSceneMaxUndo() > 0)
  2398. {
  2399. UndoState nUndo = new UndoState(this);
  2400. m_undo.Push(nUndo);
  2401. }
  2402. }
  2403. }
  2404. }
  2405. }
  2406. public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
  2407. {
  2408. // In this case we're using a sphere with a radius of the largest dimention of the prim
  2409. // TODO: Change to take shape into account
  2410. EntityIntersection returnresult = new EntityIntersection();
  2411. Vector3 vAbsolutePosition = AbsolutePosition;
  2412. Vector3 vScale = Scale;
  2413. Vector3 rOrigin = iray.Origin;
  2414. Vector3 rDirection = iray.Direction;
  2415. //rDirection = rDirection.Normalize();
  2416. // Buidling the first part of the Quadratic equation
  2417. Vector3 r2ndDirection = rDirection*rDirection;
  2418. float itestPart1 = r2ndDirection.X + r2ndDirection.Y + r2ndDirection.Z;
  2419. // Buidling the second part of the Quadratic equation
  2420. Vector3 tmVal2 = rOrigin - vAbsolutePosition;
  2421. Vector3 r2Direction = rDirection*2.0f;
  2422. Vector3 tmVal3 = r2Direction*tmVal2;
  2423. float itestPart2 = tmVal3.X + tmVal3.Y + tmVal3.Z;
  2424. // Buidling the third part of the Quadratic equation
  2425. Vector3 tmVal4 = rOrigin*rOrigin;
  2426. Vector3 tmVal5 = vAbsolutePosition*vAbsolutePosition;
  2427. Vector3 tmVal6 = vAbsolutePosition*rOrigin;
  2428. // Set Radius to the largest dimention of the prim
  2429. float radius = 0f;
  2430. if (vScale.X > radius)
  2431. radius = vScale.X;
  2432. if (vScale.Y > radius)
  2433. radius = vScale.Y;
  2434. if (vScale.Z > radius)
  2435. radius = vScale.Z;
  2436. // the second part of this is the default prim size
  2437. // once we factor in the aabb of the prim we're adding we can
  2438. // change this to;
  2439. // radius = (radius / 2) - 0.01f;
  2440. //
  2441. radius = (radius / 2) + (0.5f / 2) - 0.1f;
  2442. //radius = radius;
  2443. float itestPart3 = tmVal4.X + tmVal4.Y + tmVal4.Z + tmVal5.X + tmVal5.Y + tmVal5.Z -
  2444. (2.0f*(tmVal6.X + tmVal6.Y + tmVal6.Z + (radius*radius)));
  2445. // Yuk Quadradrics.. Solve first
  2446. float rootsqr = (itestPart2*itestPart2) - (4.0f*itestPart1*itestPart3);
  2447. if (rootsqr < 0.0f)
  2448. {
  2449. // No intersection
  2450. return returnresult;
  2451. }
  2452. float root = ((-itestPart2) - (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f);
  2453. if (root < 0.0f)
  2454. {
  2455. // perform second quadratic root solution
  2456. root = ((-itestPart2) + (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f);
  2457. // is there any intersection?
  2458. if (root < 0.0f)
  2459. {
  2460. // nope, no intersection
  2461. return returnresult;
  2462. }
  2463. }
  2464. // We got an intersection. putting together an EntityIntersection object with the
  2465. // intersection information
  2466. Vector3 ipoint =
  2467. new Vector3(iray.Origin.X + (iray.Direction.X*root), iray.Origin.Y + (iray.Direction.Y*root),
  2468. iray.Origin.Z + (iray.Direction.Z*root));
  2469. returnresult.HitTF = true;
  2470. returnresult.ipoint = ipoint;
  2471. // Normal is calculated by the difference and then normalizing the result
  2472. Vector3 normalpart = ipoint - vAbsolutePosition;
  2473. returnresult.normal = normalpart / normalpart.Length();
  2474. // It's funny how the Vector3 object has a Distance function, but the Axiom.Math object doesn't.
  2475. // I can write a function to do it.. but I like the fact that this one is Static.
  2476. Vector3 distanceConvert1 = new Vector3(iray.Origin.X, iray.Origin.Y, iray.Origin.Z);
  2477. Vector3 distanceConvert2 = new Vector3(ipoint.X, ipoint.Y, ipoint.Z);
  2478. float distance = (float) Util.GetDistanceTo(distanceConvert1, distanceConvert2);
  2479. returnresult.distance = distance;
  2480. return returnresult;
  2481. }
  2482. public EntityIntersection TestIntersectionOBB(Ray iray, Quaternion parentrot, bool frontFacesOnly, bool faceCenters)
  2483. {
  2484. // In this case we're using a rectangular prism, which has 6 faces and therefore 6 planes
  2485. // This breaks down into the ray---> plane equation.
  2486. // TODO: Change to take shape into account
  2487. Vector3[] vertexes = new Vector3[8];
  2488. // float[] distance = new float[6];
  2489. Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
  2490. Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
  2491. Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
  2492. Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
  2493. Vector3[] normals = new Vector3[6]; // Normal for Facei
  2494. Vector3[] AAfacenormals = new Vector3[6]; // Axis Aligned face normals
  2495. AAfacenormals[0] = new Vector3(1, 0, 0);
  2496. AAfacenormals[1] = new Vector3(0, 1, 0);
  2497. AAfacenormals[2] = new Vector3(-1, 0, 0);
  2498. AAfacenormals[3] = new Vector3(0, -1, 0);
  2499. AAfacenormals[4] = new Vector3(0, 0, 1);
  2500. AAfacenormals[5] = new Vector3(0, 0, -1);
  2501. Vector3 AmBa = new Vector3(0, 0, 0); // Vertex A - Vertex B
  2502. Vector3 AmBb = new Vector3(0, 0, 0); // Vertex B - Vertex C
  2503. Vector3 cross = new Vector3();
  2504. Vector3 pos = GetWorldPosition();
  2505. Quaternion rot = GetWorldRotation();
  2506. // Variables prefixed with AX are Axiom.Math copies of the LL variety.
  2507. Quaternion AXrot = rot;
  2508. AXrot.Normalize();
  2509. Vector3 AXpos = pos;
  2510. // tScale is the offset to derive the vertex based on the scale.
  2511. // it's different for each vertex because we've got to rotate it
  2512. // to get the world position of the vertex to produce the Oriented Bounding Box
  2513. Vector3 tScale = Vector3.Zero;
  2514. Vector3 AXscale = new Vector3(m_shape.Scale.X * 0.5f, m_shape.Scale.Y * 0.5f, m_shape.Scale.Z * 0.5f);
  2515. //Vector3 pScale = (AXscale) - (AXrot.Inverse() * (AXscale));
  2516. //Vector3 nScale = (AXscale * -1) - (AXrot.Inverse() * (AXscale * -1));
  2517. // rScale is the rotated offset to find a vertex based on the scale and the world rotation.
  2518. Vector3 rScale = new Vector3();
  2519. // Get Vertexes for Faces Stick them into ABCD for each Face
  2520. // Form: Face<vertex>[face] that corresponds to the below diagram
  2521. #region ABCD Face Vertex Map Comment Diagram
  2522. // A _________ B
  2523. // | |
  2524. // | 4 top |
  2525. // |_________|
  2526. // C D
  2527. // A _________ B
  2528. // | Back |
  2529. // | 3 |
  2530. // |_________|
  2531. // C D
  2532. // A _________ B B _________ A
  2533. // | Left | | Right |
  2534. // | 0 | | 2 |
  2535. // |_________| |_________|
  2536. // C D D C
  2537. // A _________ B
  2538. // | Front |
  2539. // | 1 |
  2540. // |_________|
  2541. // C D
  2542. // C _________ D
  2543. // | |
  2544. // | 5 bot |
  2545. // |_________|
  2546. // A B
  2547. #endregion
  2548. #region Plane Decomposition of Oriented Bounding Box
  2549. tScale = new Vector3(AXscale.X, -AXscale.Y, AXscale.Z);
  2550. rScale = tScale * AXrot;
  2551. vertexes[0] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2552. // vertexes[0].X = pos.X + vertexes[0].X;
  2553. //vertexes[0].Y = pos.Y + vertexes[0].Y;
  2554. //vertexes[0].Z = pos.Z + vertexes[0].Z;
  2555. FaceA[0] = vertexes[0];
  2556. FaceB[3] = vertexes[0];
  2557. FaceA[4] = vertexes[0];
  2558. tScale = AXscale;
  2559. rScale = tScale * AXrot;
  2560. vertexes[1] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2561. // vertexes[1].X = pos.X + vertexes[1].X;
  2562. // vertexes[1].Y = pos.Y + vertexes[1].Y;
  2563. //vertexes[1].Z = pos.Z + vertexes[1].Z;
  2564. FaceB[0] = vertexes[1];
  2565. FaceA[1] = vertexes[1];
  2566. FaceC[4] = vertexes[1];
  2567. tScale = new Vector3(AXscale.X, -AXscale.Y, -AXscale.Z);
  2568. rScale = tScale * AXrot;
  2569. vertexes[2] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2570. //vertexes[2].X = pos.X + vertexes[2].X;
  2571. //vertexes[2].Y = pos.Y + vertexes[2].Y;
  2572. //vertexes[2].Z = pos.Z + vertexes[2].Z;
  2573. FaceC[0] = vertexes[2];
  2574. FaceD[3] = vertexes[2];
  2575. FaceC[5] = vertexes[2];
  2576. tScale = new Vector3(AXscale.X, AXscale.Y, -AXscale.Z);
  2577. rScale = tScale * AXrot;
  2578. vertexes[3] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2579. //vertexes[3].X = pos.X + vertexes[3].X;
  2580. // vertexes[3].Y = pos.Y + vertexes[3].Y;
  2581. // vertexes[3].Z = pos.Z + vertexes[3].Z;
  2582. FaceD[0] = vertexes[3];
  2583. FaceC[1] = vertexes[3];
  2584. FaceA[5] = vertexes[3];
  2585. tScale = new Vector3(-AXscale.X, AXscale.Y, AXscale.Z);
  2586. rScale = tScale * AXrot;
  2587. vertexes[4] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2588. // vertexes[4].X = pos.X + vertexes[4].X;
  2589. // vertexes[4].Y = pos.Y + vertexes[4].Y;
  2590. // vertexes[4].Z = pos.Z + vertexes[4].Z;
  2591. FaceB[1] = vertexes[4];
  2592. FaceA[2] = vertexes[4];
  2593. FaceD[4] = vertexes[4];
  2594. tScale = new Vector3(-AXscale.X, AXscale.Y, -AXscale.Z);
  2595. rScale = tScale * AXrot;
  2596. vertexes[5] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2597. // vertexes[5].X = pos.X + vertexes[5].X;
  2598. // vertexes[5].Y = pos.Y + vertexes[5].Y;
  2599. // vertexes[5].Z = pos.Z + vertexes[5].Z;
  2600. FaceD[1] = vertexes[5];
  2601. FaceC[2] = vertexes[5];
  2602. FaceB[5] = vertexes[5];
  2603. tScale = new Vector3(-AXscale.X, -AXscale.Y, AXscale.Z);
  2604. rScale = tScale * AXrot;
  2605. vertexes[6] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2606. // vertexes[6].X = pos.X + vertexes[6].X;
  2607. // vertexes[6].Y = pos.Y + vertexes[6].Y;
  2608. // vertexes[6].Z = pos.Z + vertexes[6].Z;
  2609. FaceB[2] = vertexes[6];
  2610. FaceA[3] = vertexes[6];
  2611. FaceB[4] = vertexes[6];
  2612. tScale = new Vector3(-AXscale.X, -AXscale.Y, -AXscale.Z);
  2613. rScale = tScale * AXrot;
  2614. vertexes[7] = (new Vector3((pos.X + rScale.X), (pos.Y + rScale.Y), (pos.Z + rScale.Z)));
  2615. // vertexes[7].X = pos.X + vertexes[7].X;
  2616. // vertexes[7].Y = pos.Y + vertexes[7].Y;
  2617. // vertexes[7].Z = pos.Z + vertexes[7].Z;
  2618. FaceD[2] = vertexes[7];
  2619. FaceC[3] = vertexes[7];
  2620. FaceD[5] = vertexes[7];
  2621. #endregion
  2622. // Get our plane normals
  2623. for (int i = 0; i < 6; i++)
  2624. {
  2625. //m_log.Info("[FACECALCULATION]: FaceA[" + i + "]=" + FaceA[i] + " FaceB[" + i + "]=" + FaceB[i] + " FaceC[" + i + "]=" + FaceC[i] + " FaceD[" + i + "]=" + FaceD[i]);
  2626. // Our Plane direction
  2627. AmBa = FaceA[i] - FaceB[i];
  2628. AmBb = FaceB[i] - FaceC[i];
  2629. cross = Vector3.Cross(AmBb, AmBa);
  2630. // normalize the cross product to get the normal.
  2631. normals[i] = cross / cross.Length();
  2632. //m_log.Info("[NORMALS]: normals[ " + i + "]" + normals[i].ToString());
  2633. //distance[i] = (normals[i].X * AmBa.X + normals[i].Y * AmBa.Y + normals[i].Z * AmBa.Z) * -1;
  2634. }
  2635. EntityIntersection returnresult = new EntityIntersection();
  2636. returnresult.distance = 1024;
  2637. float c = 0;
  2638. float a = 0;
  2639. float d = 0;
  2640. Vector3 q = new Vector3();
  2641. #region OBB Version 2 Experiment
  2642. //float fmin = 999999;
  2643. //float fmax = -999999;
  2644. //float s = 0;
  2645. //for (int i=0;i<6;i++)
  2646. //{
  2647. //s = iray.Direction.Dot(normals[i]);
  2648. //d = normals[i].Dot(FaceB[i]);
  2649. //if (s == 0)
  2650. //{
  2651. //if (iray.Origin.Dot(normals[i]) > d)
  2652. //{
  2653. //return returnresult;
  2654. //}
  2655. // else
  2656. //{
  2657. //continue;
  2658. //}
  2659. //}
  2660. //a = (d - iray.Origin.Dot(normals[i])) / s;
  2661. //if (iray.Direction.Dot(normals[i]) < 0)
  2662. //{
  2663. //if (a > fmax)
  2664. //{
  2665. //if (a > fmin)
  2666. //{
  2667. //return returnresult;
  2668. //}
  2669. //fmax = a;
  2670. //}
  2671. //}
  2672. //else
  2673. //{
  2674. //if (a < fmin)
  2675. //{
  2676. //if (a < 0 || a < fmax)
  2677. //{
  2678. //return returnresult;
  2679. //}
  2680. //fmin = a;
  2681. //}
  2682. //}
  2683. //}
  2684. //if (fmax > 0)
  2685. // a= fmax;
  2686. //else
  2687. // a=fmin;
  2688. //q = iray.Origin + a * iray.Direction;
  2689. #endregion
  2690. // Loop over faces (6 of them)
  2691. for (int i = 0; i < 6; i++)
  2692. {
  2693. AmBa = FaceA[i] - FaceB[i];
  2694. AmBb = FaceB[i] - FaceC[i];
  2695. d = Vector3.Dot(normals[i], FaceB[i]);
  2696. //if (faceCenters)
  2697. //{
  2698. // c = normals[i].Dot(normals[i]);
  2699. //}
  2700. //else
  2701. //{
  2702. c = Vector3.Dot(iray.Direction, normals[i]);
  2703. //}
  2704. if (c == 0)
  2705. continue;
  2706. a = (d - Vector3.Dot(iray.Origin, normals[i])) / c;
  2707. if (a < 0)
  2708. continue;
  2709. // If the normal is pointing outside the object
  2710. if (Vector3.Dot(iray.Direction, normals[i]) < 0 || !frontFacesOnly)
  2711. {
  2712. //if (faceCenters)
  2713. //{ //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
  2714. // q = iray.Origin + a * normals[i];
  2715. //}
  2716. //else
  2717. //{
  2718. q = iray.Origin + iray.Direction * a;
  2719. //}
  2720. float distance2 = (float)GetDistanceTo(q, AXpos);
  2721. // Is this the closest hit to the object's origin?
  2722. //if (faceCenters)
  2723. //{
  2724. // distance2 = (float)GetDistanceTo(q, iray.Origin);
  2725. //}
  2726. if (distance2 < returnresult.distance)
  2727. {
  2728. returnresult.distance = distance2;
  2729. returnresult.HitTF = true;
  2730. returnresult.ipoint = q;
  2731. //m_log.Info("[FACE]:" + i.ToString());
  2732. //m_log.Info("[POINT]: " + q.ToString());
  2733. //m_log.Info("[DIST]: " + distance2.ToString());
  2734. if (faceCenters)
  2735. {
  2736. returnresult.normal = AAfacenormals[i] * AXrot;
  2737. Vector3 scaleComponent = AAfacenormals[i];
  2738. float ScaleOffset = 0.5f;
  2739. if (scaleComponent.X != 0) ScaleOffset = AXscale.X;
  2740. if (scaleComponent.Y != 0) ScaleOffset = AXscale.Y;
  2741. if (scaleComponent.Z != 0) ScaleOffset = AXscale.Z;
  2742. ScaleOffset = Math.Abs(ScaleOffset);
  2743. Vector3 offset = returnresult.normal * ScaleOffset;
  2744. returnresult.ipoint = AXpos + offset;
  2745. ///pos = (intersectionpoint + offset);
  2746. }
  2747. else
  2748. {
  2749. returnresult.normal = normals[i];
  2750. }
  2751. returnresult.AAfaceNormal = AAfacenormals[i];
  2752. }
  2753. }
  2754. }
  2755. return returnresult;
  2756. }
  2757. /// <summary>
  2758. /// Serialize this part to xml.
  2759. /// </summary>
  2760. /// <param name="xmlWriter"></param>
  2761. public void ToXml(XmlWriter xmlWriter)
  2762. {
  2763. serializer.Serialize(xmlWriter, this);
  2764. }
  2765. public void TriggerScriptChangedEvent(Changed val)
  2766. {
  2767. if (m_parentGroup != null)
  2768. {
  2769. if (m_parentGroup.Scene != null)
  2770. m_parentGroup.Scene.TriggerObjectChanged(LocalId, (uint)val);
  2771. }
  2772. }
  2773. public void TrimPermissions()
  2774. {
  2775. _baseMask &= (uint)PermissionMask.All;
  2776. _ownerMask &= (uint)PermissionMask.All;
  2777. _groupMask &= (uint)PermissionMask.All;
  2778. _everyoneMask &= (uint)PermissionMask.All;
  2779. _nextOwnerMask &= (uint)PermissionMask.All;
  2780. }
  2781. public void Undo()
  2782. {
  2783. lock (m_undo)
  2784. {
  2785. if (m_undo.Count > 0)
  2786. {
  2787. UndoState goback = m_undo.Pop();
  2788. if (goback != null)
  2789. goback.PlaybackState(this);
  2790. }
  2791. }
  2792. }
  2793. public void UpdateExtraParam(ushort type, bool inUse, byte[] data)
  2794. {
  2795. m_shape.ReadInUpdateExtraParam(type, inUse, data);
  2796. if (type == 0x30)
  2797. {
  2798. if (m_shape.SculptEntry && m_shape.SculptTexture != UUID.Zero)
  2799. {
  2800. m_parentGroup.Scene.CommsManager.AssetCache.GetAsset(
  2801. m_shape.SculptTexture, SculptTextureCallback, true);
  2802. }
  2803. }
  2804. ParentGroup.HasGroupChanged = true;
  2805. ScheduleFullUpdate();
  2806. }
  2807. public void UpdateGroupPosition(Vector3 pos)
  2808. {
  2809. if ((pos.X != GroupPosition.X) ||
  2810. (pos.Y != GroupPosition.Y) ||
  2811. (pos.Z != GroupPosition.Z))
  2812. {
  2813. Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
  2814. GroupPosition = newPos;
  2815. ScheduleTerseUpdate();
  2816. }
  2817. }
  2818. public virtual void UpdateMovement()
  2819. {
  2820. }
  2821. /// <summary>
  2822. ///
  2823. /// </summary>
  2824. /// <param name="pos"></param>
  2825. public void UpdateOffSet(Vector3 pos)
  2826. {
  2827. if ((pos.X != OffsetPosition.X) ||
  2828. (pos.Y != OffsetPosition.Y) ||
  2829. (pos.Z != OffsetPosition.Z))
  2830. {
  2831. Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
  2832. OffsetPosition = newPos;
  2833. ScheduleTerseUpdate();
  2834. }
  2835. }
  2836. public void UpdatePermissions(UUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
  2837. {
  2838. bool set = addRemTF == 1;
  2839. bool god = m_parentGroup.Scene.Permissions.IsGod(AgentID);
  2840. uint baseMask = _baseMask;
  2841. if (god)
  2842. baseMask = 0x7ffffff0;
  2843. // Are we the owner?
  2844. if ((AgentID == _ownerID) || god)
  2845. {
  2846. switch (field)
  2847. {
  2848. case 1:
  2849. if (god)
  2850. {
  2851. _baseMask = ApplyMask(_baseMask, set, mask);
  2852. Inventory.ApplyGodPermissions(_baseMask);
  2853. }
  2854. break;
  2855. case 2:
  2856. _ownerMask = ApplyMask(_ownerMask, set, mask) &
  2857. baseMask;
  2858. break;
  2859. case 4:
  2860. _groupMask = ApplyMask(_groupMask, set, mask) &
  2861. baseMask;
  2862. break;
  2863. case 8:
  2864. _everyoneMask = ApplyMask(_everyoneMask, set, mask) &
  2865. baseMask;
  2866. break;
  2867. case 16:
  2868. _nextOwnerMask = ApplyMask(_nextOwnerMask, set, mask) &
  2869. baseMask;
  2870. break;
  2871. }
  2872. SendFullUpdateToAllClients();
  2873. SendObjectPropertiesToClient(AgentID);
  2874. }
  2875. }
  2876. public bool IsHingeJoint()
  2877. {
  2878. // For now, we use the NINJA naming scheme for identifying joints.
  2879. // In the future, we can support other joint specification schemes such as a
  2880. // custom checkbox in the viewer GUI.
  2881. if (m_parentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
  2882. {
  2883. string hingeString = "hingejoint";
  2884. return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
  2885. }
  2886. else
  2887. {
  2888. return false;
  2889. }
  2890. }
  2891. public bool IsBallJoint()
  2892. {
  2893. // For now, we use the NINJA naming scheme for identifying joints.
  2894. // In the future, we can support other joint specification schemes such as a
  2895. // custom checkbox in the viewer GUI.
  2896. if (m_parentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
  2897. {
  2898. string ballString = "balljoint";
  2899. return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
  2900. }
  2901. else
  2902. {
  2903. return false;
  2904. }
  2905. }
  2906. public bool IsJoint()
  2907. {
  2908. // For now, we use the NINJA naming scheme for identifying joints.
  2909. // In the future, we can support other joint specification schemes such as a
  2910. // custom checkbox in the viewer GUI.
  2911. if (m_parentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
  2912. {
  2913. return IsHingeJoint() || IsBallJoint();
  2914. }
  2915. else
  2916. {
  2917. return false;
  2918. }
  2919. }
  2920. public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVD)
  2921. {
  2922. bool wasUsingPhysics = ((ObjectFlags & (uint) PrimFlags.Physics) != 0);
  2923. bool wasTemporary = ((ObjectFlags & (uint)PrimFlags.TemporaryOnRez) != 0);
  2924. bool wasPhantom = ((ObjectFlags & (uint)PrimFlags.Phantom) != 0);
  2925. bool wasVD = VolumeDetectActive;
  2926. if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom) && (IsVD==wasVD) )
  2927. {
  2928. return;
  2929. }
  2930. // Special cases for VD. VD can only be called from a script
  2931. // and can't be combined with changes to other states. So we can rely
  2932. // that...
  2933. // ... if VD is changed, all others are not.
  2934. // ... if one of the others is changed, VD is not.
  2935. if (IsVD) // VD is active, special logic applies
  2936. {
  2937. // State machine logic for VolumeDetect
  2938. // More logic below
  2939. bool phanReset = (IsPhantom != wasPhantom) && !IsPhantom;
  2940. if (phanReset) // Phantom changes from on to off switch VD off too
  2941. {
  2942. IsVD = false; // Switch it of for the course of this routine
  2943. VolumeDetectActive = false; // and also permanently
  2944. if (PhysActor != null)
  2945. PhysActor.SetVolumeDetect(0); // Let physics know about it too
  2946. }
  2947. else
  2948. {
  2949. IsPhantom = false;
  2950. // If volumedetect is active we don't want phantom to be applied.
  2951. // If this is a new call to VD out of the state "phantom"
  2952. // this will also cause the prim to be visible to physics
  2953. }
  2954. }
  2955. if (UsePhysics && IsJoint())
  2956. {
  2957. IsPhantom = true;
  2958. }
  2959. if (UsePhysics)
  2960. {
  2961. AddFlag(PrimFlags.Physics);
  2962. if (!wasUsingPhysics)
  2963. {
  2964. DoPhysicsPropertyUpdate(UsePhysics, false);
  2965. if (m_parentGroup != null)
  2966. {
  2967. if (!m_parentGroup.IsDeleted)
  2968. {
  2969. if (LocalId == m_parentGroup.RootPart.LocalId)
  2970. {
  2971. m_parentGroup.CheckSculptAndLoad();
  2972. }
  2973. }
  2974. }
  2975. }
  2976. }
  2977. else
  2978. {
  2979. RemFlag(PrimFlags.Physics);
  2980. if (wasUsingPhysics)
  2981. {
  2982. DoPhysicsPropertyUpdate(UsePhysics, false);
  2983. }
  2984. }
  2985. if (IsPhantom || IsAttachment) // note: this may have been changed above in the case of joints
  2986. {
  2987. AddFlag(PrimFlags.Phantom);
  2988. if (PhysActor != null)
  2989. {
  2990. m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
  2991. /// that's not wholesome. Had to make Scene public
  2992. PhysActor = null;
  2993. }
  2994. }
  2995. else // Not phantom
  2996. {
  2997. RemFlag(PrimFlags.Phantom);
  2998. if (PhysActor == null)
  2999. {
  3000. // It's not phantom anymore. So make sure the physics engine get's knowledge of it
  3001. PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
  3002. Name,
  3003. Shape,
  3004. new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z),
  3005. new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
  3006. RotationOffset,
  3007. UsePhysics);
  3008. if (PhysActor != null)
  3009. {
  3010. PhysActor.LocalID = LocalId;
  3011. DoPhysicsPropertyUpdate(UsePhysics, true);
  3012. if (m_parentGroup != null)
  3013. {
  3014. if (!m_parentGroup.IsDeleted)
  3015. {
  3016. if (LocalId == m_parentGroup.RootPart.LocalId)
  3017. {
  3018. m_parentGroup.CheckSculptAndLoad();
  3019. }
  3020. }
  3021. }
  3022. if (
  3023. ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
  3024. ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
  3025. ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
  3026. (CollisionSound != UUID.Zero)
  3027. )
  3028. {
  3029. PhysActor.OnCollisionUpdate += PhysicsCollision;
  3030. PhysActor.SubscribeEvents(1000);
  3031. }
  3032. }
  3033. }
  3034. else // it already has a physical representation
  3035. {
  3036. PhysActor.IsPhysical = UsePhysics;
  3037. DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
  3038. if (m_parentGroup != null)
  3039. {
  3040. if (!m_parentGroup.IsDeleted)
  3041. {
  3042. if (LocalId == m_parentGroup.RootPart.LocalId)
  3043. {
  3044. m_parentGroup.CheckSculptAndLoad();
  3045. }
  3046. }
  3047. }
  3048. }
  3049. }
  3050. if (IsVD)
  3051. {
  3052. // If the above logic worked (this is urgent candidate to unit tests!)
  3053. // we now have a physicsactor.
  3054. // Defensive programming calls for a check here.
  3055. // Better would be throwing an exception that could be catched by a unit test as the internal
  3056. // logic should make sure, this Physactor is always here.
  3057. if (this.PhysActor != null)
  3058. {
  3059. PhysActor.SetVolumeDetect(1);
  3060. AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
  3061. this.VolumeDetectActive = true;
  3062. }
  3063. }
  3064. else
  3065. { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
  3066. // (mumbles, well, at least if you have infinte CPU powers :-) )
  3067. if (this.PhysActor != null)
  3068. {
  3069. PhysActor.SetVolumeDetect(0);
  3070. }
  3071. this.VolumeDetectActive = false;
  3072. }
  3073. if (IsTemporary)
  3074. {
  3075. AddFlag(PrimFlags.TemporaryOnRez);
  3076. }
  3077. else
  3078. {
  3079. RemFlag(PrimFlags.TemporaryOnRez);
  3080. }
  3081. // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
  3082. ParentGroup.HasGroupChanged = true;
  3083. ScheduleFullUpdate();
  3084. }
  3085. public void UpdateRotation(Quaternion rot)
  3086. {
  3087. if ((rot.X != RotationOffset.X) ||
  3088. (rot.Y != RotationOffset.Y) ||
  3089. (rot.Z != RotationOffset.Z) ||
  3090. (rot.W != RotationOffset.W))
  3091. {
  3092. //StoreUndoState();
  3093. RotationOffset = rot;
  3094. ParentGroup.HasGroupChanged = true;
  3095. ScheduleTerseUpdate();
  3096. }
  3097. }
  3098. /// <summary>
  3099. /// Update the shape of this part.
  3100. /// </summary>
  3101. /// <param name="shapeBlock"></param>
  3102. public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
  3103. {
  3104. m_shape.PathBegin = shapeBlock.PathBegin;
  3105. m_shape.PathEnd = shapeBlock.PathEnd;
  3106. m_shape.PathScaleX = shapeBlock.PathScaleX;
  3107. m_shape.PathScaleY = shapeBlock.PathScaleY;
  3108. m_shape.PathShearX = shapeBlock.PathShearX;
  3109. m_shape.PathShearY = shapeBlock.PathShearY;
  3110. m_shape.PathSkew = shapeBlock.PathSkew;
  3111. m_shape.ProfileBegin = shapeBlock.ProfileBegin;
  3112. m_shape.ProfileEnd = shapeBlock.ProfileEnd;
  3113. m_shape.PathCurve = shapeBlock.PathCurve;
  3114. m_shape.ProfileCurve = shapeBlock.ProfileCurve;
  3115. m_shape.ProfileHollow = shapeBlock.ProfileHollow;
  3116. m_shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
  3117. m_shape.PathRevolutions = shapeBlock.PathRevolutions;
  3118. m_shape.PathTaperX = shapeBlock.PathTaperX;
  3119. m_shape.PathTaperY = shapeBlock.PathTaperY;
  3120. m_shape.PathTwist = shapeBlock.PathTwist;
  3121. m_shape.PathTwistBegin = shapeBlock.PathTwistBegin;
  3122. if (PhysActor != null)
  3123. {
  3124. PhysActor.Shape = m_shape;
  3125. }
  3126. // This is what makes vehicle trailers work
  3127. // A script in a child prim re-issues
  3128. // llSetPrimitiveParams(PRIM_TYPE) every few seconds. That
  3129. // prevents autoreturn. This is not well known. It also works
  3130. // in SL.
  3131. //
  3132. if (ParentGroup.RootPart != this)
  3133. ParentGroup.RootPart.Rezzed = DateTime.Now;
  3134. ParentGroup.HasGroupChanged = true;
  3135. ScheduleFullUpdate();
  3136. }
  3137. // Added to handle bug in libsecondlife's TextureEntry.ToBytes()
  3138. // not handling RGBA properly. Cycles through, and "fixes" the color
  3139. // info
  3140. public void UpdateTexture(Primitive.TextureEntry tex)
  3141. {
  3142. //Color4 tmpcolor;
  3143. //for (uint i = 0; i < 32; i++)
  3144. //{
  3145. // if (tex.FaceTextures[i] != null)
  3146. // {
  3147. // tmpcolor = tex.GetFace((uint) i).RGBA;
  3148. // tmpcolor.A = tmpcolor.A*255;
  3149. // tmpcolor.R = tmpcolor.R*255;
  3150. // tmpcolor.G = tmpcolor.G*255;
  3151. // tmpcolor.B = tmpcolor.B*255;
  3152. // tex.FaceTextures[i].RGBA = tmpcolor;
  3153. // }
  3154. //}
  3155. //tmpcolor = tex.DefaultTexture.RGBA;
  3156. //tmpcolor.A = tmpcolor.A*255;
  3157. //tmpcolor.R = tmpcolor.R*255;
  3158. //tmpcolor.G = tmpcolor.G*255;
  3159. //tmpcolor.B = tmpcolor.B*255;
  3160. //tex.DefaultTexture.RGBA = tmpcolor;
  3161. UpdateTextureEntry(tex.ToBytes());
  3162. }
  3163. /// <summary>
  3164. /// Update the texture entry for this part.
  3165. /// </summary>
  3166. /// <param name="textureEntry"></param>
  3167. public void UpdateTextureEntry(byte[] textureEntry)
  3168. {
  3169. m_shape.TextureEntry = textureEntry;
  3170. TriggerScriptChangedEvent(Changed.TEXTURE);
  3171. ParentGroup.HasGroupChanged = true;
  3172. ParentGroup.ScheduleGroupForFullUpdate();
  3173. }
  3174. public void aggregateScriptEvents()
  3175. {
  3176. AggregateScriptEvents = 0;
  3177. // Aggregate script events
  3178. lock (m_scriptEvents)
  3179. {
  3180. foreach (scriptEvents s in m_scriptEvents.Values)
  3181. {
  3182. AggregateScriptEvents |= s;
  3183. }
  3184. }
  3185. uint objectflagupdate = 0;
  3186. if (
  3187. ((AggregateScriptEvents & scriptEvents.touch) != 0) ||
  3188. ((AggregateScriptEvents & scriptEvents.touch_end) != 0) ||
  3189. ((AggregateScriptEvents & scriptEvents.touch_start) != 0)
  3190. )
  3191. {
  3192. objectflagupdate |= (uint) PrimFlags.Touch;
  3193. }
  3194. if ((AggregateScriptEvents & scriptEvents.money) != 0)
  3195. {
  3196. objectflagupdate |= (uint) PrimFlags.Money;
  3197. }
  3198. if (AllowedDrop)
  3199. {
  3200. objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
  3201. }
  3202. if (
  3203. ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
  3204. ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
  3205. ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
  3206. (CollisionSound != UUID.Zero)
  3207. )
  3208. {
  3209. // subscribe to physics updates.
  3210. if (PhysActor != null)
  3211. {
  3212. PhysActor.OnCollisionUpdate += PhysicsCollision;
  3213. PhysActor.SubscribeEvents(1000);
  3214. }
  3215. }
  3216. else
  3217. {
  3218. if (PhysActor != null)
  3219. {
  3220. PhysActor.UnSubscribeEvents();
  3221. PhysActor.OnCollisionUpdate -= PhysicsCollision;
  3222. }
  3223. }
  3224. if (m_parentGroup == null)
  3225. {
  3226. ScheduleFullUpdate();
  3227. return;
  3228. }
  3229. if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
  3230. {
  3231. m_parentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;
  3232. }
  3233. else
  3234. {
  3235. m_parentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting;
  3236. }
  3237. LocalFlags=(PrimFlags)objectflagupdate;
  3238. if (m_parentGroup != null && m_parentGroup.RootPart == this)
  3239. m_parentGroup.aggregateScriptEvents();
  3240. else
  3241. ScheduleFullUpdate();
  3242. }
  3243. public int registerTargetWaypoint(Vector3 target, float tolerance)
  3244. {
  3245. if (m_parentGroup != null)
  3246. {
  3247. return m_parentGroup.registerTargetWaypoint(target, tolerance);
  3248. }
  3249. return 0;
  3250. }
  3251. public void unregisterTargetWaypoint(int handle)
  3252. {
  3253. if (m_parentGroup != null)
  3254. {
  3255. m_parentGroup.unregisterTargetWaypoint(handle);
  3256. }
  3257. }
  3258. public void SetCameraAtOffset(Vector3 v)
  3259. {
  3260. m_cameraAtOffset = v;
  3261. }
  3262. public void SetCameraEyeOffset(Vector3 v)
  3263. {
  3264. m_cameraEyeOffset = v;
  3265. }
  3266. public void SetForceMouselook(bool force)
  3267. {
  3268. m_forceMouselook = force;
  3269. }
  3270. public Vector3 GetCameraAtOffset()
  3271. {
  3272. return m_cameraAtOffset;
  3273. }
  3274. public Vector3 GetCameraEyeOffset()
  3275. {
  3276. return m_cameraEyeOffset;
  3277. }
  3278. public bool GetForceMouselook()
  3279. {
  3280. return m_forceMouselook;
  3281. }
  3282. public override string ToString()
  3283. {
  3284. return String.Format("{0} {1} (parent {2}))", Name, UUID, ParentGroup);
  3285. }
  3286. #endregion Public Methods
  3287. public void SendTerseUpdateToClient(IClientAPI remoteClient)
  3288. {
  3289. if (ParentGroup == null || ParentGroup.IsDeleted)
  3290. return;
  3291. Vector3 lPos = OffsetPosition;
  3292. byte state = Shape.State;
  3293. if (IsAttachment)
  3294. {
  3295. if (ParentGroup.RootPart != this)
  3296. return;
  3297. lPos = ParentGroup.RootPart.AttachedPos;
  3298. state = (byte)AttachmentPoint;
  3299. }
  3300. else
  3301. {
  3302. if (ParentGroup.RootPart == this)
  3303. lPos = AbsolutePosition;
  3304. }
  3305. remoteClient.SendPrimTerseUpdate(m_regionHandle,
  3306. (ushort)(m_parentGroup.GetTimeDilation() *
  3307. (float)ushort.MaxValue), LocalId, lPos,
  3308. RotationOffset, Velocity,
  3309. RotationalVelocity, state, FromAssetID,
  3310. OwnerID, (int)AttachmentPoint);
  3311. }
  3312. public void AddScriptLPS(int count)
  3313. {
  3314. m_parentGroup.AddScriptLPS(count);
  3315. }
  3316. public void ApplyNextOwnerPermissions()
  3317. {
  3318. _baseMask &= _nextOwnerMask;
  3319. _ownerMask &= _nextOwnerMask;
  3320. _everyoneMask &= _nextOwnerMask;
  3321. Inventory.ApplyNextOwnerPermissions();
  3322. }
  3323. }
  3324. }