示例#1
0
        internal static bool MatchString(LimitChecker limitChecker, CultureInfo cultureInfo, string content, string pattern, ContentFlags flags)
        {
            if (!limitChecker.CheckAndIncrementContentRestrictionCount(1, content))
            {
                return(false);
            }
            CompareOptions compareOptions = RestrictionEvaluator.GetCompareOptions(flags);
            ContentFlags   contentFlags   = flags & (ContentFlags.SubString | ContentFlags.Prefix);
            CompareInfo    compareInfo    = cultureInfo.CompareInfo;

            switch (contentFlags)
            {
            case ContentFlags.FullString:
                return(compareInfo.Compare(content, pattern, compareOptions) == 0);

            case ContentFlags.SubString:
                return(compareInfo.IndexOf(content, pattern, compareOptions) != -1);

            case ContentFlags.Prefix:
                return(compareInfo.IsPrefix(content, pattern, compareOptions));

            default:
                throw new InvalidRuleException(string.Format("Not supported content flags {0}", flags));
            }
        }
        private void FileArtifactContentDecidedInternal(FileArtifactContentDecidedEventData data)
        {
            m_statistics.FileArtifactContentDecidedEventCount++;

            if (data.FileArtifact.IsOutputFile && data.FileContentInfo.HasKnownLength)
            {
                m_statistics.FileArtifactOutputWithKnownLengthCount++;

                ContentFlags contentFlags = default;
                switch (data.OutputOrigin)
                {
                case PipOutputOrigin.DeployedFromCache:
                    contentFlags = ContentFlags.MaterializedFromCache;
                    break;

                case PipOutputOrigin.Produced:
                    contentFlags = ContentFlags.Produced;
                    break;
                    // We ignore the following cases:
                    // PipOutputOrigin.NotMaterialized - we cannot infer the current or future materialization status of a file
                    // PipOutputOrigin.UpToDate - not relevant to this analyzer
                }

                UpdateOrAddFile(
                    data.FileArtifact,
                    data.FileContentInfo.Length,
                    contentFlags,
                    FromContentHash(data.FileContentInfo.Hash),
                    data.FileArtifact.RewriteCount);

                m_decidedFiles.Add(data.FileArtifact);
            }
        }
示例#3
0
 public override void SetContents(ContentFlags contents, int id = -1)
 {
     if (this.Disposed == true)
     {
         throw new ObjectDisposedException(this.GetType().Name);
     }
 }
示例#4
0
        public idClipModel(idClipModel model)
        {
            _id    = model.ID;
            _owner = model.Owner;

            _enabled = model.Enabled;
            _entity  = model.Entity;

            _origin    = model.Origin;
            _axis      = model.Axis;
            _bounds    = model.Bounds;
            _absBounds = model.AbsoluteBounds;

            _material             = model.Material;
            _contents             = model.Contents;
            _collisionModelHandle = model.CollisionModelHandle;
            _traceModelCache      = null;

            if (model.TraceModelCache != null)
            {
                idConsole.Warning("TODO: LoadModel( *GetCachedTraceModel( model->traceModelIndex ) );");
            }

            _renderModelHandle = model.RenderModelHandle;
            _touchCount        = -1;
        }
示例#5
0
        private ContentFlags GetNodeContents(CollisionModelNode node)
        {
            ContentFlags contents = 0;

            while (true)
            {
                foreach (CollisionModelPolygon p in node.Polygons)
                {
                    contents |= p.Contents;
                }

                foreach (CollisionModelBrush b in node.Brushes)
                {
                    contents |= b.Contents;
                }

                if (node.PlaneType == -1)
                {
                    break;
                }

                contents |= GetNodeContents(node.Children[1]);
                node      = node.Children[0];
            }

            return(contents);
        }
示例#6
0
 /// <summary>
 /// Construct a DirectoryEntry with an already-encoded partial seal field.
 /// </summary>
 public DirectoryEntry(NameId path, PipId producerPip, ContentFlags contentFlags, uint isSharedOpaquePlusPartialSealId)
 {
     Path         = path;
     ProducerPip  = producerPip;
     ContentFlags = contentFlags;
     IsSharedOpaquePlusPartialSealId = isSharedOpaquePlusPartialSealId;
 }
示例#7
0
 /// <summary>
 /// Construct a FileEntry.
 /// </summary>
 public FileEntry(NameId name, long sizeInBytes, PipId producerPip, ContentFlags contentFlags)
 {
     Path         = name;
     SizeInBytes  = sizeInBytes;
     ProducerPip  = producerPip;
     ContentFlags = contentFlags;
 }
示例#8
0
        public static IReadOnlyList <string> GeneratextMarkup(string content, string sessionId)
        {
            var flags = new ContentFlags();

            flags.SetMarkup();

            return(GeneratePlaintextInternal(content, sessionId, flags));
        }
示例#9
0
 /// <summary>
 /// Construct a FileEntry.
 /// </summary>
 public FileEntry(NameId name, long sizeInBytes, ContentFlags contentFlags, FileHash hash, int rewriteCount)
 {
     Path         = name;
     SizeInBytes  = sizeInBytes;
     ContentFlags = contentFlags;
     Hash         = hash;
     RewriteCount = rewriteCount;
 }
示例#10
0
        public override void SetClipMask(ContentFlags mask, int id = -1)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            _clipMask = mask;
        }
示例#11
0
        public RootHandler(BinaryReader stream)
        {
            while (stream.BaseStream.Position < stream.BaseStream.Length)
            {
                int count = stream.ReadInt32();

                ContentFlags contentFlags = (ContentFlags)stream.ReadUInt32();
                LocaleFlags  localeFlags  = (LocaleFlags)stream.ReadUInt32();

                if (localeFlags == LocaleFlags.None)
                {
                    throw new Exception("localeFlags == LocaleFlags.None");
                }

                if (contentFlags != ContentFlags.None && (contentFlags & (ContentFlags.F00000008 | ContentFlags.F00000010 | ContentFlags.LowViolence | ContentFlags.NoCompression | ContentFlags.F20000000)) == 0)
                {
                    throw new Exception("contentFlags != ContentFlags.None");
                }

                RootEntry[] entries       = new RootEntry[count];
                int[]       fileDataIDs   = new int[count];
                int         fileDataIndex = 0;

                for (var i = 0; i < count; ++i)
                {
                    entries[i].LocaleFlags  = localeFlags;
                    entries[i].ContentFlags = contentFlags;

                    fileDataIDs[i] = fileDataIndex + (int)stream.ReadUInt32();
                    fileDataIndex  = fileDataIDs[i] + 1;
                }

                for (var i = 0; i < count; ++i)
                {
                    entries[i].MD5 = stream.Read <MD5Hash>();
                    ulong hash = stream.ReadUInt64();

                    RootData.Add(hash, entries[i]);

                    ulong hash2;
                    int   fileDataID = fileDataIDs[i];

                    if (FileDataStore.TryGetValue(fileDataID, out hash2))
                    {
                        if (hash2 != hash)
                        {
                            Log.Write("CASC: Hash collision for file ID {0}", fileDataID);
                        }

                        continue;
                    }

                    FileDataStore.Add(fileDataID, hash);
                    FileDataStoreReverse.Add(hash, fileDataID);
                }
            }
        }
