本文整理汇总了C++中SPtr类的典型用法代码示例。如果您正苦于以下问题:C++ SPtr类的具体用法?C++ SPtr怎么用?C++ SPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: beats
/** Load (create) all objects from RDF into the engine.
*
* @param uri URI of machine (resolvable URI to an RDF document).
* @return Loaded Machine.
*/
SPtr<Machine>
Loader::load(const Glib::ustring& uri)
{
using Glib::ustring;
ustring document_uri = uri;
// If "URI" doesn't contain a colon, try to resolve as a filename
if (uri.find(":") == ustring::npos) {
document_uri = "file://" + document_uri;
}
cout << "Loading " << document_uri << endl;
TimeUnit beats(TimeUnit::BEATS, MACHINA_PPQN);
SPtr<Machine> machine(new Machine(beats));
typedef std::map<Sord::Node, SPtr<Node> > Created;
Created created;
Sord::URI base_uri(_rdf_world, document_uri);
Sord::Model model(_rdf_world, document_uri);
SerdEnv* env = serd_env_new(base_uri.to_serd_node());
model.load_file(env, SERD_TURTLE, document_uri);
serd_env_free(env);
Sord::Node nil;
Sord::URI machina_SelectorNode(_rdf_world, MACHINA_NS_SelectorNode);
Sord::URI machina_duration(_rdf_world, MACHINA_NS_duration);
Sord::URI machina_edge(_rdf_world, MACHINA_NS_arc);
Sord::URI machina_head(_rdf_world, MACHINA_NS_head);
Sord::URI machina_node(_rdf_world, MACHINA_NS_node);
Sord::URI machina_onEnter(_rdf_world, MACHINA_NS_onEnter);
Sord::URI machina_onExit(_rdf_world, MACHINA_NS_onExit);
Sord::URI machina_probability(_rdf_world, MACHINA_NS_probability);
Sord::URI machina_start(_rdf_world, MACHINA_NS_start);
Sord::URI machina_tail(_rdf_world, MACHINA_NS_tail);
Sord::URI rdf_type(_rdf_world, MACHINA_URI_RDF "type");
Sord::Node subject = base_uri;
// Get start node ID (but re-use existing start node)
Sord::Iter i = model.find(subject, machina_start, nil);
if (i.end()) {
cerr << "error: Machine has no start node" << std::endl;
}
created[i.get_object()] = machine->initial_node();
// Get remaining nodes
for (Sord::Iter i = model.find(subject, machina_node, nil); !i.end(); ++i) {
const Sord::Node& id = i.get_object();
if (created.find(id) != created.end()) {
cerr << "warning: Machine lists the same node twice" << std::endl;
continue;
}
// Create node
Sord::Iter d = model.find(id, machina_duration, nil);
SPtr<Node> node(new Node(TimeStamp(beats, d.get_object().to_float())));
machine->add_node(node);
created[id] = node;
node->set_enter_action(
load_action(model, model.get(id, machina_onEnter, nil)));
node->set_exit_action(
load_action(model, model.get(id, machina_onExit, nil)));
}
// Get arcs
for (Sord::Iter i = model.find(subject, machina_edge, nil); !i.end(); ++i) {
Sord::Node edge = i.get_object();
Sord::Iter t = model.find(edge, machina_tail, nil);
Sord::Iter h = model.find(edge, machina_head, nil);
Sord::Iter p = model.find(edge, machina_probability, nil);
Sord::Node tail = t.get_object();
Sord::Node head = h.get_object();
Sord::Node probability = p.get_object();
float prob = probability.to_float();
Created::iterator tail_i = created.find(tail);
Created::iterator head_i = created.find(head);
if (tail_i != created.end() && head_i != created.end()) {
const SPtr<Node> tail = tail_i->second;
const SPtr<Node> head = head_i->second;
tail->add_edge(SPtr<Edge>(new Edge(tail, head, prob)));
} else {
cerr << "warning: Ignored edge between unknown nodes "
<< tail << " -> " << head << endl;
}
//.........这里部分代码省略.........
示例2: buildStateChange
void StateManager::buildStateChange(unsigned int &list, SPtr<StateProperties> previous_state, SPtr<StateProperties> next_state) {
assert(m_initialised);
assert (previous_state.isValid());
assert (next_state.isValid());
glNewList(list, GL_COMPILE);
if (previous_state->alpha_test != next_state->alpha_test) {
if (next_state->alpha_test) glEnable(GL_ALPHA_TEST);
else glDisable(GL_ALPHA_TEST);
}
if (previous_state->blend != next_state->blend) {
if (next_state->blend) glEnable(GL_BLEND);
else glDisable(GL_BLEND);
}
if (previous_state->lighting != next_state->lighting) {
// if (next_state->lighting && checkState(RENDER_LIGHTING)) glEnable(GL_LIGHTING);
if (next_state->lighting) glEnable(GL_LIGHTING);
else glDisable(GL_LIGHTING);
}
if (previous_state->two_sided_lighting != next_state->two_sided_lighting) {
// if (next_state->lighting && checkState(RENDER_LIGHTING)) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
if (next_state->lighting) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
else glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
}
for (int i = MAX_UNITS - 1; i >= 0; --i) {
glActiveTextureARB(GL_TEXTURE0_ARB + i);
if (previous_state->textures[i] != next_state->textures[i]) {
// if (next_state->textures && checkState(RENDER_TEXTURES)) glEnable(GL_TEXTURE_2D);
if (next_state->textures[i]) glEnable(GL_TEXTURE_2D);
else glDisable(GL_TEXTURE_2D);
}
}
if (previous_state->colour_material != next_state->colour_material) {
if (next_state->colour_material) glEnable(GL_COLOR_MATERIAL);
else glDisable(GL_COLOR_MATERIAL);
}
if (previous_state->depth_test != next_state->depth_test) {
if (next_state->depth_test) glEnable(GL_DEPTH_TEST);
else glDisable(GL_DEPTH_TEST);
}
if (previous_state->depth_write != next_state->depth_write) {
glDepthMask(next_state->depth_write);
}
if (previous_state->cull_face != next_state->cull_face) {
if (next_state->cull_face) glEnable(GL_CULL_FACE);
else glDisable(GL_CULL_FACE);
}
if (previous_state->cull_face_cw != next_state->cull_face_cw) {
if (next_state->cull_face_cw) glFrontFace(GL_CW);
else glFrontFace(GL_CCW);
}
if (previous_state->stencil != next_state->stencil) {
if (next_state->stencil) glEnable(GL_STENCIL_TEST);
else glDisable(GL_STENCIL_TEST);
}
if (previous_state->fog != next_state->fog) {
if (next_state->fog) glEnable(GL_FOG);
else glDisable(GL_FOG);
}
if (previous_state->rescale_normals != next_state->rescale_normals) {
if (next_state->rescale_normals) glEnable(GL_RESCALE_NORMAL);
else glDisable(GL_RESCALE_NORMAL);
}
if (previous_state->normalise != next_state->normalise) {
if (next_state->normalise) glEnable(GL_NORMALIZE);
else glDisable(GL_NORMALIZE);
}
// if ((next_state->alpha_function != previous_state->alpha_function) || (next_state->alpha_value != previous_state->alpha_value))
glAlphaFunc(next_state->alpha_function, next_state->alpha_value);
glBlendFunc(next_state->blend_src_function, next_state->blend_dest_function);
glEndList();
}
示例3: Log
/**
* match parsed interfaces with interfaces detected in system.
* ClntCfgIface objects copied to CfgMgr.
*
* @param parser
*
* @return true if ok, false if interface definitions are incorrect
*/
bool TClntCfgMgr::matchParsedSystemInterfaces(ClntParser *parser) {
int cfgIfaceCnt;
cfgIfaceCnt = parser->ClntCfgIfaceLst.count();
Log(Debug) << cfgIfaceCnt << " interface(s) specified in " << CLNTCONF_FILE << LogEnd;
SPtr<TClntCfgIface> cfgIface;
SPtr<TIfaceIface> ifaceIface;
if (cfgIfaceCnt) {
// user specified some interfaces in config file
parser->ClntCfgIfaceLst.first();
while(cfgIface = parser->ClntCfgIfaceLst.get()) {
// for each interface (from config file)
if (cfgIface->getID()==-1) {
ifaceIface = ClntIfaceMgr().getIfaceByName(cfgIface->getName());
} else {
ifaceIface = ClntIfaceMgr().getIfaceByID(cfgIface->getID());
}
if (!ifaceIface) {
if (inactiveMode()) {
Log(Info) << "Interface " << cfgIface->getFullName()
<< " is not currently available (that's ok, inactive-mode enabled)." << LogEnd;
continue;
}
Log(Error) << "Interface " << cfgIface->getFullName()
<< " specified in " << CLNTCONF_FILE << " is not present or does not support IPv6."
<< LogEnd;
return false;
}
if (cfgIface->noConfig()) {
Log(Info) << "Interface " << cfgIface->getFullName()
<< " has flag no-config set, so it is ignored." << LogEnd;
continue;
}
#ifdef MOD_REMOTE_AUTOCONF
if (RemoteAutoconf) {
List(TIPv6Addr) emptyLst;
SPtr<TOpt> optNeighbors = new TOptAddrLst(OPTION_NEIGHBORS, emptyLst, 0);
Log(Debug) << "Enabled Neighbors option on " << cfgIface->getFullName() << LogEnd;
cfgIface->addExtraOption(optNeighbors, false);
}
#endif
cfgIface->setIfaceName(ifaceIface->getName());
cfgIface->setIfaceID(ifaceIface->getID());
// setup default prefix length (used when IPv6 address is added to the interface)
ifaceIface->setPrefixLength(cfgIface->getOnLinkPrefixLength());
if (!ifaceIface->flagUp() || !ifaceIface->countLLAddress()) {
if (inactiveMode()) {
Log(Notice) << "Interface " << ifaceIface->getFullName()
<< " is not operational yet (does not have "
<< "link-local address or is down), skipping it for now." << LogEnd;
addIface(cfgIface);
makeInactiveIface(cfgIface->getID(), true, true, true); // move it to InactiveLst
continue;
}
Log(Crit) << "Interface " << ifaceIface->getFullName()
<< " is down or doesn't have any link-local address." << LogEnd;
return false;
}
// Check if the interface is during bring-up phase
// (i.e. DAD procedure for link-local addr is not complete yet)
char tmp[64];
if (cfgIface->getBindToAddr()) {
inet_ntop6(cfgIface->getBindToAddr()->getPlain(), tmp);
} else {
ifaceIface->firstLLAddress();
inet_ntop6(ifaceIface->getLLAddress(), tmp);
}
if (is_addr_tentative(ifaceIface->getName(), ifaceIface->getID(), tmp)
== LOWLEVEL_TENTATIVE_YES) {
Log(Notice) << "Interface " << ifaceIface->getFullName()
<< " has link-local address " << tmp
<< ", but it is currently tentative." << LogEnd;
if (this->inactiveMode()) {
Log(Notice) << "Interface " << ifaceIface->getFullName()
<< " is not operational yet (link-local address "
<< "is not ready), skipping it for now." << LogEnd;
addIface(cfgIface);
makeInactiveIface(cfgIface->getID(), true, true, true); // move it to InactiveLst
continue;
}
//.........这里部分代码省略.........
示例4: cookMesh
/**
* Attempts to cook a triangle or convex mesh from the provided mesh data. Will log a warning and return false if it is
* unable to cook the mesh. If the method returns true the resulting convex mesh will be output in the @p data buffer,
* and its size in @p size. The data buffer will be allocated used the generic allocator and is up to the caller to
* free it.
*/
bool cookMesh(const SPtr<MeshData>& meshData, PhysicsMeshType type, UINT8** data, UINT32& size)
{
if (meshData == nullptr)
return false;
PxCooking* cooking = gPhysX().getCooking();
if (cooking == nullptr)
{
LOGWRN("Attempting to cook a physics mesh but cooking is not enabled globally.");
return false;
}
SPtr<VertexDataDesc> vertexDesc = meshData->getVertexDesc();
if (!vertexDesc->hasElement(VES_POSITION))
{
LOGWRN("Provided PhysicsMesh mesh data has no vertex positions.");
return false;
}
if (type == PhysicsMeshType::Convex)
{
if(!cookConvex(cooking, meshData, data, size))
{
LOGWRN("Failed cooking a convex mesh. Perpahs it is too complex? Maximum number of convex vertices is 256.");
return false;
}
}
else
{
PxTriangleMeshDesc meshDesc;
meshDesc.points.count = meshData->getNumVertices();
meshDesc.points.stride = vertexDesc->getVertexStride();
meshDesc.points.data = meshData->getElementData(VES_POSITION);
meshDesc.triangles.count = meshData->getNumIndices() / 3;
meshDesc.flags |= PxMeshFlag::eFLIPNORMALS;
IndexType indexType = meshData->getIndexType();
if (indexType == IT_32BIT)
{
meshDesc.triangles.stride = 3 * sizeof(PxU32);
meshDesc.triangles.data = meshData->getIndices32();
}
else
{
meshDesc.triangles.stride = 3 * sizeof(PxU16);
meshDesc.triangles.data = meshData->getIndices16();
meshDesc.flags |= PxMeshFlag::e16_BIT_INDICES;
}
PxDefaultMemoryOutputStream output;
if (!cooking->cookTriangleMesh(meshDesc, output))
return false;
size = output.getSize();
*data = (UINT8*)bs_alloc(size);
memcpy(*data, output.getData(), size);
}
return true;
}
示例5: StateProperties
void StateManager::varconf_callback(const std::string §ion, const std::string &key, varconf::Config &config) {
StateID sID = m_state_name_map[section];
SPtr<StateProperties> record = SPtr<StateProperties>();
bool create_record = false;
if (sID > 0) {
// Record ID already exists, lets see if the record is valid.
record = m_states[sID];
if (record.isValid()) {
// Record already exists, all good
} else {
// Record does not exist, lets make a new one.
create_record = true;
}
} else {
// Not seen this record name yet, so need to fill in all the data structures.
sID = m_state_counter++;
create_record = true;
}
// If record does not exist, create it.
if (create_record) {
record = SPtr<StateProperties> (new StateProperties());
record->state = section;
// Setup default values
record->alpha_test = false;
record->blend = false;
record->lighting = false;
record->two_sided_lighting = false;
for (unsigned int i = 0; i < MAX_UNITS; ++i)
record->textures[i] = false;
record->colour_material = false;
record->depth_test = false;
record->depth_write = true;
record->cull_face = false;
record->cull_face_cw = false;
record->stencil = false;
record->fog = false;
record->rescale_normals = false;
record->normalise = false;
record->alpha_function = GL_GREATER;
record->alpha_value = 0.1f;
record->blend_src_function = GL_SRC_ALPHA;
record->blend_dest_function = GL_ONE_MINUS_SRC_ALPHA;
m_states[sID] = record;
m_state_name_map[record->state] = sID;
m_name_state_vector[sID] = record->state;
if (debug) printf("[StateManager] Adding State: %s\n", section.c_str());
}
if (key == ALPHA_TEST) record->alpha_test = (bool)config.getItem(section, key);
else if (key == BLEND) record->blend = (bool)config.getItem(section, key);
else if (key == LIGHTING) record->lighting = (bool)config.getItem(section, key);
else if (key == TWO_SIDED_LIGHTING) record->two_sided_lighting = (bool)config.getItem(section, key);
else if (key == COLOUR_MATERIAL) record->colour_material = (bool)config.getItem(section, key);
else if (key == DEPTH_TEST) record->depth_test = (bool)config.getItem(section, key);
else if (key == DEPTH_WRITE) record->depth_write = (bool)config.getItem(section, key);
else if (key == CULL_FACE) record->cull_face = (bool)config.getItem(section, key);
else if (key == CULL_FACE_CW) record->cull_face_cw = (bool)config.getItem(section, key);
else if (key == STENCIL) record->stencil = (bool)config.getItem(section, key);
else if (key == FOG) record->fog = (bool)config.getItem(section, key);
else if (key == RESCALE_NORMALS) record->rescale_normals = (bool)config.getItem(section, key);
else if (key == NORMALISE) record->normalise = (bool)config.getItem(section, key);
else if (key == ALPHA_FUNCTION) record->alpha_function = getAlphaFunction((std::string)config.getItem(section, key));
else if (key == ALPHA_VALUE) record->alpha_value = (double)config.getItem(section, key);
else if (key == BLEND_SRC_FUNCTION) record->blend_src_function = getBlendFunction((std::string)config.getItem(section, key));
else if (key == BLEND_DEST_FUNCTION) record->blend_dest_function = getBlendFunction((std::string)config.getItem(section, key));
else if (key.substr(0, TEXTURE.size()) == TEXTURE) {
unsigned int unit;
cast_stream(key.substr(TEXTURE.size()), unit);
if (unit < MAX_UNITS) {
record->textures[unit] = (bool)config.getItem(section, key);
}
}
}
示例6: copyImpl
void VulkanTexture::copyImpl(const SPtr<Texture>& target, const TEXTURE_COPY_DESC& desc,
const SPtr<CommandBuffer>& commandBuffer)
{
VulkanTexture* other = static_cast<VulkanTexture*>(target.get());
const TextureProperties& srcProps = mProperties;
const TextureProperties& dstProps = other->getProperties();
bool srcHasMultisample = srcProps.getNumSamples() > 1;
bool destHasMultisample = dstProps.getNumSamples() > 1;
if ((srcProps.getUsage() & TU_DEPTHSTENCIL) != 0 || (dstProps.getUsage() & TU_DEPTHSTENCIL) != 0)
{
LOGERR("Texture copy/resolve isn't supported for depth-stencil textures.");
return;
}
bool needsResolve = srcHasMultisample && !destHasMultisample;
bool isMSCopy = srcHasMultisample || destHasMultisample;
if (!needsResolve && isMSCopy)
{
if (srcProps.getNumSamples() != dstProps.getNumSamples())
{
LOGERR("When copying textures their multisample counts must match. Ignoring copy.");
return;
}
}
VkImageLayout transferSrcLayout = mDirectlyMappable ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
VkImageLayout transferDstLayout = other->mDirectlyMappable ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
UINT32 mipWidth, mipHeight, mipDepth;
bool copyEntireSurface = desc.srcVolume.getWidth() == 0 ||
desc.srcVolume.getHeight() == 0 ||
desc.srcVolume.getDepth() == 0;
if(copyEntireSurface)
{
PixelUtil::getSizeForMipLevel(
srcProps.getWidth(),
srcProps.getHeight(),
srcProps.getDepth(),
desc.srcMip,
mipWidth,
mipHeight,
mipDepth);
}
else
{
mipWidth = desc.srcVolume.getWidth();
mipHeight = desc.srcVolume.getHeight();
mipDepth = desc.srcVolume.getDepth();
}
VkImageResolve resolveRegion;
resolveRegion.srcOffset = { (INT32)desc.srcVolume.left, (INT32)desc.srcVolume.top, (INT32)desc.srcVolume.front };
resolveRegion.dstOffset = { desc.dstPosition.x, desc.dstPosition.y, desc.dstPosition.z };
resolveRegion.extent = { mipWidth, mipHeight, mipDepth };
resolveRegion.srcSubresource.baseArrayLayer = desc.srcFace;
resolveRegion.srcSubresource.layerCount = 1;
resolveRegion.srcSubresource.mipLevel = desc.srcMip;
resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
resolveRegion.dstSubresource.baseArrayLayer = desc.dstFace;
resolveRegion.dstSubresource.layerCount = 1;
resolveRegion.dstSubresource.mipLevel = desc.dstMip;
resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
VkImageCopy imageRegion;
imageRegion.srcOffset = { (INT32)desc.srcVolume.left, (INT32)desc.srcVolume.top, (INT32)desc.srcVolume.front };
imageRegion.dstOffset = { desc.dstPosition.x, desc.dstPosition.y, desc.dstPosition.z };
imageRegion.extent = { mipWidth, mipHeight, mipDepth };
imageRegion.srcSubresource.baseArrayLayer = desc.srcFace;
imageRegion.srcSubresource.layerCount = 1;
imageRegion.srcSubresource.mipLevel = desc.srcMip;
imageRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
imageRegion.dstSubresource.baseArrayLayer = desc.dstFace;
imageRegion.dstSubresource.layerCount = 1;
imageRegion.dstSubresource.mipLevel = desc.dstMip;
imageRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
VkImageSubresourceRange srcRange;
srcRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
srcRange.baseArrayLayer = desc.srcFace;
srcRange.layerCount = 1;
srcRange.baseMipLevel = desc.srcMip;
srcRange.levelCount = 1;
VkImageSubresourceRange dstRange;
dstRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
dstRange.baseArrayLayer = desc.dstFace;
dstRange.layerCount = 1;
dstRange.baseMipLevel = desc.dstMip;
dstRange.levelCount = 1;
VulkanRenderAPI& rapi = static_cast<VulkanRenderAPI&>(RenderAPI::instance());
VulkanCmdBuffer* vkCB;
if (commandBuffer != nullptr)
vkCB = static_cast<VulkanCommandBuffer*>(commandBuffer.get())->getInternal();
//.........这里部分代码省略.........
示例7: cookConvex
/**
* Attempts to cook a convex mesh from the provided mesh data. Assumes the mesh data is not null and contains vertex
* positions as well as face indices. If the method returns true the resulting convex mesh will be output in the @p
* data buffer, and its size in @p size. The data buffer will be allocated used the generic allocator and is up to the
* caller to free it.
*/
bool cookConvex(PxCooking* cooking, const SPtr<MeshData>& meshData, UINT8** data, UINT32& size)
{
SPtr<VertexDataDesc> vertexDesc = meshData->getVertexDesc();
// Try to create hull from points
PxConvexMeshDesc convexDesc;
convexDesc.points.count = meshData->getNumVertices();
convexDesc.points.stride = vertexDesc->getVertexStride();
convexDesc.points.data = meshData->getElementData(VES_POSITION);
convexDesc.flags |= PxConvexFlag::eCOMPUTE_CONVEX;
PxDefaultMemoryOutputStream output;
if (cooking->cookConvexMesh(convexDesc, output))
{
size = output.getSize();
*data = (UINT8*)bs_alloc(size);
memcpy(*data, output.getData(), size);
return true;
}
// Try inflating the convex mesh
convexDesc.flags |= PxConvexFlag::eINFLATE_CONVEX;
if (cooking->cookConvexMesh(convexDesc, output))
{
size = output.getSize();
*data = (UINT8*)bs_alloc(size);
memcpy(*data, output.getData(), size);
return true;
}
// Nothing works, just compute an AABB
AABox box;
auto vertIter = meshData->getVec3DataIter(VES_POSITION);
do
{
box.merge(vertIter.getValue());
}
while (vertIter.moveNext());
Vector3 aabbVerts[8];
aabbVerts[0] = box.getCorner(AABox::FAR_LEFT_BOTTOM);
aabbVerts[1] = box.getCorner(AABox::FAR_RIGHT_BOTTOM);
aabbVerts[2] = box.getCorner(AABox::FAR_RIGHT_TOP);
aabbVerts[3] = box.getCorner(AABox::FAR_LEFT_TOP);
aabbVerts[4] = box.getCorner(AABox::NEAR_LEFT_BOTTOM);
aabbVerts[5] = box.getCorner(AABox::NEAR_RIGHT_BOTTOM);
aabbVerts[6] = box.getCorner(AABox::NEAR_RIGHT_TOP);
aabbVerts[7] = box.getCorner(AABox::NEAR_LEFT_TOP);
convexDesc.points.count = 8;
convexDesc.points.stride = sizeof(Vector3);
convexDesc.points.data = &aabbVerts[0];
convexDesc.flags &= ~PxConvexFlag::eINFLATE_CONVEX;
if (cooking->cookConvexMesh(convexDesc, output))
{
size = output.getSize();
*data = (UINT8*)bs_alloc(size);
memcpy(*data, output.getData(), size);
return true;
}
return false;
}
示例8: mToggleGroup
GUIToggle::GUIToggle(const String& styleName, const GUIContent& content, SPtr<GUIToggleGroup> toggleGroup, const GUIDimensions& dimensions)
:GUIButtonBase(styleName, content, dimensions), mToggleGroup(nullptr), mIsToggled(false)
{
if(toggleGroup != nullptr)
toggleGroup->_add(this);
}
示例9: ClntIfaceMgr
bool TClntTransMgr::openSockets(SPtr<TClntCfgIface> iface) {
if (iface->noConfig())
return true;
// open socket
SPtr<TIfaceIface> realIface = ClntIfaceMgr().getIfaceByID(iface->getID());
if (!realIface) {
Log(Error) << "Interface " << iface->getFullName()
<< " not present in system." << LogEnd;
return false;
}
if (!realIface->flagUp()) {
Log(Error) << "Interface " << realIface->getFullName()
<< " is down. Unable to open socket." << LogEnd;
return false;
}
if (!realIface->flagRunning()) {
Log(Error) << "Interface " << realIface->getFullName()
<< " is not running." << LogEnd;
return false;
}
// get link-local address
char* llAddr;
realIface->firstLLAddress();
llAddr=realIface->getLLAddress();
if (!llAddr) {
Log(Error) << "Interface " << realIface->getFullName()
<< " does not have link-layer address. Weird." << LogEnd;
return false;
}
SPtr<TIPv6Addr> addr = new TIPv6Addr(llAddr);
// it's very important to open unicast socket first as it will be used for
// unicast communication
if (iface->getUnicast()) {
Log(Notice) << "Creating socket for unicast communication on " << iface->getFullName()
<< LogEnd;
SPtr<TIPv6Addr> anyaddr = new TIPv6Addr("::", true); // don't bind to a specific address
if (!realIface->addSocket(anyaddr, DHCPCLIENT_PORT, false, this->BindReuse)) {
Log(Crit) << "Unicast socket creation (addr=" << anyaddr->getPlain() << ") on "
<< iface->getFullName() << " interface failed." << LogEnd;
return false;
}
}
Log(Notice) << "Creating socket (addr=" << *addr << ") on "
<< iface->getFullName() << " interface." << LogEnd;
if (!realIface->addSocket(addr,DHCPCLIENT_PORT,true, this->BindReuse)) {
Log(Crit) << "Socket creation (addr=" << *addr << ") on "
<< iface->getFullName() << " interface failed." << LogEnd;
return false;
}
if (llAddr) {
char buf[48];
inet_ntop6(llAddr,buf);
// Log(Info) << "Socket bound to " << buf << "/port=" << DHCPCLIENT_PORT << LogEnd;
this->ctrlIface = realIface->getID();
strncpy(this->ctrlAddr,buf,48);
}
return true;
}
示例10: peer
SPtr<TClntMsg> TClntIfaceMgr::select(unsigned int timeout)
{
int bufsize=4096;
static char buf[4096];
SPtr<TIPv6Addr> peer(new TIPv6Addr());
int sockid;
int msgtype;
int ifaceid;
sockid = TIfaceMgr::select(timeout, buf, bufsize, peer);
if (sockid>0) {
if (bufsize<4) {
if (buf[0]!=CONTROL_MSG) {
Log(Warning) << "Received message is too short (" << bufsize
<< ") bytes." << LogEnd;
} else {
Log(Warning) << "Control message received." << LogEnd;
}
return 0; // NULL
}
msgtype = buf[0];
SPtr<TClntMsg> ptr;
SPtr<TIfaceIface> ptrIface;
ptrIface = this->getIfaceBySocket(sockid);
ifaceid = ptrIface->getID();
Log(Debug) << "Received " << bufsize << " bytes on interface " << ptrIface->getName() << "/"
<< ptrIface->getID() << " (socket=" << sockid << ", addr=" << *peer << "."
<< ")." << LogEnd;
switch (msgtype) {
case ADVERTISE_MSG:
ptr = new TClntMsgAdvertise(ifaceid,peer,buf,bufsize);
#ifndef MOD_DISABLE_AUTH
if (!ptr->validateAuthInfo(buf, bufsize, ClntCfgMgr().getAuthAcceptMethods())) {
Log(Error) << "Message dropped, authentication validation failed." << LogEnd;
return 0;
}
#endif
return ptr;
case SOLICIT_MSG:
case REQUEST_MSG:
case CONFIRM_MSG:
case RENEW_MSG:
case REBIND_MSG:
case RELEASE_MSG:
case DECLINE_MSG:
case INFORMATION_REQUEST_MSG:
Log(Warning) << "Illegal message type " << msgtype << " received." << LogEnd;
return 0; // NULL
case REPLY_MSG:
ptr = new TClntMsgReply(ifaceid, peer, buf, bufsize);
#ifndef MOD_DISABLE_AUTH
if (!ptr->validateAuthInfo(buf, bufsize, ClntCfgMgr().getAuthAcceptMethods())) {
Log(Error) << "Message dropped, authentication validation failed." << LogEnd;
return 0;
}
#endif
return ptr;
case RECONFIGURE_MSG:
Log(Warning) << "Reconfigure Message is currently not supported." << LogEnd;
return 0; // NULL
case RELAY_FORW_MSG: // those two msgs should not be visible for client
case RELAY_REPL_MSG:
default:
Log(Warning) << "Message type " << msgtype << " is not supposed to "
<< "be received by client. Check your relay/server configuration." << LogEnd;
return 0;
}
} else {
return 0;
}
}
示例11:
SelectionRendererCore::~SelectionRendererCore()
{
SPtr<CoreRenderer> activeRenderer = RendererManager::instance().getActive();
if (mCamera != nullptr)
activeRenderer->unregisterRenderCallback(mCamera.get(), 10);
}
示例12: Log
bool TClntIfaceMgr::modifyPrefix(int iface, SPtr<TIPv6Addr> prefix, int prefixLen,
unsigned int pref, unsigned int valid,
PrefixModifyMode mode)
{
SPtr<TClntIfaceIface> ptrIface = (Ptr*)getIfaceByID(iface);
if (!ptrIface) {
Log(Error) << "Unable to find interface with ifindex=" << iface
<< ", prefix add/modify operation failed." << LogEnd;
return false;
}
string action;
int conf = 0; // number of successfully configured prefixes
int status = -1;
switch (mode) {
case PREFIX_MODIFY_ADD:
action = "Adding";
break;
case PREFIX_MODIFY_UPDATE:
action = "Updating";
break;
case PREFIX_MODIFY_DEL:
action = "Deleting";
break;
}
// option: split this prefix and add it to all interfaces
Log(Notice) << "PD: " << action << " prefix " << prefix->getPlain() << "/" << (int)prefixLen
<< " to all interfaces (prefix will be split to /"
<< int(prefixLen+8) << " prefixes if necessary)." << LogEnd;
if (prefixLen>120) {
Log(Error) << "PD: Unable to perform prefix operation: prefix /" << prefixLen
<< " can't be split. At least /120 prefix is required." << LogEnd;
return false;
}
// get a list of interfaces that we will assign prefixes to
TIfaceIfaceLst ifaceLst;
vector<string> ifaceNames = ClntCfgMgr().getDownlinkPrefixIfaces();
for (vector<string>::const_iterator name = ifaceNames.begin(); name != ifaceNames.end(); ++name) {
SPtr<TIfaceIface> x = getIfaceByName(*name);
if (x)
ifaceLst.push_back(x);
else
Log(Warning) << "Interface " << *name << " specified in downlink-prefix-ifaces is missing." << LogEnd;
}
if (ifaceLst.size() == 0) {
SPtr<TIfaceIface> x;
firstIface();
while ( x = (Ptr*)getIface() ) {
if (x->getID() == ptrIface->getID()) {
Log(Debug) << "PD: Interface " << x->getFullName()
<< " is the interface, where prefix has been obtained, skipping." << LogEnd;
continue;
}
// for each interface present in the system...
if (!x->flagUp()) {
Log(Debug) << "PD: Interface " << x->getFullName() << " is down, ignoring." << LogEnd;
continue;
}
if (!x->flagRunning()) {
Log(Debug) << "PD: Interface " << x->getFullName()
<< " has flag RUNNING not set, ignoring." << LogEnd;
continue;
}
if (!x->flagMulticast()) {
Log(Debug) << "PD: Interface " << x->getFullName()
<< " is not multicast capable, ignoring." << LogEnd;
continue;
}
if ( !(x->getMacLen() > 5) ) {
Log(Debug) << "PD: Interface " << x->getFullName()
<< " has MAC address length " << x->getMacLen()
<< " (6 or more required), ignoring." << LogEnd;
continue;
}
x->firstLLAddress();
if (!x->getLLAddress()) {
Log(Debug) << "PD: Interface " << x->getFullName()
<< " has no link-local address, ignoring. (Disconnected? Not associated? No-link?)" << LogEnd;
continue;
}
ifaceLst.push_back(x);
}
}
Log(Info) << "PD: Using " << ifaceLst.size() << " suitable interface(s):";
TIfaceIfaceLst::const_iterator i;
for (TIfaceIfaceLst::const_iterator i=ifaceLst.begin(); i!=ifaceLst.end(); ++i) {
Log(Cont) << (*i)->getName() << " ";
}
Log(Cont) << LogEnd;
if (ifaceLst.size() == 0) {
Log(Warning) << "Suitable interfaces not found. Delegated prefix not split." << LogEnd;
//.........这里部分代码省略.........
示例13: ClntCfgMgr
bool TClntIfaceMgr::fqdnAdd(SPtr<TClntIfaceIface> iface, string fqdn)
{
SPtr<TIPv6Addr> DNSAddr;
SPtr<TIPv6Addr> addr;
SPtr<TClntCfgIface> cfgIface;
cfgIface = ClntCfgMgr().getIface(iface->getID());
if (!cfgIface) {
Log(Error) << "Unable to find interface with ifindex=" << iface->getID() << "." << LogEnd;
return false;
}
// For the moment, we just take the first DNS entry.
List(TIPv6Addr) DNSSrvLst = iface->getDNSServerLst();
if (!DNSSrvLst.count()) {
Log(Error) << "Unable to find DNS Server. FQDN add failed." << LogEnd;
return false;
}
DNSSrvLst.first();
DNSAddr = DNSSrvLst.get();
// And the first IP address
SPtr<TAddrIA> ptrAddrIA;
ClntAddrMgr().firstIA();
ptrAddrIA = ClntAddrMgr().getIA();
if (ptrAddrIA->countAddr() > 0) {
ptrAddrIA->firstAddr();
addr = ptrAddrIA->getAddr()->get();
Log(Notice) << "FQDN: About to perform DNS Update: DNS server=" << *DNSAddr
<< ", IP=" << *addr << " and FQDN=" << fqdn << LogEnd;
// remember DNS Address (used during address release)
ptrAddrIA->setFQDNDnsServer(DNSAddr);
TCfgMgr::DNSUpdateProtocol proto = ClntCfgMgr().getDDNSProtocol();
DNSUpdate::DnsUpdateProtocol proto2 = DNSUpdate::DNSUPDATE_TCP;
if (proto == TCfgMgr::DNSUPDATE_UDP)
proto2 = DNSUpdate::DNSUPDATE_UDP;
if (proto == TCfgMgr::DNSUPDATE_ANY)
proto2 = DNSUpdate::DNSUPDATE_ANY;
unsigned int timeout = ClntCfgMgr().getDDNSTimeout();
#ifndef MOD_CLNT_DISABLE_DNSUPDATE
/* add AAAA record */
DNSUpdate *act = new DNSUpdate(DNSAddr->getPlain(), "", fqdn, addr->getPlain(),
DNSUPDATE_AAAA, proto2);
int result = act->run(timeout);
act->showResult(result);
delete act;
#else
Log(Error) << "This version is compiled without DNS Update support." << LogEnd;
return false;
#endif
}
return true;
}
示例14: Log
bool TAddrMgr::updatePrefix(SPtr<TAddrClient> client, SPtr<TDUID> duid , SPtr<TIPv6Addr> clntAddr,
int iface, unsigned long IAID, unsigned long T1, unsigned long T2,
SPtr<TIPv6Addr> prefix, unsigned long pref, unsigned long valid,
int length, bool quiet)
{
if (!prefix) {
Log(Error) << "Attempt to update null prefix failed." << LogEnd;
return false;
}
if (!client) {
Log(Error) << "Unable to update prefix, client not defined." << LogEnd;
return false;
}
// for that client, find IA
SPtr <TAddrIA> pd;
client->firstPD();
while ( pd = client->getPD() ) {
if ( pd->getIAID() == IAID)
break;
}
// have we found this PD?
if (!pd) {
Log(Error) << "Unable to find PD (iaid=" << IAID << ") for client " << duid->getPlain() << "." << LogEnd;
return false;
}
pd->setTimestamp();
pd->setT1(T1);
pd->setT2(T2);
SPtr <TAddrPrefix> ptrPrefix;
pd->firstPrefix();
while ( ptrPrefix = pd->getPrefix() ) {
if (*ptrPrefix->get()==*prefix)
break;
}
// address already exists
if (!ptrPrefix) {
Log(Warning) << "PD: Prefix " << prefix->getPlain() << " is not known. Unable to update." << LogEnd;
return false;
}
ptrPrefix->setTimestamp();
ptrPrefix->setPref(pref);
ptrPrefix->setValid(pref);
return true;
}
示例15: removeExpired
/** this function removes expired addresses from interface and from database
* It must be called before AddrMgr::doDuties() is called.
*/
void TClntTransMgr::removeExpired() {
if (ClntAddrMgr().getValidTimeout())
return;
SPtr<TAddrIA> ptrIA;
SPtr<TAddrAddr> ptrAddr;
SPtr<TIfaceIface> ptrIface;
ClntAddrMgr().firstIA();
while (ptrIA = ClntAddrMgr().getIA()) {
if (ptrIA->getValidTimeout())
continue;
ptrIA->firstAddr();
while (ptrAddr = ptrIA->getAddr()) {
if (ptrAddr->getValidTimeout())
continue;
ptrIface = ClntIfaceMgr().getIfaceByID(ptrIA->getIface());
Log(Warning) << "Address " << ptrAddr->get()->getPlain() << " assigned to the "
<< ptrIface->getName() << "/" << ptrIface->getID()
<< " interface (in IA " << ptrIA->getIAID() <<") has expired." << LogEnd;
// remove that address from the physical interace
ptrIface->delAddr(ptrAddr->get(), ptrIface->getPrefixLength());
}
}
}