Skip to content

Commit

Permalink
OGSMOD-2694 Merge latest text features from adsk/feature/text to adsk…
Browse files Browse the repository at this point in the history
…/dev branch. (PixarAnimationStudios#207)

Description of Change(s)
Cherry-pick text commits from adsk/feature/text to adsk/dev branch.

Fixes Issue(s)
Include underline/overline feature and bugs fixing.
  • Loading branch information
sophie749 authored and GitHub Enterprise committed Jan 4, 2023
1 parent f32338c commit 14414fe
Show file tree
Hide file tree
Showing 29 changed files with 1,676 additions and 263 deletions.
8 changes: 4 additions & 4 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,11 +1468,11 @@ def InstallOpenSubdiv(context, force, buildArgs):
# TextSystem

if MacOS():
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-8dce8a7/textsystem_Darwin_8dce8a7_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-8dce8a7/textsystem_Darwin_8dce8a7_Debug.zip"
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-e21f95f/textsystem_Darwin_e21f95f_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-e21f95f/textsystem_Darwin_e21f95f_Debug.zip"
elif Windows():
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-8dce8a7/textsystem_Windows_8dce8a7_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-8dce8a7/textsystem_Windows_8dce8a7_Debug.zip"
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-e21f95f/textsystem_Windows_e21f95f_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-e21f95f/textsystem_Windows_e21f95f_Debug.zip"

def InstallTextSystem(context, force, buildArgs):
if context.buildDebug:
Expand Down
54 changes: 54 additions & 0 deletions extras/usd/examples/usdGeomExamples/complexScripts.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#usda 1.0

(
upAxis = "Y"
doc = """This layer represents the various geometric forms that curves
may be used to represent."""
)

def Xform "Text1" {
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 9, 0)
def Scope "Text11"{
def GenericText "TextA" (){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (3, 0, 0)

string markupString = "\\fArial|b0|i0|p34|c0;\\H20;\\c65300;Ěšč②Ab2ガ≈ガ \\P圭传岩 ščहिĚšč②Ab2ガ≈ガ \\P كيف هو الطقس اليو"
uniform token markupLanguage = "mtext"
color3f[] primvars:displayColor = [(0, 1, 0)]
rel textStyle:binding = </StyleA>
rel columnStyle:binding = [
</columnA>,
</columnB>,
]
rel paragraphStyle:binding = </paragraphA>
}
}
}

def TextStyle "StyleA" {
string typeface = "Times New Roman"
int textHeight = 20
}

def ColumnStyle "columnA" {
float columnWidth = 1000
float columnHeight = 300
float2 offset = (0.0, 0.0)
}

def ColumnStyle "columnB" {
float columnWidth = 1000
float columnHeight = 300
float2 offset = (0.0, -320.0)
}