示例#12
0
        /// <summary>
        /// Construct a DirectoryEntry.
        /// </summary>
        public DirectoryEntry(NameId path, PipId producerPip, ContentFlags contentFlags, bool isSharedOpaque, uint partialSealId)
        {
            Contract.Requires(!isSharedOpaque || (partialSealId > 0), "A shared opaque directory should always have a proper seal id");
            Contract.Requires((partialSealId & ~PartialSealIdMask) == 0, "The most significant bit of a partial seal id should not be used");

            Path         = path;
            ProducerPip  = producerPip;
            ContentFlags = contentFlags;
            IsSharedOpaquePlusPartialSealId = partialSealId | (isSharedOpaque ? IsSharedOpaqueBit : 0);
        }
示例#13
0
 public override string ToString()
 {
     return(Name.ToString() + ", " +
            ParentName.ToString() + ", " +
            ContentFlags.ToString() + ", " +
            streamingExtentsMin.ToString() + ", " +
            streamingExtentsMax.ToString() + ", " +
            entitiesExtentsMin.ToString() + ", " +
            entitiesExtentsMax.ToString());// + ", " +
 }
示例#14
0
        public Stream OpenFile(ulong hash, string fullName, LocaleFlags locale, ContentFlags content = ContentFlags.None)
        {
            EncodingEntry encInfo = GetEncodingEntry(hash, locale, content);

            if (encInfo != null)
            {
                return(OpenFile(encInfo.Keys[0]));
            }

            throw new FileNotFoundException(fullName);
        }
示例#15
0
            /// <summary>
            /// Update or add an entry for the given file path.
            /// </summary>
            /// <remarks>
            /// If the entry already exists, its content flags will be merged with these, and the other file attributes
            /// will be updated to the values passed here.
            /// </remarks>
            public FileId UpdateOrAdd(string filePath, long sizeInBytes, ContentFlags contentFlags, FileHash hash, int rewriteCount)
            {
                FileEntry entry = new FileEntry(
                    PathTableBuilder.GetOrAdd(filePath),
                    sizeInBytes,
                    contentFlags,
                    hash,
                    rewriteCount);

                return(UpdateOrAdd(entry, m_mergeFunc));
            }
示例#16
0
        public override void SetContents(ContentFlags contents, int id = -1)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            if (_clipModel != null)
            {
                _clipModel.Contents = contents;
            }
        }
示例#17
0
 private static CompareOptions GetCompareOptions(ContentFlags flags)
 {
     if ((flags & (ContentFlags.IgnoreNonSpace | ContentFlags.Loose)) != ContentFlags.FullString)
     {
         return(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth);
     }
     if ((flags & (ContentFlags.IgnoreCase | ContentFlags.Loose)) != ContentFlags.FullString)
     {
         return(CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth);
     }
     return(CompareOptions.IgnoreWidth);
 }
示例#18
0
        public CASCFolder SetFlags(LocaleFlags locale, ContentFlags content, bool createTree = true)
        {
            Locale  = locale;
            Content = content;

            if (createTree)
            {
                Root = CreateStorageTree();
            }

            return(Root);
        }
示例#19
0
        public CASCFolder SetFlags(LocaleFlags locale, ContentFlags content, bool createTree = true)
        {
            using (var _ = new PerfCounter(GetType().Name + "::SetFlags()"))
            {
                Locale = locale;
                Content = content;

                if (createTree)
                    Root = CreateStorageTree();

                return Root;
            }
        }
示例#20
0
 public void WriteXml(StringBuilder sb, int indent)
 {
     CacheDatXml.StringTag(sb, indent, "name", CacheDatXml.HashString(Name));
     CacheDatXml.StringTag(sb, indent, "parent", CacheDatXml.HashString(ParentName));
     CacheDatXml.ValueTag(sb, indent, "contentFlags", ContentFlags.ToString());
     CacheDatXml.SelfClosingTag(sb, indent, "streamingExtentsMin " + FloatUtil.GetVector3XmlString(streamingExtentsMin));
     CacheDatXml.SelfClosingTag(sb, indent, "streamingExtentsMax " + FloatUtil.GetVector3XmlString(streamingExtentsMax));
     CacheDatXml.SelfClosingTag(sb, indent, "entitiesExtentsMin " + FloatUtil.GetVector3XmlString(entitiesExtentsMin));
     CacheDatXml.SelfClosingTag(sb, indent, "entitiesExtentsMax " + FloatUtil.GetVector3XmlString(entitiesExtentsMax));
     CacheDatXml.ValueTag(sb, indent, "unk1", Unk1.ToString());
     CacheDatXml.ValueTag(sb, indent, "unk2", Unk2.ToString());
     CacheDatXml.ValueTag(sb, indent, "unk3", Unk3.ToString());
     CacheDatXml.ValueTag(sb, indent, "unk4", Unk4.ToString());
 }
示例#21
0
        private void Init()
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException("idClipModel");
            }

            _enabled  = true;
            _contents = ContentFlags.Body;

            _renderModelHandle = -1;
            _traceModelCache   = null;
            _touchCount        = -1;
        }
示例#22
0
        public CASCFolder SetFlags(LocaleFlags locale, ContentFlags content, bool createTree = true)
        {
            using (var _ = new PerfCounter(GetType().Name + "::SetFlags()"))
            {
                Locale  = locale;
                Content = content;

                if (createTree)
                {
                    Root = CreateStorageTree();
                }

                return(Root);
            }
        }
        private bool IsBrushSolid(BspLoader bspLoader, int brushId)
        {
            BspBrush brush = bspLoader.Brushes[brushId];

            if (brush.ShaderNum == -1)
            {
                return(false);
            }

            ContentFlags flags = bspLoader.IsVbsp
                ? (ContentFlags)brush.ShaderNum
                : bspLoader.Shaders[brush.ShaderNum].ContentFlags;

            return((flags & ContentFlags.Solid) != 0);
        }
示例#24
0
        private static bool EvaluateContentRestriction(Restriction.ContentRestriction restriction, IRuleEvaluationContext context)
        {
            RestrictionEvaluator.ValidateContentRestriction(restriction);
            PropTag propTag = restriction.PropTag;

            if (restriction.MultiValued)
            {
                propTag = RuleUtil.GetMultiValuePropTag(propTag);
            }
            context.TraceFunction <PropTag, ContentFlags, object>("ContentRestriction tag [{0}] flags [{1}] value [{2}]", propTag, restriction.Flags, restriction.PropValue.Value);
            object obj = context[propTag];
            bool   flag;

            if (obj == null)
            {
                flag = false;
            }
            else if (restriction.MultiValued)
            {
                flag = RestrictionEvaluator.MatchMultiValueWithPattern(context, restriction.PropTag, obj, restriction.PropValue.Value, restriction.Flags);
            }
            else if (RuleUtil.IsTextProp(restriction.PropTag))
            {
                flag = RestrictionEvaluator.MatchString(context.LimitChecker, context.CultureInfo, (string)obj, (string)restriction.PropValue.Value, restriction.Flags);
            }
            else
            {
                if (!RuleUtil.IsBinaryProp(restriction.PropTag))
                {
                    throw new InvalidRuleException(string.Format("Content restriction can't be used on tag {0}", restriction.PropTag));
                }
                flag = RestrictionEvaluator.MatchByteArray(context.LimitChecker, (byte[])obj, (byte[])restriction.PropValue.Value, restriction.Flags);
            }
            context.TraceFunction <bool, object>("ContentRestriction Evaluated to {0} with property value [{1}]", flag, obj);
            if (!flag && propTag == PropTag.SenderSearchKey)
            {
                object obj2 = context[PropTag.SenderSmtpAddress];
                if (obj2 != null)
                {
                    string       @string      = CTSGlobals.AsciiEncoding.GetString((byte[])restriction.PropValue.Value);
                    ContentFlags contentFlags = ContentFlags.SubString | ContentFlags.IgnoreCase;
                    context.TraceFunction("No match found in SenderSearchKey, searching for string in SenderSmtpAddress...");
                    context.TraceFunction <PropTag, ContentFlags, string>("ContentRestriction tag [{0}] flags [{1}] value [{2}]", PropTag.SenderSmtpAddress, contentFlags, @string);
                    flag = RestrictionEvaluator.MatchString(context.LimitChecker, context.CultureInfo, (string)obj2, @string, contentFlags);
                }
            }
            return(flag);
        }
