Search Unity

Custom CinemachineTargetGroup / ICinemachineTargetGroup

Discussion in 'Cinemachine' started by plan-systems, Apr 18, 2022.

  1. plan-systems

    plan-systems

    Joined:
    Mar 8, 2020
    Posts:
    44
    Hi friends,

    Surprisingly, I didn't find posts or existing code illuminating a custom ICinemachineTargetGroup implementation. Namely, I'm seeing more info on the "observer" Matrix4x4 passed to GetViewSpaceAngularBounds() and GetViewSpaceBoundingBox() so that I can implement my own.

    The docs are lean on details, but is the gist of GetViewSpaceBoundingBox() that observer.MultiplyPoint(pt) in principle is called for all points in the target group and the bounds of that are returned? Even then, how is GetViewSpaceAngularBounds() calculated?

    Or perhaps someone has some snippets of these procs to demonstrate the values that are returned?

    These snippets would be useful for others, especially given the nuances of CinemachineTargetGroup and others would benefit. I will be happy to post my final code here for others as well.

    Thanks,
    Drew
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    I don't really understand your question. You can search in the CM code for callers of that method to see what they do with the result.
     
  3. plan-systems

    plan-systems

    Joined:
    Mar 8, 2020
    Posts:
    44
    Hi Greg, firstly, thanks for the response and your massive attendance to this forum!

    Unfortunately, example invocations of GetViewSpaceBoundingBox() and GetViewSpaceAngularBounds() are unknown / unavailable. This is expected since only Cinemachine itself consumes ICinemachineTargetGroup. So my question is really to just understand the specs of these two functions (or to get example snippets).

    If I knew the line(s) that calculate the Matrix4x4 (from a given a CinemachineVirtualCamera) that these methods expect, then I would be able to proceed by playing with a stock CinemachineTargetGroup and reverse-introspect the details of these methods. Alternatively, if I just had some snips or hints on the math contained in CinemachineTargetGroup.cs then I would be able to proceed directly with a more capable implementation.

    The driving force behind all this is that the stock CinemachineTargetGroup class has potential for improvements that others would appreciate as well (and would be happy to share that). I also would be happy to donate this code as example code fodder for upcoming Cinemachine releases if that was of interest. I think an area of improvement with Cinemachine are in offering a variety of ICinemachineTargetGroup implementations that specialize in certain things.

    Thanks G,
    Drew
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Are you trying to do this from metadata? Cinemachine source is freely available. Just look at it.

    We're always interested in ideas for improvement. What do you have in mind?
     
  5. plan-systems

    plan-systems

    Joined:
    Mar 8, 2020
    Posts:
    44
    Lol, oops, I did *not* know that. Amazed my previous searches didn't yield that, but a slice of humble pie will never hurt anyone. I found the repo and sorry to waste your time.

    In short, I'm looking at a CinemachineTargetGroup specializing in high number of targets that can change frequently and have more efficient evaluation (stages) of bounding computation, so that the stock impl doesn't burn cycles on item traversal and unneeded computation. I'll post when I have something.

    Thanks brother,
    Drew
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    That would be helpful indeed. Good luck!
     
    plan-systems likes this.