Commit Graph

19 Commits

Author SHA1 Message Date
Hans Goudey 8157f33911 Cleanup: Move opensubdiv C-API headers to C++
All the relevant code is C++ now, so we don't need to complicate things
with the trip through C anymore. We will still need some wrappers, since
opensubdiv is an optional dependency though. The goal is to make it
simpler to remove the unnecessary/costly abstraction levels between
Blender mesh data and the opensubdiv code.
2023-12-11 07:50:29 -05:00
Campbell Barton 1b508de749 License headers: use SPDX-FileCopyrightText in intern/opensubdiv 2023-06-15 16:47:51 +10:00
Sergey Sharybin a20f45bab9 Fix unqualified access to std::move in OpenSubdiv 2023-04-19 10:02:09 +02:00
Sergey Sharybin a12a8a71bb Remove "All Rights Reserved" from Blender Foundation copyright code
The goal is to solve confusion of the "All rights reserved" for licensing
code under an open-source license.

The phrase "All rights reserved" comes from a historical convention that
required this phrase for the copyright protection to apply. This convention
is no longer relevant.

However, even though the phrase has no meaning in establishing the copyright
it has not lost meaning in terms of licensing.

This change makes it so code under the Blender Foundation copyright does
not use "all rights reserved". This is also how the GPL license itself
states how to apply it to the source code:

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software ...

This change does not change copyright notice in cases when the copyright
is dual (BF and an author), or just an author of the code. It also does
mot change copyright which is inherited from NaN Holding BV as it needs
some further investigation about what is the proper way to handle it.
2023-03-30 10:51:59 +02:00
Harley Acheson 3a7fd309fc Spelling: It's Versus Its
Corrects incorrect usage of contraction for 'it is', when possessive 'its' was required.

Differential Revision: https://developer.blender.org/D9250

Reviewed by Campbell Barton
2020-10-19 08:12:33 -07:00
Campbell Barton 4786719dbd Cleanup: spelling 2020-09-24 14:27:48 +10:00
Sergey Sharybin efa4ae17f0 OpenSubdiv: Only store edges topology for non-smooth edges
This change makes it so vertices of edge are only stored when edge
has non-zero crease. This allows to lower memory footprint of 1.5M
faces from 78 MiB to 54 MiB in the case all creases are zero.

Meshes with crease are more hard to predict due to array-based
storage, so it all depends on index of edge with crease. Worst case
(all edges are creased) still stays at 78 MiB.
2020-05-27 12:07:16 +02:00
Sergey Sharybin 42cb1e3a2c OpenSubdiv: Optimize faces storage in mesh topology
Avoid per-face pointer and allocation: store everything as continuous
arrays.

Memory footprint for 1.5M faces:

- Theoretical worst case (all vertices and edges have crease) memory
  goes down from 114 MiB to 96 MiB (15% improvement).

  This case is not currently achievable since Blender does not expose
  vertex crease yet.

- Current real life worst case (all edges have crease) memory goes
  down from 108 MiB to 90 MiB (17% improvement).

- Best case (no creases at all) memory goes down from 96 MiB to 78 MiB
  (19% improvement).
2020-05-27 12:07:16 +02:00
Sergey Sharybin 38b50fe393 OpenSubdiv: Hide individual topology elements
Move all API to happen via MeshTopology.

This is a preparation for an upcoming memory optimization.
2020-05-27 12:07:16 +02:00
Sergey Sharybin a444400900 OpenSubdiv: Keep explicit storage of base mesh faces
Allows to perform comparison by doing linear comparison of indices.

Before cyclic match was used to deal with possibly changed winding from
OpenSubdiv side.

Speeds up comparison (and hence improves FPS), makes code more reliable
nut uses more memory.
2020-05-27 12:07:16 +02:00
Sergey Sharybin 1e0de7c2ea OpenSubdiv: Compare edge topology
This change makes it so topology refiner comparison will check vertices
of all existing/provided edges.

The initial claim that due to manifold nature of mesh there is no need
in "deep" edges check was wrong: some areas might only provide edges
with non-zero creases. So if crease of one edge goes changes from 1.0
to 0.0 and crease of other edge goes from 0.0 to 1.0 the old comparison
code would not have caught it.
2020-05-27 12:07:16 +02:00
Sergey Sharybin ece54172d0 OpenSubdiv: Use explicit storage for edge sharpness
Similar to previous change in vertex sharpness, explicitly store value
provided by the converter.

Allows to avoid rather fragile check for boundary edges.

Also allows to avoid need in constructing edge map. This lowers memory
footprint of the comparison process and avoids memory allocations
during the comparison (which is an extra benefit from the performance
point of view).
2020-05-27 12:07:16 +02:00
Sergey Sharybin 614d70a87d OpenSubdiv: Compare sharpness based on converter
This change starts the transition of topology refiner comparison
to compare actual values given by the converter, which will not be
affected by the refinement or face winding synchronization steps.

Currently is only implemented for vertex sharpness, but will be
extended further as followup development.

Fixes T71908: Subdiv: Incorrect topology comparison, leading to poor performance
2020-05-27 12:07:16 +02:00
Sergey Sharybin 444ca1a117 OpenSubdiv: Refactor, move utils to base
Also split them across utilities and types.
2020-05-27 12:07:16 +02:00
Sergey Sharybin be03a756e5 OpenSubdiv: Cleanup, move utility function to base type conversion 2020-05-27 12:07:16 +02:00
Sergey Sharybin 0ff665e4ce OpenSubdiv: Refactor, move type conversion to base fodler 2020-05-27 12:07:16 +02:00
Sergey Sharybin 6fc9d106ad OpenSubdiv: Completely disable topology verification
Previously it was enabled for debug builds, now it is to be enabled
explicitly.

The reason for this is to reduce overhead when debugging other areas
which might involve subdivision surface. When conversion is to be
debugged set this manually in the code.
2020-05-27 12:07:16 +02:00
Sergey Sharybin 4ab36c4393 OpenSubdiv: Refactor creation of topology refiner
Consolidate it inside of the topology refiner implementation class,
which would allow to store extra data acquired during construction
of the OpenSubdiv's object.
2020-05-27 12:07:15 +02:00
Sergey Sharybin c81a5f58f8 OpenSubdiv: Refactor, move topology refiner factory to topology folder 2020-05-27 12:07:15 +02:00