示例#25
0
            /// <summary>
            /// Get or add an entry for the given file path.
            /// </summary>
            /// <remarks>
            /// If the entry already exists, the sizeInBytes value passed here will be ignored!
            /// The only time that value can be set is when adding a new file not previously recorded.
            /// TODO: consider failing if this happens?
            /// </remarks>
            public DirectoryId GetOrAdd(
                string directoryPath,
                PipId producerPip,
                ContentFlags contentFlags,
                bool isSharedOpaque,
                uint partialSealId)
            {
                DirectoryEntry entry = new DirectoryEntry(
                    PathTableBuilder.GetOrAdd(directoryPath),
                    producerPip,
                    contentFlags,
                    isSharedOpaque,
                    partialSealId);

                return(GetOrAdd(entry));
            }
示例#26
0
        protected void GetMatchFlagsAndOptions(ContentFlags contentFlags, out MatchFlags matchFlags, out MatchOptions matchOptions)
        {
            ContentFlags contentFlags2 = contentFlags & (ContentFlags)51;

            switch (contentFlags2)
            {
            case ContentFlags.SubString:
                matchOptions = MatchOptions.SubString;
                break;

            case ContentFlags.Prefix:
                matchOptions = MatchOptions.Prefix;
                break;

            default:
                if (contentFlags2 != ContentFlags.PrefixOnWords)
                {
                    if (contentFlags2 != ContentFlags.ExactPhrase)
                    {
                        matchOptions = MatchOptions.FullString;
                    }
                    else
                    {
                        matchOptions = MatchOptions.ExactPhrase;
                    }
                }
                else
                {
                    matchOptions = MatchOptions.PrefixOnWords;
                }
                break;
            }
            matchFlags = MatchFlags.Default;
            if ((contentFlags & ContentFlags.IgnoreCase) != ContentFlags.FullString)
            {
                matchFlags |= MatchFlags.IgnoreCase;
            }
            if ((contentFlags & ContentFlags.IgnoreNonSpace) != ContentFlags.FullString)
            {
                matchFlags |= MatchFlags.IgnoreNonSpace;
            }
            if ((contentFlags & ContentFlags.Loose) != ContentFlags.FullString)
            {
                matchFlags |= MatchFlags.Loose;
            }
        }
示例#27
0
        private EncodingEntry GetEncodingEntryOld(ulong hash, LocaleFlags locale, ContentFlags content)
        {
            var rootInfos = RootHandler.GetRootInfo(hash);

            foreach (var rootInfo in rootInfos)
            {
                if ((rootInfo.Block.LocaleFlags & locale) != 0 && (rootInfo.Block.ContentFlags & content) == 0)
                {
                    var encInfo = EncodingHandler.GetEncodingInfo(rootInfo.MD5);

                    if (encInfo != null)
                    {
                        return(encInfo);
                    }
                }
            }

            return(null);
        }
示例#28
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        /// an ent will be excluded from testing if:
        /// cm->entity == passEntity (don't clip against the pass entity)
        /// cm->entity == passOwner (missiles don't clip with owner)
        /// cm->owner == passEntity (don't interact with your own missiles)
        /// cm->owner == passOwner (don't interact with other missiles from same owner)
        /// </remarks>
        /// <param name="bounds"></param>
        /// <param name="contentMask"></param>
        /// <param name="passEntity"></param>
        /// <returns></returns>
        private idClipModel[] GetTraceClipModels(idBounds bounds, ContentFlags contentMask, idEntity passEntity)
        {
            idConsole.Warning("TODO: idClip.GetTraceClipModels");
            // TODO

            /*int i, num;
            *  idClipModel	*cm;
            *  idEntity *passOwner;
            *
            *  num = ClipModelsTouchingBounds( bounds, contentMask, clipModelList, MAX_GENTITIES );
            *
            *  if ( !passEntity ) {
            *       return num;
            *  }
            *
            *  if ( passEntity->GetPhysics()->GetNumClipModels() > 0 ) {
            *       passOwner = passEntity->GetPhysics()->GetClipModel()->GetOwner();
            *  } else {
            *       passOwner = NULL;
            *  }
            *
            *  for ( i = 0; i < num; i++ ) {
            *
            *       cm = clipModelList[i];
            *
            *       // check if we should ignore this entity
            *       if ( cm->entity == passEntity ) {
            *               clipModelList[i] = NULL;			// don't clip against the pass entity
            *       } else if ( cm->entity == passOwner ) {
            *               clipModelList[i] = NULL;			// missiles don't clip with their owner
            *       } else if ( cm->owner ) {
            *               if ( cm->owner == passEntity ) {
            *                       clipModelList[i] = NULL;		// don't clip against own missiles
            *               } else if ( cm->owner == passOwner ) {
            *                       clipModelList[i] = NULL;		// don't clip against other missiles from same owner
            *               }
            *       }
            *  }
            *
            *  return num;*/

            return(null);
        }
示例#29
0
        private EncodingEntry GetEncodingEntry(ulong hash, LocaleFlags locale, ContentFlags content)
        {
            var rootInfos = RootHandler.GetRootInfo(hash);

            var rootInfosLocale = rootInfos.Where(re => (re.Block.LocaleFlags & locale) != 0);

            if (rootInfosLocale.Count() > 1)
            {
                if (content != ContentFlags.None)
                {
                    var rootInfosLocaleAndContent = rootInfosLocale.Where(re => (re.Block.ContentFlags & content) == 0);

                    if (rootInfosLocaleAndContent.Any())
                    {
                        rootInfosLocale = rootInfosLocaleAndContent;
                    }
                }
            }

            return(EncodingHandler.GetEncodingInfo(rootInfosLocale.First().MD5));
        }
示例#30
0
        private ContentFlags ContentsFromString(string str)
        {
            idLexer lexer = new idLexer();

            lexer.LoadMemory(str, "ContentsFromString");

            idToken      token;
            ContentFlags contents = ContentFlags.None;
            string       tmp;

            while ((token = lexer.ReadToken()) != null)
            {
                if (token.ToString() == ",")
                {
                    continue;
                }

                tmp = token.ToString();

                switch (tmp)
                {
                case "aas_solid":
                    tmp = "AasSolid";
                    break;

                case "aas_obstacle":
                    tmp = "AasObstacle";
                    break;

                case "flashlight_trigger":
                    tmp = "FlashlightTrigger";
                    break;
                }

                contents |= (ContentFlags)Enum.Parse(typeof(ContentFlags), tmp, true);
            }

            return(contents);
        }
