Skip to content

Commit

Permalink
Merge pull request PixarAnimationStudios#125 from autodesk-forks/Pier…
Browse files Browse the repository at this point in the history
…re/TextCherryPick

[OGSMOD-2048]Cherry pick changes related with text feature
  • Loading branch information
rsanthanam authored and GitHub Enterprise committed Jun 1, 2022
2 parents 555c90b + 94660e4 commit 065d688
Show file tree
Hide file tree
Showing 51 changed files with 5,141 additions and 3 deletions.
52 changes: 52 additions & 0 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,37 @@ def InstallOpenSubdiv(context, force, buildArgs):
OPENSUBDIV = Dependency("OpenSubdiv", InstallOpenSubdiv,
"include/opensubdiv/version.h")

############################################################
# TextSystem

if MacOS():
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.1.0-20eedfe/textsystem_Darwin_20eedfe_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.1.0-20eedfe/textsystem_Darwin_20eedfe_Debug.zip"
elif Windows():
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.1.0-20eedfe/textsystem_Windows_20eedfe_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.1.0-20eedfe/textsystem_Windows_20eedfe_Debug.zip"

def InstallTextSystem(context, force, buildArgs):
if context.buildDebug:
TEXTSYSTEM_URL = TEXTSYSTEM_DEBUG_URL
else:
TEXTSYSTEM_URL = TEXTSYSTEM_RELEASE_URL
with CurrentWorkingDirectory(DownloadURL(TEXTSYSTEM_URL, context, force)):
if buildArgs:
PrintWarning("Ignoring build arguments {}, TextSystem is "
"not built from source on this platform."
.format(buildArgs))
if MacOS():
CopyFiles(context, "lib/*.*", "lib")
CopyDirectory(context, "include/TextSystem", "include/TextSystem")
elif Windows():
CopyFiles(context, "bin\\*.*", "lib")
CopyFiles(context, "lib\\*.*", "lib")
CopyDirectory(context, "include\\TextSystem", "include\\TextSystem")

TEXTSYSTEM = Dependency("TextSystem", InstallTextSystem,
"include/TextSystem/TextSystem.h")

############################################################
# PyOpenGL

Expand Down Expand Up @@ -1559,6 +1590,11 @@ def InstallUSD(context, force, buildArgs):
else:
extraArgs.append('-DPXR_ENABLE_MATERIALX_SUPPORT=OFF')

if context.buildTextSystem:
extraArgs.append('-DPXR_ENABLE_TEXT_SUPPORT=ON')
else:
extraArgs.append('-DPXR_ENABLE_TEXT_SUPPORT=OFF')

if Windows():
# Increase the precompiled header buffer limit.
extraArgs.append('-DCMAKE_CXX_FLAGS="/Zm150"')
Expand Down Expand Up @@ -1861,6 +1897,14 @@ def InstallUSD(context, force, buildArgs):
subgroup.add_argument("--no-materialx", dest="build_materialx", action="store_false",
help="Do not build MaterialX plugin for USD (default)")

group = parser.add_argument_group(title="TextSystem Plugin Options")
subgroup = group.add_mutually_exclusive_group()
subgroup.add_argument("--textsystem", dest="build_textsystem", action="store_true",
default=False,
help="Build TextSystem plugin for USD (default)")
subgroup.add_argument("--no-textsystem", dest="build_textsystem", action="store_false",
help="Do not build TextSystem plugin for USD")

args = parser.parse_args()

class InstallContext:
Expand Down Expand Up @@ -1990,6 +2034,9 @@ def __init__(self, args):
# - MaterialX Plugin
self.buildMaterialX = args.build_materialx

# - TextSystem Plugin
self.buildTextSystem = args.build_textsystem

def GetBuildArguments(self, dep):
return self.buildArgs.get(dep.name.lower(), [])

Expand Down Expand Up @@ -2045,6 +2092,9 @@ def ForceBuildDependency(self, dep):

requiredDependencies += [OPENSUBDIV]

if context.buildTextSystem:
requiredDependencies += [TEXTSYSTEM]

if context.enableOpenVDB:
requiredDependencies += [BLOSC, BOOST, OPENEXR, OPENVDB, TBB]