def ParagraphStyle "paragraphA" {
float leftIndent = 15.0
float rightIndent = 30.0
float firstLineIndent = 55.0
float paragraphSpace = 15.0
float[] tabStopPosition = [150.0, 350.0, 550.0, 750.0]
uniform token[] tabStopType = ["centerTab", "centerTab", "centerTab", "centerTab"]
}
4 changes: 2 additions & 2 deletions extras/usd/examples/usdGeomExamples/multilineText.usda
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def Xform "Text1" {
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (3, 0, 0)

string markupString = "\\fArial|b0|i0|p34|c0;\\H20;\\c65300;Pipelines capable of producing computer graphics films and games typically generate, store, and transmit large quantities of 3D data, which we call \\H30;\\c42137;scene description\\H20;\\c65300;. Each of many cooperating applications in the pipeline (modeling, shading, animation, lighting, fx, rendering) typically has its own special form of scene description tailored to the specific needs and workflows of the application, which is neither readable nor editable by any other application. \\P\\fArial|b0|i1|p34|c0;\\H30;\\c12255232;Universal Scene Description (USD)\\fArial|b0|i0|p34|c0;\\H20;\\c65300; is the first publicly available software that addresses the need to robustly and scalably interchange and augment arbitrary 3D scenes that may be composed from many elemental assets.\\PUSD organizes data into hierarchical namespaces of \\H30;\\c42137;Prims\\H20;\\c65300; (short for \"primitive\"). Built on top of this low-level, generic scene description, USD provides a set of schemas that establish a standard encoding and client API for common 3D computer graphics concepts like:\n\tGeometry\tShading\tModel and Asset\\P\\H30;\\c42137;Composition arcs\\H20;\\c65300; are the \"operators\" that allow USD to create rich compositions of many layers containing mixes of \"base\" scene description and overrides. Composition arcs include:\n\tsublayers\tinherits\tvariantSets\treferences\n\tpayloads\tspecializes\tTestA\tTestB\n\tTestC\tTestD\tTestE"
string markupString = "\\fArial|b0|i0|p34|c0;\\H20;\\c65300;\\l\\oPipelines capable of producing computer graphics films and games typically generate, store, and transmit large quantities of 3D data, \\Owhich we call \\H30;\\c42137;scene description\\H20;\\o\\c65300;. Each of many cooperating applications in the pipeline (modeling, shading, animation, lighting, fx, rendering) typically has its own special form \\Oof scene description tailored to the specific needs and workflows of the application, which is neither readable nor editable by any other application.\\o \\P\\fArial|b0|i1|p34|c0;\\H30;\\c12255232;\\OUniversal Scene Description (USD)\\fArial|b0|i0|p34|c0;\\H20;\\c65300; is the first\\o publicly available \\Osoftware that \\oaddresses the need to robustly and scalably interchange and augment arbitrary 3D scenes that may be composed from many elemental assets.\\PUSD organizes data into hierarchical \\Lnamespaces of \\H30;\\c42137;Prims\\H20;\\c65300; (short for \"primitive\").\\lBuilt on top of this low-level, \\Lgeneric scene description, USD provides a set of schemas that establish\\l a standard encoding and client API for common 3D computer graphics concepts like:\n\tGeometry\tShading\tModel and Asset\\P\\H30;\\c42137;\\LComposition arcs\\H20;\\c65300; are the \"operators\" that \\lallow USD to create\\L rich compositions of many \\llayers containing \\Lmixes of \"base\" scene description and overrides. Composition arcs include:\n\tsublayers\tinherits\tvariantSets\treferences\n\tpayloads\tspecializes\tTestA\tTestB\n\tTestC\tTestD\tTestE\\l"
uniform token markupLanguage = "mtext"
color3f[] primvars:displayColor = [(0, 1, 1)]
color3f[] primvars:displayColor = [(0, 1, 0)]
rel textStyle:binding = </StyleA>
rel columnStyle:binding = [
</columnA>,
Expand Down
7 changes: 4 additions & 3 deletions extras/usd/examples/usdGeomExamples/simpleText.usda
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def Xform "Text1" {
rel textStyle:binding = </StyleA>
rel textRenderingTechnique:binding = </TechniqueA>
}

def SimpleText "TextB" (
prepend apiSchemas = ["TextStyleAPI"]
prepend apiSchemas = ["TextRenderingTechniqueAPI"]
Expand All @@ -36,7 +35,7 @@ def Xform "Text1" {
rel textStyle:binding = </StyleB>
rel textRenderingTechnique:binding = </TechniqueB>

uniform bool primvars:cameraFacing = 1
uniform int primvars:cameraFacing = 1
}

def SimpleText "TextC" (
Expand All @@ -49,7 +48,7 @@ def Xform "Text1" {
color3f[] primvars:displayColor = [(0, 1, 1)]
rel textStyle:binding = </StyleB>

uniform bool primvars:cameraFacing = 1
uniform int primvars:cameraFacing = 1
}
}
}
Expand All @@ -58,12 +57,14 @@ def TextStyle "StyleA" {
string typeface = "Times New Roman"
int textHeight = 100
bool bold = 1
string overlineType = "Normal"
}

def TextStyle "StyleB" {
string typeface = "Arial"
int textHeight = 70
bool italic = 1
string underlineType = "Normal"
}

def TextRenderingTechnique "TechniqueA" {
Expand Down
18 changes: 13 additions & 5 deletions pxr/imaging/hd/dataSourceLegacyPrim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ class Hd_DataSourceSimpleTextTopology : public HdContainerDataSource
{
}

bool Has(const TfToken &name) override
bool Has(const TfToken &name)
{
if (name == HdSimpleTextTopologySchemaTokens->pointCount) {
return true;
Expand Down Expand Up @@ -1206,7 +1206,7 @@ class Hd_DataSourceSimpleText : public HdContainerDataSource
}


bool Has(const TfToken &name) override
bool Has(const TfToken &name)
{
if (name == HdSimpleTextSchemaTokens->topology) {
return true;
Expand Down Expand Up @@ -1337,6 +1337,8 @@ class Hd_GenericTextTopologyStore

DEFINE_GENERICTEXT_TOPOLOGY_ACCESSOR_DATASOURCE(
PointCountDataSource, int, GetPointCount);
DEFINE_GENERICTEXT_TOPOLOGY_ACCESSOR_DATASOURCE(
DecorationCountDataSource, int, GetDecorationCount);

private:
SdfPath _id;
Expand All @@ -1355,9 +1357,10 @@ class Hd_DataSourceGenericTextTopology : public HdContainerDataSource
{
}

bool Has(const TfToken &name) override
bool Has(const TfToken &name)
{
if (name == HdGenericTextTopologySchemaTokens->pointCount) {
if (name == HdGenericTextTopologySchemaTokens->pointCount ||
name == HdGenericTextTopologySchemaTokens->decorationCount) {
return true;
}
return false;
Expand All @@ -1367,6 +1370,7 @@ class Hd_DataSourceGenericTextTopology : public HdContainerDataSource
{
return{
HdGenericTextTopologySchemaTokens->pointCount,
HdGenericTextTopologySchemaTokens->decorationCount,
};
}

Expand All @@ -1376,6 +1380,10 @@ class Hd_DataSourceGenericTextTopology : public HdContainerDataSource
return Hd_GenericTextTopologyStore::
PointCountDataSource::New(_stts);
}
if (name == HdGenericTextTopologySchemaTokens->decorationCount) {
return Hd_GenericTextTopologyStore::
DecorationCountDataSource::New(_stts);
}
return nullptr;
}

Expand All @@ -1395,7 +1403,7 @@ class Hd_DataSourceGenericText : public HdContainerDataSource
}


bool Has(const TfToken &name) override
bool Has(const TfToken &name)
{
if (name == HdGenericTextSchemaTokens->topology) {
return true;
Expand Down
6 changes: 4 additions & 2 deletions pxr/imaging/hd/genericText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ HdGenericText::GetBuiltinPrimvarNames() const
HdTokens->textUV,
HdTokens->triType,
HdTokens->textColor,
HdTokens->textOpacity

HdTokens->textOpacity,
HdTokens->linePoints,
HdTokens->lineColors,
HdTokens->lineOpacities
};
return primvarNames;
}
Expand Down
14 changes: 8 additions & 6 deletions pxr/imaging/hd/genericTextTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ PXR_NAMESPACE_OPEN_SCOPE
HdGenericTextTopology::HdGenericTextTopology()
: HdTopology()
, _pointCount(0)
, _decorationCount(0)
{
HD_PERF_COUNTER_INCR(HdPerfTokens->genericTextTopology);
}
HdGenericTextTopology::HdGenericTextTopology(size_t pointCount)
: HdTopology(), _pointCount(pointCount)
HdGenericTextTopology::HdGenericTextTopology(size_t pointCount, size_t decorationCount)
: HdTopology(), _pointCount(pointCount), _decorationCount(decorationCount)
{
HD_PERF_COUNTER_INCR(HdPerfTokens->genericTextTopology);
}

HdGenericTextTopology::HdGenericTextTopology(const HdGenericTextTopology& src)
: HdTopology(src), _pointCount(src._pointCount)
: HdTopology(src), _pointCount(src._pointCount), _decorationCount(src._decorationCount)
{
HD_PERF_COUNTER_INCR(HdPerfTokens->genericTextTopology);
}
Expand All @@ -59,7 +60,7 @@ HdGenericTextTopology::operator==(HdGenericTextTopology const &other) const
HD_TRACE_FUNCTION();

// The topology is the same if the pointCount is the same.
return _pointCount == other._pointCount;
return _pointCount == other._pointCount && _decorationCount == other._decorationCount;
}

bool
Expand All @@ -68,7 +69,7 @@ HdGenericTextTopology::operator!=(HdGenericTextTopology const &other) const
HD_TRACE_FUNCTION();

// The topology is not the same if the pointCount is not the same.
return _pointCount != other._pointCount;
return _pointCount != other._pointCount && _decorationCount != other._decorationCount;
}

HdTopology::ID
Expand All @@ -79,6 +80,7 @@ HdGenericTextTopology::ComputeHash() const
HdTopology::ID hash = 0;
// We only need to hash the point count.
hash = ArchHash64((const char*)&_pointCount, sizeof(size_t), hash);
hash = ArchHash64((const char*)&_decorationCount, sizeof(size_t), hash);

// Note: We don't hash topological visibility, because it is treated as a
// per-prim opinion, and hence, shouldn't break topology sharing.
Expand All @@ -88,7 +90,7 @@ HdGenericTextTopology::ComputeHash() const
std::ostream&
operator << (std::ostream &out, HdGenericTextTopology const &topo)
{
out << "(" << topo.GetPointCount() << ")";
out << "(" << topo.GetPointCount() << ", " << topo.GetDecorationCount() << ")";
return out;
}

Expand Down
8 changes: 7 additions & 1 deletion pxr/imaging/hd/genericTextTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PXR_NAMESPACE_OPEN_SCOPE
class HdGenericTextTopology : public HdTopology {
public:
HD_API HdGenericTextTopology();
HD_API HdGenericTextTopology(size_t pointCount);
HD_API HdGenericTextTopology(size_t pointCount, size_t decorationCount);
HD_API HdGenericTextTopology(const HdGenericTextTopology& src);
HD_API virtual ~HdGenericTextTopology();

Expand All @@ -52,6 +52,11 @@ class HdGenericTextTopology : public HdTopology {
/// Returns point count of the generic text geometry.
size_t GetPointCount() const {
return _pointCount;
}

/// Returns point count of the text geometry.
size_t GetDecorationCount() const {
return _decorationCount;
}

/// Equality check between two genericText topologies.
Expand All @@ -60,6 +65,7 @@ class HdGenericTextTopology : public HdTopology {

private:
size_t _pointCount;
size_t _decorationCount;
};

HD_API
Expand Down
23 changes: 21 additions & 2 deletions pxr/imaging/hd/genericTextTopologySchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ HdGenericTextTopologySchema::GetPointCount()
HdGenericTextTopologySchemaTokens->pointCount);
}

HdIntDataSourceHandle
HdGenericTextTopologySchema::GetDecorationCount()
{
return _GetTypedDataSource<HdIntDataSource>(
HdGenericTextTopologySchemaTokens->decorationCount);
}

/*static*/
HdContainerDataSourceHandle
HdGenericTextTopologySchema::BuildRetained(
const HdIntDataSourceHandle &pointCount
const HdIntDataSourceHandle &pointCount,
const HdIntDataSourceHandle &decorationCount
)
{
TfToken names[1];
Expand All @@ -58,6 +66,10 @@ HdGenericTextTopologySchema::BuildRetained(
names[count] = HdGenericTextTopologySchemaTokens->pointCount;
values[count++] = pointCount;
}
if (decorationCount) {
names[count] = HdGenericTextTopologySchemaTokens->decorationCount;
values[count++] = decorationCount;
}

return HdRetainedContainerDataSource::New(count, names, values);
}
Expand Down Expand Up @@ -91,12 +103,19 @@ HdGenericTextTopologySchema::Builder::SetPointCount(
_pointCount = pointCount;
return *this;
}
HdGenericTextTopologySchema::Builder &
HdGenericTextTopologySchema::Builder::SetDecorationCount(
const HdIntDataSourceHandle &decorationCount)
{
_decorationCount = decorationCount;
return *this;
}

HdContainerDataSourceHandle
HdGenericTextTopologySchema::Builder::Build()
{
return HdGenericTextTopologySchema::BuildRetained(
_pointCount
_pointCount, _decorationCount
);
}

Expand Down
11 changes: 10 additions & 1 deletion pxr/imaging/hd/genericTextTopologySchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ PXR_NAMESPACE_OPEN_SCOPE
#define HDGENERICTEXTTOPOLOGY_SCHEMA_TOKENS \
(topology) \
(pointCount) \
(decorationCount) \
(lineTopology)

TF_DECLARE_PUBLIC_TOKENS(HdGenericTextTopologySchemaTokens, HD_API,
HDGENERICTEXTTOPOLOGY_SCHEMA_TOKENS);
Expand All @@ -55,6 +57,8 @@ class HdGenericTextTopologySchema : public HdSchema

HD_API
HdIntDataSourceHandle GetPointCount();
HD_API
HdIntDataSourceHandle GetDecorationCount();

// RETRIEVING AND CONSTRUCTING

Expand All @@ -66,7 +70,7 @@ class HdGenericTextTopologySchema : public HdSchema
HD_API
static HdContainerDataSourceHandle
BuildRetained(
const HdIntDataSourceHandle &pointCount
const HdIntDataSourceHandle &pointCount, const HdIntDataSourceHandle &decorationCount
);

/// \class HdGenericTextTopologySchema::Builder
Expand All @@ -82,12 +86,17 @@ class HdGenericTextTopologySchema : public HdSchema
Builder &SetPointCount(
const HdIntDataSourceHandle &pointCount);

HD_API
Builder &SetDecorationCount(
const HdIntDataSourceHandle &decorationCount);

/// Returns a container data source containing the members set thus far.
HD_API
HdContainerDataSourceHandle Build();

private:
HdIntDataSourceHandle _pointCount;
HdIntDataSourceHandle _decorationCount;
};

/// Retrieves a container data source with the schema's default name token
Expand Down
Loading

0 comments on commit 14414fe

Please sign in to comment.