示例#31
0
		public override void SetContents(ContentFlags contents, int id = -1)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			_clipModel.Contents = contents;
		}
示例#32
0
		public idClipModel(idClipModel model)
		{
			_id = model.ID;
			_owner = model.Owner;
			
			_enabled = model.Enabled;
			_entity = model.Entity;

			_origin = model.Origin;
			_axis = model.Axis;
			_bounds = model.Bounds;
			_absBounds = model.AbsoluteBounds;

			_material = model.Material;
			_contents = model.Contents;
			_collisionModelHandle = model.CollisionModelHandle;
			_traceModelCache = null;

			if(model.TraceModelCache != null)
			{
				idConsole.Warning("TODO: LoadModel( *GetCachedTraceModel( model->traceModelIndex ) );");
			}

			_renderModelHandle = model.RenderModelHandle;
			_touchCount = -1;
		}
示例#33
0
        public CASCFolder SetFlags(LocaleFlags locale, ContentFlags content, bool createTree = true)
        {
            Locale = locale;
            Content = content;

            if (createTree)
                Root = CreateStorageTree();

            return Root;
        }
示例#34
0
		/// <summary>
		/// Set the contents of a specific clip model or the whole physics object.
		/// </summary>
		/// <param name="contents"></param>
		/// <param name="id"></param>
		public abstract void SetContents(ContentFlags contents, int id = -1);
示例#35
0
		/// <summary>
		/// Parses the material, if there are any errors during parsing the defaultShader will be set.
		/// </summary>
		/// <param name="lexer"></param>
		private void ParseMaterial(idLexer lexer)
		{
			_registerCount = PredefinedRegisterCount; // leave space for the parms to be copied in.

			for(int i = 0; i < _registerCount; i++)
			{
				_parsingData.RegisterIsTemporary[i] = true; // they aren't constants that can be folded.
			}

			TextureRepeat textureRepeatDefault = TextureRepeat.Repeat; // allow a global setting for repeat.
			idToken token = null;

			string tokenValue;
			string tokenLower;
			int count;

			while(true)
			{
				if(TestMaterialFlag(Renderer.MaterialFlags.Defaulted) == true)
				{
					// we have a parse error.
					return;
				}

				if((token = lexer.ExpectAnyToken()) == null)
				{
					this.MaterialFlag = MaterialFlags.Defaulted;
					return;
				}

				tokenValue = token.ToString();
				tokenLower = tokenValue.ToLower();

				// end of material definition
				if(tokenLower == "}")
				{
					break;
				}
				else if(tokenLower == "qer_editorimage")
				{
					token = lexer.ReadTokenOnLine();
					_editorImageName = (token != null) ? token.ToString() : string.Empty;

					lexer.SkipRestOfLine();
				}
				else if(tokenLower == "description")
				{
					token = lexer.ReadTokenOnLine();
					_description = (token != null) ? token.ToString() : string.Empty;
				}
				// check for the surface / content bit flags.
				else if(CheckSurfaceParameter(token) == true)
				{

				}
				else if(tokenLower == "polygonoffset")
				{
					this.MaterialFlag = Renderer.MaterialFlags.PolygonOffset;

					if((token = lexer.ReadTokenOnLine()) == null)
					{
						_polygonOffset = 1;
					}
					else
					{
						_polygonOffset = token.ToFloat();
					}
				}
				// noshadow.
				else if(tokenLower == "noshadows")
				{
					this.MaterialFlag = MaterialFlags.NoShadows;
				}
				else if(tokenLower == "suppressinsubview")
				{
					_suppressInSubview = true;
				}
				else if(tokenLower == "portalsky")
				{
					_portalSky = true;
				}
				else if(tokenLower == "noselfshadow")
				{
					this.MaterialFlag = Renderer.MaterialFlags.NoSelfShadow;
				}
				else if(tokenLower == "noportalfog")
				{
					this.MaterialFlag = Renderer.MaterialFlags.NoPortalFog;
				}
				// forceShadows allows nodraw surfaces to cast shadows.
				else if(tokenLower == "forceshadows")
				{
					this.MaterialFlag = Renderer.MaterialFlags.ForceShadows;
				}
				// overlay / decal suppression.
				else if(tokenLower == "nooverlays")
				{
					_allowOverlays = false;
				}
				// moster blood overlay forcing for alpha tested or translucent surfaces.
				else if(tokenLower == "forceoverlays")
				{
					_parsingData.ForceOverlays = true;
				}
				else if(tokenLower == "translucent")
				{
					_coverage = MaterialCoverage.Translucent;
				}
				// global zero clamp.
				else if(tokenLower == "zeroclamp")
				{
					textureRepeatDefault = TextureRepeat.ClampToZero;
				}
				// global clamp.
				else if(tokenLower == "clamp")
				{
					textureRepeatDefault = TextureRepeat.Clamp;
				}
				// global clamp.
				else if(tokenLower == "alphazeroclamp")
				{
					textureRepeatDefault = TextureRepeat.ClampToZero;
				}
				// forceOpaque is used for skies-behind-windows.
				else if(tokenLower == "forceopaque")
				{
					_coverage = MaterialCoverage.Opaque;
				}
				else if(tokenLower == "twosided")
				{
					_cullType = CullType.TwoSided;

					// twoSided implies no-shadows, because the shadow
					// volume would be coplanar with the surface, giving depth fighting
					// we could make this no-self-shadows, but it may be more important
					// to receive shadows from no-self-shadow monsters.
					this.MaterialFlag = Renderer.MaterialFlags.NoShadows;
				}
				else if(tokenLower == "backsided")
				{
					_cullType = CullType.Back;

					// the shadow code doesn't handle this, so just disable shadows.
					// We could fix this in the future if there was a need.
					this.MaterialFlag = Renderer.MaterialFlags.NoShadows;
				}
				else if(tokenLower == "foglight")
				{
					_fogLight = true;
				}
				else if(tokenLower == "blendlight")
				{
					_blendLight = true;
				}
				else if(tokenLower == "ambientlight")
				{
					_ambientLight = true;
				}
				else if(tokenLower == "mirror")
				{
					_sort = (float) MaterialSort.Subview;
					_coverage = MaterialCoverage.Opaque;
				}
				else if(tokenLower == "nofog")
				{
					_noFog = true;
				}
				else if(tokenLower == "unsmoothedtangents")
				{
					_unsmoothedTangents = true;
				}
				// lightFallofImage <imageprogram>
				// specifies the image to use for the third axis of projected
				// light volumes.
				else if(tokenLower == "lightfalloffimage")
				{
					_lightFalloffImage = idE.ImageManager.ImageFromFile(ParsePastImageProgram(lexer), TextureFilter.Default, false, TextureRepeat.Clamp, TextureDepth.Default);
				}
				// guisurf <guifile> | guisurf entity
				// an entity guisurf must have an idUserInterface
				// specified in the renderEntity.
				else if(tokenLower == "guisurf")
				{
					token = lexer.ReadTokenOnLine();
					tokenLower = token.ToString().ToLower();

					if(tokenLower == "entity")
					{
						_entityGui = 1;
					}
					else if(tokenLower == "entity2")
					{
						_entityGui = 2;
					}
					else if(tokenLower == "entity3")
					{
						_entityGui = 3;
					}
					else
					{
						_userInterface = idE.UIManager.FindInterface(token.ToString(), true);
					}
				}
				// sort.
				else if(tokenLower == "sort")
				{
					ParseSort(lexer);
				}
				// spectrum <integer>.
				else if(tokenLower == "spectrum")
				{
					int.TryParse(lexer.ReadTokenOnLine().ToString(), out _spectrum);
				}
				// deform < sprite | tube | flare >.
				else if(tokenLower == "deform")
				{
					ParseDeform(lexer);
				}
				// decalInfo <staySeconds> <fadeSeconds> (<start rgb>) (<end rgb>).
				else if(tokenLower == "decalinfo")
				{
					ParseDecalInfo(lexer);
				}
				// renderbump <args...>.
				else if(tokenLower == "renderbump")
				{
					_renderBump = lexer.ParseRestOfLine();
				}
				// diffusemap for stage shortcut.
				else if(tokenLower == "diffusemap")
				{
					idLexer newLexer = new idLexer(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.NoStringEscapeCharacters | LexerOptions.AllowPathNames);
					newLexer.LoadMemory(string.Format("blend diffusemap\nmap {0}\n}}\n", ParsePastImageProgram(lexer)), "diffusemap");

					ParseStage(newLexer, textureRepeatDefault);
				}
				// specularmap for stage shortcut.
				else if(tokenLower == "specularmap")
				{
					idLexer newLexer = new idLexer(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.NoStringEscapeCharacters | LexerOptions.AllowPathNames);
					newLexer.LoadMemory(string.Format("blend specularmap\nmap {0}\n}}\n", ParsePastImageProgram(lexer)), "specularmap");

					ParseStage(newLexer, textureRepeatDefault);
				}
				// normalmap for stage shortcut.
				else if(tokenLower == "bumpmap")
				{
					idLexer newLexer = new idLexer(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.NoStringEscapeCharacters | LexerOptions.AllowPathNames);
					newLexer.LoadMemory(string.Format("blend bumpmap\nmap {0}\n}}\n", ParsePastImageProgram(lexer)), "bumpmap");

					ParseStage(newLexer, textureRepeatDefault);
				}
				// DECAL_MACRO for backwards compatibility with the preprocessor macros.
				else if(tokenLower == "decal_macro")
				{
					// polygonOffset
					this.MaterialFlag = Renderer.MaterialFlags.PolygonOffset;
					_polygonOffset = -1;

					// discrete
					_surfaceFlags |= SurfaceFlags.Discrete;
					_contentFlags &= ~ContentFlags.Solid;

					// sort decal.
					_sort = (float) MaterialSort.Decal;

					// noShadows
					this.MaterialFlag = Renderer.MaterialFlags.NoShadows;
				}
				else if(tokenValue == "{")
				{
					// create the new stage.
					ParseStage(lexer, textureRepeatDefault);
				}
				else
				{
					idConsole.WriteLine("unknown general material parameter '{0}' in '{1}'", tokenValue, this.Name);
					return;
				}
			}

			// add _flat or _white stages if needed.
			AddImplicitStages();

			// order the diffuse / bump / specular stages properly.
			SortInteractionStages();

			// if we need to do anything with normals (lighting or environment mapping)
			// and two sided lighting was asked for, flag
			// shouldCreateBackSides() and change culling back to single sided,
			// so we get proper tangent vectors on both sides.

			// we can't just call ReceivesLighting(), because the stages are still
			// in temporary form.
			if(_cullType == CullType.TwoSided)
			{
				count = _parsingData.Stages.Count;

				for(int i = 0; i < count; i++)
				{
					if((_parsingData.Stages[i].Lighting != StageLighting.Ambient) || (_parsingData.Stages[i].Texture.TextureCoordinates != TextureCoordinateGeneration.Explicit))
					{
						if(_cullType == CullType.TwoSided)
						{
							_cullType = CullType.Front;
							_shouldCreateBackSides = true;
						}

						break;
					}
				}
			}

			// currently a surface can only have one unique texgen for all the stages on old hardware.
			TextureCoordinateGeneration firstGen = TextureCoordinateGeneration.Explicit;

			count = _parsingData.Stages.Count;

			for(int i = 0; i < count; i++)
			{
				if(_parsingData.Stages[i].Texture.TextureCoordinates != TextureCoordinateGeneration.Explicit)
				{
					if(firstGen == TextureCoordinateGeneration.Explicit)
					{
						firstGen = _parsingData.Stages[i].Texture.TextureCoordinates;
					}
					else if(firstGen != _parsingData.Stages[i].Texture.TextureCoordinates)
					{
						idConsole.Warning("material '{0}' has multiple stages with a texgen", this.Name);
						break;
					}
				}
			}
		}
示例#36
0
		private void Clear()
		{
			_description = "<none>";
			_renderBump = string.Empty;

			_contentFlags = ContentFlags.Solid;
			_surfaceFlags = SurfaceFlags.None;
			_materialFlags = 0;

			_sort = (float) MaterialSort.Bad;
			_coverage = MaterialCoverage.Bad;
			_cullType = CullType.Front;

			_deformType = DeformType.None;
			_deformRegisters = new int[4];

			_ops = null;
			_expressionRegisters = null;
			_constantRegisters = null;
			_stages = new MaterialStage[] { };

			_stageCount = 0;
			_ambientStageCount = 0;
			_registerCount = 0;
			
			_lightFalloffImage = null;
			_entityGui = 0;
			_shouldCreateBackSides = false;
			_editorImageName = null;

			_fogLight = false;
			_blendLight = false;
			_ambientLight = false;
			_noFog = false;
			_hasSubview = false;
			_allowOverlays = true;
			_unsmoothedTangents = false;

			_userInterface = null;
			_referenceCount = 0;
			
			/*editorAlpha = 1.0;*/
			_spectrum = 0;

			_polygonOffset = 0;
			_suppressInSubview = false;
			_portalSky = false;

			_decalInfo.StayTime = 10000;
			_decalInfo.FadeTime = 4000;
			_decalInfo.Start = new float[] { 1, 1, 1, 1 };
			_decalInfo.End = new float[] { 0, 0, 0, 0 };
		}
示例#37
0
		public MaterialInfoParameter(string name, bool clearSolid, SurfaceFlags surfaceFlags, ContentFlags contentFlags)
		{
			Name = name;
			ClearSolid = clearSolid;
			SurfaceFlags = surfaceFlags;
			ContentFlags = contentFlags;
		}
示例#38
0
		public override void SetClipMask(ContentFlags mask, int id = -1)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			_clipMask = mask;
		}
示例#39
0
		bool HasContent (ContentFlags cf)
		{
			return (entry.ContentFlags & cf) == cf && WrappedType != null;
		}
示例#40
0
		/// <summary>
		/// 
		/// </summary>
		/// <remarks>
		/// an ent will be excluded from testing if:
		/// cm->entity == passEntity (don't clip against the pass entity)
		/// cm->entity == passOwner (missiles don't clip with owner)
		/// cm->owner == passEntity (don't interact with your own missiles)
		/// cm->owner == passOwner (don't interact with other missiles from same owner)
		/// </remarks>
		/// <param name="bounds"></param>
		/// <param name="contentMask"></param>
		/// <param name="passEntity"></param>
		/// <returns></returns>
		private idClipModel[] GetTraceClipModels(idBounds bounds, ContentFlags contentMask, idEntity passEntity)
		{
			idConsole.Warning("TODO: idClip.GetTraceClipModels");
			// TODO
			/*int i, num;
			idClipModel	*cm;
			idEntity *passOwner;

			num = ClipModelsTouchingBounds( bounds, contentMask, clipModelList, MAX_GENTITIES );

			if ( !passEntity ) {
				return num;
			}

			if ( passEntity->GetPhysics()->GetNumClipModels() > 0 ) {
				passOwner = passEntity->GetPhysics()->GetClipModel()->GetOwner();
			} else {
				passOwner = NULL;
			}

			for ( i = 0; i < num; i++ ) {

				cm = clipModelList[i];

				// check if we should ignore this entity
				if ( cm->entity == passEntity ) {
					clipModelList[i] = NULL;			// don't clip against the pass entity
				} else if ( cm->entity == passOwner ) {
					clipModelList[i] = NULL;			// missiles don't clip with their owner
				} else if ( cm->owner ) {
					if ( cm->owner == passEntity ) {
						clipModelList[i] = NULL;		// don't clip against own missiles
					} else if ( cm->owner == passOwner ) {
						clipModelList[i] = NULL;		// don't clip against other missiles from same owner
					}
				}
			}

			return num;*/

			return null;
		}
示例#41
0
		/// <summary>
		/// See if the current token matches one of the surface parameter bit flags.
		/// </summary>
		/// <param name="token"></param>
		/// <returns></returns>
		private bool CheckSurfaceParameter(idToken token)
		{
			string tokenLower = token.ToString().ToLower();

			foreach(MaterialInfoParameter infoParameter in InfoParameters)
			{
				if(tokenLower == infoParameter.Name)
				{
					if((infoParameter.SurfaceFlags & Renderer.SurfaceFlags.TypeMask) == Renderer.SurfaceFlags.TypeMask)
					{
						// ensure we only have one surface type set
						_surfaceFlags &= ~SurfaceFlags.TypeMask;
					}

					_surfaceFlags |= infoParameter.SurfaceFlags;
					_contentFlags |= infoParameter.ContentFlags;

					if(infoParameter.ClearSolid == true)
					{
						_contentFlags &= ~ContentFlags.Solid;
					}

					return true;
				}
			}

			return false;
		}
示例#42
0
		/// <summary>
		/// Set the contents a specific clip model or the whole physics object collides with.
		/// </summary>
		/// <param name="mask"></param>
		/// <param name="id"></param>
		public abstract void SetClipMask(ContentFlags mask, int id = -1);
示例#43
0
		/// <summary>
		/// Parses the current material definition and finds all necessary images.
		/// </summary>
		/// <param name="text"></param>
		/// <returns></returns>
		public override bool Parse(string text)
		{
			idLexer lexer = new idLexer(idDeclFile.LexerOptions);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			// reset to the unparsed state.
			Clear();

			_parsingData = new MaterialParsingData(); // this is only valid during parsing.

			// parse it
			ParseMaterial(lexer);

			// TODO: fs_copyFiles
			// if we are doing an fs_copyfiles, also reference the editorImage
			/*if ( cvarSystem->GetCVarInteger( "fs_copyFiles" ) ) {
				GetEditorImage();
			}*/

			// count non-lit stages.
			_ambientStageCount = 0;
			_stageCount = _parsingData.Stages.Count;

			for(int i = 0; i < _stageCount; i++)
			{
				if(_parsingData.Stages[i].Lighting == StageLighting.Ambient)
				{
					_ambientStageCount++;
				}
			}

			// see if there is a subview stage
			if(_sort == (float) MaterialSort.Subview)
			{
				_hasSubview = true;
			}
			else
			{
				_hasSubview = false;
				int count = _parsingData.Stages.Count;

				for(int i = 0; i < count; i++)
				{
					if(_parsingData.Stages[i].Texture.Dynamic != null)
					{
						_hasSubview = true;
					}
				}
			}

			// automatically determine coverage if not explicitly set.
			if(_coverage == MaterialCoverage.Bad)
			{
				// automatically set MC_TRANSLUCENT if we don't have any interaction stages and 
				// the first stage is blended and not an alpha test mask or a subview.
				if(_stageCount == 0)
				{
					// non-visible.
					_coverage = MaterialCoverage.Translucent;
				}
				else if(_stageCount != _ambientStageCount)
				{
					// we have an interaction draw.
					_coverage = MaterialCoverage.Opaque;
				}
				else
				{
					MaterialStates drawStateBits = _parsingData.Stages[0].DrawStateBits & MaterialStates.SourceBlendBits;

					if(((drawStateBits & MaterialStates.DestinationBlendBits) != MaterialStates.DestinationBlendZero)
						|| (drawStateBits == MaterialStates.SourceBlendDestinationColor)
						|| (drawStateBits == MaterialStates.SourceBlendOneMinusDestinationColor)
						|| (drawStateBits == MaterialStates.SourceBlendDestinationAlpha)
						|| (drawStateBits == MaterialStates.SourceBlendOneMinusDestinationAlpha))
					{
						// blended with the destination
						_coverage = MaterialCoverage.Translucent;
					}
					else
					{
						_coverage = MaterialCoverage.Opaque;
					}
				}
			}

			// translucent automatically implies noshadows.
			if(_coverage == MaterialCoverage.Translucent)
			{
				this.MaterialFlag = MaterialFlags.NoShadows;
			}
			else
			{
				// mark the contents as opaque.
				_contentFlags |= ContentFlags.Opaque;
			}

			// the sorts can make reasonable defaults.
			if(_sort == (float) MaterialSort.Bad)
			{
				if(TestMaterialFlag(MaterialFlags.PolygonOffset) == true)
				{
					_sort = (float) MaterialSort.Decal;
				}
				else if(_coverage == MaterialCoverage.Translucent)
				{
					_sort = (float) MaterialSort.Medium;
				}
				else
				{
					_sort = (float) MaterialSort.Opaque;
				}
			}

			// anything that references _currentRender will automatically get sort = SS_POST_PROCESS
			// and coverage = MC_TRANSLUCENT.
			for(int i = 0; i < _stageCount; i++)
			{
				MaterialStage stage = _parsingData.Stages[i];

				if(stage.Texture.Image == idE.ImageManager.CurrentRenderImage)
				{
					if(_sort != (float) MaterialSort.PortalSky)
					{
						_sort = (float) MaterialSort.PostProcess;
						_coverage = MaterialCoverage.Translucent;
					}

					break;
				}

				if(stage.NewStage.IsEmpty == false)
				{
					NewMaterialStage newShaderStage = stage.NewStage;
					int imageCount = newShaderStage.FragmentProgramImages.Length;

					for(int j = 0; j < imageCount; j++)
					{
						if(newShaderStage.FragmentProgramImages[j] == idE.ImageManager.CurrentRenderImage)
						{
							if(_sort != (float) MaterialSort.PortalSky)
							{
								_sort = (float) MaterialSort.PostProcess;
								_coverage = MaterialCoverage.Translucent;
							}

							i = _stageCount;
							break;
						}
					}
				}
			}

			// set the drawStateBits depth flags.
			for(int i = 0; i < _stageCount; i++)
			{
				MaterialStage stage = _parsingData.Stages[i];

				if(_sort == (float) MaterialSort.PostProcess)
				{
					// post-process effects fill the depth buffer as they draw, so only the
					// topmost post-process effect is rendered.
					stage.DrawStateBits |= MaterialStates.DepthFunctionLess;
				}
				else if((_coverage == MaterialCoverage.Translucent) || (stage.IgnoreAlphaTest == true))
				{
					// translucent surfaces can extend past the exactly marked depth buffer.
					stage.DrawStateBits |= MaterialStates.DepthFunctionLess | MaterialStates.DepthMask;
				}
				else
				{
					// opaque and perforated surfaces must exactly match the depth buffer,
					// which gets alpha test correct.
					stage.DrawStateBits |= MaterialStates.DepthFunctionEqual | MaterialStates.DepthMask;
				}

				_parsingData.Stages[i] = stage;
			}

			// determine if this surface will accept overlays / decals.
			if(_parsingData.ForceOverlays == true)
			{
				// explicitly flaged in material definition
				_allowOverlays = true;
			}
			else
			{
				if(this.IsDrawn == false)
				{
					_allowOverlays = false;
				}

				if(this.Coverage != MaterialCoverage.Opaque)
				{
					_allowOverlays = false;
				}

				if((this.SurfaceFlags & Renderer.SurfaceFlags.NoImpact) == Renderer.SurfaceFlags.NoImpact)
				{
					_allowOverlays = false;
				}
			}

			// add a tiny offset to the sort orders, so that different materials
			// that have the same sort value will at least sort consistantly, instead
			// of flickering back and forth.

			/* this messed up in-game guis
			if ( sort != SS_SUBVIEW ) {
				int	hash, l;

				l = name.Length();
				hash = 0;
				for ( int i = 0 ; i < l ; i++ ) {
					hash ^= name[i];
				}
				sort += hash * 0.01;
			}
			*/

			if(_stageCount > 0)
			{
				_stages = _parsingData.Stages.ToArray();
			}

			if(_parsingData.Operations.Count > 0)
			{
				_ops = _parsingData.Operations.ToArray();
			}

			if(_registerCount > 0)
			{
				_expressionRegisters = new float[_registerCount];

				Array.Copy(_parsingData.ShaderRegisters, _expressionRegisters, _registerCount);
			}

			// see if the registers are completely constant, and don't need to be evaluated per-surface.
			CheckForConstantRegisters();

			_parsingData = null;

			// finish things up
			if(TestMaterialFlag(MaterialFlags.Defaulted) == true)
			{
				MakeDefault();
				return false;
			}

			return true;
		}
示例#44
0
		public ContentFlags ContentsModel(Vector3 start, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, object modelHandle, Vector3 modelOrigin, Matrix modelAxis)
		{
			idConsole.Warning("TODO: idClip.ContentsModel");
			_contentCount++;

			// TODO: NEED ENGINE SOURCE return idR.CollisionModelManager.Contents(start, TraceModelForClipModel(model), traceModelAxis, contentMask, modelHandle, modelOrigin, modelAxis);
			return ContentFlags.None;
		}
示例#45
0
		private void Init()
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException("idClipModel");
			}

			_enabled = true;
			_contents = ContentFlags.Body;

			_renderModelHandle = -1;
			_traceModelCache = null;
			_touchCount = -1;
		}		
示例#46
0
		public bool Translation(out TraceResult result, Vector3 start, Vector3 end, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, idEntity passEntity)
		{
			idConsole.Warning("TODO: idClip.Translation");
			// TODO
			/*if(TestHugeTranslation(result, model, start, end, traceModelAxis) == true)
			{
				return true;
			}*/

			// TODO
			/*idTraceModel traceModel = TraceModelForClipModel(model);
			idBounds traceBounds = new idBounds();
			TraceResult traceResult;
			float radius = 0;

			if((passEntity == null) || (passEntity.Index != idR.EntityIndexWorld))
			{
				// test world
				_translationCount++;

				// TODO: idR.CollisionModelManager.Translation(out result, start, end, traceModel, traceModelAxis, contentMask, 0, Vector3.Zero, Matrix.Identity);
				result.ContactInformation.EntityIndex = (result.Fraction != 1.0f) ? idR.EntityIndexWorld : idR.EntityIndexNone;

				if(result.Fraction == 0.0f)
				{
					return true; // blocked immediately by the world
				}
			}
			else
			{
				result = new TraceResult();
				result.Fraction = 1.0f;
				result.EndPosition = end;
				result.EndAxis = traceModelAxis;
			}

			if(traceModel == null)
			{
				traceBounds = idBounds.FromPointTranslation(start, result.EndPosition - start);
				radius = 0.0f;
			}
			else
			{
				traceBounds = idBounds.FromBoundsTranslation(traceModel.Bounds, start, traceModelAxis, result.EndPosition - start);
				radius = traceModel.Bounds.GetRadius();
			}

			idClipModel[] clipModelList = GetTraceClipModels(traceBounds, contentMask, passEntity);

			foreach(idClipModel touch in clipModelList)
			{
				if(touch == null)
				{
					continue;
				}

				if(touch.RenderModelHandle != -1)
				{
					_renderModelTraceCount++;
					traceResult = TraceRenderModel(start, end, radius, traceModelAxis, touch);
				}
				else
				{
					_translationCount++;
					// TODO: traceResult = idR.CollisionModelManager.Translation(start, end, traceModel, traceModelAxis, contentMask, touch.Handle, touch.Origin, touch.Axis);
				}

				if(traceResult.Fraction < result.Fraction)
				{
					result = traceResult;
					result.ContactInformation.EntityIndex = touch.Entity.Index;
					result.ContactInformation.ID = touch.ID;

					if(result.Fraction == 0.0f)
					{
						break;
					}
				}
			}

			return (result.Fraction < 1.0f);*/
			result = new TraceResult();
			return false;
		}
示例#47
0
		public TraceResult RotationModel(Vector3 start, idRotation rotation, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, int modelHandle, Vector3 modelOrigin, Matrix modelAxis)
		{
			idConsole.Warning("TODO: idClip.RotationModel");
			// TODO: idTraceModel traceModel = TraceModelForClipModel(model);

			_rotationCount++;

			// TODO: return idR.CollisionModelManager.Rotation(start, rotation, traceModel, traceModelAxis, contentMask, modelHandle, modelOrigin, modelAxis);
			return new TraceResult();
		}
		void UpdateContent (IType cls)
		{
			Name = cls.Name; 
			ctype = cls.ClassType;
			modifiers = cls.Modifiers;
			typeModifier = cls.TypeModifier;
			this.typeParameterCount = cls.TypeParameters.Count;
			flags = (ContentFlags) 0;
			if (this.typeParameterCount > 0)
				flags |= ContentFlags.HasGenericParams;
			if (cls.Attributes.Count () > 0)
				flags |= ContentFlags.HasAttributes;
			if ((cls.BaseType != null && !cls.BaseType.ToInvariantString ().Equals (DomReturnType.Object.ToInvariantString ())) || cls.ImplementedInterfaces.Count () > 0)
				flags |= ContentFlags.HasBaseTypes;
			if (cls.CompilationUnit != null)
				flags |= ContentFlags.HasCompilationUnit;
				
			if (cls.Documentation != null && cls.Documentation.Length > 0)
				flags |= ContentFlags.HasDocumentation;
			if (cls.EventCount > 0)
				flags |= ContentFlags.HasEvents;
			if (cls.FieldCount > 0)
				flags |= ContentFlags.HasFields;
			if (cls.IndexerCount > 0)
				flags |= ContentFlags.HasIndexers;
			if (cls.InnerTypeCount > 0)
				flags |= ContentFlags.HasInnerClasses;
			if (cls.MethodCount > 0)
				flags |= ContentFlags.HasMethods;
			
			if (cls.PropertyCount > 0)
				flags |= ContentFlags.HasProperties;
			if (cls.HasParts)
				flags |= ContentFlags.HasParts;
				
			if (cls.Location != DomLocation.Empty)
				flags |= ContentFlags.HasRegion;
			if (cls.BodyRegion != DomRegion.Empty)
				flags |= ContentFlags.HasBodyRegion;
			if (cls.ConstructorCount > 0)
				flags |= ContentFlags.HasConstructors;
			if (cls.IsObsolete)
				flags |= ContentFlags.IsObsolete;
			if (cls.HasExtensionMethods)
				flags |= ContentFlags.HasExtensionMethods;
		}
示例#49
0
		public bool Rotation(out TraceResult result, Vector3 start, idRotation rotation, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, idEntity passEntity)
		{
			idConsole.Warning("TODO: idClip.Rotation");
			/*idTraceModel traceModel = TraceModelForClipModel(model);
			idBounds traceBounds = new idBounds();
			TraceResult traceResult;

			if((passEntity == null) || (passEntity.Index != idR.EntityIndexWorld))
			{
				// test world
				_rotationCount++;

				// TODO: NEED ENGINE SOURCE idR.CollisionModelManager.Rotation(out result, start, rotation, traceModel, traceModelAxis, contentMask, 0, Vector3.Zero, Matrix.Identity);
				result.ContactInformation.EntityIndex = (result.Fraction != 1.0f) ? idR.EntityIndexWorld : idR.EntityIndexNone;

				if(result.Fraction == 0.0f)
				{
					return true; // blocked immediately by the world
				}
			}
			else
			{
				result = new TraceResult();
				result.Fraction = 1.0f;
				result.EndPosition = start;
				result.EndAxis = traceModelAxis * rotation.ToMatrix();
			}

			if(traceModel == null)
			{
				traceBounds = idBounds.FromPointRotation(start, rotation);
			}
			else
			{
				traceBounds = idBounds.FromBoundsRotation(traceModel.Bounds, start, traceModelAxis, rotation);
			}

			idClipModel[] clipModelList = GetTraceClipModels(traceBounds, contentMask, passEntity);

			foreach(idClipModel touch in clipModelList)
			{
				if(touch == null)
				{
					continue;
				}

				if(touch.RenderModelHandle != -1)
				{
					continue;
				}

				_rotationCount++;
				// TODO: traceResult = idR.CollisionModelManager.Rotation(start, rotation, traceModel, traceModelAxis, contentMask, touch.Handle, touch.Origin, touch.Axis);

				if(traceResult.Fraction < result.Fraction)
				{
					result = traceResult;
					result.ContactInformation.EntityIndex = touch.Entity.Index;
					result.ContactInformation.ID = touch.ID;

					if(result.Fraction == 0.0f)
					{
						break;
					}
				}
			}

			return (result.Fraction < 1.0f);*/
			result = new TraceResult();
			return false;
		}
示例#50
0
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Invalid arguments count!");
                Console.WriteLine("Usage: CASCConsole <pattern> <destination> <localeFlags> <contentFlags>");
                return;
            }

            Console.WriteLine("Settings:");
            Console.WriteLine("    WowPath: {0}", Settings.Default.StoragePath);
            Console.WriteLine("    OnlineMode: {0}", Settings.Default.OnlineMode);

            Console.WriteLine("Loading...");

            BackgroundWorkerEx bgLoader = new BackgroundWorkerEx();

            bgLoader.ProgressChanged += BgLoader_ProgressChanged;

            CASCConfig config = Settings.Default.OnlineMode
                ? CASCConfig.LoadOnlineStorageConfig(Settings.Default.Product, "us")
                : CASCConfig.LoadLocalStorageConfig(Settings.Default.StoragePath);

            CASCHandler cascHandler = CASCHandler.OpenStorage(config, bgLoader);

            string       pattern = args[0];
            string       dest    = args[1];
            LocaleFlags  locale  = (LocaleFlags)Enum.Parse(typeof(LocaleFlags), args[2]);
            ContentFlags content = (ContentFlags)Enum.Parse(typeof(ContentFlags), args[3]);

            cascHandler.Root.LoadListFile(Path.Combine(Environment.CurrentDirectory, "listfile.txt"), bgLoader);
            CASCFolder root = cascHandler.Root.SetFlags(locale, content);

            Console.WriteLine("Loaded.");

            Console.WriteLine("Extract params:", pattern, dest, locale);
            Console.WriteLine("    Pattern: {0}", pattern);
            Console.WriteLine("    Destination: {0}", dest);
            Console.WriteLine("    LocaleFlags: {0}", locale);
            Console.WriteLine("    ContentFlags: {0}", content);

            Wildcard wildcard = new Wildcard(pattern, true, RegexOptions.IgnoreCase);

            foreach (var file in root.GetFiles())
            {
                if (wildcard.IsMatch(file.FullName))
                {
                    Console.Write("Extracting '{0}'...", file.FullName);

                    try
                    {
                        cascHandler.SaveFileTo(file.FullName, dest);
                        Console.WriteLine(" Ok!");
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(" Error!");
                        Logger.WriteLine(exc.Message);
                    }
                }
            }

            Console.WriteLine("Extracted.");
        }
示例#51
0
		public ContentFlags Contents(Vector3 start, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, idEntity passEntity)
		{
			idConsole.Warning("TODO: idClip.Contents");
			ContentFlags contents = ContentFlags.None;
			idBounds traceModelBounds = new idBounds();
			
			// TODO
			/*idTraceModel traceModel = TraceModelForClipModel(model);

			if((passEntity == null) || (passEntity.Index != idR.EntityIndexWorld))
			{
				// test world
				_contentCount++;
				// TODO: NEED ENGINE SOURCE contents = idR.CollisionModelManager.Contents(start, traceModel, traceModelAxis, contentMask, 0, Vector3.Zero, Matrix.Identity);
			}
			else
			{
				contents = ContentFlags.None;
			}

			if(traceModel == null)
			{
				traceModelBounds.Min = start;
				traceModelBounds.Max = start;
			}
			else if(traceModelAxis != Matrix.Identity)
			{
				traceModelBounds = idBounds.FromTransformedBounds(traceModel.Bounds, start, traceModelAxis);
			}
			else
			{
				traceModelBounds.Min = traceModel.Bounds.Min + start;
				traceModelBounds.Max = traceModel.Bounds.Max + start;
			}

			idClipModel[] traceModelList = GetTraceClipModels(traceModelBounds, -1, passEntity);

			foreach(idClipModel touch in traceModelList)
			{
				if(touch == null)
				{
					continue;
				}

				// no contents test with render models
				if(touch.RenderModelHandle != -1)
				{
					continue;
				}

				// if the entity does not have any contents we are looking for
				if((touch.Contents & contentMask) == ContentFlags.None)
				{
					continue;
				}

				// if the entity has no new contents flags
				if((touch.Contents & contents) == touch.Contents)
				{
					continue;
				}

				_contentCount++;

				// TODO
				/*if(idR.CollisionModelManager.Contents(start, traceModel, traceModelAxis, contentMask, touch.Handle, touch.Origin, touch.Axis) > 0)
				{
					contents |= (touch.Contents & contentMask);
				}*/
			/*}*/

			return contents;
		}