Expand Down Expand Up @@ -2215,6 +2265,7 @@ def _JoinVersion(v):
HDF5 support: {enableHDF5}
Draco Plugin {buildDraco}
MaterialX Plugin {buildMaterialX}
TextSystem Plugin {buildTextSystem}
Dependencies {dependencies}"""

Expand Down Expand Up @@ -2273,6 +2324,7 @@ def FormatBuildArguments(buildArgs):
buildAlembic=("On" if context.buildAlembic else "Off"),
buildDraco=("On" if context.buildDraco else "Off"),
buildMaterialX=("On" if context.buildMaterialX else "Off"),
buildTextSystem=("On" if context.buildTextSystem else "Off"),
enableHDF5=("On" if context.enableHDF5 else "Off"))

Print(summaryMsg)
Expand Down
1 change: 1 addition & 0 deletions cmake/defaults/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ option(PXR_PREFER_SAFETY_OVER_SPEED
"Enable certain checks designed to avoid crashes or out-of-bounds memory reads with malformed input files. These checks may negatively impact performance."
ON)
option(PXR_USE_AR_2 "Use Asset Resolver (Ar) 2.0" ON)
option(PXR_ENABLE_TEXT_SUPPORT "Enable Text support" ON)

# Determine GFX api
# Metal only valid on Apple platforms
Expand Down
6 changes: 6 additions & 0 deletions cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ if(PXR_ENABLE_OSL_SUPPORT)
add_definitions(-DPXR_OSL_SUPPORT_ENABLED)
endif()

# --TextSystem
if(PXR_ENABLE_TEXT_SUPPORT)
find_package( TEXTSYSTEM REQUIRED COMPONENTS text_system)
add_definitions(-DPXR_TEXTSYSTEM_SUPPORT_ENABLED)
endif()

# ----------------------------------------------

set(BUILD_SHARED_LIBS "${build_shared_libs}")
87 changes: 87 additions & 0 deletions cmake/modules/FindTextSystem.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# - Find TextSystem library
# Find the native TextSystem includes and library
# This module defines
# TEXTSYSTEM_INCLUDE_DIRS, where to find TextSystem headers, Set when
# TEXTSYSTEM_INCLUDE_DIR is found.
# TEXTSYSTEM_LIBRARIES, libraries to link against to use TextSystem.
# TEXTSYSTEM_ROOT_DIR, the base directory to search for TextSystem.
# This can also be an environment variable.
# TEXTSYSTEM_FOUND, if false, do not try to use TextSystem.
#
# also defined, but not for general use are
# TEXTSYSTEM_LIBRARY, where to find the TextSystem library.

#=============================================================================
# Copyright 2021 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

# If TEXTSYSTEM_ROOT_DIR was defined in the environment, use it.
IF(NOT TEXTSYSTEM_ROOT_DIR AND NOT $ENV{TEXTSYSTEM_ROOT_DIR} STREQUAL "")
SET(TEXTSYSTEM_ROOT_DIR $ENV{TEXTSYSTEM_ROOT_DIR})
ENDIF()

SET(TEXTSYSTEM_FIND_COMPONENTS
text_system
)

SET(TEXTSYSTEM_SEARCH_DIRS
${TEXTSYSTEM_ROOT_DIR}
)

FIND_PATH(TEXTSYSTEM_INCLUDE_DIR
NAMES
TextSystem/TextSystem.h
HINTS
${TEXTSYSTEM_SEARCH_DIRS}
PATH_SUFFIXES
include
)

SET(TEXTSYSTEM_LIBRARIES)
FOREACH(COMPONENT ${TEXTSYSTEM_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
FIND_LIBRARY(TEXTSYSTEM_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${TEXTSYSTEM_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if(DEFINED TEXTSYSTEM_${UPPERCOMPONENT}_LIBRARY)
LIST(APPEND
TEXTSYSTEM_LIBRARIES
"${TEXTSYSTEM_${UPPERCOMPONENT}_LIBRARY}")
set(TEXTSYSTEM_FOUND TRUE)
endif()
ENDFOREACH()

IF(TEXTSYSTEM_FOUND)
SET(TEXTSYSTEM_LIBRARIES ${TEXTSYSTEM_LIBRARIES})
list(APPEND TEXTSYSTEM_INCLUDE_DIRS ${TEXTSYSTEM_INCLUDE_DIR})
list(APPEND TEXTSYSTEM_INCLUDE_DIRS ${TEXTSYSTEM_INCLUDE_DIR}/TextSystem)
ENDIF(TEXTSYSTEM_FOUND)

MARK_AS_ADVANCED(
TEXTSYSTEM_INCLUDE_DIRS
)
FOREACH(COMPONENT ${TEXTSYSTEM_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
MARK_AS_ADVANCED(TEXTSYSTEM_${UPPERCOMPONENT}_LIBRARY)
ENDFOREACH()

# handle the QUIETLY and REQUIRED arguments and set TEXTSYSTEM_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TEXTSYSTEM
REQUIRED_VARS
TEXTSYSTEM_INCLUDE_DIRS
TEXTSYSTEM_LIBRARIES
)
54 changes: 54 additions & 0 deletions extras/usd/examples/usdGeomExamples/simpleText.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, 0, -100)
def Scope "Text11"{
def SimpleText "TextA" (){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (-300, 60, 0)

string typeface = "Times New Roman"
int textHeight = 100
bool bold = 1
string textData = "The quick brown fox"
color3f[] primvars:displayColor = [(1, 1, 0)]
}

def SimpleText "TextB" (){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (-300, -40, 0)

string typeface = "Consolas"
int textHeight = 70
bool italic = 1
string textData = "jumps over the"
color3f[] primvars:displayColor = [(1, 0, 1)]

uniform bool primvars:cameraFacing = 1
}

def SimpleText "TextC" (){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (-300, -140, 0)

string typeface = "Castellar"
int textHeight = 70
string textData = "lazy dog"
color3f[] primvars:displayColor = [(0, 1, 1)]

uniform bool primvars:cameraFacing = 1
uniform bool primvars:pixelScale = 1
float3 scaleCenter = (0, 0, 0)
float screenSpaceSize = 5.0
float modelSpaceSize = 1.0
}
}
}
9 changes: 9 additions & 0 deletions pxr/imaging/hd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ set(PXR_PREFIX pxr/imaging)
set(PXR_PACKAGE hd)

set(optionalPublicClasses "")
if (PXR_ENABLE_TEXT_SUPPORT)
list(APPEND optionalPublicClasses
simpleText
simpleTextTopology
simpleTextSchema
simpleTextTopologySchema
)
endif()

pxr_library(hd
LIBRARIES
Expand Down Expand Up @@ -159,6 +167,7 @@ pxr_library(hd
volumeFieldSchema
vtBufferSource
xformSchema
${optionalPublicClasses}

PUBLIC_HEADERS
api.h
Expand Down
Loading

0 comments on commit 065d688

Please sign in to comment.