Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Aram-Azhari · Oct 30, 2013 at 10:02 AM · multithreadingcalculationsinversetransformpoint

Calculating InverseTransformPoint outside unity

Hi,

I need to calculate InverseTransformPoint of some points, but without using unity classes (multithreading issue). Do you know a code piece or a good straightforward reference that I can implement this function quickly?

In short:

  GameObject g= new GameObject(); var result = g.transform.InverseTransformPoint(new Vector(1,2,3)); // Now, imagine doing this outside Unity.

What I want is the code that does InverseTransformPoint. Thank you.

Comment
Add comment · Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Oct 30, 2013 at 10:13 AM 0
Share

I think it's called a map, to be facetious :P

Really though, I think you need to explain.

avatar image Aram-Azhari · Oct 30, 2013 at 10:27 AM 0
Share

I updated the question,

avatar image meat5000 ♦ · Oct 30, 2013 at 10:54 AM 0
Share

What is this multithreading issue you have? It'd be good to have the information in the QA

avatar image Aram-Azhari · Oct 30, 2013 at 10:56 AM 0
Share

It's the fact that no unity object can be manipulated nor read from other threads. And whoever claims that they do, they really don't. They just dispatch it to the main thread, hence not really running on the other thread.

avatar image meat5000 ♦ · Oct 30, 2013 at 11:01 AM 0
Share

I'm guessing this also apply to static variables? It pretty much has to inject the value into the main thread in Async, right?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by fafase · Oct 30, 2013 at 10:31 AM

You are trying to convert a world space into local space.

You need to define your local space matrix and multiply your point by that matrix.

Your local matrix is (if I remember right) the composite matrix of your new origin.

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Oct 30, 2013 at 10:37 AM 0
Share

Will this do it?

avatar image fafase · Oct 30, 2013 at 10:39 AM 1
Share

Yes but the main part is to fill up the values of the matrix. Depending if you are in 2D or 3D the matrix is different. Then you multiply scale rotation translation of the origin object and you get your composite matrix. $$anonymous$$ultiply your object composite matrix by the origin matrix and you get the object in local space.

avatar image Aram-Azhari · Oct 30, 2013 at 10:40 AM 1
Share

So, I need to get g.transform.worldToLocal$$anonymous$$atrix and then multiply my point by that? (using meat5000's link)

avatar image Bunny83 · Oct 30, 2013 at 11:21 AM 1
Share

Yes, all you need is the worldToLocal$$anonymous$$atrix, but keep in $$anonymous$$d to read the value synchronised and save a copy for your processing thread. Also the link above is about the $$anonymous$$atrix class of the .NET framework which is just a 3x3 matrix and only used for 2d transformations. That has nothing to do with Unity.

While it's true that most unity "objects" are not useable from other threads, most structs can be used without any problem besides the usual syncronising.

$$anonymous$$eep in $$anonymous$$d that even reading a variable from another thread can cause the content of that variable be corrupted due to caching.

So you need to read your worldToLocal$$anonymous$$atrix inside the Unity main thread and pass it syncronised to your thread.

Without more information about the actual task of your thread we can't suggest any alternatives. Hopefully you can decide if it's worth to do the calculations in a seperate thread. If it's something "quite small", the performance would actually decrease.

avatar image Aram-Azhari · Oct 30, 2013 at 11:25 AM 0
Share

Thanks for the comment. It is not small. It is big, it is very very big. I know it sounds funny but I'm talking tens of thousands of geometry manipulations. $$anonymous$$ay be I'm better off creating them outside unity and bringing them back in once they're done.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multithreading doesn’t improve performance 0 Answers

"...can only be called from the main thread" - MultiThreading 1 Answer

Defer graphics.blit until render thread? (Android) 1 Answer

Split screen as two processes 0 Answers

Are UnityEngine.Object types still not thread safe? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges