public ActionResult Edit([Bind(Exclude = "Image")] ContactHeader contactHeader, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        contactHeader.Image = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);


                        db.Entry(contactHeader).State = EntityState.Modified;
                        db.SaveChanges();

                        return(RedirectToAction("Index", "ContactHead"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }
            return(View());
        }
        public unsafe void Execute()
        {
            // Add a contact to any dynamic spheres
            for (int m = 0; m < Motions.Length; m++)
            {
                if (Bodies[m].Collider->Type == ColliderType.Sphere)
                {
                    var    sc      = (SphereCollider *)Bodies[m].Collider;
                    float3 bodyPos = Bodies[m].WorldFromBody.pos;

                    var ch = new ContactHeader();
                    ch.BodyPair.BodyAIndex = m;
                    ch.BodyPair.BodyBIndex = Motions.Length;
                    ch.NumContacts         = 1;
                    ch.Normal = new float3(0, 1, 0);

                    var cp = new ContactPoint
                    {
                        Distance = math.dot(ch.Normal, bodyPos) - sc->Radius,
                        Position = bodyPos - ch.Normal * math.dot(ch.Normal, bodyPos)
                    };

                    Contacts.AddContact(ch, cp);
                }
            }

            Contacts.CommitAddedContacts();
        }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        if (m_ContactModifierGroup.CalculateLength() == 0)
        {
            return(inputDeps);
        }

        if (m_StepPhysicsWorld.Simulation.Type == SimulationType.NoPhysics)
        {
            return(inputDeps);
        }

        var modifiers     = m_ContactModifierGroup.ToComponentDataArray <ModifyNarrowphaseContacts>(Allocator.TempJob);
        var surfaceNormal = modifiers[0].surfaceNormal;
        var surfaceRBIdx  = m_BuildPhysicsWorld.PhysicsWorld.GetRigidBodyIndex(modifiers[0].surfaceEntity);

        SimulationCallbacks.Callback callback = (ref ISimulation simulation, JobHandle inDeps) =>
        {
            inDeps.Complete();  // TODO: shouldn't be needed (jobify the below)

            SimulationData.Contacts.Iterator iterator = simulation.Contacts.GetIterator();
            while (iterator.HasItemsLeft())
            {
                ContactHeader manifold      = iterator.GetNextContactHeader();
                bool          bUpdateNormal = (manifold.BodyPair.BodyAIndex == surfaceRBIdx) || (manifold.BodyPair.BodyBIndex == surfaceRBIdx);

                float distanceScale = 1;
                if (bUpdateNormal)
                {
                    var newNormal = surfaceNormal;
                    distanceScale = math.dot(newNormal, manifold.Normal);

                    //<todo.eoin.hpi Feels pretty weird.
                    //<todo.eoin.hp Need to make this work if user has read a contact
                    iterator.SetManifoldNormal(newNormal);
                }
                for (int i = 0; i < manifold.NumContacts; i++)
                {
                    ContactPoint cp = iterator.GetNextContact();

                    if (bUpdateNormal)
                    {
                        cp.Distance *= distanceScale;
                        iterator.UpdatePreviousContact(cp);
                    }
                }
            }

            return(inDeps);
        };

        modifiers.Dispose();

        m_StepPhysicsWorld.EnqueueCallback(SimulationCallbacks.Phase.PostCreateContacts, callback);

        return(inputDeps);
    }
        private void Test()
        {
            ContactHeader c = Parse("\"A. G. Bell\" <sip:[email protected]> ;tag=a48s");

            Assert.Equal("A. G. Bell", c.FirstContact.Name);
            Assert.Equal("sip", c.FirstContact.Uri.Scheme);
            Assert.Equal("agb", c.FirstContact.Uri.UserName);
            Assert.Equal("bell-telephone.com", c.FirstContact.Uri.Domain);
            Assert.Equal("a48s", c.Parameters["tag"]);
        }
Exemple #5
0
 private void CreateCommonHeaders(SipUser sipUser, LocalSipUserAgentServer localSipUas, SipTransportManager sipTransportManager)
 {
     this.viaHeader     = new ViaHeader(localSipUas, sipTransportManager.SipProtocol, sipTransportManager.SipTransport);
     this.fromHeader    = new FromHeader(sipUser, localSipUas, sipTransportManager.SipProtocol);
     this.toHeader      = new ToHeader(localSipUas, sipTransportManager.SipProtocol);
     this.callIdHeader  = new CallIdHeader();
     this.contactHeader = new ContactHeader(localSipUas, sipTransportManager.SipProtocol);
     this.routeHeader   = new RouteHeader(localSipUas, sipTransportManager.SipProtocol);
     this.userAgent     = new UserAgentHeader();
     this.expiresHeader = new ExpiresHeader();
     this.maxForwards   = new MaxForwardsHeader();
     this.allowHeader   = new AllowHeader();
     this.contentLength = new ContentLength(body);
 }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound("ID is missing"));
            }

            ContactHeader contactHeader = db.ContactHeaders.Find(id);

            if (contactHeader == null)
            {
                return(HttpNotFound("ID was not found"));
            }

            return(View(contactHeader));
        }
Exemple #7
0
        public void Execute(int workItemIndex)
        {
            OutputStream.Begin(workItemIndex);

            while (ManifoldIterator.HasItemsLeft())
            {
                ContactHeader contactHeader = ManifoldIterator.GetNextContactHeader();
                for (int c = 0; c < contactHeader.NumContacts; c++)
                {
                    Unity.Physics.ContactPoint contact = ManifoldIterator.GetNextContact();
                    float3 x0    = contact.Position;
                    float3 x1    = contactHeader.Normal * contact.Distance;
                    Color  color = Color.green;
                    OutputStream.Arrow(x0, x1, color);
                }
            }

            OutputStream.End();
        }
Exemple #8
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        if (m_ContactModifierGroup.CalculateLength() == 0)
        {
            return(inputDeps);
        }

        if (m_StepPhysicsWorld.Simulation.Type == SimulationType.NoPhysics)
        {
            return(inputDeps);
        }

        SimulationCallbacks.Callback preparationCallback = (ref ISimulation simulation, JobHandle inDeps) =>
        {
            inDeps.Complete();  // shouldn't be needed (jobify the below)

            SimulationData.Contacts.Iterator iterator = simulation.Contacts.GetIterator();
            while (iterator.HasItemsLeft())
            {
                ContactHeader manifold = iterator.GetNextContactHeader();

                // JacobianModifierFlags format for this example
                // UserData 0 - soft contact
                // UserData 1 - surface velocity
                // UserData 2 - infinite inertia
                // UserData 3 - no torque
                // UserData 4 - clip impulse
                // UserData 5 - disabled contact

                if (0 != (manifold.BodyCustomDatas.CustomDataA & (byte)(1 << 0)) ||
                    0 != (manifold.BodyCustomDatas.CustomDataB & (byte)(1 << 0)))
                {
                    manifold.JacobianFlags |= JacobianFlags.UserFlag0; // Soft Contact
                }
                if (0 != (manifold.BodyCustomDatas.CustomDataA & (byte)(1 << 1)) ||
                    0 != (manifold.BodyCustomDatas.CustomDataB & (byte)(1 << 1)))
                {
                    manifold.JacobianFlags |= JacobianFlags.EnableSurfaceVelocity;
                }
                if (0 != (manifold.BodyCustomDatas.CustomDataA & (byte)(1 << 2)) ||
                    0 != (manifold.BodyCustomDatas.CustomDataB & (byte)(1 << 2)))
                {
                    manifold.JacobianFlags |= JacobianFlags.EnableMassFactors;
                }
                if (0 != (manifold.BodyCustomDatas.CustomDataA & (byte)(1 << 3)) ||
                    0 != (manifold.BodyCustomDatas.CustomDataB & (byte)(1 << 3)))
                {
                    manifold.JacobianFlags |= JacobianFlags.UserFlag1; // No Torque
                }
                if (0 != (manifold.BodyCustomDatas.CustomDataA & (byte)(1 << 4)) ||
                    0 != (manifold.BodyCustomDatas.CustomDataB & (byte)(1 << 4)))
                {
                    manifold.JacobianFlags |= JacobianFlags.EnableMaxImpulse; // No Torque
                }
                if (0 != (manifold.BodyCustomDatas.CustomDataA & (byte)(1 << 5)) ||
                    0 != (manifold.BodyCustomDatas.CustomDataB & (byte)(1 << 5)))
                {
                    manifold.JacobianFlags |= JacobianFlags.Disabled;
                }

                iterator.UpdatePreviousContactHeader(manifold);

                // Just read contacts
                for (int i = 0; i < manifold.NumContacts; i++)
                {
                    iterator.GetNextContact();
                }
            }

            return(inDeps);
        };

        SimulationCallbacks.Callback jacobianModificationCallback = (ref ISimulation simulation, JobHandle inDeps) =>
        {
            inDeps.Complete();  // shouldn't be needed (jobify the below)

            JacobianIterator iterator = simulation.Jacobians.Iterator;
            while (iterator.HasJacobiansLeft())
            {
                // JacobianModifierFlags format for this example
                // UserFlag0 - soft contact
                // UserFlag1 - no torque

                // Jacobian header
                ref JacobianHeader jacHeader = ref iterator.ReadJacobianHeader();

                // Triggers can only be disabled, other modifiers have no effect
                if (jacHeader.Type == JacobianType.Contact)
                {
                    // Contact jacobian modification
                    ref ContactJacobian contactJacobian = ref jacHeader.AccessBaseJacobian <ContactJacobian>();
                    {
                        // Check if NoTorque modifier
                        if ((jacHeader.Flags & JacobianFlags.UserFlag1) != 0)
                        {
                            // Disable all friction angular effects
                            contactJacobian.Friction0.AngularA       = 0.0f;
                            contactJacobian.Friction1.AngularA       = 0.0f;
                            contactJacobian.AngularFriction.AngularA = 0.0f;
                            contactJacobian.Friction0.AngularB       = 0.0f;
                            contactJacobian.Friction1.AngularB       = 0.0f;
                            contactJacobian.AngularFriction.AngularB = 0.0f;
                        }

                        // Check if SurfaceVelocity present
                        if (jacHeader.HasSurfaceVelocity)
                        {
                            // Since surface normal can change, make sure angular velocity is always relative to it, not independent
                            float3 angVel = contactJacobian.BaseJacobian.Normal * (new float3(0.0f, 1.0f, 0.0f));
                            float3 linVel = float3.zero;

                            Math.CalculatePerpendicularNormalized(contactJacobian.BaseJacobian.Normal, out float3 dir0, out float3 dir1);
                            float linVel0 = math.dot(linVel, dir0);
                            float linVel1 = math.dot(linVel, dir1);

                            float angVelProj = math.dot(angVel, contactJacobian.BaseJacobian.Normal);

                            jacHeader.SurfaceVelocity = new SurfaceVelocity {
                                ExtraFrictionDv = new float3(linVel0, linVel1, angVelProj)
                            };
                        }
Exemple #9
0
        public static void Consume()
        {
            // For getting the raw XML
            SecurityHandler.Instance.CollectRawRequestResponse          = true;
            CrmHandler.Instance.CollectRawRequestResponse               = true;
            ProjectManagementHandler.Instance.CollectRawRequestResponse = true;

            IEnumerable <string> messages;

            if (SecurityHandler.Instance.TryAuthenticate(out messages))
            {
                RawMessageHelper.Instance.SaveRecentRequestResponsePair("c:\\temp\\TryAuthenticate.txt");
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info("Sucessfully authenticated on transactional API");
                }

                // Get a customer

                var newContactHeader = new ContactHeader();
                newContactHeader.FirstName = "FirstTest";
                newContactHeader.LastName  = "LastTest";
                newContactHeader.GUID      = Guid.NewGuid();

                var newCustomer = new Customer()
                {
                    Name      = "NewCustomerDDDDD",
                    AccountNo = String.Empty,
                    Action    = TransactionalApi.SDK.CrmService.DataAction.Created,
                    Address   = new Address()
                    {
                        Address1 = "123", Country = "Denmark", City = "Copenhagen", State = "dunno", ZipCode = "68000"
                    },
                    CalculateVAT           = true,
                    Contacts               = new ContactHeader[] { newContactHeader },
                    CreditorID             = string.Empty,
                    Currency               = "DKK",
                    DefaultDiscountPercent = 2,
                    Status = "Customer",
                    ID     = 11078
                };

                var customersResult = CrmHandler.Instance.CrmClient.InsertCustomer(newCustomer, 2,
                                                                                   CrmHandler.Instance.Token);
                RawMessageHelper.Instance.SaveRecentRequestResponsePair("c:\\temp\\InsertCustomer.txt");
                if (customersResult.ResponseState == TransactionalApi.SDK.CrmService.ExecutionStatus.Success)
                {
                    var customer = customersResult.Return.FirstOrDefault();
                    if (customer != null)
                    {
                    }
                    else
                    {
                        if (Logger.IsWarnEnabled)
                        {
                            Logger.Warn("No customer found");
                        }
                    }
                }
                else
                {
                    foreach (var apiMessage in customersResult.Messages)
                    {
                        if (Logger.IsErrorEnabled)
                        {
                            Logger.Error(apiMessage.Message);
                        }
                    }
                }
            }
            else
            {
                if (Logger.IsWarnEnabled)
                {
                    Logger.Warn("Failed to authenticate to transactional API");
                    Logger.Warn(string.Join(",", messages));
                }
            }
        }
Exemple #10
0
        public unsafe void ManifoldQueryTest()
        {
            const uint seed      = 0x98765432;
            Random     rnd       = new Random(seed);
            int        numWorlds = 1000;

            uint dbgWorld = 0;

            if (dbgWorld > 0)
            {
                numWorlds = 1;
            }

            for (int iWorld = 0; iWorld < numWorlds; iWorld++)
            {
                // Save state to repro this query without doing everything that came before it
                if (dbgWorld > 0)
                {
                    rnd.state = dbgWorld;
                }
                uint worldState            = rnd.state;
                Physics.PhysicsWorld world = TestUtils.GenerateRandomWorld(ref rnd, rnd.NextInt(1, 20), 3.0f);

                // Manifold test
                // TODO would be nice if we could change the world collision tolerance
                for (int iBodyA = 0; iBodyA < world.NumBodies; iBodyA++)
                {
                    for (int iBodyB = iBodyA + 1; iBodyB < world.NumBodies; iBodyB++)
                    {
                        Physics.RigidBody bodyA = world.Bodies[iBodyA];
                        Physics.RigidBody bodyB = world.Bodies[iBodyB];
                        if (bodyA.Collider->Type == ColliderType.Mesh && bodyB.Collider->Type == ColliderType.Mesh)
                        {
                            continue; // TODO - no mesh-mesh manifold support yet
                        }

                        // Build manifolds
                        BlockStream        contacts      = new BlockStream(1, 0, Allocator.Temp);
                        BlockStream.Writer contactWriter = contacts;
                        contactWriter.BeginForEachIndex(0);
                        ManifoldQueries.BodyBody(ref world, new BodyIndexPair {
                            BodyAIndex = iBodyA, BodyBIndex = iBodyB
                        }, 1.0f, ref contactWriter);
                        contactWriter.EndForEachIndex();

                        // Read each manifold
                        BlockStream.Reader contactReader = contacts;
                        contactReader.BeginForEachIndex(0);
                        int manifoldIndex = 0;
                        while (contactReader.RemainingItemCount > 0)
                        {
                            string failureMessage = iWorld + " (" + worldState + ") " + iBodyA + " vs " + iBodyB + " #" + manifoldIndex;
                            manifoldIndex++;

                            // Read the manifold header
                            ContactHeader header = contactReader.Read <ContactHeader>();
                            ConvexConvexManifoldQueries.Manifold manifold = new ConvexConvexManifoldQueries.Manifold();
                            manifold.NumContacts = header.NumContacts;
                            manifold.Normal      = header.Normal;

                            // Get the leaf shapes
                            ChildCollider leafA, leafB;
                            {
                                Collider.GetLeafCollider(bodyA.Collider, bodyA.WorldFromBody, header.ColliderKeys.ColliderKeyA, out leafA);
                                Collider.GetLeafCollider(bodyB.Collider, bodyB.WorldFromBody, header.ColliderKeys.ColliderKeyB, out leafB);
                            }

                            // Read each contact point
                            int minIndex = 0;
                            for (int iContact = 0; iContact < header.NumContacts; iContact++)
                            {
                                // Read the contact and find the closest
                                ContactPoint contact = contactReader.Read <ContactPoint>();
                                manifold[iContact] = contact;
                                if (contact.Distance < manifold[minIndex].Distance)
                                {
                                    minIndex = iContact;
                                }

                                // Check that the contact point is on or inside the shape
                                CheckPointOnSurface(ref leafA, contact.Position + manifold.Normal * contact.Distance, failureMessage + " contact " + iContact + " leaf A");
                                CheckPointOnSurface(ref leafB, contact.Position, failureMessage + " contact " + iContact + " leaf B");
                            }

                            // Check the closest point
                            {
                                ContactPoint           closestPoint = manifold[minIndex];
                                RigidTransform         aFromWorld   = math.inverse(leafA.TransformFromChild);
                                DistanceQueries.Result result       = new DistanceQueries.Result
                                {
                                    PositionOnAinA = math.transform(aFromWorld, closestPoint.Position + manifold.Normal * closestPoint.Distance),
                                    NormalInA      = math.mul(aFromWorld.rot, manifold.Normal),
                                    Distance       = closestPoint.Distance
                                };

                                MTransform aFromB            = new MTransform(math.mul(aFromWorld, leafB.TransformFromChild));
                                float      referenceDistance = DistanceQueries.ConvexConvex(leafA.Collider, leafB.Collider, aFromB).Distance;
                                ValidateDistanceResult(result, ref ((ConvexCollider *)leafA.Collider)->ConvexHull, ref ((ConvexCollider *)leafB.Collider)->ConvexHull, aFromB, referenceDistance, failureMessage + " closest point");
                            }

                            // Check that the manifold is flat
                            CheckManifoldFlat(ref manifold, manifold.Normal, failureMessage + ": non-flat A");
                            CheckManifoldFlat(ref manifold, float3.zero, failureMessage + ": non-flat B");
                        }

                        contacts.Dispose();
                    }
                }

                world.Dispose(); // TODO leaking memory if the test fails
            }
        }