本文整理汇总了C++中IsValid函数的典型用法代码示例。如果您正苦于以下问题:C++ IsValid函数的具体用法?C++ IsValid怎么用?C++ IsValid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsValid函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wxCHECK_MSG
wxString wxChoice::GetString(unsigned int n) const
{
wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("wxChoice::GetString(): invalid index") );
return m_strings[n] ;
}
开发者ID:SCP-682,项目名称:Cities3D,代码行数:6,代码来源:choice.cpp
示例2: MatricesValid
void CompoundMatrix::MultVectorImpl(Number alpha, const Vector &x,
Number beta, Vector &y) const
{
if (!matrices_valid_) {
matrices_valid_ = MatricesValid();
}
DBG_ASSERT(matrices_valid_);
// The vectors are assumed to be compound Vectors as well
const CompoundVector* comp_x = dynamic_cast<const CompoundVector*>(&x);
CompoundVector* comp_y = dynamic_cast<CompoundVector*>(&y);
#ifndef ALLOW_NESTED
// A few sanity checks
if (comp_x) {
DBG_ASSERT(NComps_Cols()==comp_x->NComps());
}
else {
DBG_ASSERT(NComps_Cols() == 1);
}
if (comp_y) {
DBG_ASSERT(NComps_Rows()==comp_y->NComps());
}
else {
DBG_ASSERT(NComps_Rows() == 1);
}
#endif
if (comp_x) {
if (NComps_Cols()!=comp_x->NComps()) {
comp_x = NULL;
}
}
if (comp_y) {
if (NComps_Rows()!=comp_y->NComps()) {
comp_y = NULL;
}
}
// Take care of the y part of the addition
if ( beta!=0.0 ) {
y.Scal(beta);
}
else {
y.Set(0.0); // In case y hasn't been initialized yet
}
for ( Index irow = 0; irow < NComps_Rows(); irow++ ) {
SmartPtr<Vector> y_i;
if (comp_y) {
y_i = comp_y->GetCompNonConst(irow);
}
else {
y_i = &y;
}
DBG_ASSERT(IsValid(y_i));
for ( Index jcol = 0; jcol < NComps_Cols(); jcol++ ) {
if ( (owner_space_->Diagonal() && irow == jcol)
|| (!owner_space_->Diagonal() && ConstComp(irow,jcol)) ) {
SmartPtr<const Vector> x_j;
if (comp_x) {
x_j = comp_x->GetComp(jcol);
}
else if (NComps_Cols() == 1) {
x_j = &x;
}
DBG_ASSERT(IsValid(x_j));
ConstComp(irow, jcol)->MultVector(alpha, *x_j,
1., *y_i);
}
}
}
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:75,代码来源:IpCompoundMatrix.cpp
示例3: IsValid
bool CFantomAddress::IsScript() const {
return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
}
开发者ID:ch1c4um,项目名称:fantom,代码行数:3,代码来源:base58.cpp
示例4: DBG_ASSERT
// Specialized method (overloaded from IpMatrix)
void CompoundMatrix::AddMSinvZImpl(Number alpha, const Vector& S,
const Vector& Z, Vector& X) const
{
// The vectors are assumed to be compound Vectors as well (unless they
// are assumed to consist of only one component
const CompoundVector* comp_S = dynamic_cast<const CompoundVector*>(&S);
const CompoundVector* comp_Z = dynamic_cast<const CompoundVector*>(&Z);
CompoundVector* comp_X = dynamic_cast<CompoundVector*>(&X);
#ifndef ALLOW_NESTED
// A few sanity checks for sizes
if (comp_S) {
DBG_ASSERT(NComps_Cols()==comp_S->NComps());
}
else {
DBG_ASSERT(NComps_Cols() == 1);
}
if (comp_Z) {
DBG_ASSERT(NComps_Cols()==comp_Z->NComps());
}
else {
DBG_ASSERT(NComps_Cols() == 1);
}
if (comp_X) {
DBG_ASSERT(NComps_Rows()==comp_X->NComps());
}
else {
DBG_ASSERT(NComps_Rows() == 1);
}
#endif
if (comp_S) {
if (NComps_Cols()!=comp_S->NComps()) {
comp_S = NULL;
}
}
if (comp_Z) {
if (NComps_Cols()!=comp_Z->NComps()) {
comp_Z = NULL;
}
}
if (comp_X) {
if (NComps_Rows()!=comp_X->NComps()) {
comp_X = NULL;
}
}
for ( Index irow = 0; irow < NComps_Rows(); irow++ ) {
SmartPtr<Vector> X_i;
if (comp_X) {
X_i = comp_X->GetCompNonConst(irow);
}
else {
X_i = &X;
}
DBG_ASSERT(IsValid(X_i));
for ( Index jcol = 0; jcol < NComps_Cols(); jcol++ ) {
if ( (owner_space_->Diagonal() && irow == jcol)
|| (!owner_space_->Diagonal() && ConstComp(irow, jcol)) ) {
SmartPtr<const Vector> S_j;
if (comp_S) {
S_j = comp_S->GetComp(jcol);
}
else {
S_j = &S;
}
DBG_ASSERT(IsValid(S_j));
SmartPtr<const Vector> Z_j;
if (comp_Z) {
Z_j = comp_Z->GetComp(jcol);
}
else {
Z_j = &Z;
}
DBG_ASSERT(IsValid(Z_j));
ConstComp(irow, jcol)->AddMSinvZ(alpha, *S_j, *Z_j, *X_i);
}
}
}
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:82,代码来源:IpCompoundMatrix.cpp
示例5: ASSERT
CFile::FILESIZE CWinFile::GetPos() const
{
ASSERT(IsValid());
return _telli64(m_hFile);
}
开发者ID:aaalexandrov,项目名称:Alex,代码行数:5,代码来源:WinFile.cpp
示例6: DrawMinimap
void APlayerHUD::DrawMinimap()
{
ARealmPlayerController* pc = Cast<ARealmPlayerController>(PlayerOwner);
if (!IsValid(pc) || (IsValid(pc) && !IsValid(pc->GetPlayerCharacter())) || !IsValid(gameMinimap))
return;
float trueNorth, playerHeading, actualMapRange;
FVector2D playerPos, displayPlayerPos, startPos;
const APlayerHUD* defaultHUD = GetDefault<APlayerHUD>();
if (!IsValid(defaultHUD))
return;
mapPosition.X = defaultHUD->mapPosition.X * Canvas->ClipX;
mapPosition.Y = defaultHUD->mapPosition.Y * Canvas->ClipY;
actualMapRange = FMath::Max(gameMinimap->mapSizeMax.X - gameMinimap->mapSizeMin.X, gameMinimap->mapSizeMax.Y - gameMinimap->mapSizeMin.Y);
playerPos = FVector2D::ZeroVector;
FVector pp = pc->GetPlayerCharacter()->GetActorLocation();
pp.X = pp.X / actualMapRange;
pp.Y = pp.Y / actualMapRange;
playerPos.X = pp.X;
playerPos.Y = pp.Y;
trueNorth = gameMinimap->GetRadianHeading();
playerHeading = GetUnitHeading(pc->GetPlayerCharacter());
displayPlayerPos.X = playerPos.Size() * FMath::Cos(FMath::Atan2(playerPos.Y, playerPos.X));
displayPlayerPos.Y = playerPos.Size() * FMath::Sin(FMath::Atan2(playerPos.Y, playerPos.X));
startPos.X = displayPlayerPos.X;
startPos.Y = displayPlayerPos.Y;
//draw the back
Canvas->SetDrawColor(FColor::Black);
Canvas->K2_DrawMaterial(gameMinimap->mapBackground, mapPosition, FVector2D(mapDimensions / 1920.f * Canvas->ClipX, mapDimensions / 1080.f * Canvas->ClipY), FVector2D::ZeroVector); //draw map back
//draw this player
Canvas->SetDrawColor(FColor::Yellow);
FVector2D pdp = FVector2D(mapPosition.X + mapDimensions * (displayPlayerPos.X), mapPosition.Y + mapDimensions * (displayPlayerPos.Y));
Canvas->K2_DrawBox(pdp, FVector2D(32.f / 1920.f * Canvas->ClipX, 32.f / 1080.f * Canvas->ClipY));
//draw other units
for (TActorIterator<AGameCharacter> unititr(GetWorld()); unititr; ++unititr)
{
AGameCharacter* gc = (*unititr);
if (gc->IsAlive() && !gc->bHidden) //draw visible and alive units
{
playerHeading = GetUnitHeading(gc);
pp = gc->GetActorLocation();
pp.X = pp.X / actualMapRange;
pp.Y = pp.Y / actualMapRange;
displayPlayerPos.X = pp.Size() * FMath::Cos(FMath::Atan2(pp.Y, pp.X));
displayPlayerPos.Y = pp.Size() * FMath::Sin(FMath::Atan2(pp.Y, pp.X));
Canvas->SetDrawColor(FColor::Green);
pdp = FVector2D(mapPosition.X + mapDimensions * (displayPlayerPos.X), mapPosition.Y + mapDimensions * (displayPlayerPos.Y));
Canvas->K2_DrawBox(pdp, FVector2D(20.f / 1920.f * Canvas->ClipX, 20.f / 1080.f * Canvas->ClipY));
}
}
}
开发者ID:weelcheel,项目名称:Mythos-Realm,代码行数:66,代码来源:PlayerHUD.cpp
示例7: Save
bool PngImage::Save(FILE *pStream)
{
if (pStream && IsValid())
{
bool success = false;
png_structp pPngStruct = NULL;
png_infop pPngInfo = NULL;
int bpp = IMAGE_BPP_8;
int colorType = PNG_COLOR_TYPE_RGB;
png_bytep *pImageRows = NULL;
uint rowSize;
uint offset = 0;
//create png write struct
pPngStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pPngStruct)
{
//png struct allocation failed
goto Exit_Save;
}
//create png info struct
pPngInfo = png_create_info_struct(pPngStruct);
if (!pPngInfo)
{
//png info allocation failed
goto Exit_Save;
}
//required for png library use
if (setjmp(pPngStruct->jmpbuf))
{
//handle png write error
goto Exit_Save;
}
//initialize png io
png_init_io(pPngStruct, pStream);
//use paeth filtering
png_set_filter(pPngStruct, 0, PNG_FILTER_PAETH);
//set compression level
png_set_compression_level(pPngStruct, Z_BEST_COMPRESSION);
//write png image info header
png_set_IHDR(pPngStruct, pPngInfo, m_width, m_height, bpp, colorType,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_write_info(pPngStruct, pPngInfo);
//allocate space for image row pointers
pImageRows = new png_bytep [m_height];
if (!pImageRows)
{
//allocation failed
goto Exit_Save;
}
//set individual row pointers to correct offsets
rowSize = png_get_rowbytes(pPngStruct, pPngInfo);
for (uint i = 0; i < m_height; ++i)
{
pImageRows[i] = m_pImageData + offset;
offset += rowSize;
}
//write image data
png_write_image(pPngStruct, pImageRows);
png_write_end(pPngStruct, NULL);
//image successfully saved
success = true;
Exit_Save:
delete pImageRows;
if (pPngStruct && pPngInfo)
{
//free png struct and png info
png_destroy_write_struct(&pPngStruct, &pPngInfo);
}
else if (pPngStruct)
{
//free png struct only
png_destroy_write_struct(&pPngStruct, NULL);
}
return success;
}
return false;
}
开发者ID:RocketAlien,项目名称:scenic,代码行数:89,代码来源:image.cpp
示例8: control
Zip::Zip(Control &control_, char *zipfile_name) : control(control_),
magic(0),
zipbuffer(NULL)
{
#ifdef UNIX_FILE_SYSTEM
zipfile = SystemFopen(zipfile_name, "rb");
if (zipfile)
{
int rc = fseek(zipfile, -END_SIZE, SEEK_END);
if (rc == 0)
{
zipbuffer = new char[END_SIZE];
buffer_ptr = zipbuffer;
SystemFread(buffer_ptr, sizeof(char), END_SIZE, zipfile);
magic = GetU4();
}
}
#elif defined(WIN32_FILE_SYSTEM)
zipfile = CreateFile(zipfile_name,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_READONLY,
NULL);
if (zipfile != INVALID_HANDLE_VALUE)
{
mapfile = CreateFileMapping(zipfile, NULL, PAGE_READONLY, 0, 0, NULL);
zipbuffer = (mapfile == INVALID_HANDLE_VALUE ?
NULL :
(char *) MapViewOfFile(mapfile,
FILE_MAP_READ,
0, 0, 0)
);
if (zipbuffer)
{
buffer_ptr = &zipbuffer[GetFileSize(zipfile, NULL) - END_SIZE];
magic = GetU4();
}
}
#endif
// The following was posted to the dev list, but was just
// too good to not put in here, the next person to have to
// deal with this crap will appreciate it. -=Chris
//
// From: Mo DeJong <[email protected]>
//
// Ode to a zip file:
//
// I can't read it forwards
// I can't read it backwards
// I must know where to begin
// so I need to look in the middle
// to find the middle, I must know the end
// but I don't know where that is, so I guess
//
// -------------------------------------------------
// This may or may not be a valid zip file. The zip file might have
// a file comment so we can't be sure where the END header is located.
// We check for the LOC header at byte 0 to make sure this is a valid
// zip file and then scan over the file backwards in search of the
// END header.
if (zipbuffer != NULL && ! IsValid()) {
u4 sig = 0;
#ifdef UNIX_FILE_SYSTEM
int res = fseek(zipfile, 0, SEEK_SET);
assert(res == 0);
char *tmpbuffer = new char[LOC_SIZE];
buffer_ptr = tmpbuffer;
SystemFread(buffer_ptr, sizeof(char), LOC_SIZE, zipfile);
sig = GetU4();
delete [] tmpbuffer;
buffer_ptr = NULL;
if (sig == LOC_SIG)
{
int block_size = 8192;
tmpbuffer = new char[block_size];
char *holdbuffer = new char[8];
char *index_ptr;
res = fseek(zipfile, 0, SEEK_END);
assert(res == 0);
long zip_file_size = ftell(zipfile);
int num_loops = zip_file_size / block_size;
magic = 0;
for (; magic == 0 && num_loops >= 0 ; num_loops--) {
if ((ftell(zipfile) - block_size) < 0)
{
block_size = ftell(zipfile);
//.........这里部分代码省略.........
开发者ID:prog012,项目名称:jikes,代码行数:101,代码来源:zip.cpp
示例9: DroppedOnPanel
FReply FKismetDelegateDragDropAction::DroppedOnPanel(const TSharedRef< SWidget >& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph)
{
if(IsValid())
{
FNodeConstructionParams NewNodeParams;
NewNodeParams.Property = GetVariableProperty();
const UClass* VariableSourceClass = CastChecked<UClass>(NewNodeParams.Property->GetOuter());
const UBlueprint* DropOnBlueprint = FBlueprintEditorUtils::FindBlueprintForGraph(&Graph);
NewNodeParams.Graph = &Graph;
NewNodeParams.GraphPosition = GraphPosition;
NewNodeParams.bSelfContext = VariableSourceClass == NULL || DropOnBlueprint->SkeletonGeneratedClass->IsChildOf(VariableSourceClass);;
NewNodeParams.AnalyticCallback = AnalyticCallback;
FMenuBuilder MenuBuilder(true, NULL);
const FText VariableNameText = FText::FromName( VariableName );
MenuBuilder.BeginSection("BPDelegateDroppedOn", VariableNameText );
{
const bool bBlueprintCallable = NewNodeParams.Property->HasAllPropertyFlags(CPF_BlueprintCallable);
if(bBlueprintCallable)
{
MenuBuilder.AddMenuEntry(
LOCTEXT("CallDelegate", "Call"),
FText::Format( LOCTEXT("CallDelegateToolTip", "Call {0}"), VariableNameText ),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetDelegateDragDropAction::MakeMCDelegateNode<UK2Node_CallDelegate>,NewNodeParams)
));
}
if(NewNodeParams.Property->HasAllPropertyFlags(CPF_BlueprintAssignable))
{
MenuBuilder.AddMenuEntry(
LOCTEXT("AddDelegate", "Bind"),
FText::Format( LOCTEXT("AddDelegateToolTip", "Bind event to {0}"), VariableNameText ),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetDelegateDragDropAction::MakeMCDelegateNode<UK2Node_AddDelegate>,NewNodeParams)
));
MenuBuilder.AddMenuEntry(
LOCTEXT("AddRemove", "Unbind"),
FText::Format( LOCTEXT("RemoveDelegateToolTip", "Unbind event from {0}"), VariableNameText ),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetDelegateDragDropAction::MakeMCDelegateNode<UK2Node_RemoveDelegate>, NewNodeParams)
));
MenuBuilder.AddMenuEntry(
LOCTEXT("AddClear", "Unbind all"),
FText::Format( LOCTEXT("ClearDelegateToolTip", "Unbind all events from {0}"), VariableNameText ),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetDelegateDragDropAction::MakeMCDelegateNode<UK2Node_ClearDelegate>, NewNodeParams)
));
const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();
check(Schema);
const EGraphType GraphType = Schema->GetGraphType(&Graph);
const bool bSupportsEventGraphs = (DropOnBlueprint && FBlueprintEditorUtils::DoesSupportEventGraphs(DropOnBlueprint));
const bool bAllowEvents = ((GraphType == GT_Ubergraph) && bSupportsEventGraphs);
if(bAllowEvents)
{
MenuBuilder.AddMenuEntry(
LOCTEXT("AddEvent", "Event"),
FText::Format( LOCTEXT("EventDelegateToolTip", "Create event with the {0} signature"), VariableNameText ),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetDelegateDragDropAction::MakeEvent, NewNodeParams)
));
MenuBuilder.AddMenuEntry(
LOCTEXT("AssignEvent", "Assign"),
LOCTEXT("AssignDelegateToolTip", "Create and bind event"),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetDelegateDragDropAction::AssignEvent, NewNodeParams)
));
}
}
}
MenuBuilder.EndSection();
FSlateApplication::Get().PushMenu(Owner, MenuBuilder.MakeWidget(), ScreenPosition, FPopupTransitionEffect( FPopupTransitionEffect::ContextMenu));
}
return FReply::Handled();
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:86,代码来源:BPDelegateDragDropAction.cpp
示例10: Load
bool PngImage::Load(FILE *pStream)
{
if (pStream && !IsValid())
{
bool success = false;
ubyte aPngHeader[PNG_IMAGE_HEADER_SIZE];
png_structp pPngStruct = NULL;
png_infop pPngInfo = NULL;
//float gamma = 0.0;
uint rowSize;
ubyte *pImageData = NULL;
png_bytep *pImageRows = NULL;
uint offset = 0;
png_uint_32 width = 0;
png_uint_32 height = 0;
int bpp = 0;
int colorType = 0;
//check png signature
if (sizeof(aPngHeader) != fread(aPngHeader, 1, sizeof(aPngHeader), pStream))
{
//read failed
goto Exit_Load;
}
if (!png_check_sig(aPngHeader, sizeof(aPngHeader)))
{
//file is not a png image
goto Exit_Load;
}
//create png read struct
pPngStruct = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pPngStruct)
{
//png struct allocation failed
goto Exit_Load;
}
//create png info struct
pPngInfo = png_create_info_struct(pPngStruct);
if (!pPngInfo)
{
//png info allocation failed
goto Exit_Load;
}
//required for png library use
if (setjmp(pPngStruct->jmpbuf))
{
//handle png read error
goto Exit_Load;
}
//initialize png io
png_init_io(pPngStruct, pStream);
//set offset into the file since png header has been already read
png_set_sig_bytes(pPngStruct, sizeof(aPngHeader));
//read png image info header
png_read_info(pPngStruct, pPngInfo);
png_get_IHDR(pPngStruct, pPngInfo, &width, &height, &bpp, &colorType,
NULL, NULL, NULL);
DbgMessage("Image %ux%ux%ubpp", width, height, bpp);
//filter out unsupported images
if (bpp < PNG_IMAGE_MIN_BPP || bpp > PNG_IMAGE_MAX_BPP)
{
goto Exit_Load;
}
//convert palette images to rgb
if (PNG_COLOR_TYPE_PALETTE == colorType)
{
png_set_expand(pPngStruct);
}
//convert low-bpp images to 8 bpp
if (bpp < IMAGE_BPP_8)
{
png_set_expand(pPngStruct);
}
//strip alpha channel
if ((colorType & PNG_COLOR_MASK_ALPHA) ||
png_get_valid(pPngStruct, pPngInfo, PNG_INFO_tRNS))
{
png_set_strip_alpha(pPngStruct);
}
//strip 16 bpp images down to 8 bpp
if (IMAGE_BPP_16 == bpp)
{
png_set_strip_16(pPngStruct);
}
//convert grayscale images to rgb
if (PNG_COLOR_TYPE_GRAY == colorType || PNG_COLOR_TYPE_GRAY_ALPHA == colorType)
{
//.........这里部分代码省略.........
开发者ID:RocketAlien,项目名称:scenic,代码行数:101,代码来源:image.cpp
示例11: SCOPE_CYCLE_COUNTER
// Runs calculations on friction component, applies friction force to effected component and returns reaction forces(forces that can effect track or a wheel)
void UMMTFrictionComponent::ApplyFriction(const FVector& ContactPointLocation, const FVector& ContactPointNormal, const FVector& InducedVelocity, const FVector& PreNormalForceAtPoint,
const EPhysicalSurface& PhysicalSurface, const float& NumberOfContactPoints, const float& DeltaTime, FVector& NormalizedReactionForce, FVector& RollingFrictionForce)
{
// Gather stats
SCOPE_CYCLE_COUNTER(STAT_MMTFrictionApply);
float NormalForceAtContactPoint = PreNormalForceAtPoint.ProjectOnTo(ContactPointNormal).Size();
// Check if Effected Component Mesh reference is valid and escape early otherwise
if (!IsValid(EffectedComponentMesh))
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, FString::Printf(TEXT("%s->%s component's EffectedComponentMesh reference is invalid!"), *GetOwner()->GetName(), *GetName()));
UE_LOG(LogTemp, Warning, TEXT("%s->%s component's EffectedComponentMesh reference is invalid!"), *GetOwner()->GetName(), *GetName());
NormalizedReactionForce = FVector::ZeroVector;
RollingFrictionForce = FVector::ZeroVector;
return;
}
//Find relative velocity of the friction surface and ground/another object at point
FVector RelativeVelocityAtPoint = EffectedComponentMesh->GetPhysicsLinearVelocityAtPoint(ContactPointLocation) + InducedVelocity + FrictionSurfaceVelocity;
RelativeVelocityAtPoint = RelativeVelocityAtPoint.VectorPlaneProject(RelativeVelocityAtPoint, ContactPointNormal);
//filter out oscillations when vehicle is standing still but friction overshoots
RelativeVelocityAtPoint = (PrevRelativeVelocityAtPoint + RelativeVelocityAtPoint) * 0.5;
PrevRelativeVelocityAtPoint = RelativeVelocityAtPoint;
// early exit if velocity is too low to consider as vehicle most likely standing still
if (RelativeVelocityAtPoint.Size() < 1.0f)
{
NormalizedReactionForce = FVector::ZeroVector;
RollingFrictionForce = FVector::ZeroVector;
return;
}
//Calculate static and kinetic friction coefficients, taking into account velocity direction and friction ellipse
float MuStatic;
float MuKinetic;
UMMTBPFunctionLibrary::GetMuFromFrictionElipse(RelativeVelocityAtPoint.GetSafeNormal(), ReferenceFrameTransform.TransformVector(FVector(1.0f, 1.0f, 1.0f)),
MuXStatic, MuXKinetic, MuYStatic, MuYKinetic, MuStatic, MuKinetic);
//Calculate "stopping force" which is amount of force necessary to completely remove velocity of the object
FVector StoppingForce = ((RelativeVelocityAtPoint * (-1.0f) * EffectedComponentMesh->GetMass()) / DeltaTime) / NumberOfContactPoints;
//Static friction threshold
float MuStaticByLoad = NormalForceAtContactPoint * MuStatic;
//Friction Force that will be applied to effected mesh component
FVector ApplicationForce;
if (StoppingForce.Size() >= MuStaticByLoad)
{
ApplicationForce = StoppingForce.GetClampedToSize(0.0f, NormalForceAtContactPoint * MuKinetic);
if (IsDebugMode)
{
DrawDebugString(GetWorld(), ContactPointLocation, FString("Kinetic Friction"), nullptr, FColor::Magenta, 0.0f, false);
}
}
else
{
ApplicationForce = StoppingForce.GetClampedToSize(0.0f, MuStaticByLoad);
if (IsDebugMode)
{
DrawDebugString(GetWorld(), ContactPointLocation, FString("Static Friction"), nullptr, FColor::Red, 0.0f, false);
}
}
//Apply friction force
UMMTBPFunctionLibrary::MMTAddForceAtLocationComponent(EffectedComponentMesh, ApplicationForce, ContactPointLocation);
//Calculate Reaction force
NormalizedReactionForce = (ApplicationForce * (-1.0f)) / EffectedComponentMesh->GetMass();
//Calculate Rolling Friction
float RollingFrictionCoefficient = FPhysicalSurfaceRollingFrictionCoefficient().RollingFrictionCoefficient;
for (int32 i = 0; i < PhysicsSurfaceResponse.Num(); i++)
{
if (PhysicsSurfaceResponse[i].PhysicalSurface == PhysicalSurface)
{
RollingFrictionCoefficient = PhysicsSurfaceResponse[i].RollingFrictionCoefficient;
break;
}
}
RollingFrictionForce = RelativeVelocityAtPoint.GetSafeNormal() * NormalForceAtContactPoint * RollingFrictionCoefficient;
if (IsDebugMode)
{
DrawDebugLine(GetWorld(), ContactPointLocation, ContactPointLocation + ApplicationForce * 0.005f, FColor::Yellow, false, 0.0f, 0, 3.0f);
DrawDebugLine(GetWorld(), ContactPointLocation, ContactPointLocation + RollingFrictionForce * 0.005f, FColor::Green, false, 0.0f, 0, 3.0f);
DrawDebugString(GetWorld(), ContactPointLocation+FVector(0.0f, 0.0f, 50.0f), (PhysicalSurfaceEnum ? PhysicalSurfaceEnum->GetEnumName(PhysicalSurface) : FString("<Invalid Enum>")), nullptr, FColor::Cyan, 0.0f, false);
//DrawDebugString(GetWorld(), ContactPointLocation + FVector(0.0f, 0.0f, 25.0f), FString("Normal Force: ") + FString::SanitizeFloat(NormalForceAtContactPoint), nullptr, FColor::Turquoise, 0.0f, false);
}
}
开发者ID:BoredEngineer,项目名称:MMT_Plugin,代码行数:95,代码来源:MMTFrictionComponent.cpp
示例12: wxCHECK_RET
// ----------------------------------------------------------------------------
// client data
// ----------------------------------------------------------------------------
void wxChoice::DoSetItemClientData(unsigned int n, void* clientData)
{
wxCHECK_RET( IsValid(n), wxT("wxChoice::DoSetItemClientData: invalid index") );
m_datas[n] = (char*)clientData ;
}
开发者ID:SCP-682,项目名称:Cities3D,代码行数:9,代码来源:choice.cpp
示例13: Reinit
bool wxRegExImpl::Compile(const wxString& expr, int flags)
{
Reinit();
#ifdef WX_NO_REGEX_ADVANCED
# define FLAVORS wxRE_BASIC
#else
# define FLAVORS (wxRE_ADVANCED | wxRE_BASIC)
wxASSERT_MSG( (flags & FLAVORS) != FLAVORS,
wxT("incompatible flags in wxRegEx::Compile") );
#endif
wxASSERT_MSG( !(flags & ~(FLAVORS | wxRE_ICASE | wxRE_NOSUB | wxRE_NEWLINE)),
wxT("unrecognized flags in wxRegEx::Compile") );
// translate our flags to regcomp() ones
int flagsRE = 0;
if ( !(flags & wxRE_BASIC) )
{
#ifndef WX_NO_REGEX_ADVANCED
if (flags & wxRE_ADVANCED)
flagsRE |= REG_ADVANCED;
else
#endif
flagsRE |= REG_EXTENDED;
}
if ( flags & wxRE_ICASE )
flagsRE |= REG_ICASE;
if ( flags & wxRE_NOSUB )
flagsRE |= REG_NOSUB;
if ( flags & wxRE_NEWLINE )
flagsRE |= REG_NEWLINE;
// compile it
#ifdef WXREGEX_USING_BUILTIN
bool conv = true;
// FIXME-UTF8: use wc_str() after removing ANSI build
int errorcode = wx_re_comp(&m_RegEx, expr.c_str(), expr.length(), flagsRE);
#else
// FIXME-UTF8: this is potentially broken, we shouldn't even try it
// and should always use builtin regex library (or PCRE?)
const wxWX2MBbuf conv = expr.mbc_str();
int errorcode = conv ? regcomp(&m_RegEx, conv, flagsRE) : REG_BADPAT;
#endif
if ( errorcode )
{
wxLogError(_("Invalid regular expression '%s': %s"),
expr.c_str(), GetErrorMsg(errorcode, !conv).c_str());
m_isCompiled = false;
}
else // ok
{
// don't allocate the matches array now, but do it later if necessary
if ( flags & wxRE_NOSUB )
{
// we don't need it at all
m_nMatches = 0;
}
else
{
// we will alloc the array later (only if really needed) but count
// the number of sub-expressions in the regex right now
// there is always one for the whole expression
m_nMatches = 1;
// and some more for bracketed subexperessions
for ( const wxChar *cptr = expr.c_str(); *cptr; cptr++ )
{
if ( *cptr == wxT('\\') )
{
// in basic RE syntax groups are inside \(...\)
if ( *++cptr == wxT('(') && (flags & wxRE_BASIC) )
{
m_nMatches++;
}
}
else if ( *cptr == wxT('(') && !(flags & wxRE_BASIC) )
{
// we know that the previous character is not an unquoted
// backslash because it would have been eaten above, so we
// have a bare '(' and this indicates a group start for the
// extended syntax. '(?' is used for extensions by perl-
// like REs (e.g. advanced), and is not valid for POSIX
// extended, so ignore them always.
if ( cptr[1] != wxT('?') )
m_nMatches++;
}
}
}
m_isCompiled = true;
}
return IsValid();
}
开发者ID:BauerBox,项目名称:wxWidgets,代码行数:97,代码来源:regex.cpp
示例14: wxCHECK_MSG
int wxRegExImpl::Replace(wxString *text,
const wxString& replacement,
size_t maxMatches) const
{
wxCHECK_MSG( text, wxNOT_FOUND, wxT("NULL text in wxRegEx::Replace") );
wxCHECK_MSG( IsValid(), wxNOT_FOUND, wxT("must successfully Compile() first") );
// the input string
#ifndef WXREGEX_CONVERT_TO_MB
const wxChar *textstr = text->c_str();
size_t textlen = text->length();
#else
const wxWX2MBbuf textstr = WXREGEX_CHAR(*text);
if (!textstr)
{
wxLogError(_("Failed to find match for regular expression: %s"),
GetErrorMsg(0, true).c_str());
return 0;
}
size_t textlen = strlen(textstr);
text->clear();
#endif
// the replacement text
wxString textNew;
// the result, allow 25% extra
wxString result;
result.reserve(5 * textlen / 4);
// attempt at optimization: don't iterate over the string if it doesn't
// contain back references at all
bool mayHaveBackrefs =
replacement.find_first_of(wxT("\\&")) != wxString::npos;
if ( !mayHaveBackrefs )
{
textNew = replacement;
}
// the position where we start looking for the match
size_t matchStart = 0;
// number of replacement made: we won't make more than maxMatches of them
// (unless maxMatches is 0 which doesn't limit the number of replacements)
size_t countRepl = 0;
// note that "^" shouldn't match after the first call to Matches() so we
// use wxRE_NOTBOL to prevent it from happening
while ( (!maxMatches || countRepl < maxMatches) &&
Matches(
#ifndef WXREGEX_CONVERT_TO_MB
textstr + matchStart,
#else
textstr.data() + matchStart,
#endif
countRepl ? wxRE_NOTBOL : 0
WXREGEX_IF_NEED_LEN(textlen - matchStart)) )
{
// the string possibly contains back references: we need to calculate
// the replacement text anew after each match
if ( mayHaveBackrefs )
{
mayHaveBackrefs = false;
textNew.clear();
textNew.reserve(replacement.length());
for ( const wxChar *p = replacement.c_str(); *p; p++ )
{
size_t index = (size_t)-1;
if ( *p == wxT('\\') )
{
if ( wxIsdigit(*++p) )
{
// back reference
wxChar *end;
index = (size_t)wxStrtoul(p, &end, 10);
p = end - 1; // -1 to compensate for p++ in the loop
}
//else: backslash used as escape character
}
else if ( *p == wxT('&') )
{
// treat this as "\0" for compatbility with ed and such
index = 0;
}
// do we have a back reference?
if ( index != (size_t)-1 )
{
// yes, get its text
size_t start, len;
if ( !GetMatch(&start, &len, index) )
{
wxFAIL_MSG( wxT("invalid back reference") );
// just eat it...
}
else
//.........这里部分代码省略.........
开发者ID:BauerBox,项目名称:wxWidgets,代码行数:101,代码来源:regex.cpp
示例15: aPBIt
//=======================================================================
// function: PreparePaveBlocks
// purpose:
//=======================================================================
void NMTTools_CheckerSI::PreparePaveBlocks(const Standard_Integer nE)
{
myIsDone=Standard_False;
//
// char buf[32]={"SR"};
Standard_Boolean bIsValid;
Standard_Integer nV1, nV2, iErr;
Standard_Real aT1, aT2;
TopoDS_Edge aE;
TopoDS_Vertex aV1, aV2;
//
BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
// Edge
aE=TopoDS::Edge(myDS->Shape(nE));
if (BRep_Tool::Degenerated(aE)) {
myIsDone=Standard_True;
return;
}
//
BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
BOPTools_PaveBlockIterator aPBIt(nE, aPS);
for (; aPBIt.More(); aPBIt.Next()) {
BOPTools_PaveBlock& aPB=aPBIt.Value();
const IntTools_Range& aRange=aPB.Range();
//
const BOPTools_Pave& aPave1=aPB.Pave1();
nV1=aPave1.Index();
aV1=TopoDS::Vertex(myDS->Shape(nV1));
aT1=aPave1.Param();
//
const BOPTools_Pave& aPave2=aPB.Pave2();
nV2=aPave2.Index();
aV2=TopoDS::Vertex(myDS->Shape(nV2));
aT2=aPave2.Param();
//
bIsValid=Standard_True;
if (nV1==nV2) {
bIsValid=IsValid(aE, aV1, aT1, aT2);
if (!bIsValid) {
//printf(" pb SR: nV nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
myStopStatus=1;
}
}
//
IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
iErr=aSR.ErrorStatus();
if (!aSR.IsDone()) {
//printf(" pb SR: Done nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
aSR.SetShrunkRange(aRange);
//throw BOPTColStd_Failure(buf) ;
}
else if (iErr!=6) {
CorrectShrunkRanges (0, aPave1, aSR);
CorrectShrunkRanges (1, aPave2, aSR);
}
aPB.SetShrunkRange(aSR);
aLPB.Append(aPB);
} //for (; aPBIt.More(); aPBIt.Next())
myIsDone=Standard_True;
}
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:65,代码来源:NMTTools_CheckerSI_1.cpp
示例16: GetCU
void
DWARFDIE::Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const
{
if (s && IsValid())
m_die->Dump (GetDWARF(), GetCU(), *s, recurse_depth);
}
开发者ID:k06a,项目名称:lldb,代码行数:6,代码来源:DWARFDIE.cpp
示例17: NLOG
void CUnit::RecieveMessage(CMessage &message){
NLOG("CUnit::RecieveMessage");
if(!IsValid()){
return;
}
if(message.GetType() == string("update")){
if(under_construction){
return;
}
if(EVERY_((GetAge()%32+20))){
if(currentTask.get() != 0){
if(!currentTask->IsValid()){
//
taskManager->TaskFinished();
if(taskManager->HasTasks()){
currentTask = taskManager->GetNextTask();
if(currentTask.get() != 0){
currentTask->Init();
G->RegisterMessageHandler(currentTask);
}
}else{
currentTask = boost::shared_ptr<IModule>();
}
}
}else{
//
if(taskManager->HasTasks()){
currentTask = taskManager->GetNextTask();
if(currentTask.get() != 0){
currentTask->Init();
G->RegisterMessageHandler(currentTask);
}
}
}
}
}else if(message.GetType() == string("unitfinished")){
if(message.GetParameter(0) == this->uid){
under_construction = false;
LoadBehaviours();
}
}else if(message.GetType() == string("unitdestroyed")){
if(message.GetParameter(0) == uid){
if(!utd->IsMobile()){
G->BuildingPlacer->UnBlock(G->GetUnitPos(uid),utd);
}
G->RemoveHandler(currentTask);
taskManager->RemoveAllTasks();
G->RemoveHandler(taskManager);
if(!behaviours.empty()){
behaviours.erase(behaviours.begin(),behaviours.end());
behaviours.clear();
}
this->End();
return;
}
}
if(under_construction){
return;
}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:67,代码来源:CUnit.cpp
示例18: IsValid
bool ON_Line::Create( const ON_3dPoint& from_pt, const ON_3dPoint& to_pt )
{
from = from_pt;
to = to_pt;
return IsValid();
}
开发者ID:ckvk,项目名称:opennurbs,代码行数:6,代码来源:opennurbs_line.cpp
示例19: IsValid
bool CAnoncoinSecret::SetString(const char* pszSecret)
{
return CBase58Data::SetString(pszSecret) && IsValid();
}
开发者ID:Anoncoin,项目名称:anoncoin,代码行数:4,代码来源:base58.cpp
注:本文中的IsValid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论