From 2b6d22691141b8cdccfc44d25890f99e1f72b3dd Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 2 Feb 2013 13:33:44 -0800 Subject: BulletSim: correct angular vertical attraction to properly correct an upside down vehicle. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 8ecf2ff..b51e9fd 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1326,7 +1326,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // If verticalError.Z is negative, the vehicle is upside down. Add additional push. if (verticalError.Z < 0f) { - vertContributionV.X += PIOverFour; + vertContributionV.X += Math.Sign(vertContributionV.X) * PIOverFour; // vertContribution.Y -= PIOverFour; } -- cgit v1.1 From ad438ee59fce1b262135ef0f7cd1213f3a79df50 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 3 Feb 2013 16:08:09 -0800 Subject: BulletSim: rework some parameter setting implementation moving functionality that was in BSScene to BSParam. Remove unused parameters that were passed to the unmanaged code. Update DLLs and SOs for the new param block. --- OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | 70 +++++------ .../Region/Physics/BulletSPlugin/BSApiTemplate.cs | 38 +----- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 131 ++++++++++++--------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 58 ++++----- .../Region/Physics/BulletSPlugin/BSTerrainMesh.cs | 13 +- 5 files changed, 152 insertions(+), 158 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index 04e77b8..39e62dd 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs @@ -1088,7 +1088,7 @@ private sealed class BulletConstraintXNA : BulletConstraint { CollisionWorld.WorldData.ParamData p = new CollisionWorld.WorldData.ParamData(); - p.angularDamping = o[0].XangularDamping; + p.angularDamping = BSParam.AngularDamping; p.defaultFriction = o[0].defaultFriction; p.defaultFriction = o[0].defaultFriction; p.defaultDensity = o[0].defaultDensity; @@ -1096,32 +1096,32 @@ private sealed class BulletConstraintXNA : BulletConstraint p.collisionMargin = o[0].collisionMargin; p.gravity = o[0].gravity; - p.linearDamping = o[0].XlinearDamping; - p.angularDamping = o[0].XangularDamping; - p.deactivationTime = o[0].XdeactivationTime; - p.linearSleepingThreshold = o[0].XlinearSleepingThreshold; - p.angularSleepingThreshold = o[0].XangularSleepingThreshold; - p.ccdMotionThreshold = o[0].XccdMotionThreshold; - p.ccdSweptSphereRadius = o[0].XccdSweptSphereRadius; - p.contactProcessingThreshold = o[0].XcontactProcessingThreshold; - - p.terrainImplementation = o[0].XterrainImplementation; - p.terrainFriction = o[0].XterrainFriction; - - p.terrainHitFraction = o[0].XterrainHitFraction; - p.terrainRestitution = o[0].XterrainRestitution; - p.terrainCollisionMargin = o[0].XterrainCollisionMargin; - - p.avatarFriction = o[0].XavatarFriction; - p.avatarStandingFriction = o[0].XavatarStandingFriction; - p.avatarDensity = o[0].XavatarDensity; - p.avatarRestitution = o[0].XavatarRestitution; - p.avatarCapsuleWidth = o[0].XavatarCapsuleWidth; - p.avatarCapsuleDepth = o[0].XavatarCapsuleDepth; - p.avatarCapsuleHeight = o[0].XavatarCapsuleHeight; - p.avatarContactProcessingThreshold = o[0].XavatarContactProcessingThreshold; + p.linearDamping = BSParam.LinearDamping; + p.angularDamping = BSParam.AngularDamping; + p.deactivationTime = BSParam.DeactivationTime; + p.linearSleepingThreshold = BSParam.LinearSleepingThreshold; + p.angularSleepingThreshold = BSParam.AngularSleepingThreshold; + p.ccdMotionThreshold = BSParam.CcdMotionThreshold; + p.ccdSweptSphereRadius = BSParam.CcdSweptSphereRadius; + p.contactProcessingThreshold = BSParam.ContactProcessingThreshold; + + p.terrainImplementation = BSParam.TerrainImplementation; + p.terrainFriction = BSParam.TerrainFriction; + + p.terrainHitFraction = BSParam.TerrainHitFraction; + p.terrainRestitution = BSParam.TerrainRestitution; + p.terrainCollisionMargin = BSParam.TerrainCollisionMargin; + + p.avatarFriction = BSParam.AvatarFriction; + p.avatarStandingFriction = BSParam.AvatarStandingFriction; + p.avatarDensity = BSParam.AvatarDensity; + p.avatarRestitution = BSParam.AvatarRestitution; + p.avatarCapsuleWidth = BSParam.AvatarCapsuleWidth; + p.avatarCapsuleDepth = BSParam.AvatarCapsuleDepth; + p.avatarCapsuleHeight = BSParam.AvatarCapsuleHeight; + p.avatarContactProcessingThreshold = BSParam.AvatarContactProcessingThreshold; - p.vehicleAngularDamping = o[0].XvehicleAngularDamping; + p.vehicleAngularDamping = BSParam.VehicleAngularDamping; p.maxPersistantManifoldPoolSize = o[0].maxPersistantManifoldPoolSize; p.maxCollisionAlgorithmPoolSize = o[0].maxCollisionAlgorithmPoolSize; @@ -1132,15 +1132,15 @@ private sealed class BulletConstraintXNA : BulletConstraint p.shouldEnableFrictionCaching = o[0].shouldEnableFrictionCaching; p.numberOfSolverIterations = o[0].numberOfSolverIterations; - p.linksetImplementation = o[0].XlinksetImplementation; - p.linkConstraintUseFrameOffset = o[0].XlinkConstraintUseFrameOffset; - p.linkConstraintEnableTransMotor = o[0].XlinkConstraintEnableTransMotor; - p.linkConstraintTransMotorMaxVel = o[0].XlinkConstraintTransMotorMaxVel; - p.linkConstraintTransMotorMaxForce = o[0].XlinkConstraintTransMotorMaxForce; - p.linkConstraintERP = o[0].XlinkConstraintERP; - p.linkConstraintCFM = o[0].XlinkConstraintCFM; - p.linkConstraintSolverIterations = o[0].XlinkConstraintSolverIterations; - p.physicsLoggingFrames = o[0].XphysicsLoggingFrames; + p.linksetImplementation = BSParam.LinksetImplementation; + p.linkConstraintUseFrameOffset = BSParam.LinkConstraintUseFrameOffset; + p.linkConstraintEnableTransMotor = BSParam.LinkConstraintEnableTransMotor; + p.linkConstraintTransMotorMaxVel = BSParam.LinkConstraintTransMotorMaxVel; + p.linkConstraintTransMotorMaxForce = BSParam.LinkConstraintTransMotorMaxForce; + p.linkConstraintERP = BSParam.LinkConstraintERP; + p.linkConstraintCFM = BSParam.LinkConstraintCFM; + p.linkConstraintSolverIterations = BSParam.LinkConstraintSolverIterations; + p.physicsLoggingFrames = o[0].physicsLoggingFrames; DefaultCollisionConstructionInfo ccci = new DefaultCollisionConstructionInfo(); DefaultCollisionConfiguration cci = new DefaultCollisionConfiguration(); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index abbd22c..5e06c1e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -174,32 +174,6 @@ public struct ConfigurationParameters public float collisionMargin; public float gravity; - public float XlinearDamping; - public float XangularDamping; - public float XdeactivationTime; - public float XlinearSleepingThreshold; - public float XangularSleepingThreshold; - public float XccdMotionThreshold; - public float XccdSweptSphereRadius; - public float XcontactProcessingThreshold; - - public float XterrainImplementation; - public float XterrainFriction; - public float XterrainHitFraction; - public float XterrainRestitution; - public float XterrainCollisionMargin; - - public float XavatarFriction; - public float XavatarStandingFriction; - public float XavatarDensity; - public float XavatarRestitution; - public float XavatarCapsuleWidth; - public float XavatarCapsuleDepth; - public float XavatarCapsuleHeight; - public float XavatarContactProcessingThreshold; - - public float XvehicleAngularDamping; - public float maxPersistantManifoldPoolSize; public float maxCollisionAlgorithmPoolSize; public float shouldDisableContactPoolDynamicAllocation; @@ -208,17 +182,9 @@ public struct ConfigurationParameters public float shouldSplitSimulationIslands; public float shouldEnableFrictionCaching; public float numberOfSolverIterations; + public float useSingleSidedMeshes; - public float XlinksetImplementation; - public float XlinkConstraintUseFrameOffset; - public float XlinkConstraintEnableTransMotor; - public float XlinkConstraintTransMotorMaxVel; - public float XlinkConstraintTransMotorMaxForce; - public float XlinkConstraintERP; - public float XlinkConstraintCFM; - public float XlinkConstraintSolverIterations; - - public float XphysicsLoggingFrames; + public float physicsLoggingFrames; public const float numericTrue = 1f; public const float numericFalse = 0f; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 8c098b2..fbef7e7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -68,6 +68,24 @@ public static class BSParam public static float TerrainRestitution { get; private set; } public static float TerrainCollisionMargin { get; private set; } + public static float DefaultFriction; + public static float DefaultDensity; + public static float DefaultRestitution; + public static float CollisionMargin; + public static float Gravity; + + // Physics Engine operation + public static float MaxPersistantManifoldPoolSize; + public static float MaxCollisionAlgorithmPoolSize; + public static float ShouldDisableContactPoolDynamicAllocation; + public static float ShouldForceUpdateAllAabbs; + public static float ShouldRandomizeSolverOrder; + public static float ShouldSplitSimulationIslands; + public static float ShouldEnableFrictionCaching; + public static float NumberOfSolverIterations; + public static bool UseSingleSidedMeshes { get { return UseSingleSidedMeshesF != ConfigurationParameters.numericFalse; } } + public static float UseSingleSidedMeshesF; + // Avatar parameters public static float AvatarFriction { get; private set; } public static float AvatarStandingFriction { get; private set; } @@ -287,29 +305,29 @@ public static class BSParam new ParameterDefn("DefaultFriction", "Friction factor used on new objects", 0.2f, - (s,cf,p,v) => { s.UnmanagedParams[0].defaultFriction = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].defaultFriction; }, - (s,p,l,v) => { s.UnmanagedParams[0].defaultFriction = v; } ), + (s,cf,p,v) => { DefaultFriction = cf.GetFloat(p, v); }, + (s) => { return DefaultFriction; }, + (s,p,l,v) => { DefaultFriction = v; s.UnmanagedParams[0].defaultFriction = v; } ), new ParameterDefn("DefaultDensity", "Density for new objects" , 10.000006836f, // Aluminum g/cm3 - (s,cf,p,v) => { s.UnmanagedParams[0].defaultDensity = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].defaultDensity; }, - (s,p,l,v) => { s.UnmanagedParams[0].defaultDensity = v; } ), + (s,cf,p,v) => { DefaultDensity = cf.GetFloat(p, v); }, + (s) => { return DefaultDensity; }, + (s,p,l,v) => { DefaultDensity = v; s.UnmanagedParams[0].defaultDensity = v; } ), new ParameterDefn("DefaultRestitution", "Bouncyness of an object" , 0f, - (s,cf,p,v) => { s.UnmanagedParams[0].defaultRestitution = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].defaultRestitution; }, - (s,p,l,v) => { s.UnmanagedParams[0].defaultRestitution = v; } ), + (s,cf,p,v) => { DefaultRestitution = cf.GetFloat(p, v); }, + (s) => { return DefaultRestitution; }, + (s,p,l,v) => { DefaultRestitution = v; s.UnmanagedParams[0].defaultRestitution = v; } ), new ParameterDefn("CollisionMargin", "Margin around objects before collisions are calculated (must be zero!)", 0.04f, - (s,cf,p,v) => { s.UnmanagedParams[0].collisionMargin = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].collisionMargin; }, - (s,p,l,v) => { s.UnmanagedParams[0].collisionMargin = v; } ), + (s,cf,p,v) => { CollisionMargin = cf.GetFloat(p, v); }, + (s) => { return CollisionMargin; }, + (s,p,l,v) => { CollisionMargin = v; s.UnmanagedParams[0].collisionMargin = v; } ), new ParameterDefn("Gravity", "Vertical force of gravity (negative means down)", -9.80665f, - (s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].gravity; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); }, + (s,cf,p,v) => { Gravity = cf.GetFloat(p, v); }, + (s) => { return Gravity; }, + (s,p,l,v) => { Gravity = v; s.UnmanagedParams[0].gravity = v; }, (s,o,v) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,v)); } ), @@ -317,49 +335,49 @@ public static class BSParam 0f, (s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); }, (s) => { return LinearDamping; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); }, + (s,p,l,v) => { LinearDamping = v; }, (s,o,v) => { s.PE.SetDamping(o.PhysBody, v, AngularDamping); } ), new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", 0f, (s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); }, (s) => { return AngularDamping; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); }, + (s,p,l,v) => { AngularDamping = v; }, (s,o,v) => { s.PE.SetDamping(o.PhysBody, LinearDamping, v); } ), new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", 0.2f, (s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); }, (s) => { return DeactivationTime; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{DeactivationTime=x;}, p, l, v); }, + (s,p,l,v) => { DeactivationTime = v; }, (s,o,v) => { s.PE.SetDeactivationTime(o.PhysBody, v); } ), new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static", 0.8f, (s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); }, (s) => { return LinearSleepingThreshold; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); }, + (s,p,l,v) => { LinearSleepingThreshold = v;}, (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", 1.0f, (s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); }, (s) => { return AngularSleepingThreshold; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, + (s,p,l,v) => { AngularSleepingThreshold = v;}, (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , 0.0f, // set to zero to disable (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, (s) => { return CcdMotionThreshold; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, + (s,p,l,v) => { CcdMotionThreshold = v;}, (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ), new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , 0.2f, (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); }, (s) => { return CcdSweptSphereRadius; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, + (s,p,l,v) => { CcdSweptSphereRadius = v;}, (s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ), new ParameterDefn("ContactProcessingThreshold", "Distance above which contacts can be discarded (0 means no discard)" , 0.0f, (s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); }, (s) => { return ContactProcessingThreshold; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); }, + (s,p,l,v) => { ContactProcessingThreshold = v;}, (s,o,v) => { s.PE.SetContactProcessingThreshold(o.PhysBody, v); } ), new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)", @@ -392,7 +410,7 @@ public static class BSParam 0.2f, (s,cf,p,v) => { AvatarFriction = cf.GetFloat(p, v); }, (s) => { return AvatarFriction; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarFriction=x;}, p, l, v); } ), + (s,p,l,v) => { AvatarFriction = v; } ), new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.", 10.0f, (s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); }, @@ -407,32 +425,32 @@ public static class BSParam 3.5f, (s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); }, (s) => { return AvatarDensity; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarDensity=x;}, p, l, v); } ), + (s,p,l,v) => { AvatarDensity = v; } ), new ParameterDefn("AvatarRestitution", "Bouncyness. Changed on avatar recreation.", 0f, (s,cf,p,v) => { AvatarRestitution = cf.GetFloat(p, v); }, (s) => { return AvatarRestitution; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarRestitution=x;}, p, l, v); } ), + (s,p,l,v) => { AvatarRestitution = v; } ), new ParameterDefn("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule", 0.6f, (s,cf,p,v) => { AvatarCapsuleWidth = cf.GetFloat(p, v); }, (s) => { return AvatarCapsuleWidth; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleWidth=x;}, p, l, v); } ), + (s,p,l,v) => { AvatarCapsuleWidth = v; } ), new ParameterDefn("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule", 0.45f, (s,cf,p,v) => { AvatarCapsuleDepth = cf.GetFloat(p, v); }, (s) => { return AvatarCapsuleDepth; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleDepth=x;}, p, l, v); } ), + (s,p,l,v) => { AvatarCapsuleDepth = v; } ), new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", 1.5f, (s,cf,p,v) => { AvatarCapsuleHeight = cf.GetFloat(p, v); }, (s) => { return AvatarCapsuleHeight; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleHeight=x;}, p, l, v); } ), + (s,p,l,v) => { AvatarCapsuleHeight = v; } ), new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", 0.1f, (s,cf,p,v) => { AvatarContactProcessingThreshold = cf.GetFloat(p, v); }, (s) => { return AvatarContactProcessingThreshold; }, - (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarContactProcessingThreshold=x;}, p, l, v); } ), + (s,p,l,v) => { AvatarContactProcessingThreshold = v; } ), new ParameterDefn("AvatarStepHeight", "Height of a step obstacle to consider step correction", 0.3f, (s,cf,p,v) => { AvatarStepHeight = cf.GetFloat(p, v); }, @@ -497,44 +515,49 @@ public static class BSParam new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)", 0f, - (s,cf,p,v) => { s.UnmanagedParams[0].maxPersistantManifoldPoolSize = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].maxPersistantManifoldPoolSize; }, - (s,p,l,v) => { s.UnmanagedParams[0].maxPersistantManifoldPoolSize = v; } ), + (s,cf,p,v) => { MaxPersistantManifoldPoolSize = cf.GetFloat(p, v); }, + (s) => { return MaxPersistantManifoldPoolSize; }, + (s,p,l,v) => { MaxPersistantManifoldPoolSize = v; s.UnmanagedParams[0].maxPersistantManifoldPoolSize = v; } ), new ParameterDefn("MaxCollisionAlgorithmPoolSize", "Number of collisions pooled (0 means default of 4096)", 0f, - (s,cf,p,v) => { s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize; }, - (s,p,l,v) => { s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = v; } ), + (s,cf,p,v) => { MaxCollisionAlgorithmPoolSize = cf.GetFloat(p, v); }, + (s) => { return MaxCollisionAlgorithmPoolSize; }, + (s,p,l,v) => { MaxCollisionAlgorithmPoolSize = v; s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = v; } ), new ParameterDefn("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count", ConfigurationParameters.numericFalse, - (s,cf,p,v) => { s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, - (s) => { return s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation; }, - (s,p,l,v) => { s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = v; } ), + (s,cf,p,v) => { ShouldDisableContactPoolDynamicAllocation = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, + (s) => { return ShouldDisableContactPoolDynamicAllocation; }, + (s,p,l,v) => { ShouldDisableContactPoolDynamicAllocation = v; s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = v; } ), new ParameterDefn("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step", ConfigurationParameters.numericFalse, - (s,cf,p,v) => { s.UnmanagedParams[0].shouldForceUpdateAllAabbs = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, - (s) => { return s.UnmanagedParams[0].shouldForceUpdateAllAabbs; }, - (s,p,l,v) => { s.UnmanagedParams[0].shouldForceUpdateAllAabbs = v; } ), + (s,cf,p,v) => { ShouldForceUpdateAllAabbs = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, + (s) => { return ShouldForceUpdateAllAabbs; }, + (s,p,l,v) => { ShouldForceUpdateAllAabbs = v; s.UnmanagedParams[0].shouldForceUpdateAllAabbs = v; } ), new ParameterDefn("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction", ConfigurationParameters.numericTrue, - (s,cf,p,v) => { s.UnmanagedParams[0].shouldRandomizeSolverOrder = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, - (s) => { return s.UnmanagedParams[0].shouldRandomizeSolverOrder; }, - (s,p,l,v) => { s.UnmanagedParams[0].shouldRandomizeSolverOrder = v; } ), + (s,cf,p,v) => { ShouldRandomizeSolverOrder = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, + (s) => { return ShouldRandomizeSolverOrder; }, + (s,p,l,v) => { ShouldRandomizeSolverOrder = v; s.UnmanagedParams[0].shouldRandomizeSolverOrder = v; } ), new ParameterDefn("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands", ConfigurationParameters.numericTrue, - (s,cf,p,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, - (s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; }, - (s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ), + (s,cf,p,v) => { ShouldSplitSimulationIslands = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, + (s) => { return ShouldSplitSimulationIslands; }, + (s,p,l,v) => { ShouldSplitSimulationIslands = v; s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ), new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching", ConfigurationParameters.numericTrue, - (s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, - (s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; }, - (s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ), + (s,cf,p,v) => { ShouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, + (s) => { return ShouldEnableFrictionCaching; }, + (s,p,l,v) => { ShouldEnableFrictionCaching = v; s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ), new ParameterDefn("NumberOfSolverIterations", "Number of internal iterations (0 means default)", 0f, // zero says use Bullet default - (s,cf,p,v) => { s.UnmanagedParams[0].numberOfSolverIterations = cf.GetFloat(p, v); }, - (s) => { return s.UnmanagedParams[0].numberOfSolverIterations; }, - (s,p,l,v) => { s.UnmanagedParams[0].numberOfSolverIterations = v; } ), + (s,cf,p,v) => { NumberOfSolverIterations = cf.GetFloat(p, v); }, + (s) => { return NumberOfSolverIterations; }, + (s,p,l,v) => { NumberOfSolverIterations = v; s.UnmanagedParams[0].numberOfSolverIterations = v; } ), + new ParameterDefn("UseSingleSidedMeshes", "Whether to compute collisions based on single sided meshes.", + ConfigurationParameters.numericTrue, + (s,cf,p,v) => { UseSingleSidedMeshesF = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, + (s) => { return UseSingleSidedMeshesF; }, + (s,p,l,v) => { UseSingleSidedMeshesF = v; s.UnmanagedParams[0].useSingleSidedMeshes = v; } ), new ParameterDefn("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)", (float)BSLinkset.LinksetImplementation.Compound, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index a4690ba..6cd72f2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -882,41 +882,41 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters BSParam.ParameterDefn theParam; if (BSParam.TryGetParameter(parm, out theParam)) { + // Set the value in the C# code theParam.setter(this, parm, localID, val); + + // Optionally set the parameter in the unmanaged code + if (theParam.onObject != null) + { + // update all the localIDs specified + // If the local ID is APPLY_TO_NONE, just change the default value + // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs + // If the localID is a specific object, apply the parameter change to only that object + List objectIDs = new List(); + switch (localID) + { + case PhysParameterEntry.APPLY_TO_NONE: + // This will cause a call into the physical world if some operation is specified (SetOnObject). + objectIDs.Add(TERRAIN_ID); + TaintedUpdateParameter(parm, objectIDs, val); + break; + case PhysParameterEntry.APPLY_TO_ALL: + lock (PhysObjects) objectIDs = new List(PhysObjects.Keys); + TaintedUpdateParameter(parm, objectIDs, val); + break; + default: + // setting only one localID + objectIDs.Add(localID); + TaintedUpdateParameter(parm, objectIDs, val); + break; + } + } + ret = true; } return ret; } - // update all the localIDs specified - // If the local ID is APPLY_TO_NONE, just change the default value - // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs - // If the localID is a specific object, apply the parameter change to only that object - internal delegate void AssignVal(float x); - internal void UpdateParameterObject(AssignVal setDefault, string parm, uint localID, float val) - { - List objectIDs = new List(); - switch (localID) - { - case PhysParameterEntry.APPLY_TO_NONE: - setDefault(val); // setting only the default value - // This will cause a call into the physical world if some operation is specified (SetOnObject). - objectIDs.Add(TERRAIN_ID); - TaintedUpdateParameter(parm, objectIDs, val); - break; - case PhysParameterEntry.APPLY_TO_ALL: - setDefault(val); // setting ALL also sets the default value - lock (PhysObjects) objectIDs = new List(PhysObjects.Keys); - TaintedUpdateParameter(parm, objectIDs, val); - break; - default: - // setting only one localID - objectIDs.Add(localID); - TaintedUpdateParameter(parm, objectIDs, val); - break; - } - } - // schedule the actual updating of the paramter to when the phys engine is not busy private void TaintedUpdateParameter(string parm, List lIDs, float val) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs index 8244f02..d7e800d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs @@ -96,7 +96,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys { // DISASTER!! PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape", ID); - physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain mesh! base={1}", LogHeader, TerrainBase); + PhysicsScene.Logger.ErrorFormat("{0} Failed creation of terrain mesh! base={1}", LogHeader, TerrainBase); // Something is very messed up and a crash is in our future. return; } @@ -108,7 +108,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys if (!m_terrainBody.HasPhysicalBody) { // DISASTER!! - physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase); + PhysicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase); // Something is very messed up and a crash is in our future. return; } @@ -131,6 +131,12 @@ public sealed class BSTerrainMesh : BSTerrainPhys m_terrainBody.collisionType = CollisionType.Terrain; m_terrainBody.ApplyCollisionMask(PhysicsScene); + if (BSParam.UseSingleSidedMeshes) + { + PhysicsScene.DetailLog("{0},BSTerrainMesh.settingCustomMaterial", id); + PhysicsScene.PE.AddToCollisionFlags(m_terrainBody, CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK); + } + // Make it so the terrain will not move or be considered for movement. PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION); } @@ -176,8 +182,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys // Convert the passed heightmap to mesh information suitable for CreateMeshShape2(). // Return 'true' if successfully created. - public static bool ConvertHeightmapToMesh( - BSScene physicsScene, + public static bool ConvertHeightmapToMesh( BSScene physicsScene, float[] heightMap, int sizeX, int sizeY, // parameters of incoming heightmap float extentX, float extentY, // zero based range for output vertices Vector3 extentBase, // base to be added to all vertices -- cgit v1.1 From 13233da66c96e9fb8b4f8c5c98aa34c8b6ccf1b7 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 3 Feb 2013 21:48:11 -0800 Subject: BulletSim: add debugging looking for doorway sculpty problems --- .../Physics/BulletSPlugin/BSShapeCollection.cs | 30 +++++++++++++++++++--- .../Region/Physics/BulletSPlugin/BulletSimData.cs | 4 +++ .../Region/Physics/BulletSPlugin/BulletSimTODO.txt | 3 +++ 3 files changed, 33 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 9febd90..0af8e13 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs @@ -622,7 +622,6 @@ public sealed class BSShapeCollection : IDisposable private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) { BulletShape newShape = new BulletShape(); - IMesh meshData = null; MeshDesc meshDesc; if (Meshes.TryGetValue(newMeshKey, out meshDesc)) @@ -632,7 +631,7 @@ public sealed class BSShapeCollection : IDisposable } else { - meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, true, false); + IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, true, false); if (meshData != null) { @@ -648,8 +647,31 @@ public sealed class BSShapeCollection : IDisposable verticesAsFloats[vi++] = vv.Z; } - // m_log.DebugFormat("{0}: BSShapeCollection.CreatePhysicalMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", - // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count); + // DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,key={1},lod={2},size={3},indices={4},vertices={5}", + // BSScene.DetailLogZero, newMeshKey.ToString("X"), lod, size, indices.Length, vertices.Count); + + /* + // DEBUG DEBUG + for (int ii = 0; ii < indices.Length; ii += 3) + { + DetailLog("{0,3}: {1,3},{2,3},{3,3}: <{4,10},{5,10},{6,10}>, <{7,10},{8,10},{9,10}>, <{10,10},{11,10},{12,10}>", + ii / 3, + indices[ii + 0], + indices[ii + 1], + indices[ii + 2], + verticesAsFloats[indices[ii+0] + 0], + verticesAsFloats[indices[ii+0] + 1], + verticesAsFloats[indices[ii+0] + 2], + verticesAsFloats[indices[ii+1] + 0], + verticesAsFloats[indices[ii+1] + 1], + verticesAsFloats[indices[ii+1] + 2], + verticesAsFloats[indices[ii+2] + 0], + verticesAsFloats[indices[ii+2] + 1], + verticesAsFloats[indices[ii+2] + 2] + ); + } + // END DEBUG DEBUG + */ newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, indices.GetLength(0), indices, vertices.Count, verticesAsFloats); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index c7a2f7e..8012d91 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs @@ -217,6 +217,10 @@ public static class BulletSimData { // Map of collisionTypes to flags for collision groups and masks. +// An object's 'group' is the collison groups this object belongs to +// An object's 'filter' is the groups another object has to belong to in order to collide with me +// A collision happens if ((obj1.group & obj2.filter) != 0) || ((obj2.group & obj1.filter) != 0) +// // As mentioned above, don't use the CollisionFilterGroups definitions directly in the code // but, instead, use references to this dictionary. Finding and debugging // collision flag problems will be made easier. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index a3b3556..1eaa523 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -128,6 +128,9 @@ Physical and phantom will drop through the terrain LINKSETS ====================================================== Child prims do not report collisions +Allow children of a linkset to be phantom: + http://opensim-dev.2196679.n2.nabble.com/Setting-a-single-child-prim-to-Phantom-tp7578513.html + Add OS_STATUS_PHANTOM_PRIM to llSetLinkPrimitaveParamsFast. Editing a child of a linkset causes the child to go phantom Move a child prim once when it is physical and can never move it again without it going phantom Offset the center of the linkset to be the geometric center of all the prims -- cgit v1.1 From dce9e323f4f0fdccd2f34266e870de9cbcebd2f0 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 5 Feb 2013 16:51:02 -0800 Subject: BulletSim: remove degenerate triangles from meshes. This fixes the invisible barriers in sculptie doorways (Mantis 6529). Bump up level-of-detail for physical meshes to 32 (the max). This fixes the invisible barriers that showed up in prim cut arches. NOTE: the default LOD values are removed from OpenSimDefaults.ini. If you don't change your OpenSimDefaults.ini, you will continue to see the arch problem. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 18 +++-- .../Physics/BulletSPlugin/BSShapeCollection.cs | 81 ++++++++++++---------- .../Region/Physics/BulletSPlugin/BulletSimTODO.txt | 2 + OpenSim/Region/Physics/Manager/IMesher.cs | 1 + OpenSim/Region/Physics/Meshing/Mesh.cs | 2 +- 5 files changed, 59 insertions(+), 45 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index fbef7e7..bdd9ce4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -39,6 +39,7 @@ public static class BSParam { // Level of Detail values kept as float because that's what the Meshmerizer wants public static float MeshLOD { get; private set; } + public static float MeshCircularLOD { get; private set; } public static float MeshMegaPrimLOD { get; private set; } public static float MeshMegaPrimThreshold { get; private set; } public static float SculptLOD { get; private set; } @@ -219,20 +220,25 @@ public static class BSParam (s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ), new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", - 8f, + 32f, (s,cf,p,v) => { MeshLOD = (float)cf.GetInt(p, (int)v); }, (s) => { return MeshLOD; }, (s,p,l,v) => { MeshLOD = v; } ), - new ParameterDefn("MeshLevelOfDetailMegaPrim", "Level of detail to render meshes larger than threshold meters", - 16f, - (s,cf,p,v) => { MeshMegaPrimLOD = (float)cf.GetInt(p, (int)v); }, - (s) => { return MeshMegaPrimLOD; }, - (s,p,l,v) => { MeshMegaPrimLOD = v; } ), + new ParameterDefn("MeshLevelOfDetailCircular", "Level of detail for prims with circular cuts or shapes", + 32f, + (s,cf,p,v) => { MeshCircularLOD = (float)cf.GetInt(p, (int)v); }, + (s) => { return MeshCircularLOD; }, + (s,p,l,v) => { MeshCircularLOD = v; } ), new ParameterDefn("MeshLevelOfDetailMegaPrimThreshold", "Size (in meters) of a mesh before using MeshMegaPrimLOD", 10f, (s,cf,p,v) => { MeshMegaPrimThreshold = (float)cf.GetInt(p, (int)v); }, (s) => { return MeshMegaPrimThreshold; }, (s,p,l,v) => { MeshMegaPrimThreshold = v; } ), + new ParameterDefn("MeshLevelOfDetailMegaPrim", "Level of detail to render meshes larger than threshold meters", + 32f, + (s,cf,p,v) => { MeshMegaPrimLOD = (float)cf.GetInt(p, (int)v); }, + (s) => { return MeshMegaPrimLOD; }, + (s,p,l,v) => { MeshMegaPrimLOD = v; } ), new ParameterDefn("SculptLevelOfDetail", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)", 32f, (s,cf,p,v) => { SculptLOD = (float)cf.GetInt(p, (int)v); }, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 0af8e13..f17e513 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs @@ -602,8 +602,8 @@ public sealed class BSShapeCollection : IDisposable if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == BSPhysicsShapeType.SHAPE_MESH) return false; - if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2}", - prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newMeshKey.ToString("X")); + if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2},size={3},lod={4}", + prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newMeshKey.ToString("X"), prim.Size, lod); // Since we're recreating new, get rid of the reference to the previous shape DereferenceShape(prim.PhysShape, shapeCallback); @@ -631,50 +631,50 @@ public sealed class BSShapeCollection : IDisposable } else { - IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, true, false); + IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, + false, // say it is not physical so a bounding box is not built + false // do not cache the mesh and do not use previously built versions + ); if (meshData != null) { - int[] indices = meshData.getIndexListAsInt(); - List vertices = meshData.getVertexList(); - - float[] verticesAsFloats = new float[vertices.Count * 3]; - int vi = 0; - foreach (OMV.Vector3 vv in vertices) - { - verticesAsFloats[vi++] = vv.X; - verticesAsFloats[vi++] = vv.Y; - verticesAsFloats[vi++] = vv.Z; - } - // DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,key={1},lod={2},size={3},indices={4},vertices={5}", - // BSScene.DetailLogZero, newMeshKey.ToString("X"), lod, size, indices.Length, vertices.Count); - - /* - // DEBUG DEBUG - for (int ii = 0; ii < indices.Length; ii += 3) + int[] indices = meshData.getIndexListAsInt(); + // int realIndicesIndex = indices.Length; + float[] verticesAsFloats = meshData.getVertexListAsFloat(); + + // Remove degenerate triangles. These are triangles with two of the vertices + // are the same. This is complicated by the problem that vertices are not + // made unique in sculpties so we have to compare the values in the vertex. + int realIndicesIndex = 0; + for (int tri = 0; tri < indices.Length; tri += 3) { - DetailLog("{0,3}: {1,3},{2,3},{3,3}: <{4,10},{5,10},{6,10}>, <{7,10},{8,10},{9,10}>, <{10,10},{11,10},{12,10}>", - ii / 3, - indices[ii + 0], - indices[ii + 1], - indices[ii + 2], - verticesAsFloats[indices[ii+0] + 0], - verticesAsFloats[indices[ii+0] + 1], - verticesAsFloats[indices[ii+0] + 2], - verticesAsFloats[indices[ii+1] + 0], - verticesAsFloats[indices[ii+1] + 1], - verticesAsFloats[indices[ii+1] + 2], - verticesAsFloats[indices[ii+2] + 0], - verticesAsFloats[indices[ii+2] + 1], - verticesAsFloats[indices[ii+2] + 2] - ); + int v1 = indices[tri + 0] * 3; + int v2 = indices[tri + 1] * 3; + int v3 = indices[tri + 2] * 3; + if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] + && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] + && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2] ) + || ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] + && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] + && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2] ) + || ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] + && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] + && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2] ) ) + ) + { + // None of the vertices of the triangles are the same. This is a good triangle; + indices[realIndicesIndex + 0] = indices[tri + 0]; + indices[realIndicesIndex + 1] = indices[tri + 1]; + indices[realIndicesIndex + 2] = indices[tri + 2]; + realIndicesIndex += 3; + } } - // END DEBUG DEBUG - */ + DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", + BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, - indices.GetLength(0), indices, vertices.Count, verticesAsFloats); + realIndicesIndex, indices, verticesAsFloats.Length/3, verticesAsFloats); } } newShape.shapeKey = newMeshKey; @@ -853,6 +853,11 @@ public sealed class BSShapeCollection : IDisposable { // level of detail based on size and type of the object float lod = BSParam.MeshLOD; + + // prims with curvy internal cuts need higher lod + if (pbs.HollowShape == HollowShape.Circle) + lod = BSParam.MeshCircularLOD; + if (pbs.SculptEntry) lod = BSParam.SculptLOD; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 1eaa523..bda7c47 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -65,6 +65,8 @@ Vehicle attributes are not restored when a vehicle is rezzed on region creation GENERAL TODO LIST: ================================================= +Level-of-detail for mesh creation. Prims with circular interiors require lod of 32. + Is much saved with lower LODs? At the moment, all set to 32. Collisions are inconsistant: arrows are supposed to hit and report collision. Often don't. If arrow show at prim, collision reported about 1/3 of time. If collision reported, both arrow and prim report it. The arrow bounces off the prim 9 out of 10 times. diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs index 10c4bd3..2e7bb5d 100644 --- a/OpenSim/Region/Physics/Manager/IMesher.cs +++ b/OpenSim/Region/Physics/Manager/IMesher.cs @@ -59,6 +59,7 @@ namespace OpenSim.Region.Physics.Manager List getVertexList(); int[] getIndexListAsInt(); int[] getIndexListAsIntLocked(); + float[] getVertexListAsFloat(); float[] getVertexListAsFloatLocked(); void getIndexListAsPtrToIntArray(out IntPtr indices, out int triStride, out int indexCount); void getVertexListAsPtrToFloatArray(out IntPtr vertexList, out int vertexStride, out int vertexCount); diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index f781ff9..bd8e306 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs @@ -152,7 +152,7 @@ namespace OpenSim.Region.Physics.Meshing return result; } - private float[] getVertexListAsFloat() + public float[] getVertexListAsFloat() { if (m_vertices == null) throw new NotSupportedException(); -- cgit v1.1 From 5c94346bd7fd218ede591182b045aeb4a57b108e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Feb 2013 01:17:19 +0000 Subject: refactor: Move functions that lookup asset ids from task inventory or pass them through to ScriptUtils class in OpenSim.Region.Framework.dll Renames functions to better reflect what they do. This is so that code registering with modInvoke() can reuse this code to provide functions that behave in a consistent manner with existing LSL/OSSL functions. --- .../Framework/Scenes/Scripting/ScriptUtils.cs | 122 +++++++++++++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 104 +++--------------- 2 files changed, 137 insertions(+), 89 deletions(-) create mode 100644 OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs new file mode 100644 index 0000000..d8aa258 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs @@ -0,0 +1,122 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.Framework.Scenes.Scripting +{ + /// + /// Utility functions for use by scripts manipulating the scene. + /// + public static class ScriptUtils + { + /// + /// Get an asset id given an item name and an item type. + /// + /// UUID.Zero if the name and type did not match any item. + /// + /// + /// + public static UUID GetAssetIdFromItemName(SceneObjectPart part, string name, int type) + { + TaskInventoryItem item = part.Inventory.GetInventoryItem(name); + + if (item != null && item.Type == type) + return item.AssetID; + else + return UUID.Zero; + } + + /// + /// accepts a valid UUID, -or- a name of an inventory item. + /// Returns a valid UUID or UUID.Zero if key invalid and item not found + /// in prim inventory. + /// + /// Scene object part to search for inventory item + /// + /// + public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier) + { + UUID key; + + // if we can parse the string as a key, use it. + // else try to locate the name in inventory of object. found returns key, + // not found returns UUID.Zero + if (!UUID.TryParse(identifier, out key)) + { + TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); + + if (item != null) + key = item.AssetID; + else + key = UUID.Zero; + } + + return key; + } + + + /// + /// Return the UUID of the asset matching the specified key or name + /// and asset type. + /// + /// Scene object part to search for inventory item + /// + /// + /// + public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type) + { + UUID key; + + if (!UUID.TryParse(identifier, out key)) + { + TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); + if (item != null && item.Type == (int)type) + key = item.AssetID; + } + else + { + lock (part.TaskInventory) + { + foreach (KeyValuePair item in part.TaskInventory) + { + if (item.Value.Type == (int)type && item.Value.Name == identifier) + { + key = item.Value.ItemID; + break; + } + } + } + } + + return key; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0db6fe3..4fa3c60 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Animation; +using OpenSim.Region.Framework.Scenes.Scripting; using OpenSim.Region.Physics.Manager; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; @@ -333,79 +334,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - protected UUID InventoryKey(string name, int type) - { - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); - - if (item != null && item.Type == type) - return item.AssetID; - else - return UUID.Zero; - } - - /// - /// accepts a valid UUID, -or- a name of an inventory item. - /// Returns a valid UUID or UUID.Zero if key invalid and item not found - /// in prim inventory. - /// - /// - /// - protected UUID KeyOrName(string k) - { - UUID key; - - // if we can parse the string as a key, use it. - // else try to locate the name in inventory of object. found returns key, - // not found returns UUID.Zero - if (!UUID.TryParse(k, out key)) - { - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); - - if (item != null) - key = item.AssetID; - else - key = UUID.Zero; - } - - return key; - } - - /// - /// Return the UUID of the asset matching the specified key or name - /// and asset type. - /// - /// - /// - /// - protected UUID KeyOrName(string k, AssetType type) - { - UUID key; - - if (!UUID.TryParse(k, out key)) - { - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); - if (item != null && item.Type == (int)type) - key = item.AssetID; - } - else - { - lock (m_host.TaskInventory) - { - foreach (KeyValuePair item in m_host.TaskInventory) - { - if (item.Value.Type == (int)type && item.Value.Name == k) - { - key = item.Value.ItemID; - break; - } - } - } - } - - - return key; - } - //These are the implementations of the various ll-functions used by the LSL scripts. public LSL_Float llSin(double f) { @@ -1816,7 +1744,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID textureID = new UUID(); - textureID = InventoryKey(texture, (int)AssetType.Texture); + textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); if (textureID == UUID.Zero) { if (!UUID.TryParse(texture, out textureID)) @@ -2450,7 +2378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_SoundModule != null) { m_SoundModule.SendSound(m_host.UUID, - KeyOrName(sound, AssetType.Sound), volume, false, 0, + ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0, 0, false, false); } } @@ -2460,7 +2388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), + m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), volume, 20, false); } } @@ -2470,7 +2398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), + m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), volume, 20, true); } } @@ -2492,7 +2420,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_SoundModule != null) { m_SoundModule.SendSound(m_host.UUID, - KeyOrName(sound, AssetType.Sound), volume, false, 0, + ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0, 0, true, false); } } @@ -2504,7 +2432,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_SoundModule != null) { m_SoundModule.SendSound(m_host.UUID, - KeyOrName(sound, AssetType.Sound), volume, true, 0, 0, + ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, true, 0, 0, false, false); } } @@ -2521,7 +2449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); if (m_SoundModule != null) - m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0); + m_SoundModule.PreloadSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 0); ScriptSleep(1000); } @@ -3352,7 +3280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence != null) { // Do NOT try to parse UUID, animations cannot be triggered by ID - UUID animID = InventoryKey(anim, (int)AssetType.Animation); + UUID animID = ScriptUtils.GetAssetIdFromItemName(m_host, anim, (int)AssetType.Animation); if (animID == UUID.Zero) presence.Animator.AddAnimation(anim, m_host.UUID); else @@ -3374,7 +3302,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence != null) { - UUID animID = KeyOrName(anim); + UUID animID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, anim); if (animID == UUID.Zero) presence.Animator.RemoveAnimation(anim); @@ -4319,7 +4247,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void DoLLTeleport(ScenePresence sp, string destination, Vector3 targetPos, Vector3 targetLookAt) { - UUID assetID = KeyOrName(destination); + UUID assetID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, destination); // The destinaion is not an asset ID and also doesn't name a landmark. // Use it as a sim name @@ -4386,7 +4314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // TODO: Parameter check logic required. - m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); + m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound); m_host.CollisionSoundVolume = (float)impact_volume; } @@ -5912,7 +5840,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_SoundModule != null) { m_SoundModule.TriggerSoundLimited(m_host.UUID, - KeyOrName(sound, AssetType.Sound), volume, + ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, bottom_south_west, top_north_east); } } @@ -6346,7 +6274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: - prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); + prules.Texture = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, rules.GetLSLStringItem(i + 1)); break; case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: @@ -7269,9 +7197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID sculptId; if (!UUID.TryParse(map, out sculptId)) - { - sculptId = InventoryKey(map, (int)AssetType.Texture); - } + sculptId = ScriptUtils.GetAssetIdFromItemName(m_host, map, (int)AssetType.Texture); if (sculptId == UUID.Zero) return; -- cgit v1.1 From 36463612794f95776e8ddea14333827cbce35eff Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 5 Feb 2013 17:19:55 -0800 Subject: BulletSim: make removing zero width triangles from meshes optional and, for the moment, default to 'off'. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 6 +++ .../Physics/BulletSPlugin/BSShapeCollection.cs | 51 ++++++++++++---------- 2 files changed, 33 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index bdd9ce4..306928a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -62,6 +62,7 @@ public static class BSParam public static bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed public static bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes public static bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects + public static bool ShouldRemoveZeroWidthTriangles { get; private set; } public static float TerrainImplementation { get; private set; } public static float TerrainFriction { get; private set; } @@ -218,6 +219,11 @@ public static class BSParam (s,cf,p,v) => { ShouldUseHullsForPhysicalObjects = cf.GetBoolean(p, BSParam.BoolNumeric(v)); }, (s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); }, (s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ), + new ParameterDefn("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes", + ConfigurationParameters.numericFalse, + (s,cf,p,v) => { ShouldRemoveZeroWidthTriangles = cf.GetBoolean(p, BSParam.BoolNumeric(v)); }, + (s) => { return BSParam.NumericBool(ShouldRemoveZeroWidthTriangles); }, + (s,p,l,v) => { ShouldRemoveZeroWidthTriangles = BSParam.BoolNumeric(v); } ), new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", 32f, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index f17e513..f59b9d9 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs @@ -640,34 +640,37 @@ public sealed class BSShapeCollection : IDisposable { int[] indices = meshData.getIndexListAsInt(); - // int realIndicesIndex = indices.Length; + int realIndicesIndex = indices.Length; float[] verticesAsFloats = meshData.getVertexListAsFloat(); - // Remove degenerate triangles. These are triangles with two of the vertices - // are the same. This is complicated by the problem that vertices are not - // made unique in sculpties so we have to compare the values in the vertex. - int realIndicesIndex = 0; - for (int tri = 0; tri < indices.Length; tri += 3) + if (BSParam.ShouldRemoveZeroWidthTriangles) { - int v1 = indices[tri + 0] * 3; - int v2 = indices[tri + 1] * 3; - int v3 = indices[tri + 2] * 3; - if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] - && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] - && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2] ) - || ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] - && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] - && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2] ) - || ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] - && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] - && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2] ) ) - ) + // Remove degenerate triangles. These are triangles with two of the vertices + // are the same. This is complicated by the problem that vertices are not + // made unique in sculpties so we have to compare the values in the vertex. + realIndicesIndex = 0; + for (int tri = 0; tri < indices.Length; tri += 3) { - // None of the vertices of the triangles are the same. This is a good triangle; - indices[realIndicesIndex + 0] = indices[tri + 0]; - indices[realIndicesIndex + 1] = indices[tri + 1]; - indices[realIndicesIndex + 2] = indices[tri + 2]; - realIndicesIndex += 3; + int v1 = indices[tri + 0] * 3; + int v2 = indices[tri + 1] * 3; + int v3 = indices[tri + 2] * 3; + if (!((verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] + && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] + && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2]) + || (verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] + && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] + && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2]) + || (verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] + && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] + && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2])) + ) + { + // None of the vertices of the triangles are the same. This is a good triangle; + indices[realIndicesIndex + 0] = indices[tri + 0]; + indices[realIndicesIndex + 1] = indices[tri + 1]; + indices[realIndicesIndex + 2] = indices[tri + 2]; + realIndicesIndex += 3; + } } } DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", -- cgit v1.1 From eddfed3812354c5990631be0ac985cc25d5aa0e9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Feb 2013 01:37:22 +0000 Subject: Allow JsonReadNotecard() to accept the name of the notecard as well as the asset ID. Agreed in discussion with cmickeyb. This is to make this consistent with similar existing LSL/OSSL functions such as llTriggerSound() and osNpcLoadAppearance() that allow an item name or an asset id. --- .../Scripting/JsonStore/JsonStoreScriptModule.cs | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 5b7a79d..ec880a7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -39,6 +39,7 @@ using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Scripting; using System.Collections.Generic; using System.Text.RegularExpressions; @@ -256,10 +257,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// // ----------------------------------------------------------------- [ScriptInvocation] - public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) + public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier) { UUID reqID = UUID.Random(); - Util.FireAndForget(delegate(object o) { DoJsonReadNotecard(reqID,hostID,scriptID,storeID,path,assetID); }); + Util.FireAndForget(o => DoJsonReadNotecard(reqID, hostID, scriptID, storeID, path, notecardIdentifier)); return reqID; } @@ -463,14 +464,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- - private void DoJsonReadNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) + private void DoJsonReadNotecard( + UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier) { + UUID assetID; + + if (!UUID.TryParse(notecardIdentifier, out assetID)) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(hostID); + assetID = ScriptUtils.GetAssetIdFromItemName(part, notecardIdentifier, (int)AssetType.Notecard); + } + AssetBase a = m_scene.AssetService.Get(assetID.ToString()); if (a == null) - GenerateRuntimeError(String.Format("Unable to find notecard asset {0}",assetID)); + GenerateRuntimeError(String.Format("Unable to find notecard asset {0}", assetID)); if (a.Type != (sbyte)AssetType.Notecard) - GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); + GenerateRuntimeError(String.Format("Invalid notecard asset {0}", assetID)); m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); @@ -483,11 +493,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } catch (Exception e) { - m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message); + m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}", e.Message); } - GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); - m_comms.DispatchReply(scriptID,0,"",reqID.ToString()); + GenerateRuntimeError(String.Format("Json parsing failed for {0}", assetID)); + m_comms.DispatchReply(scriptID, 0, "", reqID.ToString()); } // ----------------------------------------------------------------- -- cgit v1.1 From dfe5826f9fd8854ddb5f0cc465564d8f124d7786 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Feb 2013 01:44:37 +0000 Subject: Remove wrong code in ScriptUtils.GetAssetIdFromKeyOrItemName which would return the item ID instead of the asset ID if the identifier was a uuid that matched an inventory item name. This would practically never happen. This makes this overloaded version of the function consistent with the other version. It looks like this accidentally came over in commit c5af16a from Tue Oct 16 12:40:21 2012 However, there's arguably a case for looking for an item name that matches a UUID before assuming that the identifier is already an asset ID. --- OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs index d8aa258..f08ba59 100644 --- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs +++ b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs @@ -82,7 +82,6 @@ namespace OpenSim.Region.Framework.Scenes.Scripting return key; } - /// /// Return the UUID of the asset matching the specified key or name /// and asset type. @@ -101,20 +100,6 @@ namespace OpenSim.Region.Framework.Scenes.Scripting if (item != null && item.Type == (int)type) key = item.AssetID; } - else - { - lock (part.TaskInventory) - { - foreach (KeyValuePair item in part.TaskInventory) - { - if (item.Value.Type == (int)type && item.Value.Name == identifier) - { - key = item.Value.ItemID; - break; - } - } - } - } return key; } -- cgit v1.1 From 9ebad38c34315302d6ed26356fc4da5c0465e3cb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Feb 2013 02:08:44 +0000 Subject: Remove unused ScriptEngineLoader and ScriptEngineInterface in OpenSim.Region.Framework.dll I believe this predates the generic system of registering interfaces and is very long unused. --- OpenSim/Region/Framework/Scenes/Scene.cs | 11 -- .../Scenes/Scripting/ScriptEngineInterface.cs | 38 ------- .../Scenes/Scripting/ScriptEngineLoader.cs | 119 --------------------- 3 files changed, 168 deletions(-) delete mode 100644 OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs delete mode 100644 OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f8d84e3..482235c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4482,19 +4482,8 @@ namespace OpenSim.Region.Framework.Scenes #region Script Engine - private List ScriptEngines = new List(); public bool DumpAssetsToFile; - /// - /// - /// - /// - public void AddScriptEngine(ScriptEngineInterface scriptEngine) - { - ScriptEngines.Add(scriptEngine); - scriptEngine.InitializeEngine(this); - } - private bool ScriptDanger(SceneObjectPart part,Vector3 pos) { ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs deleted file mode 100644 index 812a21c..0000000 --- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineInterface.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//TODO: WHERE TO PLACE THIS? - -namespace OpenSim.Region.Framework.Scenes.Scripting -{ - public interface ScriptEngineInterface - { - void InitializeEngine(Scene Sceneworld); - void Shutdown(); -// void StartScript(string ScriptID, IScriptHost ObjectID); - } -} diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs deleted file mode 100644 index c58ccc5..0000000 --- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptEngineLoader.cs +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* Original code: Tedd Hansen */ -using System; -using System.IO; -using System.Reflection; -using log4net; - -namespace OpenSim.Region.Framework.Scenes.Scripting -{ - public class ScriptEngineLoader - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public ScriptEngineInterface LoadScriptEngine(string EngineName) - { - ScriptEngineInterface ret = null; - try - { - ret = - LoadAndInitAssembly( - Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), - "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); - } - catch (Exception e) - { - m_log.Error("[ScriptEngine]: " + - "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + - e.StackTrace.ToString()); - } - return ret; - } - - /// - /// Does actual loading and initialization of script Assembly - /// - /// AppDomain to load script into - /// FileName of script assembly (.dll) - /// - private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) - { - //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); - // Load .Net Assembly (.dll) - // Initialize and return it - - // TODO: Add error handling - - Assembly a; - //try - //{ - - - // Load to default appdomain (temporary) - a = Assembly.LoadFrom(FileName); - // Load to specified appdomain - // TODO: Insert security - //a = FreeAppDomain.Load(FileName); - //} - //catch (Exception e) - //{ - // m_log.Error("[ScriptEngine]: Error loading assembly \String.Empty + FileName + "\": " + e.ToString()); - //} - - - //m_log.Debug("Loading: " + FileName); - //foreach (Type _t in a.GetTypes()) - //{ - // m_log.Debug("Type: " + _t.ToString()); - //} - - Type t; - //try - //{ - t = a.GetType(NameSpace, true); - //} - //catch (Exception e) - //{ - // m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString()); - //} - - ScriptEngineInterface ret; - //try - //{ - ret = (ScriptEngineInterface) Activator.CreateInstance(t); - //} - //catch (Exception e) - //{ - // m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString()); - //} - - return ret; - } - } -} -- cgit v1.1