SceneObjectPart.cs 135 KB

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